提交 6a3b8379 编写于 作者: S slguan

Merge branch 'release/v1.6.4.0'

# Conflicts:
#	src/os/windows/src/twindows.c
#	src/system/src/vnodeImport.c
#	src/util/src/tutil.c
...@@ -23,5 +23,14 @@ tests/script/ ...@@ -23,5 +23,14 @@ tests/script/
tests/pytest/ tests/pytest/
tests/jenkins/ tests/jenkins/
tests/hdfs/ tests/hdfs/
*.iml *.iml
*.class
nmake/
sln/
hdfs/
c/
taoshebei/
taosdalipu/
Target/
*.failed
*.sql
\ No newline at end of file
...@@ -3,171 +3,252 @@ PROJECT(TDengine) ...@@ -3,171 +3,252 @@ PROJECT(TDengine)
SET(CMAKE_C_STANDARD 11) SET(CMAKE_C_STANDARD 11)
SET(CMAKE_VERBOSE_MAKEFILE ON) SET(CMAKE_VERBOSE_MAKEFILE ON)
SET(TD_ROOT_DIR ${PROJECT_SOURCE_DIR})
# #
# If it is a Linux operating system # If need to set debug options
# 1.Generate debug version: # 1.Generate debug version:
# mkdir debug; cd debug; # mkdir debug; cd debug;
# cmake -DCMAKE_BUILD_TYPE=Debug .. # cmake -DCMAKE_BUILD_TYPE=Debug ..
# 2.Generate release version: # 2.Generate release version:
# mkdir release; cd release; # mkdir release; cd release;
# cmake -DCMAKE_BUILD_TYPE=Release .. # cmake -DCMAKE_BUILD_TYPE=Release ..
#
#
# If it is a Windows operating system # If it is a Windows operating system
# 1.Use command line tool of VS2013 or higher version # 1.Use command line tool of VS2013 or higher version
# mkdir build; cd build; # mkdir build; cd build;
# cmake -G "NMake Makefiles" .. # cmake -G "NMake Makefiles" ..
# nmake install # nmake install
# 2.Use the VS development interface tool # 2.Use the VS development interface tool
# mkdir build; cd build; # mkdir build; cd build;
# cmake -A x64 .. # cmake -A x64 ..
# open the file named TDengine.sln # open the file named TDengine.sln
# #
# Set macro definitions according to os platform IF (NOT DEFINED TD_CLUSTER)
SET(TD_WINDOWS FALSE) MESSAGE(STATUS "Build the Lite Version")
SET(TD_LINUX FALSE) SET(TD_CLUSTER FALSE)
SET(TD_ARM FALSE) SET(TD_LITE TRUE)
SET(TD_DARWIN FALSE)
SET(TD_COMMUNITY_DIR ${PROJECT_SOURCE_DIR})
IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux") MESSAGE(STATUS "Community directory: " ${TD_COMMUNITY_DIR})
SET(TD_OS_DIR ${PROJECT_SOURCE_DIR}/src/os/linux)
SET(TD_LINUX TRUE) # Set macro definitions according to os platform
ADD_DEFINITIONS(-DLINUX) SET(TD_LINUX_64 FALSE)
SET(TD_LINUX_32 FALSE)
SET(TD_ARM FALSE)
SET(TD_ARM_64 FALSE)
SET(TD_ARM_32 FALSE)
SET(TD_MIPS_64 FALSE)
SET(TD_DARWIN_64 FALSE)
SET(TD_WINDOWS_64 FALSE)
# if generate ARM version:
# cmake -DARMVER=arm32 .. or cmake -DARMVER=arm64
IF (${ARMVER} MATCHES "arm32")
SET(TD_ARM TRUE)
SET(TD_ARM_32 TRUE)
ADD_DEFINITIONS(-D_TD_ARM_)
ADD_DEFINITIONS(-D_TD_ARM_32_)
ELSEIF (${ARMVER} MATCHES "arm64")
SET(TD_ARM TRUE)
SET(TD_ARM_64 TRUE)
ADD_DEFINITIONS(-D_TD_ARM_)
ADD_DEFINITIONS(-D_TD_ARM_64_)
ENDIF ()
IF (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") IF (TD_ARM)
SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -malign-double -g -Wno-char-subscripts -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE") ADD_DEFINITIONS(-D_TD_ARM_)
ELSE () IF (TD_ARM_32)
SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -malign-double -g -Wno-char-subscripts -malign-stringops -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE") ADD_DEFINITIONS(-D_TD_ARM_32_)
ELSEIF (TD_ARM_64)
ADD_DEFINITIONS(-D_TD_ARM_64_)
ELSE ()
EXIT ()
ENDIF ()
ENDIF () ENDIF ()
SET(DEBUG_FLAGS "-O0 -DDEBUG")
SET(RELEASE_FLAGS "-O0") IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
IF (${CMAKE_SIZEOF_VOID_P} MATCHES 8)
ADD_DEFINITIONS(-D_REENTRANT -D__USE_POSIX -D_LIBC_REENTRANT) SET(TD_LINUX_64 TRUE)
SET(TD_OS_DIR ${TD_COMMUNITY_DIR}/src/os/linux)
IF (${CMAKE_SIZEOF_VOID_P} MATCHES 8) ADD_DEFINITIONS(-D_M_X64)
MESSAGE(STATUS "The current platform is Linux 64-bit") MESSAGE(STATUS "The current platform is Linux 64-bit")
ADD_DEFINITIONS(-D_M_X64) ELSEIF (${CMAKE_SIZEOF_VOID_P} MATCHES 4)
IF (TD_ARM)
SET(TD_LINUX_32 TRUE)
SET(TD_OS_DIR ${TD_COMMUNITY_DIR}/src/os/linux)
#ADD_DEFINITIONS(-D_M_IX86)
MESSAGE(STATUS "The current platform is Linux 32-bit")
ELSE ()
MESSAGE(FATAL_ERROR "The current platform is Linux 32-bit, but no ARM not supported yet")
EXIT ()
ENDIF ()
ELSE () ELSE ()
MESSAGE(FATAL_ERROR "The current platform is Linux 32-bit, not supported yet") MESSAGE(FATAL_ERROR "The current platform is Linux neither 32-bit nor 64-bit, not supported yet")
EXIT ()
ENDIF ()
ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
IF (${CMAKE_SIZEOF_VOID_P} MATCHES 8)
SET(TD_DARWIN_64 TRUE)
SET(TD_OS_DIR ${TD_COMMUNITY_DIR}/src/os/darwin)
MESSAGE(STATUS "The current platform is Darwin 64-bit")
ELSE ()
MESSAGE(FATAL_ERROR "The current platform is Darwin 32-bit, not supported yet")
EXIT ()
ENDIF ()
ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
IF (${CMAKE_SIZEOF_VOID_P} MATCHES 8)
SET(TD_WINDOWS_64 TRUE)
SET(TD_OS_DIR ${TD_COMMUNITY_DIR}/src/os/windows)
ADD_DEFINITIONS(-D_M_X64)
MESSAGE(STATUS "The current platform is Windows 64-bit")
ELSE ()
MESSAGE(FATAL_ERROR "The current platform is Windows 32-bit, not supported yet")
EXIT ()
ENDIF ()
ELSE()
MESSAGE(FATAL_ERROR "The current platform is not Linux/Darwin/Windows, stop compile")
EXIT () EXIT ()
ENDIF () ENDIF ()
ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Windows") FIND_PROGRAM(TD_MVN_INSTALLED mvn)
SET(CMAKE_GENERATOR "NMake Makefiles" CACHE INTERNAL "" FORCE) IF (TD_MVN_INSTALLED)
SET(TD_OS_DIR ${PROJECT_SOURCE_DIR}/src/os/windows) MESSAGE(STATUS "MVN is installed and JDBC will be compiled")
SET(TD_WINDOWS TRUE)
ADD_DEFINITIONS(-DWINDOWS)
ADD_DEFINITIONS(-D__CLEANUP_C)
ADD_DEFINITIONS(-DPTW32_STATIC_LIB)
ADD_DEFINITIONS(-DPTW32_BUILD)
SET(COMMON_FLAGS "/nologo /WX- /Oi /Oy- /Gm- /EHsc /MT /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Gd /errorReport:prompt /analyze-")
SET(DEBUG_FLAGS "/Zi /W3 /GL")
SET(RELEASE_FLAGS "/W0 /GL")
ADD_DEFINITIONS(-D_MBCS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
IF (${CMAKE_SIZEOF_VOID_P} MATCHES 8)
MESSAGE(STATUS "The current platform is Windows 64-bit")
ADD_DEFINITIONS(-D_M_X64)
ELSE () ELSE ()
MESSAGE(FATAL_ERROR "The current platform is Windows 32-bit, not supported yet") MESSAGE(STATUS "MVN is not installed and JDBC is not compiled")
EXIT ()
ENDIF () ENDIF ()
ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") #
# debug flag
SET(TD_OS_DIR ${PROJECT_SOURCE_DIR}/src/os/darwin) #
SET(TD_DARWIN TRUE) # ADD_DEFINITIONS(-D_CHECK_HEADER_FILE_)
ADD_DEFINITIONS(-DDARWIN) IF (${MEM_CHECK} MATCHES "true")
ADD_DEFINITIONS(-DTAOS_MEM_CHECK)
SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -malign-double -g -Wno-char-subscripts -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE -Wno-unused-variable -Wno-bitfield-constant-conversion") ENDIF ()
SET(DEBUG_FLAGS "-O0 -DDEBUG")
SET(RELEASE_FLAGS "-O0")
ADD_DEFINITIONS(-D_REENTRANT -D__USE_POSIX -D_LIBC_REENTRANT)
IF (${CMAKE_SIZEOF_VOID_P} MATCHES 8) IF (TD_CLUSTER)
MESSAGE(STATUS "The current platform is Darwin 64-bit") ADD_DEFINITIONS(-DCLUSTER)
ADD_DEFINITIONS(-D_M_X64) ADD_DEFINITIONS(-DTSDB_REPLICA_MAX_NUM=3)
ELSE () ELSE ()
MESSAGE(FATAL_ERROR "The current platform is Darwin 32-bit, not supported yet") ADD_DEFINITIONS(-DLITE)
ADD_DEFINITIONS(-DTSDB_REPLICA_MAX_NUM=1)
ENDIF ()
IF (TD_LINUX_64)
SET(DEBUG_FLAGS "-O0 -DDEBUG")
SET(RELEASE_FLAGS "-O0")
IF (NOT TD_ARM)
IF (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -malign-double -g -Wno-char-subscripts -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
ELSE ()
SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -malign-double -g -Wno-char-subscripts -malign-stringops -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
ENDIF ()
ELSE ()
SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -g -Wno-char-subscripts -fsigned-char -munaligned-access -fpack-struct=8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
ENDIF ()
ADD_DEFINITIONS(-DLINUX)
ADD_DEFINITIONS(-D_REENTRANT -D__USE_POSIX -D_LIBC_REENTRANT)
ELSEIF (TD_LINUX_32)
IF (NOT TD_ARM)
EXIT ()
ENDIF ()
SET(DEBUG_FLAGS "-O0 -DDEBUG")
SET(RELEASE_FLAGS "-O0")
SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -g -Wno-char-subscripts -fsigned-char -munaligned-access -fpack-struct=8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
ADD_DEFINITIONS(-DLINUX)
ADD_DEFINITIONS(-D_REENTRANT -D__USE_POSIX -D_LIBC_REENTRANT)
ADD_DEFINITIONS(-DUSE_LIBICONV)
ELSEIF (TD_WINDOWS_64)
SET(CMAKE_GENERATOR "NMake Makefiles" CACHE INTERNAL "" FORCE)
SET(COMMON_FLAGS "/nologo /WX- /Oi /Oy- /Gm- /EHsc /MT /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Gd /errorReport:prompt /analyze-")
SET(DEBUG_FLAGS "/Zi /W3 /GL")
SET(RELEASE_FLAGS "/W0 /GL")
ADD_DEFINITIONS(-DWINDOWS)
ADD_DEFINITIONS(-D__CLEANUP_C)
ADD_DEFINITIONS(-DPTW32_STATIC_LIB)
ADD_DEFINITIONS(-DPTW32_BUILD)
ADD_DEFINITIONS(-D_MBCS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
ELSEIF (TD_DARWIN_64)
SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -malign-double -g -Wno-char-subscripts -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE -Wno-unused-variable -Wno-bitfield-constant-conversion")
SET(DEBUG_FLAGS "-O0 -DDEBUG")
SET(RELEASE_FLAGS "-O0")
ADD_DEFINITIONS(-DDARWIN)
ADD_DEFINITIONS(-D_REENTRANT -D__USE_POSIX -D_LIBC_REENTRANT)
ELSE ()
MESSAGE(FATAL_ERROR "The current platform is not support yet, stop compile")
EXIT () EXIT ()
ENDIF () ENDIF ()
ELSE () # Set compiler options
MESSAGE(FATAL_ERROR "The current platform is not Linux/MAC/Windows, stop compile") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${COMMON_FLAGS} ${DEBUG_FLAGS}")
EXIT () SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${COMMON_FLAGS} ${RELEASE_FLAGS}")
ENDIF () # Set c++ compiler options
# SET(COMMON_CXX_FLAGS "${COMMON_FLAGS} -std=c++11")
# SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${COMMON_CXX_FLAGS} ${DEBUG_FLAGS}")
# SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${COMMON_CXX_FLAGS} ${RELEASE_FLAGS}")
# Set compiler options IF (${CMAKE_BUILD_TYPE} MATCHES "Debug")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${COMMON_FLAGS} ${DEBUG_FLAGS}") MESSAGE(STATUS "Build Debug Version")
SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${COMMON_FLAGS} ${RELEASE_FLAGS}") ELSEIF (${CMAKE_BUILD_TYPE} MATCHES "Release")
MESSAGE(STATUS "Build Release Version")
# Set c++ compiler options
# SET(COMMON_CXX_FLAGS "${COMMON_FLAGS} -std=c++11")
# SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${COMMON_CXX_FLAGS} ${DEBUG_FLAGS}")
# SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${COMMON_CXX_FLAGS} ${RELEASE_FLAGS}")
IF (${CMAKE_BUILD_TYPE} MATCHES "Debug")
MESSAGE(STATUS "Build Debug Version")
ELSEIF (${CMAKE_BUILD_TYPE} MATCHES "Release")
MESSAGE(STATUS "Build Release Version")
ELSE ()
IF (TD_WINDOWS)
SET(CMAKE_BUILD_TYPE "Release")
MESSAGE(STATUS "Build Release Version")
ELSE () ELSE ()
SET(CMAKE_BUILD_TYPE "Debug") IF (TD_WINDOWS_64)
MESSAGE(STATUS "Build Debug Version") SET(CMAKE_BUILD_TYPE "Release")
ENDIF() MESSAGE(STATUS "Build Release Version in Windows as default")
ENDIF () ELSE ()
SET(CMAKE_BUILD_TYPE "Debug")
MESSAGE(STATUS "Build Debug Version as default")
ENDIF()
ENDIF ()
FIND_PROGRAM(TD_MVN_INSTALLED mvn) #set output directory
IF (TD_MVN_INSTALLED) SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/build/lib)
MESSAGE(STATUS "MVN is installed and JDBC will be compiled") SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/build/bin)
ELSE () SET(TD_TESTS_OUTPUT_DIR ${PROJECT_BINARY_DIR}/test)
MESSAGE(STATUS "MVN is not installed and JDBC is not compiled")
MESSAGE(STATUS "Operating system dependency directory: " ${TD_OS_DIR})
MESSAGE(STATUS "Project source directory: " ${PROJECT_SOURCE_DIR})
MESSAGE(STATUS "Project binary files output path: " ${PROJECT_BINARY_DIR})
MESSAGE(STATUS "Project executable files output path: " ${EXECUTABLE_OUTPUT_PATH})
MESSAGE(STATUS "Project library files output path: " ${LIBRARY_OUTPUT_PATH})
IF (TD_LINUX_64)
SET(TD_MAKE_INSTALL_SH "${TD_COMMUNITY_DIR}/packaging/tools/make_install.sh")
INSTALL(CODE "MESSAGE(\"make install script: ${TD_MAKE_INSTALL_SH}\")")
INSTALL(CODE "execute_process(COMMAND chmod 777 ${TD_MAKE_INSTALL_SH})")
INSTALL(CODE "execute_process(COMMAND ${TD_MAKE_INSTALL_SH} ${TD_COMMUNITY_DIR} ${PROJECT_BINARY_DIR})")
ELSEIF (TD_LINUX_32)
IF (NOT TD_ARM)
EXIT ()
ENDIF ()
SET(TD_MAKE_INSTALL_SH "${TD_COMMUNITY_DIR}/packaging/tools/make_install.sh")
INSTALL(CODE "MESSAGE(\"make install script: ${TD_MAKE_INSTALL_SH}\")")
INSTALL(CODE "execute_process(COMMAND chmod 777 ${TD_MAKE_INSTALL_SH})")
INSTALL(CODE "execute_process(COMMAND ${TD_MAKE_INSTALL_SH} ${TD_COMMUNITY_DIR} ${PROJECT_BINARY_DIR})")
ELSEIF (TD_WINDOWS_64)
SET(CMAKE_INSTALL_PREFIX C:/TDengine)
INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/src/connector/go DESTINATION connector)
INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/src/connector/grafana DESTINATION connector)
INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/src/connector/python DESTINATION connector)
INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/tests/examples DESTINATION .)
INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/packaging/cfg DESTINATION .)
INSTALL(FILES ${TD_COMMUNITY_DIR}/src/inc/taos.h DESTINATION include)
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.lib DESTINATION driver)
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.exp DESTINATION driver)
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.dll DESTINATION driver)
INSTALL(FILES ${EXECUTABLE_OUTPUT_PATH}/taos.exe DESTINATION .)
#INSTALL(TARGETS taos RUNTIME DESTINATION driver)
#INSTALL(TARGETS shell RUNTIME DESTINATION .)
IF (TD_MVN_INSTALLED)
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-1.0.2-dist.jar DESTINATION connector/jdbc)
ENDIF ()
ENDIF ()
ENDIF () ENDIF ()
#set output directory
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/build/lib)
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/build/bin)
SET(TD_TESTS_OUTPUT_DIR ${PROJECT_BINARY_DIR}/test)
MESSAGE(STATUS "Operating system dependency directory: " ${TD_OS_DIR})
MESSAGE(STATUS "Project source directory: " ${PROJECT_SOURCE_DIR})
MESSAGE(STATUS "Project binary files output path: " ${PROJECT_BINARY_DIR})
MESSAGE(STATUS "Project executable files output path: " ${EXECUTABLE_OUTPUT_PATH})
MESSAGE(STATUS "Project library files output path: " ${LIBRARY_OUTPUT_PATH})
ADD_SUBDIRECTORY(deps) ADD_SUBDIRECTORY(deps)
ADD_SUBDIRECTORY(src) ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(tests)
IF (TD_LINUX)
SET(TD_MAKE_INSTALL_SH "${TD_ROOT_DIR}/packaging/tools/make_install.sh")
INSTALL(CODE "MESSAGE(\"make install script: ${TD_MAKE_INSTALL_SH}\")")
INSTALL(CODE "execute_process(COMMAND chmod 777 ${TD_MAKE_INSTALL_SH})")
INSTALL(CODE "execute_process(COMMAND ${TD_MAKE_INSTALL_SH} ${TD_ROOT_DIR} ${PROJECT_BINARY_DIR})")
ELSEIF (TD_WINDOWS)
SET(CMAKE_INSTALL_PREFIX C:/TDengine)
INSTALL(DIRECTORY ${TD_ROOT_DIR}/src/connector/go DESTINATION connector)
INSTALL(DIRECTORY ${TD_ROOT_DIR}/src/connector/grafana DESTINATION connector)
INSTALL(DIRECTORY ${TD_ROOT_DIR}/src/connector/python DESTINATION connector)
INSTALL(DIRECTORY ${TD_ROOT_DIR}/tests/examples DESTINATION .)
INSTALL(DIRECTORY ${TD_ROOT_DIR}/packaging/cfg DESTINATION .)
INSTALL(FILES ${TD_ROOT_DIR}/src/inc/taos.h DESTINATION include)
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.lib DESTINATION driver)
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.exp DESTINATION driver)
INSTALL(TARGETS taos RUNTIME DESTINATION driver)
INSTALL(TARGETS shell RUNTIME DESTINATION .)
IF (TD_MVN_INSTALLED)
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-1.0.2-dist.jar DESTINATION connector/jdbc)
ENDIF ()
ENDIF ()
INCLUDE(CPack) INCLUDE(CPack)
\ No newline at end of file
CMAKE_MINIMUM_REQUIRED(VERSION 2.8) CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(TDengine) PROJECT(TDengine)
ADD_SUBDIRECTORY(zlib-1.2.11) ADD_SUBDIRECTORY(zlib-1.2.11)
......
CMAKE_MINIMUM_REQUIRED(VERSION 2.8) CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(TDengine) PROJECT(TDengine)
IF (TD_WINDOWS) IF (TD_WINDOWS_64)
LIST(APPEND SRC iconv.c) LIST(APPEND SRC iconv.c)
LIST(APPEND SRC localcharset.c) LIST(APPEND SRC localcharset.c)
INCLUDE_DIRECTORIES(.) INCLUDE_DIRECTORIES(.)
......
CMAKE_MINIMUM_REQUIRED(VERSION 2.8) CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(TDengine) PROJECT(TDengine)
IF (TD_WINDOWS) IF (TD_WINDOWS_64)
LIST(APPEND SRC pthread.c)
INCLUDE_DIRECTORIES(.) INCLUDE_DIRECTORIES(.)
LIST(APPEND SRC pthread.c)
ADD_LIBRARY(pthread ${SRC}) ADD_LIBRARY(pthread ${SRC})
ENDIF () ENDIF ()
CMAKE_MINIMUM_REQUIRED(VERSION 2.8) CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(TDengine) PROJECT(TDengine)
IF (TD_WINDOWS) IF (TD_WINDOWS_64)
LIST(APPEND SRC regex.c)
INCLUDE_DIRECTORIES(inc .) INCLUDE_DIRECTORIES(inc .)
LIST(APPEND SRC regex.c)
ADD_LIBRARY(regex ${SRC}) ADD_LIBRARY(regex ${SRC})
ENDIF () ENDIF ()
CMAKE_MINIMUM_REQUIRED(VERSION 2.8) CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(TDengine) PROJECT(TDengine)
IF (TD_LINUX) IF (TD_LINUX_64)
AUX_SOURCE_DIRECTORY(src SRC)
INCLUDE_DIRECTORIES(inc) INCLUDE_DIRECTORIES(inc)
AUX_SOURCE_DIRECTORY(src SRC)
ADD_LIBRARY(z ${SRC}) ADD_LIBRARY(z ${SRC})
ENDIF () ENDIF ()
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
*/ */
/* @(#) $Id$ */ /* @(#) $Id$ */
//#include <stdint.h>
#ifndef ZCONF_H #ifndef ZCONF_H
#define ZCONF_H #define ZCONF_H
...@@ -238,16 +238,16 @@ ...@@ -238,16 +238,16 @@
#endif #endif
#ifdef Z_SOLO #ifdef Z_SOLO
typedef unsigned long z_size_t; typedef uint64_t z_size_t;
#else #else
# define z_longlong long long # define z_longlong int64_t
# if defined(NO_SIZE_T) # if defined(NO_SIZE_T)
typedef unsigned NO_SIZE_T z_size_t; typedef unsigned NO_SIZE_T z_size_t;
# elif defined(STDC) # elif defined(STDC)
# include <stddef.h> # include <stddef.h>
typedef size_t z_size_t; typedef size_t z_size_t;
# else # else
typedef unsigned long z_size_t; typedef uint64_t z_size_t;
# endif # endif
# undef z_longlong # undef z_longlong
#endif #endif
...@@ -391,7 +391,7 @@ ...@@ -391,7 +391,7 @@
typedef unsigned char Byte; /* 8 bits */ typedef unsigned char Byte; /* 8 bits */
#endif #endif
typedef unsigned int uInt; /* 16 bits or more */ typedef unsigned int uInt; /* 16 bits or more */
typedef unsigned long uLong; /* 32 bits or more */ typedef uint64_t uLong; /* 32 bits or more */
#ifdef SMALL_MEDIUM #ifdef SMALL_MEDIUM
/* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
...@@ -419,7 +419,7 @@ typedef uLong FAR uLongf; ...@@ -419,7 +419,7 @@ typedef uLong FAR uLongf;
# if (UINT_MAX == 0xffffffffUL) # if (UINT_MAX == 0xffffffffUL)
# define Z_U4 unsigned # define Z_U4 unsigned
# elif (ULONG_MAX == 0xffffffffUL) # elif (ULONG_MAX == 0xffffffffUL)
# define Z_U4 unsigned long # define Z_U4 uint64_t
# elif (USHRT_MAX == 0xffffffffUL) # elif (USHRT_MAX == 0xffffffffUL)
# define Z_U4 unsigned short # define Z_U4 unsigned short
# endif # endif
...@@ -428,7 +428,7 @@ typedef uLong FAR uLongf; ...@@ -428,7 +428,7 @@ typedef uLong FAR uLongf;
#ifdef Z_U4 #ifdef Z_U4
typedef Z_U4 z_crc_t; typedef Z_U4 z_crc_t;
#else #else
typedef unsigned long z_crc_t; typedef uint64_t z_crc_t;
#endif #endif
#if 1 /* was set to #if 1 by ./configure */ #if 1 /* was set to #if 1 by ./configure */
...@@ -501,7 +501,7 @@ typedef uLong FAR uLongf; ...@@ -501,7 +501,7 @@ typedef uLong FAR uLongf;
#endif #endif
#ifndef z_off_t #ifndef z_off_t
# define z_off_t long # define z_off_t int64_t
#endif #endif
#if !defined(_WIN32) && defined(Z_LARGE64) #if !defined(_WIN32) && defined(Z_LARGE64)
......
...@@ -999,7 +999,7 @@ ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, ...@@ -999,7 +999,7 @@ ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm,
stream state was inconsistent. stream state was inconsistent.
*/ */
ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm)); ZEXTERN int64_t ZEXPORT inflateMark OF((z_streamp strm));
/* /*
This function returns two values, one in the lower 16 bits of the return This function returns two values, one in the lower 16 bits of the return
value, and the other in the remaining upper bits, obtained by shifting the value, and the other in the remaining upper bits, obtained by shifting the
...@@ -1890,7 +1890,7 @@ ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp)); ...@@ -1890,7 +1890,7 @@ ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp));
ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void)); ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void));
ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int));
ZEXTERN int ZEXPORT inflateValidate OF((z_streamp, int)); ZEXTERN int ZEXPORT inflateValidate OF((z_streamp, int));
ZEXTERN unsigned long ZEXPORT inflateCodesUsed OF ((z_streamp)); ZEXTERN uint64_t ZEXPORT inflateCodesUsed OF ((z_streamp));
ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp)); ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp));
ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp)); ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp));
#if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(Z_SOLO) #if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(Z_SOLO)
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
*/ */
/* @(#) $Id$ */ /* @(#) $Id$ */
#include <stdint.h>
#include "zutil.h" #include "zutil.h"
local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2)); local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
...@@ -26,7 +26,7 @@ local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2)); ...@@ -26,7 +26,7 @@ local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
(thank you to John Reiser for pointing this out) */ (thank you to John Reiser for pointing this out) */
# define CHOP(a) \ # define CHOP(a) \
do { \ do { \
unsigned long tmp = a >> 16; \ uint64_t tmp = a >> 16; \
a &= 0xffffUL; \ a &= 0xffffUL; \
a += (tmp << 4) - tmp; \ a += (tmp << 4) - tmp; \
} while (0) } while (0)
...@@ -65,7 +65,7 @@ uLong ZEXPORT adler32_z(adler, buf, len) ...@@ -65,7 +65,7 @@ uLong ZEXPORT adler32_z(adler, buf, len)
const Bytef *buf; const Bytef *buf;
z_size_t len; z_size_t len;
{ {
unsigned long sum2; uint64_t sum2;
unsigned n; unsigned n;
/* split Adler-32 into component sums */ /* split Adler-32 into component sums */
...@@ -145,8 +145,8 @@ local uLong adler32_combine_(adler1, adler2, len2) ...@@ -145,8 +145,8 @@ local uLong adler32_combine_(adler1, adler2, len2)
uLong adler2; uLong adler2;
z_off64_t len2; z_off64_t len2;
{ {
unsigned long sum1; uint64_t sum1;
unsigned long sum2; uint64_t sum2;
unsigned rem; unsigned rem;
/* for negative len, return invalid adler32 as a clue for debugging */ /* for negative len, return invalid adler32 as a clue for debugging */
...@@ -163,7 +163,7 @@ local uLong adler32_combine_(adler1, adler2, len2) ...@@ -163,7 +163,7 @@ local uLong adler32_combine_(adler1, adler2, len2)
sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem; sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
if (sum1 >= BASE) sum1 -= BASE; if (sum1 >= BASE) sum1 -= BASE;
if (sum1 >= BASE) sum1 -= BASE; if (sum1 >= BASE) sum1 -= BASE;
if (sum2 >= ((unsigned long)BASE << 1)) sum2 -= ((unsigned long)BASE << 1); if (sum2 >= ((uint64_t)BASE << 1)) sum2 -= ((uint64_t)BASE << 1);
if (sum2 >= BASE) sum2 -= BASE; if (sum2 >= BASE) sum2 -= BASE;
return sum1 | (sum2 << 16); return sum1 | (sum2 << 16);
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
*/ */
/* @(#) $Id$ */ /* @(#) $Id$ */
#include <stdint.h>
#define ZLIB_INTERNAL #define ZLIB_INTERNAL
#include "zlib.h" #include "zlib.h"
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
DYNAMIC_CRC_TABLE and MAKECRCH can be #defined to write out crc32.h. DYNAMIC_CRC_TABLE and MAKECRCH can be #defined to write out crc32.h.
*/ */
#include <stdint.h>
#ifdef MAKECRCH #ifdef MAKECRCH
# include <stdio.h> # include <stdio.h>
# ifndef DYNAMIC_CRC_TABLE # ifndef DYNAMIC_CRC_TABLE
...@@ -35,9 +35,9 @@ ...@@ -35,9 +35,9 @@
# define BYFOUR # define BYFOUR
#endif #endif
#ifdef BYFOUR #ifdef BYFOUR
local unsigned long crc32_little OF((unsigned long, local uint64_t crc32_little OF((uint64_t,
const unsigned char FAR *, z_size_t)); const unsigned char FAR *, z_size_t));
local unsigned long crc32_big OF((unsigned long, local uint64_t crc32_big OF((uint64_t,
const unsigned char FAR *, z_size_t)); const unsigned char FAR *, z_size_t));
# define TBLS 8 # define TBLS 8
#else #else
...@@ -45,9 +45,9 @@ ...@@ -45,9 +45,9 @@
#endif /* BYFOUR */ #endif /* BYFOUR */
/* Local functions for crc concatenation */ /* Local functions for crc concatenation */
local unsigned long gf2_matrix_times OF((unsigned long *mat, local uint64_t gf2_matrix_times OF((uint64_t *mat,
unsigned long vec)); uint64_t vec));
local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat)); local void gf2_matrix_square OF((uint64_t *square, uint64_t *mat));
local uLong crc32_combine_ OF((uLong crc1, uLong crc2, z_off64_t len2)); local uLong crc32_combine_ OF((uLong crc1, uLong crc2, z_off64_t len2));
...@@ -170,7 +170,7 @@ local void write_table(out, table) ...@@ -170,7 +170,7 @@ local void write_table(out, table)
for (n = 0; n < 256; n++) for (n = 0; n < 256; n++)
fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ", fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ",
(unsigned long)(table[n]), (uint64_t)(table[n]),
n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", ")); n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", "));
} }
#endif /* MAKECRCH */ #endif /* MAKECRCH */
...@@ -199,8 +199,8 @@ const z_crc_t FAR * ZEXPORT get_crc_table() ...@@ -199,8 +199,8 @@ const z_crc_t FAR * ZEXPORT get_crc_table()
#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1 #define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
/* ========================================================================= */ /* ========================================================================= */
unsigned long ZEXPORT crc32_z(crc, buf, len) uint64_t ZEXPORT crc32_z(crc, buf, len)
unsigned long crc; uint64_t crc;
const unsigned char FAR *buf; const unsigned char FAR *buf;
z_size_t len; z_size_t len;
{ {
...@@ -234,8 +234,8 @@ unsigned long ZEXPORT crc32_z(crc, buf, len) ...@@ -234,8 +234,8 @@ unsigned long ZEXPORT crc32_z(crc, buf, len)
} }
/* ========================================================================= */ /* ========================================================================= */
unsigned long ZEXPORT crc32(crc, buf, len) uint64_t ZEXPORT crc32(crc, buf, len)
unsigned long crc; uint64_t crc;
const unsigned char FAR *buf; const unsigned char FAR *buf;
uInt len; uInt len;
{ {
...@@ -263,8 +263,8 @@ unsigned long ZEXPORT crc32(crc, buf, len) ...@@ -263,8 +263,8 @@ unsigned long ZEXPORT crc32(crc, buf, len)
#define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4 #define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4
/* ========================================================================= */ /* ========================================================================= */
local unsigned long crc32_little(crc, buf, len) local uint64_t crc32_little(crc, buf, len)
unsigned long crc; uint64_t crc;
const unsigned char FAR *buf; const unsigned char FAR *buf;
z_size_t len; z_size_t len;
{ {
...@@ -293,7 +293,7 @@ local unsigned long crc32_little(crc, buf, len) ...@@ -293,7 +293,7 @@ local unsigned long crc32_little(crc, buf, len)
c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
} while (--len); } while (--len);
c = ~c; c = ~c;
return (unsigned long)c; return (uint64_t)c;
} }
/* ========================================================================= */ /* ========================================================================= */
...@@ -303,8 +303,8 @@ local unsigned long crc32_little(crc, buf, len) ...@@ -303,8 +303,8 @@ local unsigned long crc32_little(crc, buf, len)
#define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4 #define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4
/* ========================================================================= */ /* ========================================================================= */
local unsigned long crc32_big(crc, buf, len) local uint64_t crc32_big(crc, buf, len)
unsigned long crc; uint64_t crc;
const unsigned char FAR *buf; const unsigned char FAR *buf;
z_size_t len; z_size_t len;
{ {
...@@ -333,7 +333,7 @@ local unsigned long crc32_big(crc, buf, len) ...@@ -333,7 +333,7 @@ local unsigned long crc32_big(crc, buf, len)
c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
} while (--len); } while (--len);
c = ~c; c = ~c;
return (unsigned long)(ZSWAP32(c)); return (uint64_t)(ZSWAP32(c));
} }
#endif /* BYFOUR */ #endif /* BYFOUR */
...@@ -341,11 +341,11 @@ local unsigned long crc32_big(crc, buf, len) ...@@ -341,11 +341,11 @@ local unsigned long crc32_big(crc, buf, len)
#define GF2_DIM 32 /* dimension of GF(2) vectors (length of CRC) */ #define GF2_DIM 32 /* dimension of GF(2) vectors (length of CRC) */
/* ========================================================================= */ /* ========================================================================= */
local unsigned long gf2_matrix_times(mat, vec) local uint64_t gf2_matrix_times(mat, vec)
unsigned long *mat; uint64_t *mat;
unsigned long vec; uint64_t vec;
{ {
unsigned long sum; uint64_t sum;
sum = 0; sum = 0;
while (vec) { while (vec) {
...@@ -359,8 +359,8 @@ local unsigned long gf2_matrix_times(mat, vec) ...@@ -359,8 +359,8 @@ local unsigned long gf2_matrix_times(mat, vec)
/* ========================================================================= */ /* ========================================================================= */
local void gf2_matrix_square(square, mat) local void gf2_matrix_square(square, mat)
unsigned long *square; uint64_t *square;
unsigned long *mat; uint64_t *mat;
{ {
int n; int n;
...@@ -375,9 +375,9 @@ local uLong crc32_combine_(crc1, crc2, len2) ...@@ -375,9 +375,9 @@ local uLong crc32_combine_(crc1, crc2, len2)
z_off64_t len2; z_off64_t len2;
{ {
int n; int n;
unsigned long row; uint64_t row;
unsigned long even[GF2_DIM]; /* even-power-of-two zeros operator */ uint64_t even[GF2_DIM]; /* even-power-of-two zeros operator */
unsigned long odd[GF2_DIM]; /* odd-power-of-two zeros operator */ uint64_t odd[GF2_DIM]; /* odd-power-of-two zeros operator */
/* degenerate case (also disallow negative lengths) */ /* degenerate case (also disallow negative lengths) */
if (len2 <= 0) if (len2 <= 0)
......
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
*/ */
/* @(#) $Id$ */ /* @(#) $Id$ */
#include <stdint.h>
#include "deflate.h" #include "deflate.h"
const char deflate_copyright[] = const char deflate_copyright[] =
...@@ -430,7 +430,7 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength) ...@@ -430,7 +430,7 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
fill_window(s); fill_window(s);
} }
s->strstart += s->lookahead; s->strstart += s->lookahead;
s->block_start = (long)s->strstart; s->block_start = (int64_t)s->strstart;
s->insert = s->lookahead; s->insert = s->lookahead;
s->lookahead = 0; s->lookahead = 0;
s->match_length = s->prev_length = MIN_MATCH-1; s->match_length = s->prev_length = MIN_MATCH-1;
...@@ -1512,7 +1512,7 @@ local void fill_window(s) ...@@ -1512,7 +1512,7 @@ local void fill_window(s)
zmemcpy(s->window, s->window+wsize, (unsigned)wsize - more); zmemcpy(s->window, s->window+wsize, (unsigned)wsize - more);
s->match_start -= wsize; s->match_start -= wsize;
s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ s->strstart -= wsize; /* we now have strstart >= MAX_DIST */
s->block_start -= (long) wsize; s->block_start -= (int64_t) wsize;
slide_hash(s); slide_hash(s);
more += wsize; more += wsize;
} }
...@@ -1606,7 +1606,7 @@ local void fill_window(s) ...@@ -1606,7 +1606,7 @@ local void fill_window(s)
_tr_flush_block(s, (s->block_start >= 0L ? \ _tr_flush_block(s, (s->block_start >= 0L ? \
(charf *)&s->window[(unsigned)s->block_start] : \ (charf *)&s->window[(unsigned)s->block_start] : \
(charf *)Z_NULL), \ (charf *)Z_NULL), \
(ulg)((long)s->strstart - s->block_start), \ (ulg)((int64_t)s->strstart - s->block_start), \
(last)); \ (last)); \
s->block_start = s->strstart; \ s->block_start = s->strstart; \
flush_pending(s->strm); \ flush_pending(s->strm); \
...@@ -1766,12 +1766,12 @@ local block_state deflate_stored(s, flush) ...@@ -1766,12 +1766,12 @@ local block_state deflate_stored(s, flush)
/* If flushing and all input has been consumed, then done. */ /* If flushing and all input has been consumed, then done. */
if (flush != Z_NO_FLUSH && flush != Z_FINISH && if (flush != Z_NO_FLUSH && flush != Z_FINISH &&
s->strm->avail_in == 0 && (long)s->strstart == s->block_start) s->strm->avail_in == 0 && (int64_t)s->strstart == s->block_start)
return block_done; return block_done;
/* Fill the window with any remaining input. */ /* Fill the window with any remaining input. */
have = s->window_size - s->strstart - 1; have = s->window_size - s->strstart - 1;
if (s->strm->avail_in > have && s->block_start >= (long)s->w_size) { if (s->strm->avail_in > have && s->block_start >= (int64_t)s->w_size) {
/* Slide the window down. */ /* Slide the window down. */
s->block_start -= s->w_size; s->block_start -= s->w_size;
s->strstart -= s->w_size; s->strstart -= s->w_size;
......
...@@ -151,7 +151,7 @@ typedef struct internal_state { ...@@ -151,7 +151,7 @@ typedef struct internal_state {
* hash_shift * MIN_MATCH >= hash_bits * hash_shift * MIN_MATCH >= hash_bits
*/ */
long block_start; int64_t block_start;
/* Window position at the beginning of the current output block. Gets /* Window position at the beginning of the current output block. Gets
* negative when the window is moved backwards. * negative when the window is moved backwards.
*/ */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Copyright (C) 2004, 2010 Mark Adler * Copyright (C) 2004, 2010 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
#include <stdint.h>
#include "gzguts.h" #include "gzguts.h"
/* gzclose() is in a separate file so that it is linked in only if it is used. /* gzclose() is in a separate file so that it is linked in only if it is used.
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Copyright (C) 2004-2017 Mark Adler * Copyright (C) 2004-2017 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
#include <stdint.h>
#include "gzguts.h" #include "gzguts.h"
#if defined(_WIN32) && !defined(__BORLANDC__) && !defined(__MINGW32__) #if defined(_WIN32) && !defined(__BORLANDC__) && !defined(__MINGW32__)
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013, 2016 Mark Adler * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013, 2016 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
#include <stdint.h>
#include "gzguts.h" #include "gzguts.h"
/* Local functions */ /* Local functions */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Copyright (C) 2004-2017 Mark Adler * Copyright (C) 2004-2017 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
#include <stdint.h>
#include "gzguts.h" #include "gzguts.h"
/* Local functions */ /* Local functions */
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
with inffast.c is retained so that optimized assembler-coded versions of with inffast.c is retained so that optimized assembler-coded versions of
inflate_fast() can be used with either inflate.c or infback.c. inflate_fast() can be used with either inflate.c or infback.c.
*/ */
#include <stdint.h>
#include "zutil.h" #include "zutil.h"
#include "inftrees.h" #include "inftrees.h"
#include "inflate.h" #include "inflate.h"
...@@ -173,7 +173,7 @@ struct inflate_state FAR *state; ...@@ -173,7 +173,7 @@ struct inflate_state FAR *state;
do { \ do { \
PULL(); \ PULL(); \
have--; \ have--; \
hold += (unsigned long)(*next++) << bits; \ hold += (uint64_t)(*next++) << bits; \
bits += 8; \ bits += 8; \
} while (0) } while (0)
...@@ -258,7 +258,7 @@ void FAR *out_desc; ...@@ -258,7 +258,7 @@ void FAR *out_desc;
z_const unsigned char FAR *next; /* next input */ z_const unsigned char FAR *next; /* next input */
unsigned char FAR *put; /* next output */ unsigned char FAR *put; /* next output */
unsigned have, left; /* available input and output */ unsigned have, left; /* available input and output */
unsigned long hold; /* bit buffer */ uint64_t hold; /* bit buffer */
unsigned bits; /* bits in bit buffer */ unsigned bits; /* bits in bit buffer */
unsigned copy; /* number of stored or match bytes to copy */ unsigned copy; /* number of stored or match bytes to copy */
unsigned char FAR *from; /* where to copy match bytes from */ unsigned char FAR *from; /* where to copy match bytes from */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Copyright (C) 1995-2017 Mark Adler * Copyright (C) 1995-2017 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
#include <stdint.h>
#include "zutil.h" #include "zutil.h"
#include "inftrees.h" #include "inftrees.h"
#include "inflate.h" #include "inflate.h"
...@@ -64,7 +64,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ ...@@ -64,7 +64,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
unsigned whave; /* valid bytes in the window */ unsigned whave; /* valid bytes in the window */
unsigned wnext; /* window write index */ unsigned wnext; /* window write index */
unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */ unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */
unsigned long hold; /* local strm->hold */ uint64_t hold; /* local strm->hold */
unsigned bits; /* local strm->bits */ unsigned bits; /* local strm->bits */
code const FAR *lcode; /* local strm->lencode */ code const FAR *lcode; /* local strm->lencode */
code const FAR *dcode; /* local strm->distcode */ code const FAR *dcode; /* local strm->distcode */
...@@ -102,9 +102,9 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ ...@@ -102,9 +102,9 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
input data or output space */ input data or output space */
do { do {
if (bits < 15) { if (bits < 15) {
hold += (unsigned long)(*in++) << bits; hold += (uint64_t)(*in++) << bits;
bits += 8; bits += 8;
hold += (unsigned long)(*in++) << bits; hold += (uint64_t)(*in++) << bits;
bits += 8; bits += 8;
} }
here = lcode[hold & lmask]; here = lcode[hold & lmask];
...@@ -124,7 +124,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ ...@@ -124,7 +124,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
op &= 15; /* number of extra bits */ op &= 15; /* number of extra bits */
if (op) { if (op) {
if (bits < op) { if (bits < op) {
hold += (unsigned long)(*in++) << bits; hold += (uint64_t)(*in++) << bits;
bits += 8; bits += 8;
} }
len += (unsigned)hold & ((1U << op) - 1); len += (unsigned)hold & ((1U << op) - 1);
...@@ -133,9 +133,9 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ ...@@ -133,9 +133,9 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
} }
Tracevv((stderr, "inflate: length %u\n", len)); Tracevv((stderr, "inflate: length %u\n", len));
if (bits < 15) { if (bits < 15) {
hold += (unsigned long)(*in++) << bits; hold += (uint64_t)(*in++) << bits;
bits += 8; bits += 8;
hold += (unsigned long)(*in++) << bits; hold += (uint64_t)(*in++) << bits;
bits += 8; bits += 8;
} }
here = dcode[hold & dmask]; here = dcode[hold & dmask];
...@@ -148,10 +148,10 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ ...@@ -148,10 +148,10 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
dist = (unsigned)(here.val); dist = (unsigned)(here.val);
op &= 15; /* number of extra bits */ op &= 15; /* number of extra bits */
if (bits < op) { if (bits < op) {
hold += (unsigned long)(*in++) << bits; hold += (uint64_t)(*in++) << bits;
bits += 8; bits += 8;
if (bits < op) { if (bits < op) {
hold += (unsigned long)(*in++) << bits; hold += (uint64_t)(*in++) << bits;
bits += 8; bits += 8;
} }
} }
......
...@@ -79,7 +79,7 @@ ...@@ -79,7 +79,7 @@
* *
* The history for versions after 1.2.0 are in ChangeLog in zlib distribution. * The history for versions after 1.2.0 are in ChangeLog in zlib distribution.
*/ */
#include <stdint.h>
#include "zutil.h" #include "zutil.h"
#include "inftrees.h" #include "inftrees.h"
#include "inflate.h" #include "inflate.h"
...@@ -507,7 +507,7 @@ unsigned copy; ...@@ -507,7 +507,7 @@ unsigned copy;
do { \ do { \
if (have == 0) goto inf_leave; \ if (have == 0) goto inf_leave; \
have--; \ have--; \
hold += (unsigned long)(*next++) << bits; \ hold += (uint64_t)(*next++) << bits; \
bits += 8; \ bits += 8; \
} while (0) } while (0)
...@@ -627,7 +627,7 @@ int flush; ...@@ -627,7 +627,7 @@ int flush;
z_const unsigned char FAR *next; /* next input */ z_const unsigned char FAR *next; /* next input */
unsigned char FAR *put; /* next output */ unsigned char FAR *put; /* next output */
unsigned have, left; /* available input and output */ unsigned have, left; /* available input and output */
unsigned long hold; /* bit buffer */ uint64_t hold; /* bit buffer */
unsigned bits; /* bits in bit buffer */ unsigned bits; /* bits in bit buffer */
unsigned in, out; /* save starting available input and output */ unsigned in, out; /* save starting available input and output */
unsigned copy; /* number of stored or match bytes to copy */ unsigned copy; /* number of stored or match bytes to copy */
...@@ -1317,7 +1317,7 @@ const Bytef *dictionary; ...@@ -1317,7 +1317,7 @@ const Bytef *dictionary;
uInt dictLength; uInt dictLength;
{ {
struct inflate_state FAR *state; struct inflate_state FAR *state;
unsigned long dictid; uint64_t dictid;
int ret; int ret;
/* check state */ /* check state */
...@@ -1401,7 +1401,7 @@ int ZEXPORT inflateSync(strm) ...@@ -1401,7 +1401,7 @@ int ZEXPORT inflateSync(strm)
z_streamp strm; z_streamp strm;
{ {
unsigned len; /* number of bytes to look at or looked at */ unsigned len; /* number of bytes to look at or looked at */
unsigned long in, out; /* temporary to save total_in and total_out */ uint64_t in, out; /* temporary to save total_in and total_out */
unsigned char buf[4]; /* to restore bit buffer to byte string */ unsigned char buf[4]; /* to restore bit buffer to byte string */
struct inflate_state FAR *state; struct inflate_state FAR *state;
...@@ -1538,7 +1538,7 @@ int check; ...@@ -1538,7 +1538,7 @@ int check;
return Z_OK; return Z_OK;
} }
long ZEXPORT inflateMark(strm) int64_t ZEXPORT inflateMark(strm)
z_streamp strm; z_streamp strm;
{ {
struct inflate_state FAR *state; struct inflate_state FAR *state;
...@@ -1546,16 +1546,16 @@ z_streamp strm; ...@@ -1546,16 +1546,16 @@ z_streamp strm;
if (inflateStateCheck(strm)) if (inflateStateCheck(strm))
return -(1L << 16); return -(1L << 16);
state = (struct inflate_state FAR *)strm->state; state = (struct inflate_state FAR *)strm->state;
return (long)(((unsigned long)((long)state->back)) << 16) + return (int64_t)(((uint64_t)((int64_t)state->back)) << 16) +
(state->mode == COPY ? state->length : (state->mode == COPY ? state->length :
(state->mode == MATCH ? state->was - state->length : 0)); (state->mode == MATCH ? state->was - state->length : 0));
} }
unsigned long ZEXPORT inflateCodesUsed(strm) uint64_t ZEXPORT inflateCodesUsed(strm)
z_streamp strm; z_streamp strm;
{ {
struct inflate_state FAR *state; struct inflate_state FAR *state;
if (inflateStateCheck(strm)) return (unsigned long)-1; if (inflateStateCheck(strm)) return (uint64_t)-1;
state = (struct inflate_state FAR *)strm->state; state = (struct inflate_state FAR *)strm->state;
return (unsigned long)(state->next - state->codes); return (uint64_t)(state->next - state->codes);
} }
...@@ -88,8 +88,8 @@ struct inflate_state { ...@@ -88,8 +88,8 @@ struct inflate_state {
int havedict; /* true if dictionary provided */ int havedict; /* true if dictionary provided */
int flags; /* gzip header method and flags (0 if zlib) */ int flags; /* gzip header method and flags (0 if zlib) */
unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */ unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */
unsigned long check; /* protected copy of check value */ uint64_t check; /* protected copy of check value */
unsigned long total; /* protected copy of output count */ uint64_t total; /* protected copy of output count */
gz_headerp head; /* where to save gzip header information */ gz_headerp head; /* where to save gzip header information */
/* sliding window */ /* sliding window */
unsigned wbits; /* log base 2 of requested window size */ unsigned wbits; /* log base 2 of requested window size */
...@@ -98,7 +98,7 @@ struct inflate_state { ...@@ -98,7 +98,7 @@ struct inflate_state {
unsigned wnext; /* window write index */ unsigned wnext; /* window write index */
unsigned char FAR *window; /* allocated sliding window, if needed */ unsigned char FAR *window; /* allocated sliding window, if needed */
/* bit accumulator */ /* bit accumulator */
unsigned long hold; /* input bit accumulator */ uint64_t hold; /* input bit accumulator */
unsigned bits; /* number of bits in "in" */ unsigned bits; /* number of bits in "in" */
/* for string and stored block copying */ /* for string and stored block copying */
unsigned length; /* literal or length of data to copy */ unsigned length; /* literal or length of data to copy */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Copyright (C) 1995-2017 Mark Adler * Copyright (C) 1995-2017 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
#include <stdint.h>
#include "zutil.h" #include "zutil.h"
#include "inftrees.h" #include "inftrees.h"
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
/* @(#) $Id$ */ /* @(#) $Id$ */
/* #define GEN_TREES_H */ /* #define GEN_TREES_H */
#include <stdint.h>
#include "deflate.h" #include "deflate.h"
#ifdef ZLIB_DEBUG #ifdef ZLIB_DEBUG
...@@ -1038,7 +1038,7 @@ int ZLIB_INTERNAL _tr_tally (s, dist, lc) ...@@ -1038,7 +1038,7 @@ int ZLIB_INTERNAL _tr_tally (s, dist, lc)
if ((s->last_lit & 0x1fff) == 0 && s->level > 2) { if ((s->last_lit & 0x1fff) == 0 && s->level > 2) {
/* Compute an upper bound for the compressed length */ /* Compute an upper bound for the compressed length */
ulg out_length = (ulg)s->last_lit*8L; ulg out_length = (ulg)s->last_lit*8L;
ulg in_length = (ulg)((long)s->strstart - s->block_start); ulg in_length = (ulg)((int64_t)s->strstart - s->block_start);
int dcode; int dcode;
for (dcode = 0; dcode < D_CODES; dcode++) { for (dcode = 0; dcode < D_CODES; dcode++) {
out_length += (ulg)s->dyn_dtree[dcode].Freq * out_length += (ulg)s->dyn_dtree[dcode].Freq *
...@@ -1128,7 +1128,7 @@ local int detect_data_type(s) ...@@ -1128,7 +1128,7 @@ local int detect_data_type(s)
* set bits 0..6, 14..25, and 28..31 * set bits 0..6, 14..25, and 28..31
* 0xf3ffc07f = binary 11110011111111111100000001111111 * 0xf3ffc07f = binary 11110011111111111100000001111111
*/ */
unsigned long black_mask = 0xf3ffc07fUL; uint64_t black_mask = 0xf3ffc07fUL;
int n; int n;
/* Check for non-textual ("black-listed") bytes. */ /* Check for non-textual ("black-listed") bytes. */
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
*/ */
/* @(#) $Id$ */ /* @(#) $Id$ */
#include <stdint.h>
#define ZLIB_INTERNAL #define ZLIB_INTERNAL
#include "zlib.h" #include "zlib.h"
......
...@@ -238,16 +238,16 @@ ...@@ -238,16 +238,16 @@
#endif #endif
#ifdef Z_SOLO #ifdef Z_SOLO
typedef unsigned long z_size_t; typedef uint64_t z_size_t;
#else #else
# define z_longlong long long # define z_longlong int64_t
# if defined(NO_SIZE_T) # if defined(NO_SIZE_T)
typedef unsigned NO_SIZE_T z_size_t; typedef unsigned NO_SIZE_T z_size_t;
# elif defined(STDC) # elif defined(STDC)
# include <stddef.h> # include <stddef.h>
typedef size_t z_size_t; typedef size_t z_size_t;
# else # else
typedef unsigned long z_size_t; typedef uint64_t z_size_t;
# endif # endif
# undef z_longlong # undef z_longlong
#endif #endif
...@@ -391,7 +391,7 @@ ...@@ -391,7 +391,7 @@
typedef unsigned char Byte; /* 8 bits */ typedef unsigned char Byte; /* 8 bits */
#endif #endif
typedef unsigned int uInt; /* 16 bits or more */ typedef unsigned int uInt; /* 16 bits or more */
typedef unsigned long uLong; /* 32 bits or more */ typedef uint64_t uLong; /* 32 bits or more */
#ifdef SMALL_MEDIUM #ifdef SMALL_MEDIUM
/* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
...@@ -419,7 +419,7 @@ typedef uLong FAR uLongf; ...@@ -419,7 +419,7 @@ typedef uLong FAR uLongf;
# if (UINT_MAX == 0xffffffffUL) # if (UINT_MAX == 0xffffffffUL)
# define Z_U4 unsigned # define Z_U4 unsigned
# elif (ULONG_MAX == 0xffffffffUL) # elif (ULONG_MAX == 0xffffffffUL)
# define Z_U4 unsigned long # define Z_U4 uint64_t
# elif (USHRT_MAX == 0xffffffffUL) # elif (USHRT_MAX == 0xffffffffUL)
# define Z_U4 unsigned short # define Z_U4 unsigned short
# endif # endif
...@@ -428,7 +428,7 @@ typedef uLong FAR uLongf; ...@@ -428,7 +428,7 @@ typedef uLong FAR uLongf;
#ifdef Z_U4 #ifdef Z_U4
typedef Z_U4 z_crc_t; typedef Z_U4 z_crc_t;
#else #else
typedef unsigned long z_crc_t; typedef uint64_t z_crc_t;
#endif #endif
#if 1 /* was set to #if 1 by ./configure */ #if 1 /* was set to #if 1 by ./configure */
...@@ -501,7 +501,7 @@ typedef uLong FAR uLongf; ...@@ -501,7 +501,7 @@ typedef uLong FAR uLongf;
#endif #endif
#ifndef z_off_t #ifndef z_off_t
# define z_off_t long # define z_off_t int64_t
#endif #endif
#if !defined(_WIN32) && defined(Z_LARGE64) #if !defined(_WIN32) && defined(Z_LARGE64)
......
...@@ -999,7 +999,7 @@ ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, ...@@ -999,7 +999,7 @@ ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm,
stream state was inconsistent. stream state was inconsistent.
*/ */
ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm)); ZEXTERN int64_t ZEXPORT inflateMark OF((z_streamp strm));
/* /*
This function returns two values, one in the lower 16 bits of the return This function returns two values, one in the lower 16 bits of the return
value, and the other in the remaining upper bits, obtained by shifting the value, and the other in the remaining upper bits, obtained by shifting the
...@@ -1890,7 +1890,7 @@ ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp)); ...@@ -1890,7 +1890,7 @@ ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp));
ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void)); ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void));
ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int));
ZEXTERN int ZEXPORT inflateValidate OF((z_streamp, int)); ZEXTERN int ZEXPORT inflateValidate OF((z_streamp, int));
ZEXTERN unsigned long ZEXPORT inflateCodesUsed OF ((z_streamp)); ZEXTERN uint64_t ZEXPORT inflateCodesUsed OF ((z_streamp));
ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp)); ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp));
ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp)); ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp));
#if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(Z_SOLO) #if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(Z_SOLO)
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
*/ */
/* @(#) $Id$ */ /* @(#) $Id$ */
#include <stdint.h>
#include "zutil.h" #include "zutil.h"
#ifndef Z_SOLO #ifndef Z_SOLO
# include "gzguts.h" # include "gzguts.h"
...@@ -280,7 +280,7 @@ void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) ...@@ -280,7 +280,7 @@ void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, uInt items, uInt size) voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, uInt items, uInt size)
{ {
(void)opaque; (void)opaque;
return _halloc((long)items, size); return _halloc((int64_t)items, size);
} }
void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#endif #endif
#ifdef Z_SOLO #ifdef Z_SOLO
typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */ typedef int64_t ptrdiff_t; /* guess -- will be caught if guess is wrong */
#endif #endif
#ifndef local #ifndef local
...@@ -44,7 +44,7 @@ typedef unsigned char uch; ...@@ -44,7 +44,7 @@ typedef unsigned char uch;
typedef uch FAR uchf; typedef uch FAR uchf;
typedef unsigned short ush; typedef unsigned short ush;
typedef ush FAR ushf; typedef ush FAR ushf;
typedef unsigned long ulg; typedef uint64_t ulg;
extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
/* (size given to avoid silly warnings with Visual C++) */ /* (size given to avoid silly warnings with Visual C++) */
...@@ -89,7 +89,7 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ ...@@ -89,7 +89,7 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) # if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
/* Allow compilation with ANSI keywords only enabled */ /* Allow compilation with ANSI keywords only enabled */
void _Cdecl farfree( void *block ); void _Cdecl farfree( void *block );
void *_Cdecl farmalloc( unsigned long nbytes ); void *_Cdecl farmalloc( uint64_t nbytes );
# else # else
# include <alloc.h> # include <alloc.h>
# endif # endif
......
...@@ -63,7 +63,7 @@ Query OK, 2 row(s) in set (0.001700s)</code></pre> ...@@ -63,7 +63,7 @@ Query OK, 2 row(s) in set (0.001700s)</code></pre>
<a class='anchor' id='主要功能'></a><h2>主要功能</h2> <a class='anchor' id='主要功能'></a><h2>主要功能</h2>
<p>TDengine的核心功能是时序数据库。除此之外,为减少研发的复杂度、系统维护的难度,TDengine还提供缓存、消息队列、订阅、流式计算等功能。更详细的功能如下:</p> <p>TDengine的核心功能是时序数据库。除此之外,为减少研发的复杂度、系统维护的难度,TDengine还提供缓存、消息队列、订阅、流式计算等功能。更详细的功能如下:</p>
<ul> <ul>
<li>使用类SQL语言插入或查询数据</li> <li>使用类SQL语言插入或查询数据</li>
<li>支持C/C++, Java(JDBC), Python, Go, RESTful, and Node.JS 开发接口</li> <li>支持C/C++, Java(JDBC), Python, Go, RESTful, and Node.JS 开发接口</li>
<li>可通过Python/R/Matlab or TDengine shell做Ad Hoc查询分析</li> <li>可通过Python/R/Matlab or TDengine shell做Ad Hoc查询分析</li>
<li>通过定时连续查询支持基于滑动窗口的流式计算</li> <li>通过定时连续查询支持基于滑动窗口的流式计算</li>
......
...@@ -24,7 +24,7 @@ tags (location binary(20), type int)</code></pre> ...@@ -24,7 +24,7 @@ tags (location binary(20), type int)</code></pre>
<p>说明:</p> <p>说明:</p>
<ol> <ol>
<li>TAGS列总长度不能超过512 bytes;</li> <li>TAGS列总长度不能超过512 bytes;</li>
<li>TAGS列的数据类型不能是timestamp和nchar类型;</li> <li>TAGS列的数据类型不能是timestamp类型;</li>
<li>TAGS列名不能与其他列名相同;</li> <li>TAGS列名不能与其他列名相同;</li>
<li>TAGS列名不能为预留关键字. </li></ol></li> <li>TAGS列名不能为预留关键字. </li></ol></li>
<li><p>显示已创建的超级表</p> <li><p>显示已创建的超级表</p>
...@@ -40,7 +40,7 @@ tags (location binary(20), type int)</code></pre> ...@@ -40,7 +40,7 @@ tags (location binary(20), type int)</code></pre>
<p>统计属于某个STable并满足查询条件的子表的数量</p></li> <p>统计属于某个STable并满足查询条件的子表的数量</p></li>
</ul> </ul>
<a class='anchor' id='写数据时自动建子表'></a><h2>写数据时自动建子表</h2> <a class='anchor' id='写数据时自动建子表'></a><h2>写数据时自动建子表</h2>
<p>在某些特殊场景中,用户在写数据时并不确定某个设备的表是否存在,此时可使用自动建表语法来实现写入数据时用超级表定义的表结构自动创建不存在的子表,若该表已存在则不会建立新表。注意:自动建表语句只能自动建立子表而不能建立超级表,这就要求超级表已经被事先定义好。自动建表语法跟insert/import语法非常相似,唯一区别是语句中增加了超级表和标签信息。具体语法如下:</p> <p>在某些特殊场景中,用户在写数据时并不确定某个设备的表是否存在,此时可使用自动建表语法来实现写入数据时用超级表定义的表结构自动创建不存在的子表,若该表已存在则不会建立新表。注意:自动建表语句只能自动建立子表而不能建立超级表,这就要求超级表已经被事先定义好。自动建表语法跟insert/import语法非常相似,唯一区别是语句中增加了超级表和标签信息。具体语法如下:</p>
<pre><code class="mysql language-mysql">INSERT INTO &lt;tb_name&gt; USING &lt;stb_name&gt; TAGS (&lt;tag1_value&gt;, ...) VALUES (field_value, ...) (field_value, ...) ...;</code></pre> <pre><code class="mysql language-mysql">INSERT INTO &lt;tb_name&gt; USING &lt;stb_name&gt; TAGS (&lt;tag1_value&gt;, ...) VALUES (field_value, ...) (field_value, ...) ...;</code></pre>
<p>向表tb_name中插入一条或多条记录,如果tb_name这张表不存在,则会用超级表stb_name定义的表结构以及用户指定的标签值(即tag1_value…)来创建名为tb_name新表,并将用户指定的值写入表中。如果tb_name已经存在,则建表过程会被忽略,系统也不会检查tb_name的标签是否与用户指定的标签值一致,也即不会更新已存在表的标签。</p> <p>向表tb_name中插入一条或多条记录,如果tb_name这张表不存在,则会用超级表stb_name定义的表结构以及用户指定的标签值(即tag1_value…)来创建名为tb_name新表,并将用户指定的值写入表中。如果tb_name已经存在,则建表过程会被忽略,系统也不会检查tb_name的标签是否与用户指定的标签值一致,也即不会更新已存在表的标签。</p>
<pre><code class="mysql language-mysql">INSERT INTO &lt;tb1_name&gt; USING &lt;stb1_name&gt; TAGS (&lt;tag1_value1&gt;, ...) VALUES (&lt;field1_value1&gt;, ...) (&lt;field1_value2&gt;, ...) ... &lt;tb_name2&gt; USING &lt;stb_name2&gt; TAGS(&lt;tag1_value2&gt;, ...) VALUES (&lt;field1_value1&gt;, ...) ...;</code></pre> <pre><code class="mysql language-mysql">INSERT INTO &lt;tb1_name&gt; USING &lt;stb1_name&gt; TAGS (&lt;tag1_value1&gt;, ...) VALUES (&lt;field1_value1&gt;, ...) (&lt;field1_value2&gt;, ...) ... &lt;tb_name2&gt; USING &lt;stb_name2&gt; TAGS(&lt;tag1_value2&gt;, ...) VALUES (&lt;field1_value1&gt;, ...) ...;</code></pre>
...@@ -105,6 +105,6 @@ GROUP BY location, type </code></pre> ...@@ -105,6 +105,6 @@ GROUP BY location, type </code></pre>
<p>查询仅位于北京以外地区的温度传感器最近24小时(24h)采样值的数量count(*)、平均温度avg(degree)、最高温度max(degree)和最低温度min(degree),将采集结果按照10分钟为周期进行聚合,并将结果按所处地域(location)和传感器类型(type)再次进行聚合。</p> <p>查询仅位于北京以外地区的温度传感器最近24小时(24h)采样值的数量count(*)、平均温度avg(degree)、最高温度max(degree)和最低温度min(degree),将采集结果按照10分钟为周期进行聚合,并将结果按所处地域(location)和传感器类型(type)再次进行聚合。</p>
<pre><code class="mysql language-mysql">SELECT COUNT(*), AVG(degree), MAX(degree), MIN(degree) <pre><code class="mysql language-mysql">SELECT COUNT(*), AVG(degree), MAX(degree), MIN(degree)
FROM thermometer FROM thermometer
WHERE name&lt;&gt;'beijing' and ts&gt;=now-1d WHERE location&lt;&gt;'beijing' and ts&gt;=now-1d
INTERVAL(10M) INTERVAL(10M)
GROUP BY location, type</code></pre><a href='../index.html'>回去</a></section></main></div><?php include($s.'/footer.php'); ?><script>$('pre').addClass('prettyprint linenums');PR.prettyPrint()</script><script src='lib/docs/liner.js'></script></body></html> GROUP BY location, type</code></pre><a href='../index.html'>回去</a></section></main></div><?php include($s.'/footer.php'); ?><script>$('pre').addClass('prettyprint linenums');PR.prettyPrint()</script><script src='lib/docs/liner.js'></script></body></html>
...@@ -359,9 +359,9 @@ SELECT function_list FROM tb_name ...@@ -359,9 +359,9 @@ SELECT function_list FROM tb_name
SELECT function_list FROM stb_name SELECT function_list FROM stb_name
[WHERE where_condition] [WHERE where_condition]
[GROUP BY tags] [FILL ({ VALUE | PREV | NULL | LINEAR})]
INTERVAL (interval) INTERVAL (interval)
[FILL ({ VALUE | PREV | NULL | LINEAR})]</code></pre> [GROUP BY tags]</code></pre>
<ul> <ul>
<li>聚合时间段的长度由关键词INTERVAL指定,最短时间间隔10毫秒(10a)。聚合查询中,能够同时执行的聚合和选择函数仅限于单个输出的函数:count、avg、sum 、stddev、leastsquares、percentile、min、max、first、last,不能使用具有多行输出结果的函数(例如:top、bottom、diff以及四则运算)。</li> <li>聚合时间段的长度由关键词INTERVAL指定,最短时间间隔10毫秒(10a)。聚合查询中,能够同时执行的聚合和选择函数仅限于单个输出的函数:count、avg、sum 、stddev、leastsquares、percentile、min、max、first、last,不能使用具有多行输出结果的函数(例如:top、bottom、diff以及四则运算)。</li>
<li>WHERE语句可以指定查询的起止时间和其他过滤条件 </li> <li>WHERE语句可以指定查询的起止时间和其他过滤条件 </li>
......
...@@ -6,9 +6,9 @@ ...@@ -6,9 +6,9 @@
<p>Like a table, you can create, show, delete and describe STables. Most query operations on tables can be applied to STable too, including the aggregation and selector functions. For queries on a STable, if no tags filter, the operations are applied to all the tables created via this STable. If there is a tag filter, the operations are applied only to a subset of the tables which satisfy the tag filter conditions. It will be very convenient to use tags to put devices into different groups for aggregation.</p> <p>Like a table, you can create, show, delete and describe STables. Most query operations on tables can be applied to STable too, including the aggregation and selector functions. For queries on a STable, if no tags filter, the operations are applied to all the tables created via this STable. If there is a tag filter, the operations are applied only to a subset of the tables which satisfy the tag filter conditions. It will be very convenient to use tags to put devices into different groups for aggregation.</p>
<a class='anchor' id='Create-a-STable'></a><h2>Create a STable</h2> <a class='anchor' id='Create-a-STable'></a><h2>Create a STable</h2>
<p>Similiar to creating a standard table, syntax is: </p> <p>Similiar to creating a standard table, syntax is: </p>
<pre><code class="mysql language-mysql">CREATE TABLE &lt;stable_name&gt; (&lt;field_name&gt; TIMESTAMP, field_name1 field_type,…) TAGS(tag_name tag_type, …)</code></pre> <pre><code class="mysql language-mysql">CREATE TABLE &lt;stable_name&gt; (&lt;field_name&gt; TIMESTAMP, field_name1 field_type, ...) TAGS(tag_name tag_type, ...)</code></pre>
<p>New keyword "tags" is introduced, where tag_name is the tag name, and tag_type is the associated data type. </p> <p>New keyword "tags" is introduced, where tag_name is the tag name, and tag_type is the associated data type. </p>
<p>Note</p> <p>Note: </p>
<ol> <ol>
<li>The bytes of all tags together shall be less than 512 </li> <li>The bytes of all tags together shall be less than 512 </li>
<li>Tag's data type can not be time stamp or nchar</li> <li>Tag's data type can not be time stamp or nchar</li>
...@@ -30,12 +30,12 @@ tags (location binary(20), type int)</code></pre> ...@@ -30,12 +30,12 @@ tags (location binary(20), type int)</code></pre>
create table t4 using thermometer tags ('shanghai', 20); create table t4 using thermometer tags ('shanghai', 20);
create table t5 using thermometer tags ('new york', 10);</code></pre> create table t5 using thermometer tags ('new york', 10);</code></pre>
<a class='anchor' id='Aggregate-Tables-via-STable'></a><h2>Aggregate Tables via STable</h2> <a class='anchor' id='Aggregate-Tables-via-STable'></a><h2>Aggregate Tables via STable</h2>
<p>You can group a set of tables together by specifying the tags filter condition, then apply the aggregation operations. The result set can be grouped and ordered based on tag value. Syntax is</p> <p>You can group a set of tables together by specifying the tags filter condition, then apply the aggregation operations. The result set can be grouped and ordered based on tag value. Syntax is:</p>
<pre><code class="mysql language-mysql">SELECT function&lt;field_name&gt;, <pre><code class="mysql language-mysql">SELECT function&lt;field_name&gt;, ...
FROM &lt;stable_name&gt; FROM &lt;stable_name&gt;
WHERE &lt;tag_name&gt; &lt;[=|&lt;=|&gt;=|&lt;&gt;] values..&gt; ([AND|OR] …) WHERE &lt;tag_name&gt; &lt;[=|&lt;=|&gt;=|&lt;&gt;] values..&gt; ([AND|OR] ...
INTERVAL (&lt;time range&gt;) INTERVAL (&lt;time range&gt;)
GROUP BY &lt;tag_name&gt;, &lt;tag_name&gt; GROUP BY &lt;tag_name&gt;, &lt;tag_name&gt; ...
ORDER BY &lt;tag_name&gt; &lt;asc|desc&gt; ORDER BY &lt;tag_name&gt; &lt;asc|desc&gt;
SLIMIT &lt;group_limit&gt; SLIMIT &lt;group_limit&gt;
SOFFSET &lt;group_offset&gt; SOFFSET &lt;group_offset&gt;
...@@ -75,9 +75,9 @@ INTERVAL(10M)</code></pre> ...@@ -75,9 +75,9 @@ INTERVAL(10M)</code></pre>
<pre><code class="mysql language-mysql">DROP TABLE &lt;stable_name&gt;</code></pre> <pre><code class="mysql language-mysql">DROP TABLE &lt;stable_name&gt;</code></pre>
<p>To delete a STable, all the tables created via this STable shall be deleted first, otherwise, it will fail.</p> <p>To delete a STable, all the tables created via this STable shall be deleted first, otherwise, it will fail.</p>
<a class='anchor' id='List-the-Associated-Tables-of-a-STable'></a><h3>List the Associated Tables of a STable</h3> <a class='anchor' id='List-the-Associated-Tables-of-a-STable'></a><h3>List the Associated Tables of a STable</h3>
<pre><code class="mysql language-mysql">SELECT TBNAME,[TAG_NAME,…] FROM &lt;stable_name&gt; WHERE &lt;tag_name&gt; &lt;[=|=&lt;|&gt;=|&lt;&gt;] values..&gt; ([AND|OR] …)</code></pre> <pre><code class="mysql language-mysql">SELECT TBNAME,[TAG_NAME, ...] FROM &lt;stable_name&gt; WHERE &lt;tag_name&gt; &lt;[=|=&lt;|&gt;=|&lt;&gt;] values..&gt; ([AND|OR] ...)</code></pre>
<p>It will list all the tables which satisfy the tag filter conditions. The tables are all created from this specific STable. TBNAME is a new keyword introduced, it is the table name associated with the STable. </p> <p>It will list all the tables which satisfy the tag filter conditions. The tables are all created from this specific STable. TBNAME is a new keyword introduced, it is the table name associated with the STable. </p>
<pre><code class="mysql language-mysql">SELECT COUNT(TBNAME) FROM &lt;stable_name&gt; WHERE &lt;tag_name&gt; &lt;[=|=&lt;|&gt;=|&lt;&gt;] values..&gt; ([AND|OR] )</code></pre> <pre><code class="mysql language-mysql">SELECT COUNT(TBNAME) FROM &lt;stable_name&gt; WHERE &lt;tag_name&gt; &lt;[=|=&lt;|&gt;=|&lt;&gt;] values..&gt; ([AND|OR] ...)</code></pre>
<p>The above SQL statement will list the number of tables in a STable, which satisfy the filter condition.</p> <p>The above SQL statement will list the number of tables in a STable, which satisfy the filter condition.</p>
<a class='anchor' id='Management-of-Tags'></a><h2>Management of Tags</h2> <a class='anchor' id='Management-of-Tags'></a><h2>Management of Tags</h2>
<p>You can add, delete and change the tags for a STable, and you can change the tag value of a table. The SQL commands are listed below. </p> <p>You can add, delete and change the tags for a STable, and you can change the tag value of a table. The SQL commands are listed below. </p>
......
...@@ -8,7 +8,7 @@ C/C++ APIs are similar to the MySQL APIs. Applications should include TDengine h ...@@ -8,7 +8,7 @@ C/C++ APIs are similar to the MySQL APIs. Applications should include TDengine h
```C ```C
#include <taos.h> #include <taos.h>
``` ```
Make sure TDengine library _libtaos.so_ is installed and use _-ltaos_ option to link the library when compiling. The return values of all APIs are _-1_ or _NULL_ for failure. Make sure TDengine library _libtaos.so_ is installed and use _-ltaos_ option to link the library when compiling. In most cases, if the return value of an API is integer, it return _0_ for success and other values as an error code for failure; if the return value is pointer, then _NULL_ is used for failure.
### C/C++ sync API ### C/C++ sync API
...@@ -78,6 +78,51 @@ The 12 APIs are the most important APIs frequently used. Users can check _taos.h ...@@ -78,6 +78,51 @@ The 12 APIs are the most important APIs frequently used. Users can check _taos.h
**Note**: The connection to a TDengine server is not multi-thread safe. So a connection can only be used by one thread. **Note**: The connection to a TDengine server is not multi-thread safe. So a connection can only be used by one thread.
### C/C++ parameter binding API
TDengine also provides parameter binding APIs, like MySQL, only question mark `?` can be used to represent a parameter in these APIs.
- `TAOS_STMT* taos_stmt_init(TAOS *taos)`
Create a TAOS_STMT to represent the prepared statement for other APIs.
- `int taos_stmt_prepare(TAOS_STMT *stmt, const char *sql, unsigned long length)`
Parse SQL statement _sql_ and bind result to _stmt_ , if _length_ larger than 0, its value is used to determine the length of _sql_, the API auto detects the actual length of _sql_ otherwise.
- `int taos_stmt_bind_param(TAOS_STMT *stmt, TAOS_BIND *bind)`
Bind values to parameters. _bind_ points to an array, the element count and sequence of the array must be identical as the parameters of the SQL statement. The usage of _TAOS_BIND_ is same as _MYSQL_BIND_ in MySQL, its definition is as below:
```c
typedef struct TAOS_BIND {
int buffer_type;
void * buffer;
unsigned long buffer_length; // not used in TDengine
unsigned long *length;
int * is_null;
int is_unsigned; // not used in TDengine
int * error; // not used in TDengine
} TAOS_BIND;
```
- `int taos_stmt_add_batch(TAOS_STMT *stmt)`
Add bound parameters to batch, client can call `taos_stmt_bind_param` again after calling this API. Note this API only support _insert_ / _import_ statements, it returns an error in other cases.
- `int taos_stmt_execute(TAOS_STMT *stmt)`
Execute the prepared statement. This API can only be called once for a statement at present.
- `TAOS_RES* taos_stmt_use_result(TAOS_STMT *stmt)`
Acquire the result set of an executed statement. The usage of the result is same as `taos_use_result`, `taos_free_result` must be called after one you are done with the result set to release resources.
- `int taos_stmt_close(TAOS_STMT *stmt)`
Close the statement, release all resources.
### C/C++ async API ### C/C++ async API
In addition to sync APIs, TDengine also provides async APIs, which are more efficient. Async APIs are returned right away without waiting for a response from the server, allowing the application to continute with other tasks without blocking. So async APIs are more efficient, especially useful when in a poor network. In addition to sync APIs, TDengine also provides async APIs, which are more efficient. Async APIs are returned right away without waiting for a response from the server, allowing the application to continute with other tasks without blocking. So async APIs are more efficient, especially useful when in a poor network.
......
...@@ -54,7 +54,7 @@ STable从属于库,一个STable只属于一个库,但一个库可以有一 ...@@ -54,7 +54,7 @@ STable从属于库,一个STable只属于一个库,但一个库可以有一
说明: 说明:
1. TAGS列总长度不能超过512 bytes; 1. TAGS列总长度不能超过512 bytes;
2. TAGS列的数据类型不能是timestamp和nchar类型 2. TAGS列的数据类型不能是timestamp;
3. TAGS列名不能与其他列名相同; 3. TAGS列名不能与其他列名相同;
4. TAGS列名不能为预留关键字. 4. TAGS列名不能为预留关键字.
...@@ -169,7 +169,7 @@ SELECT function<field_name>,… ...@@ -169,7 +169,7 @@ SELECT function<field_name>,…
以温度传感器采集时序数据作为例,示范STable的使用。 在这个例子中,对每个温度计都会建立一张表,表名为温度计的ID,温度计读数的时刻记为ts,采集的值记为degree。通过tags给每个采集器打上不同的标签,其中记录温度计的地区和类型,以方便我们后面的查询。所有温度计的采集量都一样,因此我们用STable来定义表结构。 以温度传感器采集时序数据作为例,示范STable的使用。 在这个例子中,对每个温度计都会建立一张表,表名为温度计的ID,温度计读数的时刻记为ts,采集的值记为degree。通过tags给每个采集器打上不同的标签,其中记录温度计的地区和类型,以方便我们后面的查询。所有温度计的采集量都一样,因此我们用STable来定义表结构。
###定义STable表结构并使用它创建子表 ###1:定义STable表结构并使用它创建子表
创建STable语句如下: 创建STable语句如下:
...@@ -189,7 +189,7 @@ CREATE TABLE therm4 USING thermometer TAGS ('shanghai', 3); ...@@ -189,7 +189,7 @@ CREATE TABLE therm4 USING thermometer TAGS ('shanghai', 3);
其中therm1,therm2,therm3,therm4是超级表thermometer四个具体的子表,也即普通的Table。以therm1为例,它表示采集器therm1的数据,表结构完全由thermometer定义,标签location=”beijing”, type=1表示therm1的地区是北京,类型是第1类的温度计。 其中therm1,therm2,therm3,therm4是超级表thermometer四个具体的子表,也即普通的Table。以therm1为例,它表示采集器therm1的数据,表结构完全由thermometer定义,标签location=”beijing”, type=1表示therm1的地区是北京,类型是第1类的温度计。
###写入数据 ###2:写入数据
注意,写入数据时不能直接对STable操作,而是要对每张子表进行操作。我们分别向四张表therm1,therm2, therm3, therm4写入一条数据,写入语句如下: 注意,写入数据时不能直接对STable操作,而是要对每张子表进行操作。我们分别向四张表therm1,therm2, therm3, therm4写入一条数据,写入语句如下:
...@@ -200,7 +200,7 @@ INSERT INTO therm3 VALUES ('2018-01-01 00:00:00.000', 24); ...@@ -200,7 +200,7 @@ INSERT INTO therm3 VALUES ('2018-01-01 00:00:00.000', 24);
INSERT INTO therm4 VALUES ('2018-01-01 00:00:00.000', 23); INSERT INTO therm4 VALUES ('2018-01-01 00:00:00.000', 23);
``` ```
### 按标签聚合查询 ###3:按标签聚合查询
查询位于北京(beijing)和天津(tianjing)两个地区的温度传感器采样值的数量count(*)、平均温度avg(degree)、最高温度max(degree)、最低温度min(degree),并将结果按所处地域(location)和传感器类型(type)进行聚合。 查询位于北京(beijing)和天津(tianjing)两个地区的温度传感器采样值的数量count(*)、平均温度avg(degree)、最高温度max(degree)、最低温度min(degree),并将结果按所处地域(location)和传感器类型(type)进行聚合。
...@@ -211,14 +211,14 @@ WHERE location='beijing' or location='tianjin' ...@@ -211,14 +211,14 @@ WHERE location='beijing' or location='tianjin'
GROUP BY location, type GROUP BY location, type
``` ```
### 按时间周期聚合查询 ###4:按时间周期聚合查询
查询仅位于北京以外地区的温度传感器最近24小时(24h)采样值的数量count(*)、平均温度avg(degree)、最高温度max(degree)和最低温度min(degree),将采集结果按照10分钟为周期进行聚合,并将结果按所处地域(location)和传感器类型(type)再次进行聚合。 查询仅位于北京以外地区的温度传感器最近24小时(24h)采样值的数量count(*)、平均温度avg(degree)、最高温度max(degree)和最低温度min(degree),将采集结果按照10分钟为周期进行聚合,并将结果按所处地域(location)和传感器类型(type)再次进行聚合。
```mysql ```mysql
SELECT COUNT(*), AVG(degree), MAX(degree), MIN(degree) SELECT COUNT(*), AVG(degree), MAX(degree), MIN(degree)
FROM thermometer FROM thermometer
WHERE name<>'beijing' and ts>=now-1d WHERE location<>'beijing' and ts>=now-1d
INTERVAL(10M) INTERVAL(10M)
GROUP BY location, type GROUP BY location, type
``` ```
...@@ -23,7 +23,7 @@ New keyword "tags" is introduced, where tag_name is the tag name, and tag_type i ...@@ -23,7 +23,7 @@ New keyword "tags" is introduced, where tag_name is the tag name, and tag_type i
Note: Note:
1. The bytes of all tags together shall be less than 512 1. The bytes of all tags together shall be less than 512
2. Tag's data type can not be time stamp or nchar 2. Tag's data type can not be time stamp
3. Tag name shall be different from the field name 3. Tag name shall be different from the field name
4. Tag name shall not be the same as system keywords 4. Tag name shall not be the same as system keywords
5. Maximum number of tags is 6 5. Maximum number of tags is 6
...@@ -102,7 +102,7 @@ List the number of records, average, maximum, and minimum temperature every 10 m ...@@ -102,7 +102,7 @@ List the number of records, average, maximum, and minimum temperature every 10 m
```mysql ```mysql
SELECT COUNT(*), AVG(degree), MAX(degree), MIN(degree) SELECT COUNT(*), AVG(degree), MAX(degree), MIN(degree)
FROM thermometer FROM thermometer
WHERE name='beijing' and type=10 and ts>=now-1d WHERE location='beijing' and type=10 and ts>=now-1d
INTERVAL(10M) INTERVAL(10M)
``` ```
......
...@@ -424,9 +424,9 @@ SELECT function_list FROM tb_name ...@@ -424,9 +424,9 @@ SELECT function_list FROM tb_name
SELECT function_list FROM stb_name SELECT function_list FROM stb_name
[WHERE where_condition] [WHERE where_condition]
[GROUP BY tags]
INTERVAL (interval) INTERVAL (interval)
[FILL ({ VALUE | PREV | NULL | LINEAR})] [FILL ({ VALUE | PREV | NULL | LINEAR})]
[GROUP BY tags]
``` ```
- 聚合时间段的长度由关键词INTERVAL指定,最短时间间隔10毫秒(10a)。聚合查询中,能够同时执行的聚合和选择函数仅限于单个输出的函数:count、avg、sum 、stddev、leastsquares、percentile、min、max、first、last,不能使用具有多行输出结果的函数(例如:top、bottom、diff以及四则运算)。 - 聚合时间段的长度由关键词INTERVAL指定,最短时间间隔10毫秒(10a)。聚合查询中,能够同时执行的聚合和选择函数仅限于单个输出的函数:count、avg、sum 、stddev、leastsquares、percentile、min、max、first、last,不能使用具有多行输出结果的函数(例如:top、bottom、diff以及四则运算)。
......
...@@ -474,9 +474,9 @@ SELECT function_list FROM tb_name ...@@ -474,9 +474,9 @@ SELECT function_list FROM tb_name
SELECT function_list FROM stb_name SELECT function_list FROM stb_name
[WHERE where_condition] [WHERE where_condition]
[GROUP BY tags]
INTERVAL (interval) INTERVAL (interval)
[FILL ({ VALUE | PREV | NULL | LINEAR})] [FILL ({ VALUE | PREV | NULL | LINEAR})]
[GROUP BY tags]
``` ```
The downsampling time window is defined by `interval`, which is at least 10 milliseconds. The query returns a new series of downsampled data that has a series of fixed timestamps with an increment of `interval`. The downsampling time window is defined by `interval`, which is at least 10 milliseconds. The query returns a new series of downsampled data that has a series of fixed timestamps with an increment of `interval`.
......
...@@ -4,13 +4,13 @@ TDengine提供了丰富的应用程序开发接口,其中包括C/C++、JAVA、 ...@@ -4,13 +4,13 @@ TDengine提供了丰富的应用程序开发接口,其中包括C/C++、JAVA、
## C/C++ Connector ## C/C++ Connector
C/C++的API类似于MySQL的C API。应用程序使用时,需要包含TDengine头文件 _taos.h_(安装后,位于_/usr/local/taos/include_): C/C++的API类似于MySQL的C API。应用程序使用时,需要包含TDengine头文件 _taos.h_(安装后,位于 _/usr/local/taos/include_):
```C ```C
#include <taos.h> #include <taos.h>
``` ```
在编译时需要链接TDengine动态库_libtaos.so_(安装后,位于/usr/local/taos/driver,gcc编译时,请加上 -ltaos)。 所有API都以返回_-1_或_NULL_均表示失败。 在编译时需要链接TDengine动态库 _libtaos.so_ (安装后,位于 _/usr/local/taos/driver_,gcc编译时,请加上 -ltaos)。 如未特别说明,当API的返回值是整数时,_0_ 代表成功,其它是代表失败原因的错误码,当返回值是指针时, _NULL_ 表示失败。
### C/C++同步API ### C/C++同步API
...@@ -79,6 +79,51 @@ C/C++的API类似于MySQL的C API。应用程序使用时,需要包含TDengine ...@@ -79,6 +79,51 @@ C/C++的API类似于MySQL的C API。应用程序使用时,需要包含TDengine
**注意**:对于单个数据库连接,在同一时刻只能有一个线程使用该链接调用API,否则会有未定义的行为出现并可能导致客户端crash。客户端应用可以通过建立多个连接进行多线程的数据写入或查询处理。 **注意**:对于单个数据库连接,在同一时刻只能有一个线程使用该链接调用API,否则会有未定义的行为出现并可能导致客户端crash。客户端应用可以通过建立多个连接进行多线程的数据写入或查询处理。
### C/C++ 参数绑定接口
除了直接调用 `taos_query` 进行查询,TDengine也提供了支持参数绑定的Prepare API,与 MySQL 一样,这些API目前也仅支持用问号`?`来代表待绑定的参数,具体如下:
- `TAOS_STMT* taos_stmt_init(TAOS *taos)`
创建一个 TAOS_STMT 对象用于后续调用。
- `int taos_stmt_prepare(TAOS_STMT *stmt, const char *sql, unsigned long length)`
解析一条sql语句,将解析结果和参数信息绑定到stmt上,如果参数length大于0,将使用此此参数作为sql语句的长度,如等于0,将自动判断sql语句的长度。
- `int taos_stmt_bind_param(TAOS_STMT *stmt, TAOS_BIND *bind)`
进行参数绑定,bind指向一个数组,需保证此数组的元素数量和顺序与sql语句中的参数完全一致。TAOS_BIND 的使用方法与 MySQL中的 MYSQL_BIND 一致,具体定义如下:
```c
typedef struct TAOS_BIND {
int buffer_type;
void * buffer;
unsigned long buffer_length; // 未实际使用
unsigned long *length;
int * is_null;
int is_unsigned; // 未实际使用
int * error; // 未实际使用
} TAOS_BIND;
```
- `int taos_stmt_add_batch(TAOS_STMT *stmt)`
将当前绑定的参数加入批处理中,调用此函数后,可以再次调用`taos_stmt_bind_param`绑定新的参数。需要注意,此函数仅支持 insert/import 语句,如果是select等其他SQL语句,将返回错误。
- `int taos_stmt_execute(TAOS_STMT *stmt)`
执行准备好的语句。目前,一条语句只能执行一次。
- `TAOS_RES* taos_stmt_use_result(TAOS_STMT *stmt)`
获取语句的结果集。结果集的使用方式与非参数化调用时一致,使用完成后,应对此结果集调用 `taos_free_result`以释放资源。
- `int taos_stmt_close(TAOS_STMT *stmt)`
执行完毕,释放所有资源。
### C/C++异步API ### C/C++异步API
同步API之外,TDengine还提供性能更高的异步调用API处理数据插入、查询操作。在软硬件环境相同的情况下,异步API处理数据插入的速度比同步API快2~4倍。异步API采用非阻塞式的调用方式,在系统真正完成某个具体数据库操作前,立即返回。调用的线程可以去处理其他工作,从而可以提升整个应用的性能。异步API在网络延迟严重的情况下,优点尤为突出。 同步API之外,TDengine还提供性能更高的异步调用API处理数据插入、查询操作。在软硬件环境相同的情况下,异步API处理数据插入的速度比同步API快2~4倍。异步API采用非阻塞式的调用方式,在系统真正完成某个具体数据库操作前,立即返回。调用的线程可以去处理其他工作,从而可以提升整个应用的性能。异步API在网络延迟严重的情况下,优点尤为突出。
...@@ -224,13 +269,14 @@ public Connection getConn() throws Exception{ ...@@ -224,13 +269,14 @@ public Connection getConn() throws Exception{
用户可以在源代码的src/connector/python文件夹下找到python2和python3的安装包。用户可以通过pip命令安装: 用户可以在源代码的src/connector/python文件夹下找到python2和python3的安装包。用户可以通过pip命令安装:
`pip install src/connector/python/python2/` `pip install src/connector/python/[linux|windows]/python2/`
`pip install src/connector/python/python3/` `pip install src/connector/python/[linux|windows]/python3/`
如果机器上没有pip命令,用户可将src/connector/python/python3或src/connector/python/python2下的taos文件夹拷贝到应用程序的目录使用。 如果机器上没有pip命令,用户可将src/connector/python/python3或src/connector/python/python2下的taos文件夹拷贝到应用程序的目录使用。
对于windows 客户端,安装TDengine windows 客户端后,将C:\TDengine\driver\taos.dll拷贝到C:\windows\system32目录下即可。所有TDengine的连接器,均需依赖taos.dll。
### Python客户端接口 ### Python客户端接口
......
...@@ -58,6 +58,12 @@ ...@@ -58,6 +58,12 @@
# The server and client should have the same socket type. Otherwise, connect will fail. # The server and client should have the same socket type. Otherwise, connect will fail.
# sockettype udp # sockettype udp
# The compressed rpc message, option:
# -1 (no compression)
# 0 (all message compressed),
# > 0 (rpc message body which larger than this value will be compressed)
# compressMsgSize -1
# RPC re-try timer, millisecond # RPC re-try timer, millisecond
# rpcTimer 300 # rpcTimer 300
...@@ -131,10 +137,10 @@ ...@@ -131,10 +137,10 @@
# maxVnodeConnections 10000 # maxVnodeConnections 10000
# start http service in the cluster # start http service in the cluster
# enableHttp 1 # http 1
# start system monitor module in the cluster # start system monitor module in the cluster
# enableMonitor 1 # monitor 1
# number of threads used to process http requests # number of threads used to process http requests
# httpMaxThreads 2 # httpMaxThreads 2
......
...@@ -9,13 +9,13 @@ fi ...@@ -9,13 +9,13 @@ fi
if pidof taosd &> /dev/null; then if pidof taosd &> /dev/null; then
if pidof systemd &> /dev/null; then if pidof systemd &> /dev/null; then
${csudo} systemctl stop taosd || : ${csudo} systemctl stop taosd || :
elif $(which insserv &> /dev/null); then elif $(which service &> /dev/null); then
${csudo} service taosd stop || :
elif $(which update-rc.d &> /dev/null); then
${csudo} service taosd stop || : ${csudo} service taosd stop || :
else else
pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}') pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}')
${csudo} kill -9 ${pid} || : if [ -n "$pid" ]; then
${csudo} kill -9 $pid || :
fi
fi fi
echo "Stop taosd service success!" echo "Stop taosd service success!"
sleep 1 sleep 1
......
...@@ -35,6 +35,8 @@ else ...@@ -35,6 +35,8 @@ else
${csudo} rm -f ${data_link_dir} || : ${csudo} rm -f ${data_link_dir} || :
pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}') pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}')
${csudo} kill -9 ${pid} || : if [ -n "$pid" ]; then
${csudo} kill -9 $pid || :
fi
fi fi
#!/bin/bash #!/bin/bash
# #
# Generate deb package for ubuntu # Generate deb package for ubuntu
#set -x # set -x
#curr_dir=$(pwd) #curr_dir=$(pwd)
compile_dir=$1 compile_dir=$1
...@@ -24,8 +24,7 @@ fi ...@@ -24,8 +24,7 @@ fi
mkdir -p ${pkg_dir} mkdir -p ${pkg_dir}
cd ${pkg_dir} cd ${pkg_dir}
versioninfo=$(${script_dir}/../tools/get_version.sh) libfile="libtaos.so.${tdengine_ver}"
libfile="libtaos.so.${versioninfo}"
# create install dir # create install dir
install_home_path="/usr/local/taos" install_home_path="/usr/local/taos"
...@@ -49,6 +48,7 @@ cp ${compile_dir}/build/bin/taosd ${pkg_dir}${install_home_pat ...@@ -49,6 +48,7 @@ cp ${compile_dir}/build/bin/taosd ${pkg_dir}${install_home_pat
cp ${compile_dir}/build/bin/taos ${pkg_dir}${install_home_path}/bin 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/${libfile} ${pkg_dir}${install_home_path}/driver
cp ${compile_dir}/../src/inc/taos.h ${pkg_dir}${install_home_path}/include cp ${compile_dir}/../src/inc/taos.h ${pkg_dir}${install_home_path}/include
cp ${compile_dir}/../src/inc/taoserror.h ${pkg_dir}${install_home_path}/include
cp -r ${top_dir}/tests/examples/* ${pkg_dir}${install_home_path}/examples cp -r ${top_dir}/tests/examples/* ${pkg_dir}${install_home_path}/examples
cp -r ${top_dir}/src/connector/grafana ${pkg_dir}${install_home_path}/connector cp -r ${top_dir}/src/connector/grafana ${pkg_dir}${install_home_path}/connector
cp -r ${top_dir}/src/connector/python ${pkg_dir}${install_home_path}/connector cp -r ${top_dir}/src/connector/python ${pkg_dir}${install_home_path}/connector
......
文件模式从 100755 更改为 100644
...@@ -3,7 +3,9 @@ ...@@ -3,7 +3,9 @@
# Generate the deb package for ubunt, or rpm package for centos, or tar.gz package for other linux os # Generate the deb package for ubunt, or rpm package for centos, or tar.gz package for other linux os
set -e set -e
#set -x # set -x
armver=$1
curr_dir=$(pwd) curr_dir=$(pwd)
script_dir="$(dirname $(readlink -f $0))" script_dir="$(dirname $(readlink -f $0))"
...@@ -110,21 +112,28 @@ echo "char gitinfo[128] = \"$(git rev-parse --verify HEAD)\";" >> ${versioninfo ...@@ -110,21 +112,28 @@ echo "char gitinfo[128] = \"$(git rev-parse --verify HEAD)\";" >> ${versioninfo
echo "char buildinfo[512] = \"Built by ${USER} at ${build_time}\";" >> ${versioninfo} echo "char buildinfo[512] = \"Built by ${USER} at ${build_time}\";" >> ${versioninfo}
# 2. cmake executable file # 2. cmake executable file
#default use debug mode
compile_mode="debug"
if [[ $1 == "Release" ]] || [[ $1 == "release" ]]; then
compile_mode="Release"
fi
compile_dir="${top_dir}/${compile_mode}" compile_dir="${top_dir}/debug"
if [ -d ${compile_dir} ]; then if [ -d ${compile_dir} ]; then
${csudo} rm -rf ${compile_dir} ${csudo} rm -rf ${compile_dir}
fi fi
${csudo} mkdir -p ${compile_dir} ${csudo} mkdir -p ${compile_dir}
cd ${compile_dir} cd ${compile_dir}
${csudo} cmake -DCMAKE_BUILD_TYPE=${compile_mode} ${top_dir}
${csudo} make # arm only support lite ver
if [ -z "$armver" ]; then
cmake ../
elif [ "$armver" == "arm64" ]; then
cmake ../ -DARMVER=arm64
elif [ "$armver" == "arm32" ]; then
cmake ../ -DARMVER=arm32
else
echo "input parameter error!!!"
return
fi
make
cd ${curr_dir} cd ${curr_dir}
...@@ -153,7 +162,8 @@ ${csudo} ./makerpm.sh ${compile_dir} ${output_dir} ${version} ...@@ -153,7 +162,8 @@ ${csudo} ./makerpm.sh ${compile_dir} ${output_dir} ${version}
echo "do tar.gz package for all systems" echo "do tar.gz package for all systems"
cd ${script_dir}/tools cd ${script_dir}/tools
${csudo} ./makepkg.sh ${compile_dir} ${version} "${build_time}" ${csudo} ./makepkg.sh ${compile_dir} ${version} "${build_time}" ${armver}
${csudo} ./makeclient.sh ${compile_dir} ${version} "${build_time}" ${armver}
# 4. Clean up temporary compile directories # 4. Clean up temporary compile directories
#${csudo} rm -rf ${compile_dir} #${csudo} rm -rf ${compile_dir}
......
文件模式从 100755 更改为 100644
...@@ -39,8 +39,7 @@ echo topdir: %{_topdir} ...@@ -39,8 +39,7 @@ echo topdir: %{_topdir}
echo version: %{_version} echo version: %{_version}
echo buildroot: %{buildroot} echo buildroot: %{buildroot}
versioninfo=$(%{_compiledir}/../packaging/tools/get_version.sh) libfile="libtaos.so.%{_version}"
libfile="libtaos.so.${versioninfo}"
# create install path, and cp file # create install path, and cp file
mkdir -p %{buildroot}%{homepath}/bin mkdir -p %{buildroot}%{homepath}/bin
...@@ -62,6 +61,7 @@ cp %{_compiledir}/build/bin/taosdemo %{buildroot}%{homepath}/bin ...@@ -62,6 +61,7 @@ cp %{_compiledir}/build/bin/taosdemo %{buildroot}%{homepath}/bin
cp %{_compiledir}/build/bin/taosdump %{buildroot}%{homepath}/bin cp %{_compiledir}/build/bin/taosdump %{buildroot}%{homepath}/bin
cp %{_compiledir}/build/lib/${libfile} %{buildroot}%{homepath}/driver cp %{_compiledir}/build/lib/${libfile} %{buildroot}%{homepath}/driver
cp %{_compiledir}/../src/inc/taos.h %{buildroot}%{homepath}/include cp %{_compiledir}/../src/inc/taos.h %{buildroot}%{homepath}/include
cp %{_compiledir}/../src/inc/taoserror.h %{buildroot}%{homepath}/include
cp -r %{_compiledir}/../src/connector/grafana %{buildroot}%{homepath}/connector cp -r %{_compiledir}/../src/connector/grafana %{buildroot}%{homepath}/connector
cp -r %{_compiledir}/../src/connector/python %{buildroot}%{homepath}/connector cp -r %{_compiledir}/../src/connector/python %{buildroot}%{homepath}/connector
cp -r %{_compiledir}/../src/connector/go %{buildroot}%{homepath}/connector cp -r %{_compiledir}/../src/connector/go %{buildroot}%{homepath}/connector
...@@ -79,18 +79,17 @@ fi ...@@ -79,18 +79,17 @@ fi
if pidof taosd &> /dev/null; then if pidof taosd &> /dev/null; then
if pidof systemd &> /dev/null; then if pidof systemd &> /dev/null; then
${csudo} systemctl stop taosd || : ${csudo} systemctl stop taosd || :
elif $(which insserv &> /dev/null); then elif $(which service &> /dev/null); then
${csudo} service taosd stop || :
elif $(which update-rc.d &> /dev/null); then
${csudo} service taosd stop || : ${csudo} service taosd stop || :
else else
pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}') pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}')
${csudo} kill -9 ${pid} || : if [ -n "$pid" ]; then
${csudo} kill -9 $pid || :
fi
fi fi
echo "Stop taosd service success!" echo "Stop taosd service success!"
sleep 1 sleep 1
fi fi
# if taos.cfg already softlink, remove it # if taos.cfg already softlink, remove it
if [ -f %{cfg_install_dir}/taos.cfg ]; then if [ -f %{cfg_install_dir}/taos.cfg ]; then
${csudo} rm -f %{homepath}/cfg/taos.cfg || : ${csudo} rm -f %{homepath}/cfg/taos.cfg || :
...@@ -138,13 +137,16 @@ if [ $1 -eq 0 ];then ...@@ -138,13 +137,16 @@ if [ $1 -eq 0 ];then
${csudo} rm -f ${bin_link_dir}/taosdump || : ${csudo} rm -f ${bin_link_dir}/taosdump || :
${csudo} rm -f ${cfg_link_dir}/* || : ${csudo} rm -f ${cfg_link_dir}/* || :
${csudo} rm -f ${inc_link_dir}/taos.h || : ${csudo} rm -f ${inc_link_dir}/taos.h || :
${csudo} rm -f ${inc_link_dir}/taoserror.h || :
${csudo} rm -f ${lib_link_dir}/libtaos.* || : ${csudo} rm -f ${lib_link_dir}/libtaos.* || :
${csudo} rm -f ${log_link_dir} || : ${csudo} rm -f ${log_link_dir} || :
${csudo} rm -f ${data_link_dir} || : ${csudo} rm -f ${data_link_dir} || :
pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}') pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}')
${csudo} kill -9 ${pid} || : if [ -n "$pid" ]; then
${csudo} kill -9 $pid || :
fi
fi fi
fi fi
......
...@@ -7,8 +7,7 @@ set -e ...@@ -7,8 +7,7 @@ set -e
# set -x # set -x
# -----------------------Variables definition--------------------- # -----------------------Variables definition---------------------
script_dir=$(dirname $(readlink -m "$0")) verinfo=$(cat $1 | grep " version" | cut -d '"' -f2)
verinfo=$(cat ${script_dir}/../../src/util/src/version.c | grep " version" | cut -d '"' -f2)
verinfo=$(echo $verinfo | tr "\n" " ") verinfo=$(echo $verinfo | tr "\n" " ")
len=$(echo ${#verinfo}) len=$(echo ${#verinfo})
len=$((len-1)) len=$((len-1))
......
#!/bin/bash #!/bin/bash
# #
# This file is used to install TAOS time-series database on linux systems. The operating system # This file is used to install database on linux systems. The operating system
# is required to use systemd to manage services at boot # is required to use systemd to manage services at boot
set -e set -e
...@@ -41,19 +41,58 @@ if command -v sudo > /dev/null; then ...@@ -41,19 +41,58 @@ if command -v sudo > /dev/null; then
csudo="sudo" csudo="sudo"
fi fi
initd_mod=0
service_mod=2 service_mod=2
if pidof systemd &> /dev/null; then if pidof systemd &> /dev/null; then
service_mod=0 service_mod=0
elif $(which update-rc.d &> /dev/null); then elif $(which service &> /dev/null); then
service_mod=1 service_mod=1
service_config_dir="/etc/init.d" service_config_dir="/etc/init.d"
if $(which chkconfig &> /dev/null); then
initd_mod=1
elif $(which insserv &> /dev/null); then
initd_mod=2
elif $(which update-rc.d &> /dev/null); then
initd_mod=3
else
service_mod=2
fi
else else
service_mod=2 service_mod=2
fi fi
# get the operating system type for using the corresponding init file
# ubuntu/debian(deb), centos/fedora(rpm), others: opensuse, redhat, ..., no verification
#osinfo=$(awk -F= '/^NAME/{print $2}' /etc/os-release)
osinfo=$(cat /etc/os-release | grep "NAME" | cut -d '"' -f2)
#echo "osinfo: ${osinfo}"
os_type=0
if echo $osinfo | grep -qwi "ubuntu" ; then
echo "this is ubuntu system"
os_type=1
elif echo $osinfo | grep -qwi "debian" ; then
echo "this is debian system"
os_type=1
elif echo $osinfo | grep -qwi "Kylin" ; then
echo "this is Kylin system"
os_type=1
elif echo $osinfo | grep -qwi "centos" ; then
echo "this is centos system"
os_type=2
elif echo $osinfo | grep -qwi "fedora" ; then
echo "this is fedora system"
os_type=2
else
echo "this is other linux system"
os_type=0
fi
function kill_taosd() { function kill_taosd() {
pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}') pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}')
${csudo} kill -9 pid || : if [ -n "$pid" ]; then
${csudo} kill -9 $pid || :
fi
} }
function install_main_path() { function install_main_path() {
...@@ -81,7 +120,7 @@ function install_bin() { ...@@ -81,7 +120,7 @@ function install_bin() {
#Make link #Make link
[ -x ${install_main_dir}/bin/taos ] && ${csudo} ln -s ${install_main_dir}/bin/taos ${bin_link_dir}/taos || : [ -x ${install_main_dir}/bin/taos ] && ${csudo} ln -s ${install_main_dir}/bin/taos ${bin_link_dir}/taos || :
[ -x ${install_main_dir}/bin/taosd ] && ${csudo} ln -s ${install_main_dir}/bin/taosd ${bin_link_dir}/taosd || : [ -x ${install_main_dir}/bin/taosd ] && ${csudo} ln -s ${install_main_dir}/bin/taosd ${bin_link_dir}/taosd || :
[ -x ${install_main_dir}/bin/taosdump ] && ${csudo} ln -s ${install_main_dir}/bin/taosdump ${bin_link_dir}/taosdump || : [ -x ${install_main_dir}/bin/taosdump ] && ${csudo} ln -s ${install_main_dir}/bin/taosdump ${bin_link_dir}/taosdump || :
[ -x ${install_main_dir}/bin/taosdemo ] && ${csudo} ln -s ${install_main_dir}/bin/taosdemo ${bin_link_dir}/taosdemo || : [ -x ${install_main_dir}/bin/taosdemo ] && ${csudo} ln -s ${install_main_dir}/bin/taosdemo ${bin_link_dir}/taosdemo || :
[ -x ${install_main_dir}/bin/remove.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/rmtaos || : [ -x ${install_main_dir}/bin/remove.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/rmtaos || :
...@@ -89,7 +128,7 @@ function install_bin() { ...@@ -89,7 +128,7 @@ function install_bin() {
function install_lib() { function install_lib() {
# Remove links # Remove links
${csudo} rm -f ${lib_link_dir}/libtaos.* || : ${csudo} rm -f ${lib_link_dir}/libtaos.* || :
${csudo} cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/* ${csudo} cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/*
...@@ -98,24 +137,26 @@ function install_lib() { ...@@ -98,24 +137,26 @@ function install_lib() {
} }
function install_header() { function install_header() {
${csudo} rm -f ${inc_link_dir}/taos.h || : ${csudo} rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taoserror.h || :
${csudo} cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo} chmod 644 ${install_main_dir}/include/* ${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/taos.h ${inc_link_dir}/taos.h
${csudo} ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h
} }
function install_config() { function install_config() {
#${csudo} rm -f ${install_main_dir}/cfg/taos.cfg || : #${csudo} rm -f ${install_main_dir}/cfg/taos.cfg || :
if [ ! -f ${cfg_install_dir}/taos.cfg ]; then if [ ! -f ${cfg_install_dir}/taos.cfg ]; then
${csudo} mkdir -p ${cfg_install_dir} ${csudo} mkdir -p ${cfg_install_dir}
[ -f ${script_dir}/cfg/taos.cfg ] && ${csudo} cp ${script_dir}/cfg/taos.cfg ${cfg_install_dir} [ -f ${script_dir}/cfg/taos.cfg ] && ${csudo} cp ${script_dir}/cfg/taos.cfg ${cfg_install_dir}
${csudo} chmod 644 ${cfg_install_dir}/* ${csudo} chmod 644 ${cfg_install_dir}/*
fi fi
${csudo} cp -f ${script_dir}/cfg/taos.cfg ${install_main_dir}/cfg/taos.cfg.org ${csudo} cp -f ${script_dir}/cfg/taos.cfg ${install_main_dir}/cfg/taos.cfg.org
${csudo} ln -s ${cfg_install_dir}/taos.cfg ${install_main_dir}/cfg ${csudo} ln -s ${cfg_install_dir}/taos.cfg ${install_main_dir}/cfg
} }
function install_log() { function install_log() {
${csudo} rm -rf ${log_dir} || : ${csudo} rm -rf ${log_dir} || :
${csudo} mkdir -p ${log_dir} && ${csudo} chmod 777 ${log_dir} ${csudo} mkdir -p ${log_dir} && ${csudo} chmod 777 ${log_dir}
...@@ -138,14 +179,26 @@ function install_examples() { ...@@ -138,14 +179,26 @@ function install_examples() {
} }
function clean_service_on_sysvinit() { function clean_service_on_sysvinit() {
restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start" #restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start"
#${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || :
if pidof taosd &> /dev/null; then if pidof taosd &> /dev/null; then
${csudo} service taosd stop || : ${csudo} service taosd stop || :
fi fi
${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || :
if ((${initd_mod}==1)); then
${csudo} chkconfig --del taosd || :
elif ((${initd_mod}==2)); then
${csudo} insserv -r taosd || :
elif ((${initd_mod}==3)); then
${csudo} update-rc.d -f taosd remove || :
fi
${csudo} rm -f ${service_config_dir}/taosd || : ${csudo} rm -f ${service_config_dir}/taosd || :
${csudo} update-rc.d -f taosd remove || :
${csudo} init q || : if $(which init &> /dev/null); then
${csudo} init q || :
fi
} }
function install_service_on_sysvinit() { function install_service_on_sysvinit() {
...@@ -154,14 +207,27 @@ function install_service_on_sysvinit() { ...@@ -154,14 +207,27 @@ function install_service_on_sysvinit() {
sleep 1 sleep 1
# Install taosd service # Install taosd service
${csudo} cp -f ${script_dir}/init.d/taosd ${install_main_dir}/init.d
${csudo} cp ${script_dir}/init.d/taosd ${service_config_dir} && ${csudo} chmod a+x ${service_config_dir}/taosd if ((${os_type}==1)); then
restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start" ${csudo} cp -f ${script_dir}/init.d/taosd.deb ${install_main_dir}/init.d/taosd
${csudo} cp ${script_dir}/init.d/taosd.deb ${service_config_dir}/taosd && ${csudo} chmod a+x ${service_config_dir}/taosd
${csudo} grep -q -F "$restart_config_str" /etc/inittab || ${csudo} bash -c "echo '${restart_config_str}' >> /etc/inittab" elif ((${os_type}==2)); then
# TODO: for centos, change here ${csudo} cp -f ${script_dir}/init.d/taosd.rpm ${install_main_dir}/init.d/taosd
${csudo} update-rc.d taosd defaults ${csudo} cp ${script_dir}/init.d/taosd.rpm ${service_config_dir}/taosd && ${csudo} chmod a+x ${service_config_dir}/taosd
# chkconfig mysqld on fi
#restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start"
#${csudo} grep -q -F "$restart_config_str" /etc/inittab || ${csudo} bash -c "echo '${restart_config_str}' >> /etc/inittab"
if ((${initd_mod}==1)); then
${csudo} chkconfig --add taosd || :
${csudo} chkconfig --level 2345 taosd on || :
elif ((${initd_mod}==2)); then
${csudo} insserv taosd || :
${csudo} insserv -d taosd || :
elif ((${initd_mod}==3)); then
${csudo} update-rc.d taosd defaults || :
fi
} }
function clean_service_on_systemd() { function clean_service_on_systemd() {
...@@ -211,7 +277,7 @@ function install_service() { ...@@ -211,7 +277,7 @@ function install_service() {
elif ((${service_mod}==1)); then elif ((${service_mod}==1)); then
install_service_on_sysvinit install_service_on_sysvinit
else else
# must manual start taosd # must manual stop taosd
kill_taosd kill_taosd
fi fi
} }
...@@ -247,9 +313,9 @@ vercomp () { ...@@ -247,9 +313,9 @@ vercomp () {
function is_version_compatible() { function is_version_compatible() {
curr_version=$(${bin_dir}/taosd -V | cut -d ' ' -f 1) curr_version=$(${bin_dir}/taosd -V | head -1 | cut -d ' ' -f 2)
min_compatible_version=$(${script_dir}/bin/taosd -V | cut -d ' ' -f 2) min_compatible_version=$(${script_dir}/bin/taosd -V | head -1 | cut -d ' ' -f 4)
vercomp $curr_version $min_compatible_version vercomp $curr_version $min_compatible_version
case $? in case $? in
...@@ -265,7 +331,7 @@ function update_TDengine() { ...@@ -265,7 +331,7 @@ function update_TDengine() {
echo "File taos.tar.gz does not exist" echo "File taos.tar.gz does not exist"
exit 1 exit 1
fi fi
tar -zxf taos.tar.gz tar -zxf taos.tar.gz
# Check if version compatible # Check if version compatible
if ! is_version_compatible; then if ! is_version_compatible; then
...@@ -273,7 +339,7 @@ function update_TDengine() { ...@@ -273,7 +339,7 @@ function update_TDengine() {
return 1 return 1
fi fi
echo -e "${GREEN}Start to update TDEngine...${NC}" echo -e "${GREEN}Start to update TDengine...${NC}"
# Stop the service if running # Stop the service if running
if pidof taosd &> /dev/null; then if pidof taosd &> /dev/null; then
if ((${service_mod}==0)); then if ((${service_mod}==0)); then
...@@ -305,8 +371,7 @@ function update_TDengine() { ...@@ -305,8 +371,7 @@ function update_TDengine() {
if ((${service_mod}==0)); then if ((${service_mod}==0)); then
echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo} systemctl start taosd${NC}" echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo} systemctl start taosd${NC}"
elif ((${service_mod}==1)); then elif ((${service_mod}==1)); then
echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo} update-rc.d taosd default ${RED} for the first time${NC}" echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo} service taosd start${NC}"
echo -e " : ${csudo} service taosd start ${RED} after${NC}"
else else
echo -e "${GREEN_DARK}To start TDengine ${NC}: ./taosd${NC}" echo -e "${GREEN_DARK}To start TDengine ${NC}: ./taosd${NC}"
fi fi
...@@ -315,7 +380,7 @@ function update_TDengine() { ...@@ -315,7 +380,7 @@ function update_TDengine() {
echo echo
echo -e "\033[44;32;1mTDengine is updated successfully!${NC}" echo -e "\033[44;32;1mTDengine is updated successfully!${NC}"
else else
install_bin $1 install_bin
install_config install_config
echo echo
...@@ -331,9 +396,9 @@ function install_TDengine() { ...@@ -331,9 +396,9 @@ function install_TDengine() {
echo "File taos.tar.gz does not exist" echo "File taos.tar.gz does not exist"
exit 1 exit 1
fi fi
tar -zxf taos.tar.gz tar -zxf taos.tar.gz
echo -e "${GREEN}Start to install TDEngine...${NC}" echo -e "${GREEN}Start to install TDengine...${NC}"
install_main_path install_main_path
...@@ -361,10 +426,9 @@ function install_TDengine() { ...@@ -361,10 +426,9 @@ function install_TDengine() {
if ((${service_mod}==0)); then if ((${service_mod}==0)); then
echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo} systemctl start taosd${NC}" echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo} systemctl start taosd${NC}"
elif ((${service_mod}==1)); then elif ((${service_mod}==1)); then
echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo} update-rc.d taosd default ${RED} for the first time${NC}" echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo} service taosd start${NC}"
echo -e " : ${csudo} service taosd start ${RED} after${NC}"
else else
echo -e "${GREEN_DARK}To start TDengine ${NC}: ./taosd${NC}" echo -e "${GREEN_DARK}To start TDengine ${NC}: taosd${NC}"
fi fi
echo -e "${GREEN_DARK}To access TDengine ${NC}: use ${GREEN_UNDERLINE}taos${NC} in shell${NC}" echo -e "${GREEN_DARK}To access TDengine ${NC}: use ${GREEN_UNDERLINE}taos${NC} in shell${NC}"
......
#!/bin/bash #!/bin/bash
#
# This file is used to install TDengine client on linux systems. The operating system
# is required to use systemd to manage services at boot
set -e
#set -x
# -----------------------Variables definition---------------------
script_dir=$(dirname $(readlink -m "$0")) script_dir=$(dirname $(readlink -m "$0"))
${script_dir}/install.sh client # Dynamic directory
data_dir="/var/lib/taos"
log_dir="/var/log/taos"
log_link_dir="/usr/local/taos/log"
cfg_install_dir="/etc/taos"
bin_link_dir="/usr/bin"
lib_link_dir="/usr/lib"
inc_link_dir="/usr/include"
#install main path
install_main_dir="/usr/local/taos"
# old bin dir
bin_dir="/usr/local/taos/bin"
# Color setting
RED='\033[0;31m'
GREEN='\033[1;32m'
GREEN_DARK='\033[0;32m'
GREEN_UNDERLINE='\033[4;32m'
NC='\033[0m'
csudo=""
if command -v sudo > /dev/null; then
csudo="sudo"
fi
update_flag=0
function kill_client() {
pid=$(ps -ef | grep "taos" | grep -v "grep" | awk '{print $2}')
if [ -n "$pid" ]; then
${csudo} kill -9 $pid || :
fi
}
function install_main_path() {
#create install main dir and all sub dir
${csudo} rm -rf ${install_main_dir} || :
${csudo} mkdir -p ${install_main_dir}
${csudo} mkdir -p ${install_main_dir}/cfg
${csudo} mkdir -p ${install_main_dir}/bin
${csudo} mkdir -p ${install_main_dir}/connector
${csudo} mkdir -p ${install_main_dir}/driver
${csudo} mkdir -p ${install_main_dir}/examples
${csudo} mkdir -p ${install_main_dir}/include
}
function install_bin() {
# Remove links
${csudo} rm -f ${bin_link_dir}/taos || :
${csudo} rm -f ${bin_link_dir}/taosdump || :
${csudo} rm -f ${bin_link_dir}/rmtaos || :
${csudo} cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo} chmod 0555 ${install_main_dir}/bin/*
#Make link
[ -x ${install_main_dir}/bin/taos ] && ${csudo} ln -s ${install_main_dir}/bin/taos ${bin_link_dir}/taos || :
[ -x ${install_main_dir}/bin/taosdump ] && ${csudo} ln -s ${install_main_dir}/bin/taosdump ${bin_link_dir}/taosdump || :
[ -x ${install_main_dir}/bin/remove_client.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove_client.sh ${bin_link_dir}/rmtaos || :
}
function clean_lib() {
sudo rm -f /usr/lib/libtaos.so || :
sudo rm -rf ${lib_dir} || :
}
function install_lib() {
# Remove links
${csudo} rm -f ${lib_link_dir}/libtaos.* || :
${csudo} cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/*
${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
}
function install_header() {
${csudo} rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taoserror.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/taoserror.h ${inc_link_dir}/taoserror.h
}
function install_config() {
#${csudo} rm -f ${install_main_dir}/cfg/taos.cfg || :
if [ ! -f ${cfg_install_dir}/taos.cfg ]; then
${csudo} mkdir -p ${cfg_install_dir}
[ -f ${script_dir}/cfg/taos.cfg ] && ${csudo} cp ${script_dir}/cfg/taos.cfg ${cfg_install_dir}
${csudo} chmod 644 ${cfg_install_dir}/*
fi
${csudo} cp -f ${script_dir}/cfg/taos.cfg ${install_main_dir}/cfg/taos.cfg.org
${csudo} ln -s ${cfg_install_dir}/taos.cfg ${install_main_dir}/cfg
}
function install_log() {
${csudo} rm -rf ${log_dir} || :
${csudo} mkdir -p ${log_dir} && ${csudo} chmod 777 ${log_dir}
${csudo} ln -s ${log_dir} ${install_main_dir}/log
}
function install_connector() {
${csudo} cp -rf ${script_dir}/connector/* ${install_main_dir}/connector
}
function install_examples() {
if [ -d ${script_dir}/examples ]; then
${csudo} cp -rf ${script_dir}/examples/* ${install_main_dir}/examples
fi
}
function update_TDengine() {
# Start to update
if [ ! -e taos.tar.gz ]; then
echo "File taos.tar.gz does not exist"
exit 1
fi
tar -zxf taos.tar.gz
echo -e "${GREEN}Start to update TDengine client...${NC}"
# Stop the client shell if running
if pidof taos &> /dev/null; then
kill_client
sleep 1
fi
install_main_path
install_log
install_header
install_lib
install_connector
install_examples
install_bin
install_config
echo
echo -e "\033[44;32;1mTDengine client is updated successfully!${NC}"
rm -rf $(tar -tf taos.tar.gz)
}
function install_TDengine() {
# Start to install
if [ ! -e taos.tar.gz ]; then
echo "File taos.tar.gz does not exist"
exit 1
fi
tar -zxf taos.tar.gz
echo -e "${GREEN}Start to install TDengine client...${NC}"
install_main_path
install_log
install_header
install_lib
install_connector
install_examples
install_bin
install_config
echo
echo -e "\033[44;32;1mTDengine client is installed successfully!${NC}"
rm -rf $(tar -tf taos.tar.gz)
}
## ==============================Main program starts from here============================
# Install or updata client and client
# if server is already install, don't install client
if [ -e ${bin_dir}/taosd ]; then
echo -e "\033[44;32;1mThere are already installed TDengine server, so don't need install client!${NC}"
exit 0
fi
if [ -x ${bin_dir}/taos ]; then
update_flag=1
update_TDengine
else
install_TDengine
fi
...@@ -101,7 +101,7 @@ function install_lib() { ...@@ -101,7 +101,7 @@ function install_lib() {
# Remove links # Remove links
${csudo} rm -f ${lib_link_dir}/libtaos.* || : ${csudo} rm -f ${lib_link_dir}/libtaos.* || :
versioninfo=$(${script_dir}/get_version.sh) versioninfo=$(${script_dir}/get_version.sh ${source_dir}/src/util/src/version.c)
${csudo} cp ${binary_dir}/build/lib/libtaos.so.${versioninfo} ${install_main_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/* ${csudo} cp ${binary_dir}/build/lib/libtaos.so.${versioninfo} ${install_main_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/*
${csudo} ln -sf ${install_main_dir}/driver/libtaos.so.${versioninfo} ${lib_link_dir}/libtaos.so.1 ${csudo} ln -sf ${install_main_dir}/driver/libtaos.so.${versioninfo} ${lib_link_dir}/libtaos.so.1
${csudo} ln -sf ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so ${csudo} ln -sf ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so
...@@ -109,9 +109,10 @@ function install_lib() { ...@@ -109,9 +109,10 @@ function install_lib() {
function install_header() { function install_header() {
${csudo} rm -f ${inc_link_dir}/taos.h || : ${csudo} rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taoserror.h || :
${csudo} cp -f ${source_dir}/src/inc/taos.h ${install_main_dir}/include && ${csudo} chmod 644 ${install_main_dir}/include/* ${csudo} cp -f ${source_dir}/src/inc/taos.h ${source_dir}/src/inc/taoserror.h ${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/taos.h ${inc_link_dir}/taos.h
${csudo} ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h
} }
function install_config() { function install_config() {
......
#!/bin/bash
#
# Generate tar.gz package for linux client
set -e
set -x
curr_dir=$(pwd)
compile_dir=$1
version=$2
build_time=$3
armver=$4
script_dir="$(dirname $(readlink -f $0))"
top_dir="$(readlink -m ${script_dir}/../..)"
# create compressed install file.
build_dir="${compile_dir}/build"
code_dir="${top_dir}/src"
release_dir="${top_dir}/release"
community_dir="${script_dir}/../../../community/src"
package_name='linux'
install_dir="${release_dir}/taos-client-${version}-${package_name}-$(echo ${build_time}| tr ': ' -)"
# Directories and files.
bin_files="${build_dir}/bin/taos ${build_dir}/bin/taosdump ${script_dir}/remove_client.sh"
lib_files="${build_dir}/lib/libtaos.so.${version}"
header_files="${community_dir}/inc/taos.h ${community_dir}/inc/taoserror.h"
cfg_dir="${top_dir}/packaging/cfg"
install_files="${script_dir}/install_client.sh"
# make directories.
mkdir -p ${install_dir}
mkdir -p ${install_dir}/inc && cp ${header_files} ${install_dir}/inc
mkdir -p ${install_dir}/cfg && cp ${cfg_dir}/taos.cfg ${install_dir}/cfg/taos.cfg
mkdir -p ${install_dir}/bin && cp ${bin_files} ${install_dir}/bin && chmod a+x ${install_dir}/bin/*
cd ${install_dir}
tar -zcv -f taos.tar.gz * --remove-files || :
cd ${curr_dir}
cp ${install_files} ${install_dir} && chmod a+x ${install_dir}/install*
# Copy example code
mkdir -p ${install_dir}/examples
cp -r ${top_dir}/tests/examples/c ${install_dir}/examples
cp -r ${top_dir}/tests/examples/JDBC ${install_dir}/examples
cp -r ${top_dir}/tests/examples/matlab ${install_dir}/examples
cp -r ${top_dir}/tests/examples/python ${install_dir}/examples
cp -r ${top_dir}/tests/examples/R ${install_dir}/examples
cp -r ${top_dir}/tests/examples/go ${install_dir}/examples
# Copy driver
mkdir -p ${install_dir}/driver
cp ${lib_files} ${install_dir}/driver
# Copy connector
connector_dir="${community_dir}/connector"
mkdir -p ${install_dir}/connector
cp ${build_dir}/lib/*.jar ${install_dir}/connector
cp -r ${connector_dir}/grafana ${install_dir}/connector/
cp -r ${connector_dir}/python ${install_dir}/connector/
cp -r ${connector_dir}/go ${install_dir}/connector
# Copy release note
# cp ${script_dir}/release_note ${install_dir}
# exit 1
cd ${release_dir}
if [ -z "$armver" ]; then
tar -zcv -f "$(basename ${install_dir}).tar.gz" $(basename ${install_dir}) --remove-files
elif [ "$armver" == "arm64" ]; then
tar -zcv -f "$(basename ${install_dir})-arm64.tar.gz" $(basename ${install_dir}) --remove-files
elif [ "$armver" == "arm32" ]; then
tar -zcv -f "$(basename ${install_dir})-arm32.tar.gz" $(basename ${install_dir}) --remove-files
fi
cd ${curr_dir}
...@@ -6,6 +6,7 @@ curr_dir=$(pwd) ...@@ -6,6 +6,7 @@ curr_dir=$(pwd)
compile_dir=$1 compile_dir=$1
version=$2 version=$2
build_time=$3 build_time=$3
armver=$4
script_dir="$(dirname $(readlink -f $0))" script_dir="$(dirname $(readlink -f $0))"
top_dir="$(readlink -m ${script_dir}/../..)" top_dir="$(readlink -m ${script_dir}/../..)"
...@@ -20,11 +21,10 @@ install_dir="${release_dir}/taos-${version}-${package_name}-$(echo ${build_time} ...@@ -20,11 +21,10 @@ install_dir="${release_dir}/taos-${version}-${package_name}-$(echo ${build_time}
# Directories and files. # Directories and files.
bin_files="${build_dir}/bin/taosd ${build_dir}/bin/taos ${build_dir}/bin/taosdemo ${build_dir}/bin/taosdump ${script_dir}/remove.sh" bin_files="${build_dir}/bin/taosd ${build_dir}/bin/taos ${build_dir}/bin/taosdemo ${build_dir}/bin/taosdump ${script_dir}/remove.sh"
versioninfo=$(${script_dir}/get_version.sh) lib_files="${build_dir}/lib/libtaos.so.${version}"
lib_files="${build_dir}/lib/libtaos.so.${versioninfo}" header_files="${code_dir}/inc/taos.h ${code_dir}/inc/taoserror.h"
header_files="${code_dir}/inc/taos.h" cfg_dir="${top_dir}/packaging/cfg"
cfg_files="${top_dir}/packaging/cfg/*.cfg" install_files="${script_dir}/install.sh"
install_files="${script_dir}/install.sh ${script_dir}/install_client.sh"
# Init file # Init file
#init_dir=${script_dir}/deb #init_dir=${script_dir}/deb
...@@ -33,29 +33,32 @@ install_files="${script_dir}/install.sh ${script_dir}/install_client.sh" ...@@ -33,29 +33,32 @@ install_files="${script_dir}/install.sh ${script_dir}/install_client.sh"
#fi #fi
#init_files=${init_dir}/taosd #init_files=${init_dir}/taosd
# temp use rpm's taosd. TODO: later modify according to os type # temp use rpm's taosd. TODO: later modify according to os type
init_files=${script_dir}/../rpm/taosd init_file_deb=${script_dir}/../deb/taosd
init_file_rpm=${script_dir}/../rpm/taosd
# make directories. # make directories.
mkdir -p ${install_dir} mkdir -p ${install_dir}
mkdir -p ${install_dir}/inc && cp ${header_files} ${install_dir}/inc mkdir -p ${install_dir}/inc && cp ${header_files} ${install_dir}/inc
mkdir -p ${install_dir}/cfg && cp ${cfg_files} ${install_dir}/cfg mkdir -p ${install_dir}/cfg && cp ${cfg_dir}/taos.cfg ${install_dir}/cfg/taos.cfg
mkdir -p ${install_dir}/bin && cp ${bin_files} ${install_dir}/bin && chmod a+x ${install_dir}/bin/* mkdir -p ${install_dir}/bin && cp ${bin_files} ${install_dir}/bin && chmod a+x ${install_dir}/bin/*
mkdir -p ${install_dir}/init.d && cp ${init_files} ${install_dir}/init.d mkdir -p ${install_dir}/init.d && cp ${init_file_deb} ${install_dir}/init.d/taosd.deb
mkdir -p ${install_dir}/init.d && cp ${init_file_rpm} ${install_dir}/init.d/taosd.rpm
cd ${install_dir} cd ${install_dir}
tar -zcv -f taos.tar.gz * --remove-files || : tar -zcv -f taos.tar.gz * --remove-files || :
cd ${curr_dir} cd ${curr_dir}
cp ${install_files} ${install_dir} && chmod a+x ${install_dir}/install* cp ${install_files} ${install_dir} && chmod a+x ${install_dir}/install*
# Copy example code # Copy example code
mkdir -p ${install_dir}/examples mkdir -p ${install_dir}/examples
cp -r ${top_dir}/tests/examples/c ${install_dir}/examples examples_dir="${top_dir}/tests/examples"
cp -r ${top_dir}/tests/examples/JDBC ${install_dir}/examples cp -r ${examples_dir}/c ${install_dir}/examples
cp -r ${top_dir}/tests/examples/matlab ${install_dir}/examples cp -r ${examples_dir}/JDBC ${install_dir}/examples
cp -r ${top_dir}/tests/examples/python ${install_dir}/examples cp -r ${examples_dir}/matlab ${install_dir}/examples
cp -r ${top_dir}/tests/examples/R ${install_dir}/examples cp -r ${examples_dir}/python ${install_dir}/examples
cp -r ${top_dir}/tests/examples/go ${install_dir}/examples cp -r ${examples_dir}/R ${install_dir}/examples
cp -r ${examples_dir}/go ${install_dir}/examples
# Copy driver # Copy driver
mkdir -p ${install_dir}/driver mkdir -p ${install_dir}/driver
...@@ -64,18 +67,23 @@ cp ${lib_files} ${install_dir}/driver ...@@ -64,18 +67,23 @@ cp ${lib_files} ${install_dir}/driver
# Copy connector # Copy connector
connector_dir="${code_dir}/connector" connector_dir="${code_dir}/connector"
mkdir -p ${install_dir}/connector mkdir -p ${install_dir}/connector
cp ${build_dir}/lib/*.jar ${install_dir}/connector
cp -r ${connector_dir}/grafana ${install_dir}/connector/ cp -r ${connector_dir}/grafana ${install_dir}/connector/
cp -r ${connector_dir}/python ${install_dir}/connector/ cp -r ${connector_dir}/python ${install_dir}/connector/
cp -r ${connector_dir}/go ${install_dir}/connector cp -r ${connector_dir}/go ${install_dir}/connector
cp ${build_dir}/lib/*.jar ${install_dir}/connector
# Copy release note # Copy release note
cp ${script_dir}/release_note ${install_dir} # cp ${script_dir}/release_note ${install_dir}
# exit 1 # exit 1
cd ${release_dir} cd ${release_dir}
tar -zcv -f "$(basename ${install_dir}).tar.gz" $(basename ${install_dir}) --remove-files if [ -z "$armver" ]; then
tar -zcv -f "$(basename ${install_dir}).tar.gz" $(basename ${install_dir}) --remove-files
elif [ "$armver" == "arm64" ]; then
tar -zcv -f "$(basename ${install_dir})-arm64.tar.gz" $(basename ${install_dir}) --remove-files
elif [ "$armver" == "arm32" ]; then
tar -zcv -f "$(basename ${install_dir})-arm32.tar.gz" $(basename ${install_dir}) --remove-files
fi
cd ${curr_dir} cd ${curr_dir}
...@@ -42,14 +42,18 @@ initd_mod=0 ...@@ -42,14 +42,18 @@ initd_mod=0
service_mod=2 service_mod=2
if pidof systemd &> /dev/null; then if pidof systemd &> /dev/null; then
service_mod=0 service_mod=0
elif $(which insserv &> /dev/null); then elif $(which service &> /dev/null); then
service_mod=1 service_mod=1
initd_mod=1 service_config_dir="/etc/init.d"
service_config_dir="/etc/init.d" if $(which chkconfig &> /dev/null); then
elif $(which update-rc.d &> /dev/null); then initd_mod=1
service_mod=1 elif $(which insserv &> /dev/null); then
initd_mod=2 initd_mod=2
service_config_dir="/etc/init.d" elif $(which update-rc.d &> /dev/null); then
initd_mod=3
else
service_mod=2
fi
else else
service_mod=2 service_mod=2
fi fi
...@@ -57,12 +61,15 @@ fi ...@@ -57,12 +61,15 @@ fi
function kill_taosd() { function kill_taosd() {
# ${csudo} pkill -f taosd || : # ${csudo} pkill -f taosd || :
pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}') pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}')
${csudo} kill -9 ${pid} || : if [ -n "$pid" ]; then
${csudo} kill -9 $pid || :
fi
} }
function install_include() { function install_include() {
${csudo} rm -f ${inc_link_dir}/taos.h || : ${csudo} rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taoserror.h|| :
${csudo} ln -s ${inc_dir}/taos.h ${inc_link_dir}/taos.h ${csudo} ln -s ${inc_dir}/taos.h ${inc_link_dir}/taos.h
${csudo} ln -s ${inc_dir}/taoserror.h ${inc_link_dir}/taoserror.h
} }
function install_lib() { function install_lib() {
...@@ -102,20 +109,26 @@ function install_config() { ...@@ -102,20 +109,26 @@ function install_config() {
} }
function clean_service_on_sysvinit() { function clean_service_on_sysvinit() {
restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start" #restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start"
#${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || :
if pidof taosd &> /dev/null; then if pidof taosd &> /dev/null; then
${csudo} service taosd stop || : ${csudo} service taosd stop || :
fi fi
${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || :
${csudo} rm -f ${service_config_dir}/taosd || :
if ((${initd_mod}==1)); then if ((${initd_mod}==1)); then
${csudo} grep -q -F "taos" /etc/inittab && ${csudo} insserv -r taosd || : ${csudo} chkconfig --del taosd || :
elif ((${initd_mod}==2)); then elif ((${initd_mod}==2)); then
${csudo} grep -q -F "taos" /etc/inittab && ${csudo} update-rc.d -f taosd remove || : ${csudo} insserv -r taosd || :
elif ((${initd_mod}==3)); then
${csudo} update-rc.d -f taosd remove || :
fi
${csudo} rm -f ${service_config_dir}/taosd || :
if $(which init &> /dev/null); then
${csudo} init q || :
fi fi
# ${csudo} update-rc.d -f taosd remove || :
${csudo} init q || :
} }
function install_service_on_sysvinit() { function install_service_on_sysvinit() {
...@@ -126,18 +139,24 @@ function install_service_on_sysvinit() { ...@@ -126,18 +139,24 @@ function install_service_on_sysvinit() {
# Install taosd service # Install taosd service
${csudo} cp %{init_d_dir}/taosd ${service_config_dir} && ${csudo} chmod a+x ${service_config_dir}/taosd ${csudo} cp %{init_d_dir}/taosd ${service_config_dir} && ${csudo} chmod a+x ${service_config_dir}/taosd
restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start" #restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start"
#${csudo} grep -q -F "$restart_config_str" /etc/inittab || ${csudo} bash -c "echo '${restart_config_str}' >> /etc/inittab"
${csudo} grep -q -F "$restart_config_str" /etc/inittab || ${csudo} bash -c "echo '${restart_config_str}' >> /etc/inittab"
# TODO: for centos, change here if ((${initd_mod}==1)); then
${csudo} update-rc.d taosd defaults ${csudo} chkconfig --add taosd || :
# chkconfig mysqld on ${csudo} chkconfig --level 2345 taosd on || :
elif ((${initd_mod}==2)); then
${csudo} insserv taosd || :
${csudo} insserv -d taosd || :
elif ((${initd_mod}==3)); then
${csudo} update-rc.d taosd defaults || :
fi
} }
function clean_service_on_systemd() { function clean_service_on_systemd() {
taosd_service_config="${service_config_dir}/taosd.service" taosd_service_config="${service_config_dir}/taosd.service"
# taosd service already is stoped before install # taosd service already is stoped before install in preinst script
#if systemctl is-active --quiet taosd; then #if systemctl is-active --quiet taosd; then
# echo "TDengine is running, stopping it..." # echo "TDengine is running, stopping it..."
# ${csudo} systemctl stop taosd &> /dev/null || echo &> /dev/null # ${csudo} systemctl stop taosd &> /dev/null || echo &> /dev/null
......
...@@ -26,22 +26,27 @@ initd_mod=0 ...@@ -26,22 +26,27 @@ initd_mod=0
service_mod=2 service_mod=2
if pidof systemd &> /dev/null; then if pidof systemd &> /dev/null; then
service_mod=0 service_mod=0
elif $(which insserv &> /dev/null); then elif $(which service &> /dev/null); then
service_mod=1 service_mod=1
initd_mod=1 service_config_dir="/etc/init.d"
service_config_dir="/etc/init.d" if $(which chkconfig &> /dev/null); then
elif $(which update-rc.d &> /dev/null); then initd_mod=1
service_mod=1 elif $(which insserv &> /dev/null); then
initd_mod=2 initd_mod=2
service_config_dir="/etc/init.d" elif $(which update-rc.d &> /dev/null); then
initd_mod=3
else
service_mod=2
fi
else else
service_mod=2 service_mod=2
fi fi
function kill_taosd() { function kill_taosd() {
pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}') pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}')
${csudo} kill -9 ${pid} || : if [ -n "$pid" ]; then
${csudo} kill -9 $pid || :
fi
} }
function clean_service_on_systemd() { function clean_service_on_systemd() {
...@@ -57,20 +62,27 @@ function clean_service_on_systemd() { ...@@ -57,20 +62,27 @@ function clean_service_on_systemd() {
} }
function clean_service_on_sysvinit() { function clean_service_on_sysvinit() {
restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start" #restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start"
#${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || :
if pidof taosd &> /dev/null; then if pidof taosd &> /dev/null; then
echo "TDengine taosd is running, stopping it..."
${csudo} service taosd stop || : ${csudo} service taosd stop || :
fi fi
${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || :
${csudo} rm -f ${service_config_dir}/taosd || :
if ((${initd_mod}==1)); then if ((${initd_mod}==1)); then
${csudo} grep -q -F "taos" /etc/inittab && ${csudo} insserv -r taosd || : ${csudo} chkconfig --del taosd || :
elif ((${initd_mod}==2)); then elif ((${initd_mod}==2)); then
${csudo} grep -q -F "taos" /etc/inittab && ${csudo} update-rc.d -f taosd remove || : ${csudo} insserv -r taosd || :
elif ((${initd_mod}==3)); then
${csudo} update-rc.d -f taosd remove || :
fi
${csudo} rm -f ${service_config_dir}/taosd || :
if $(which init &> /dev/null); then
${csudo} init q || :
fi fi
# ${csudo} update-rc.d -f taosd remove || :
${csudo} init q || :
} }
function clean_service() { function clean_service() {
...@@ -79,7 +91,7 @@ function clean_service() { ...@@ -79,7 +91,7 @@ function clean_service() {
elif ((${service_mod}==1)); then elif ((${service_mod}==1)); then
clean_service_on_sysvinit clean_service_on_sysvinit
else else
# must manual start taosd # must manual stop taosd
kill_taosd kill_taosd
fi fi
} }
...@@ -94,6 +106,7 @@ ${csudo} rm -f ${bin_link_dir}/taosdemo || : ...@@ -94,6 +106,7 @@ ${csudo} rm -f ${bin_link_dir}/taosdemo || :
${csudo} rm -f ${bin_link_dir}/taosdump || : ${csudo} rm -f ${bin_link_dir}/taosdump || :
${csudo} rm -f ${cfg_link_dir}/* || : ${csudo} rm -f ${cfg_link_dir}/* || :
${csudo} rm -f ${inc_link_dir}/taos.h || : ${csudo} rm -f ${inc_link_dir}/taos.h || :
${csudo} rm -f ${inc_link_dir}/taoserror.h || :
${csudo} rm -f ${lib_link_dir}/libtaos.* || : ${csudo} rm -f ${lib_link_dir}/libtaos.* || :
${csudo} rm -f ${log_link_dir} || : ${csudo} rm -f ${log_link_dir} || :
......
taos-1.6.4.0 (Release on 2019-12-01)
Bug fixed:
1.Look for possible causes of file corruption and fix them
2.Encapsulate memory allocation functions to reduce the possibility of crashes
3.Increase Arm64 compilation options
4.Remove most of the warnings in the code
5.Provide a variety of connector usage documents
6.Network connection can be selected in udp and tcp
7.Allow the maximum number of Tags to be 32
8.Bugs reported by the user
taos-1.5.2.6 (Release on 2019-05-13) taos-1.5.2.6 (Release on 2019-05-13)
Bug fixed: Bug fixed:
- Nchar strings sometimes were wrongly truncated on Window - Nchar strings sometimes were wrongly truncated on Window
......
#!/bin/bash #!/bin/bash
# #
# Script to stop the service and uninstall tdengine, but retain the config, data and log files. # Script to stop the service and uninstall TDengine, but retain the config, data and log files.
RED='\033[0;31m' RED='\033[0;31m'
GREEN='\033[1;32m' GREEN='\033[1;32m'
...@@ -27,21 +27,27 @@ initd_mod=0 ...@@ -27,21 +27,27 @@ initd_mod=0
service_mod=2 service_mod=2
if pidof systemd &> /dev/null; then if pidof systemd &> /dev/null; then
service_mod=0 service_mod=0
elif $(which insserv &> /dev/null); then elif $(which service &> /dev/null); then
service_mod=1 service_mod=1
initd_mod=1 service_config_dir="/etc/init.d"
service_config_dir="/etc/init.d" if $(which chkconfig &> /dev/null); then
elif $(which update-rc.d &> /dev/null); then initd_mod=1
service_mod=1 elif $(which insserv &> /dev/null); then
initd_mod=2 initd_mod=2
service_config_dir="/etc/init.d" elif $(which update-rc.d &> /dev/null); then
initd_mod=3
else
service_mod=2
fi
else else
service_mod=2 service_mod=2
fi fi
function kill_taosd() { function kill_taosd() {
pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}') pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}')
${csudo} kill -9 ${pid} || : if [ -n "$pid" ]; then
${csudo} kill -9 $pid || :
fi
} }
function clean_bin() { function clean_bin() {
...@@ -61,6 +67,7 @@ function clean_lib() { ...@@ -61,6 +67,7 @@ function clean_lib() {
function clean_header() { function clean_header() {
# Remove link # Remove link
${csudo} rm -f ${inc_link_dir}/taos.h || : ${csudo} rm -f ${inc_link_dir}/taos.h || :
${csudo} rm -f ${inc_link_dir}/taoserror.h || :
} }
function clean_config() { function clean_config() {
...@@ -86,20 +93,27 @@ function clean_service_on_systemd() { ...@@ -86,20 +93,27 @@ function clean_service_on_systemd() {
} }
function clean_service_on_sysvinit() { function clean_service_on_sysvinit() {
restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start" #restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start"
#${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || :
if pidof taosd &> /dev/null; then if pidof taosd &> /dev/null; then
echo "TDengine taosd is running, stopping it..."
${csudo} service taosd stop || : ${csudo} service taosd stop || :
fi fi
${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || :
${csudo} rm -f ${service_config_dir}/taosd || :
if ((${initd_mod}==1)); then if ((${initd_mod}==1)); then
${csudo} grep -q -F "taos" /etc/inittab && ${csudo} insserv -r taosd || : ${csudo} chkconfig --del taosd || :
elif ((${initd_mod}==2)); then elif ((${initd_mod}==2)); then
${csudo} grep -q -F "taos" /etc/inittab && ${csudo} update-rc.d -f taosd remove || : ${csudo} insserv -r taosd || :
elif ((${initd_mod}==3)); then
${csudo} update-rc.d -f taosd remove || :
fi
${csudo} rm -f ${service_config_dir}/taosd || :
if $(which init &> /dev/null); then
${csudo} init q || :
fi fi
# ${csudo} update-rc.d -f taosd remove || :
${csudo} init q || :
} }
function clean_service() { function clean_service() {
...@@ -108,7 +122,7 @@ function clean_service() { ...@@ -108,7 +122,7 @@ function clean_service() {
elif ((${service_mod}==1)); then elif ((${service_mod}==1)); then
clean_service_on_sysvinit clean_service_on_sysvinit
else else
# must manual start taosd # must manual stop taosd
kill_taosd kill_taosd
fi fi
} }
...@@ -139,4 +153,4 @@ elif echo $osinfo | grep -qwi "centos" ; then ...@@ -139,4 +153,4 @@ elif echo $osinfo | grep -qwi "centos" ; then
${csudo} rpm -e --noscripts tdengine || : ${csudo} rpm -e --noscripts tdengine || :
fi fi
echo -e "${GREEN}TDEngine is removed successfully!${NC}" echo -e "${GREEN}TDengine is removed successfully!${NC}"
#!/bin/bash
#
# Script to stop the client and uninstall database, but retain the config and log files.
set -e
# set -x
RED='\033[0;31m'
GREEN='\033[1;32m'
NC='\033[0m'
#install main path
install_main_dir="/usr/local/taos"
log_link_dir="/usr/local/taos/log"
cfg_link_dir="/usr/local/taos/cfg"
bin_link_dir="/usr/bin"
lib_link_dir="/usr/lib"
inc_link_dir="/usr/include"
csudo=""
if command -v sudo > /dev/null; then
csudo="sudo"
fi
function kill_client() {
#pid=$(ps -ef | grep "taos" | grep -v "grep" | awk '{print $2}')
if [ -n "$(pidof taos)" ]; then
${csudo} kill -9 $pid || :
fi
}
function clean_bin() {
# Remove link
${csudo} rm -f ${bin_link_dir}/taos || :
${csudo} rm -f ${bin_link_dir}/taosump || :
${csudo} rm -f ${bin_link_dir}/rmtaos || :
}
function clean_lib() {
# Remove link
${csudo} rm -f ${lib_link_dir}/libtaos.* || :
}
function clean_header() {
# Remove link
${csudo} rm -f ${inc_link_dir}/taos.h || :
${csudo} rm -f ${inc_link_dir}/taoserror.h || :
}
function clean_config() {
# Remove link
${csudo} rm -f ${cfg_link_dir}/* || :
}
function clean_log() {
# Remove link
${csudo} rm -rf ${log_link_dir} || :
}
# Stop client.
kill_client
# Remove binary file and links
clean_bin
# Remove header file.
clean_header
# Remove lib file
clean_lib
# Remove link log directory
clean_log
# Remove link configuration file
clean_config
${csudo} rm -rf ${install_main_dir}
echo -e "${GREEN}TDengine client is removed successfully!${NC}"
CMAKE_MINIMUM_REQUIRED(VERSION 2.8) CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(TDengine) PROJECT(TDengine)
SET(PRJ_HEADER_PATH ${CMAKE_CURRENT_SOURCE_DIR}/inc)
ADD_SUBDIRECTORY(os) ADD_SUBDIRECTORY(os)
ADD_SUBDIRECTORY(util) ADD_SUBDIRECTORY(util)
ADD_SUBDIRECTORY(rpc) ADD_SUBDIRECTORY(rpc)
......
CMAKE_MINIMUM_REQUIRED(VERSION 2.8) CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(TDengine) PROJECT(TDengine)
INCLUDE_DIRECTORIES(inc)
INCLUDE_DIRECTORIES(jni)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/inc)
INCLUDE_DIRECTORIES(${TD_OS_DIR}/inc)
AUX_SOURCE_DIRECTORY(./src SRC) AUX_SOURCE_DIRECTORY(./src SRC)
INCLUDE_DIRECTORIES(inc jni ${TD_ROOT_DIR}/src/inc ${TD_OS_DIR}/inc)
IF (TD_LINUX)
INCLUDE_DIRECTORIES(${TD_ROOT_DIR}/deps/jni/linux) IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM))
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/jni/linux)
# set the static lib name # set the static lib name
ADD_LIBRARY(taos_static STATIC ${SRC}) ADD_LIBRARY(taos_static STATIC ${SRC})
...@@ -23,30 +24,38 @@ IF (TD_LINUX) ...@@ -23,30 +24,38 @@ IF (TD_LINUX)
#set version of .so #set version of .so
#VERSION so version #VERSION so version
#SOVERSION api version #SOVERSION api version
execute_process(COMMAND chmod 777 ${PROJECT_SOURCE_DIR}/../../packaging/tools/get_version.sh) IF (TD_LITE)
execute_process(COMMAND ${PROJECT_SOURCE_DIR}/../../packaging/tools/get_version.sh execute_process(COMMAND chmod 777 ${TD_COMMUNITY_DIR}/packaging/tools/get_version.sh)
OUTPUT_VARIABLE execute_process(COMMAND ${TD_COMMUNITY_DIR}/packaging/tools/get_version.sh ${TD_COMMUNITY_DIR}/src/util/src/version.c
VERSION_INFO) OUTPUT_VARIABLE
VERSION_INFO)
MESSAGE(STATUS "build lite version ${VERSION_INFO}")
ELSE ()
execute_process(COMMAND chmod 777 ${TD_COMMUNITY_DIR}/packaging/tools/get_version.sh)
execute_process(COMMAND ${TD_COMMUNITY_DIR}/packaging/tools/get_version.sh ${TD_COMMUNITY_DIR}/src/util/src/version.c
OUTPUT_VARIABLE
VERSION_INFO)
MESSAGE(STATUS "build cluster version ${VERSION_INFO}")
ENDIF ()
MESSAGE(STATUS "build version ${VERSION_INFO}") MESSAGE(STATUS "build version ${VERSION_INFO}")
SET_TARGET_PROPERTIES(taos PROPERTIES VERSION ${VERSION_INFO} SOVERSION 1) SET_TARGET_PROPERTIES(taos PROPERTIES VERSION ${VERSION_INFO} SOVERSION 1)
ELSEIF (TD_WINDOWS) ELSEIF (TD_WINDOWS_64)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/jni/windows)
INCLUDE_DIRECTORIES(${TD_ROOT_DIR}/deps/jni/windows) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/jni/windows/win32)
INCLUDE_DIRECTORIES(${TD_ROOT_DIR}/deps/jni/windows/win32) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/pthread)
INCLUDE_DIRECTORIES(${TD_ROOT_DIR}/deps/pthread)
ADD_LIBRARY(taos_static STATIC ${SRC}) ADD_LIBRARY(taos_static STATIC ${SRC})
TARGET_LINK_LIBRARIES(taos_static trpc tutil) TARGET_LINK_LIBRARIES(taos_static trpc tutil)
# generate dynamic library (*.dll) # generate dynamic library (*.dll)
ADD_LIBRARY(taos SHARED ${SRC}) ADD_LIBRARY(taos SHARED ${SRC})
SET_TARGET_PROPERTIES(taos PROPERTIES LINK_FLAGS /DEF:${TD_ROOT_DIR}/src/client/src/taos.def) SET_TARGET_PROPERTIES(taos PROPERTIES LINK_FLAGS /DEF:${TD_COMMUNITY_DIR}/src/client/src/taos.def)
TARGET_LINK_LIBRARIES(taos trpc) TARGET_LINK_LIBRARIES(taos trpc)
ELSEIF (TD_DARWIN) ELSEIF (TD_DARWIN_64)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/jni/linux)
INCLUDE_DIRECTORIES(${TD_ROOT_DIR}/deps/jni/linux)
ADD_LIBRARY(taos_static STATIC ${SRC}) ADD_LIBRARY(taos_static STATIC ${SRC})
TARGET_LINK_LIBRARIES(taos_static trpc tutil pthread m) TARGET_LINK_LIBRARIES(taos_static trpc tutil pthread m)
...@@ -55,6 +64,6 @@ ELSEIF (TD_DARWIN) ...@@ -55,6 +64,6 @@ ELSEIF (TD_DARWIN)
# generate dynamic library (*.dylib) # generate dynamic library (*.dylib)
ADD_LIBRARY(taos SHARED ${SRC}) ADD_LIBRARY(taos SHARED ${SRC})
TARGET_LINK_LIBRARIES(taos trpc tutil pthread m) TARGET_LINK_LIBRARIES(taos trpc tutil pthread m)
ENDIF () ENDIF ()
...@@ -24,9 +24,9 @@ void *taosOpenConnCache(int maxSessions, void (*cleanFp)(void *), void *tmrCtrl, ...@@ -24,9 +24,9 @@ void *taosOpenConnCache(int maxSessions, void (*cleanFp)(void *), void *tmrCtrl,
void taosCloseConnCache(void *handle); void taosCloseConnCache(void *handle);
void *taosAddConnIntoCache(void *handle, void *data, uint32_t ip, short port, char *user); void *taosAddConnIntoCache(void *handle, void *data, uint32_t ip, uint16_t port, char *user);
void *taosGetConnFromCache(void *handle, uint32_t ip, short port, char *user); void *taosGetConnFromCache(void *handle, uint32_t ip, uint16_t port, char *user);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
/*
* 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_TSCJOINPROCESS_H
#define TDENGINE_TSCJOINPROCESS_H
#ifdef __cplusplus
extern "C" {
#endif
#include "tscUtil.h"
#include "tsclient.h"
void tscFetchDatablockFromSubquery(SSqlObj* pSql);
void tscGetQualifiedTSList(SSqlObj* pSql, SJoinSubquerySupporter* p1, SJoinSubquerySupporter* p2, int32_t* num);
void tscSetupOutputColumnIndex(SSqlObj* pSql);
int32_t tscLaunchSecondSubquery(SSqlObj* pSql);
void tscJoinQueryCallback(void* param, TAOS_RES* tres, int code);
SJoinSubquerySupporter* tscCreateJoinSupporter(SSqlObj* pSql, SSubqueryState* pState, int32_t index);
void tscDestroyJoinSupporter(SJoinSubquerySupporter* pSupporter);
#define MEM_BUF_SIZE (1<<20)
#define TS_COMP_BLOCK_PADDING 0xFFFFFFFF
#define TS_COMP_FILE_MAGIC 0x87F5EC4C
#define TS_COMP_FILE_VNODE_MAX 512
typedef struct STSList {
char* rawBuf;
int32_t allocSize;
int32_t threshold;
int32_t len;
} STSList;
typedef struct STSRawBlock {
int32_t vnode;
int64_t tag;
TSKEY* ts;
int32_t len;
} STSRawBlock;
typedef struct STSElem {
TSKEY ts;
int64_t tag;
int32_t vnode;
} STSElem;
typedef struct STSCursor {
int32_t vnodeIndex;
int32_t blockIndex;
int32_t tsIndex;
int32_t order;
} STSCursor;
typedef struct STSBlock {
int64_t tag; // tag value
int32_t numOfElem; // number of elements
int32_t compLen; // size after compressed
int32_t padding; // 0xFFFFFFFF by default, after the payload
char* payload; // actual data that is compressed
} STSBlock;
typedef struct STSVnodeBlockInfo {
int32_t vnode;
/*
* The size of buffer file is not expected to be greater than 2G,
* and the offset of int32_t type is enough
*/
int32_t offset;
int32_t numOfBlocks;
int32_t compLen;
} STSVnodeBlockInfo;
typedef struct STSVnodeBlockInfoEx {
STSVnodeBlockInfo info;
int32_t len; // length before compress
} STSVnodeBlockInfoEx;
typedef struct STSBuf {
FILE* f;
char path[PATH_MAX];
uint32_t fileSize;
STSVnodeBlockInfoEx* pData;
int32_t numOfAlloc;
int32_t numOfVnodes;
char* assistBuf;
int32_t bufSize;
STSBlock block;
STSList tsData; // uncompressed raw ts data
uint64_t numOfTotal;
bool autoDelete;
int32_t tsOrder; // order of timestamp in ts comp buffer
STSCursor cur;
} STSBuf;
typedef struct STSBufFileHeader {
uint32_t magic; // file magic number
uint32_t numOfVnode; // number of vnode stored in current file
uint32_t tsOrder; // timestamp order in current file
} STSBufFileHeader;
STSBuf* tsBufCreate(bool autoDelete);
STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete);
STSBuf* tsBufCreateFromCompBlocks(const char* pData, int32_t numOfBlocks, int32_t len, int32_t tsOrder);
void tsBufDestory(STSBuf* pTSBuf);
void tsBufAppend(STSBuf* pTSBuf, int32_t vnodeId, int64_t tag, const char* pData, int32_t len);
int32_t tsBufMerge(STSBuf* pDestBuf, const STSBuf* pSrcBuf, int32_t vnodeIdx);
STSVnodeBlockInfo* tsBufGetVnodeBlockInfo(STSBuf* pTSBuf, int32_t vnodeId);
void tsBufFlush(STSBuf* pTSBuf);
void tsBufResetPos(STSBuf* pTSBuf);
STSElem tsBufGetElem(STSBuf* pTSBuf);
bool tsBufNextPos(STSBuf* pTSBuf);
STSElem tsBufGetElemStartPos(STSBuf* pTSBuf, int32_t vnodeId, int64_t tag);
STSCursor tsBufGetCursor(STSBuf* pTSBuf);
void tsBufSetTraverseOrder(STSBuf* pTSBuf, int32_t order);
void tsBufSetCursor(STSBuf* pTSBuf, STSCursor* pCur);
STSBuf* tsBufClone(STSBuf* pTSBuf);
/**
* display all data in comp block file, for debug purpose only
* @param pTSBuf
*/
void tsBufDisplay(STSBuf* pTSBuf);
#ifdef __cplusplus
}
#endif
#endif // TDENGINE_TSCJOINPROCESS_H
...@@ -23,29 +23,15 @@ extern "C" { ...@@ -23,29 +23,15 @@ extern "C" {
#include "taos.h" #include "taos.h"
#include "tsqldef.h" #include "tsqldef.h"
#include "ttypes.h" #include "ttypes.h"
#include "taosmsg.h"
#define TK_SPACE 200
#define TK_COMMENT 201
#define TK_ILLEGAL 202
#define TK_HEX 203
#define TK_OCT 204
#define TSQL_SO_ASC 1
#define TSQL_SO_DESC 0
#define MAX_TOKEN_LEN 30 #define MAX_TOKEN_LEN 30
#define TSQL_TBNAME "TBNAME"
#define TSQL_TBNAME_L "tbname"
#define TSQL_STABLE_QTYPE_COND 1
#define TSQL_STABLE_QTYPE_SET 2
// token type // token type
enum { enum {
TSQL_NODE_TYPE_EXPR = 0x1, TSQL_NODE_TYPE_EXPR = 0x1,
TSQL_NODE_TYPE_ID = 0x2, TSQL_NODE_TYPE_ID = 0x2,
TSQL_NODE_TYPE_VALUE = 0x4, TSQL_NODE_TYPE_VALUE = 0x4,
}; };
extern char tTokenTypeSwitcher[13]; extern char tTokenTypeSwitcher[13];
...@@ -119,6 +105,7 @@ enum TSQL_TYPE { ...@@ -119,6 +105,7 @@ enum TSQL_TYPE {
SHOW_MODULES = 0x6c, SHOW_MODULES = 0x6c,
SHOW_CONNECTIONS = 0x6d, SHOW_CONNECTIONS = 0x6d,
SHOW_GRANTS = 0x6e, SHOW_GRANTS = 0x6e,
SHOW_VNODES = 0x6f,
// create dnode // create dnode
CREATE_DNODE = 0x80, CREATE_DNODE = 0x80,
...@@ -155,14 +142,14 @@ enum TSQL_TYPE { ...@@ -155,14 +142,14 @@ enum TSQL_TYPE {
typedef struct SQuerySQL { typedef struct SQuerySQL {
struct tSQLExprList *pSelection; // select clause struct tSQLExprList *pSelection; // select clause
struct SSQLToken from; // from clause tVariantList * from; // from clause
struct tSQLExpr * pWhere; // where clause [optional] struct tSQLExpr * pWhere; // where clause [optional]
tVariantList * pGroupby; // groupby clause, only for tags[optional] tVariantList * pGroupby; // groupby clause, only for tags[optional]
tVariantList * pSortOrder; // orderby [optional] tVariantList * pSortOrder; // orderby [optional]
SSQLToken interval; // interval [optional] SSQLToken interval; // interval [optional]
SSQLToken sliding; // sliding window [optional] SSQLToken sliding; // sliding window [optional]
SLimitVal limit; // limit offset [optional] SLimitVal limit; // limit offset [optional]
SLimitVal glimit; // group limit offset [optional] SLimitVal slimit; // group limit offset [optional]
tVariantList * fillType; // fill type[optional] tVariantList * fillType; // fill type[optional]
SSQLToken selectToken; // sql string SSQLToken selectToken; // sql string
} SQuerySQL; } SQuerySQL;
...@@ -278,8 +265,7 @@ typedef struct tSQLExpr { ...@@ -278,8 +265,7 @@ typedef struct tSQLExpr {
uint32_t nSQLOptr; // TK_FUNCTION: sql function, TK_LE: less than(binary expr) uint32_t nSQLOptr; // TK_FUNCTION: sql function, TK_LE: less than(binary expr)
// the full sql string of function(col, param), which is actually the raw // the full sql string of function(col, param), which is actually the raw
// field name, // field name, since the function name is kept in nSQLOptr already
// since the function name is kept in nSQLOptr already
SSQLToken operand; SSQLToken operand;
struct tSQLExprList *pParam; // function parameters struct tSQLExprList *pParam; // function parameters
...@@ -327,12 +313,12 @@ void Parse(void *yyp, int yymajor, ParseTOKENTYPE yyminor, SSqlInfo *); ...@@ -327,12 +313,12 @@ void Parse(void *yyp, int yymajor, ParseTOKENTYPE yyminor, SSqlInfo *);
*/ */
void ParseFree(void *p, void (*freeProc)(void *)); void ParseFree(void *p, void (*freeProc)(void *));
tVariantList *tVariantListAppendToken(tVariantList *pList, SSQLToken *pAliasToken, uint8_t sortOrder);
tVariantList *tVariantListAppend(tVariantList *pList, tVariant *pVar, uint8_t sortOrder); tVariantList *tVariantListAppend(tVariantList *pList, tVariant *pVar, uint8_t sortOrder);
tVariantList *tVariantListInsert(tVariantList *pList, tVariant *pVar, uint8_t sortOrder, int32_t index); tVariantList *tVariantListInsert(tVariantList *pList, tVariant *pVar, uint8_t sortOrder, int32_t index);
void tVariantListDestroy(tVariantList *pList); tVariantList *tVariantListAppendToken(tVariantList *pList, SSQLToken *pAliasToken, uint8_t sortOrder);
void tVariantListDestroy(tVariantList *pList);
tFieldList *tFieldListAppend(tFieldList *pList, TAOS_FIELD *pField); tFieldList *tFieldListAppend(tFieldList *pList, TAOS_FIELD *pField);
...@@ -346,14 +332,15 @@ tSQLExprList *tSQLExprListAppend(tSQLExprList *pList, tSQLExpr *pNode, SSQLToken ...@@ -346,14 +332,15 @@ tSQLExprList *tSQLExprListAppend(tSQLExprList *pList, tSQLExpr *pNode, SSQLToken
void tSQLExprListDestroy(tSQLExprList *pList); void tSQLExprListDestroy(tSQLExprList *pList);
int32_t tSQLSyntaxNodeToString(tSQLExpr *pNode, char *dst); SQuerySQL *tSetQuerySQLElems(SSQLToken *pSelectToken, tSQLExprList *pSelection, tVariantList *pFrom, tSQLExpr *pWhere,
SQuerySQL *tSetQuerySQLElems(SSQLToken *pSelectToken, tSQLExprList *pSelection, SSQLToken *pFrom, tSQLExpr *pWhere,
tVariantList *pGroupby, tVariantList *pSortOrder, SSQLToken *pInterval, tVariantList *pGroupby, tVariantList *pSortOrder, SSQLToken *pInterval,
SSQLToken *pSliding, tVariantList *pFill, SLimitVal *pLimit, SLimitVal *pGLimit); SSQLToken *pSliding, tVariantList *pFill, SLimitVal *pLimit, SLimitVal *pGLimit);
SCreateTableSQL *tSetCreateSQLElems(tFieldList *pCols, tFieldList *pTags, SSQLToken *pMetricName, SCreateTableSQL *tSetCreateSQLElems(tFieldList *pCols, tFieldList *pTags, SSQLToken *pMetricName,
tVariantList *pTagVals, SQuerySQL *pSelect, int32_t type); tVariantList *pTagVals, SQuerySQL *pSelect, int32_t type);
void tSQLExprDestroy(tSQLExpr *);
void tSQLExprNodeDestroy(tSQLExpr *pExpr);
tSQLExpr *tSQLExprNodeClone(tSQLExpr *pExpr);
SAlterTableSQL *tAlterTableSQLElems(SSQLToken *pMeterName, tFieldList *pCols, tVariantList *pVals, int32_t type); SAlterTableSQL *tAlterTableSQLElems(SSQLToken *pMeterName, tFieldList *pCols, tVariantList *pVals, int32_t type);
...@@ -376,6 +363,7 @@ tDCLSQL *tTokenListAppend(tDCLSQL *pTokenList, SSQLToken *pToken); ...@@ -376,6 +363,7 @@ tDCLSQL *tTokenListAppend(tDCLSQL *pTokenList, SSQLToken *pToken);
void setCreateDBSQL(SSqlInfo *pInfo, int32_t type, SSQLToken *pToken, SCreateDBInfo *pDB, SSQLToken *pIgExists); void setCreateDBSQL(SSqlInfo *pInfo, int32_t type, SSQLToken *pToken, SCreateDBInfo *pDB, SSQLToken *pIgExists);
void setCreateAcctSQL(SSqlInfo *pInfo, int32_t type, SSQLToken *pName, SSQLToken *pPwd, SCreateAcctSQL *pAcctInfo); void setCreateAcctSQL(SSqlInfo *pInfo, int32_t type, SSQLToken *pName, SSQLToken *pPwd, SCreateAcctSQL *pAcctInfo);
void setDefaultCreateDbOption(SCreateDBInfo *pDBInfo);
// prefix show db.tables; // prefix show db.tables;
void setDBName(SSQLToken *pCpxName, SSQLToken *pDB); void setDBName(SSQLToken *pCpxName, SSQLToken *pDB);
......
...@@ -52,74 +52,53 @@ enum { ...@@ -52,74 +52,53 @@ enum {
}; };
typedef struct SLocalReducer { typedef struct SLocalReducer {
SLocalDataSource **pLocalDataSrc; SLocalDataSource ** pLocalDataSrc;
int32_t numOfBuffer; int32_t numOfBuffer;
int32_t numOfCompleted; int32_t numOfCompleted;
int32_t numOfVnode;
int32_t numOfVnode; SLoserTreeInfo * pLoserTree;
char * prevRowOfInput;
SLoserTreeInfo *pLoserTree; tFilePage * pResultBuf;
char * prevRowOfInput; int32_t nResultBufSize;
char * pBufForInterpo; // intermediate buffer for interpolation
tFilePage *pResultBuf; tFilePage * pTempBuffer;
int32_t nResultBufSize;
char *pBufForInterpo; // intermediate buffer for interpolation
tFilePage *pTempBuffer;
struct SQLFunctionCtx *pCtx; struct SQLFunctionCtx *pCtx;
int32_t rowSize; // size of each intermediate result.
int32_t rowSize; // size of each intermediate result. int32_t status; // denote it is in reduce process, in reduce process, it
int32_t status; // denote it is in reduce process, in reduce process, it bool hasPrevRow; // cannot be released
// cannot be released bool hasUnprocessedRow;
bool hasPrevRow; tOrderDescriptor * pDesc;
bool hasUnprocessedRow; tColModel * resColModel;
tExtMemBuffer ** pExtMemBuffer; // disk-based buffer
tOrderDescriptor *pDesc; SInterpolationInfo interpolationInfo; // interpolation support structure
tColModel * resColModel; char * pFinalRes; // result data after interpo
tFilePage * discardData;
tExtMemBuffer ** pExtMemBuffer; // disk-based buffer SResultInfo * pResInfo;
SInterpolationInfo interpolationInfo; // interpolation support structure bool discard;
int32_t offset; // limit offset value
char *pFinalRes; // result data after interpo
tFilePage *discardData;
bool discard;
int32_t offset;
} SLocalReducer; } SLocalReducer;
typedef struct SRetrieveSupport { typedef struct SSubqueryState {
tExtMemBuffer ** pExtMemBuffer; // for build loser tree
tOrderDescriptor *pOrderDescriptor;
tColModel * pFinalColModel; // colModel for final result
/*
* shared by all subqueries
* It is the number of completed retrieval subquery.
* once this value equals to numOfVnodes, all retrieval are completed.
* Local merge is launched.
*/
int32_t *numOfFinished;
int32_t numOfVnodes; // total number of vnode
int32_t vnodeIdx; // index of current vnode in vnode list
/* /*
* shared by all subqueries * the number of completed retrieval subquery, once this value equals to numOfVnodes,
* denote the status of query on vnode, if code!=0, all following * all retrieval are completed.Local merge is launched.
* retrieval on vnode are aborted.
*/ */
int32_t *code; int32_t numOfCompleted;
int32_t numOfTotal; // number of total sub-queries
SSqlObj * pParentSqlObj; int32_t code; // code from subqueries
tFilePage *localBuffer; // temp buffer, there is a buffer for each vnode to uint64_t numOfRetrievedRows; // total number of points in this query
// save data } SSubqueryState;
uint64_t *numOfTotalRetrievedPoints; // total number of points in this query
// retrieved from server
uint32_t numOfRetry; // record the number of retry times typedef struct SRetrieveSupport {
pthread_mutex_t queryMutex; tExtMemBuffer ** pExtMemBuffer; // for build loser tree
tOrderDescriptor *pOrderDescriptor;
tColModel * pFinalColModel; // colModel for final result
SSubqueryState * pState;
int32_t vnodeIdx; // index of current vnode in vnode list
SSqlObj * pParentSqlObj;
tFilePage * localBuffer; // temp buffer, there is a buffer for each vnode to
uint32_t numOfRetry; // record the number of retry times
pthread_mutex_t queryMutex;
} SRetrieveSupport; } SRetrieveSupport;
int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOrderDescriptor **pDesc, int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOrderDescriptor **pDesc,
......
...@@ -23,17 +23,19 @@ extern "C" { ...@@ -23,17 +23,19 @@ extern "C" {
/* /*
* @date 2018/09/30 * @date 2018/09/30
*/ */
#include <limits.h>
#include <stdio.h> #include <stdio.h>
#include "tsdb.h"
#include "tsclient.h"
#include "textbuffer.h" #include "textbuffer.h"
#include "tsclient.h"
#include "tsdb.h"
#include "tscSecondaryMerge.h"
#define UTIL_METER_IS_METRIC(cmd) (((cmd)->pMeterMeta != NULL) && ((cmd)->pMeterMeta->meterType == TSDB_METER_METRIC)) #define UTIL_METER_IS_METRIC(metaInfo) (((metaInfo)->pMeterMeta != NULL) && ((metaInfo)->pMeterMeta->meterType == TSDB_METER_METRIC))
#define UTIL_METER_IS_NOMRAL_METER(metaInfo) (!(UTIL_METER_IS_METRIC(metaInfo)))
#define UTIL_METER_IS_NOMRAL_METER(cmd) (!(UTIL_METER_IS_METRIC(cmd))) #define UTIL_METER_IS_CREATE_FROM_METRIC(metaInfo) \
(((metaInfo)->pMeterMeta != NULL) && ((metaInfo)->pMeterMeta->meterType == TSDB_METER_MTABLE))
#define UTIL_METER_IS_CREATE_FROM_METRIC(cmd) \ #define TSDB_COL_IS_TAG(f) (((f)&TSDB_COL_TAG) != 0)
(((cmd)->pMeterMeta != NULL) && ((cmd)->pMeterMeta->meterType == TSDB_METER_MTABLE))
typedef struct SParsedColElem { typedef struct SParsedColElem {
int16_t colIndex; int16_t colIndex;
...@@ -47,15 +49,36 @@ typedef struct SParsedDataColInfo { ...@@ -47,15 +49,36 @@ typedef struct SParsedDataColInfo {
bool hasVal[TSDB_MAX_COLUMNS]; bool hasVal[TSDB_MAX_COLUMNS];
} SParsedDataColInfo; } SParsedDataColInfo;
STableDataBlocks* tscCreateDataBlock(int32_t size); typedef struct SJoinSubquerySupporter {
SSubqueryState* pState;
SSqlObj* pObj; // parent SqlObj
bool hasMore; // has data from vnode to fetch
int32_t subqueryIndex; // index of sub query
int64_t interval; // interval time
SLimitVal limit; // limit info
uint64_t uid; // query meter uid
SColumnBaseInfo colList; // previous query information
SSqlExprInfo exprsInfo;
SFieldInfo fieldsInfo;
STagCond tagCond;
SSqlGroupbyExpr groupbyExpr;
struct STSBuf* pTSBuf;
FILE* f;
char path[PATH_MAX];
} SJoinSubquerySupporter;
void tscDestroyDataBlock(STableDataBlocks* pDataBlock); void tscDestroyDataBlock(STableDataBlocks* pDataBlock);
STableDataBlocks* tscCreateDataBlock(int32_t size);
void tscAppendDataBlock(SDataBlockList* pList, STableDataBlocks* pBlocks); void tscAppendDataBlock(SDataBlockList* pList, STableDataBlocks* pBlocks);
SParamInfo* tscAddParamToDataBlock(STableDataBlocks* pDataBlock, char type, uint8_t timePrec, short bytes, uint32_t offset);
SDataBlockList* tscCreateBlockArrayList(); SDataBlockList* tscCreateBlockArrayList();
void* tscDestroyBlockArrayList(SDataBlockList* pList); void* tscDestroyBlockArrayList(SDataBlockList* pList);
int32_t tscCopyDataBlockToPayload(SSqlObj* pSql, STableDataBlocks* pDataBlock); int32_t tscCopyDataBlockToPayload(SSqlObj* pSql, STableDataBlocks* pDataBlock);
void tscFreeUnusedDataBlocks(SDataBlockList* pList); void tscFreeUnusedDataBlocks(SDataBlockList* pList);
void tscMergeTableDataBlocks(SSqlObj* pSql, SDataBlockList* pDataList); int32_t tscMergeTableDataBlocks(SSqlObj* pSql, SDataBlockList* pDataList);
STableDataBlocks* tscGetDataBlockFromList(void* pHashList, SDataBlockList* pDataBlockList, int64_t id, int32_t size, STableDataBlocks* tscGetDataBlockFromList(void* pHashList, SDataBlockList* pDataBlockList, int64_t id, int32_t size,
int32_t startOffset, int32_t rowSize, char* tableId); int32_t startOffset, int32_t rowSize, char* tableId);
STableDataBlocks* tscCreateDataBlockEx(size_t size, int32_t rowSize, int32_t startOffset, char* name); STableDataBlocks* tscCreateDataBlockEx(size_t size, int32_t rowSize, int32_t startOffset, char* name);
...@@ -63,9 +86,6 @@ STableDataBlocks* tscCreateDataBlockEx(size_t size, int32_t rowSize, int32_t sta ...@@ -63,9 +86,6 @@ STableDataBlocks* tscCreateDataBlockEx(size_t size, int32_t rowSize, int32_t sta
SVnodeSidList* tscGetVnodeSidList(SMetricMeta* pMetricmeta, int32_t vnodeIdx); SVnodeSidList* tscGetVnodeSidList(SMetricMeta* pMetricmeta, int32_t vnodeIdx);
SMeterSidExtInfo* tscGetMeterSidInfo(SVnodeSidList* pSidList, int32_t idx); SMeterSidExtInfo* tscGetMeterSidInfo(SVnodeSidList* pSidList, int32_t idx);
bool tscProjectionQueryOnMetric(SSqlObj* pSql);
bool tscIsTwoStageMergeMetricQuery(SSqlObj* pSql);
/** /**
* *
* for the projection query on metric or point interpolation query on metric, * for the projection query on metric or point interpolation query on metric,
...@@ -73,52 +93,75 @@ bool tscIsTwoStageMergeMetricQuery(SSqlObj* pSql); ...@@ -73,52 +93,75 @@ bool tscIsTwoStageMergeMetricQuery(SSqlObj* pSql);
* *
* @param pSql sql object * @param pSql sql object
* @return * @return
*
*/ */
bool tscIsFirstProjQueryOnMetric(SSqlObj* pSql);
bool tscIsPointInterpQuery(SSqlCmd* pCmd); bool tscIsPointInterpQuery(SSqlCmd* pCmd);
void tscClearInterpInfo(SSqlCmd* pCmd); bool tscIsTWAQuery(SSqlCmd* pCmd);
bool tscProjectionQueryOnMetric(SSqlCmd* pCmd);
bool tscIsTwoStageMergeMetricQuery(SSqlCmd* pCmd);
bool tscQueryOnMetric(SSqlCmd* pCmd);
bool tscQueryMetricTags(SSqlCmd* pCmd);
bool tscIsSelectivityWithTagQuery(SSqlCmd* pCmd);
void tscAddSpecialColumnForSelect(SSqlCmd* pCmd, int32_t outputColIndex, int16_t functionId, SColumnIndex* pIndex,
SSchema* pColSchema, int16_t isTag);
void addRequiredTagColumn(SSqlCmd* pCmd, int32_t tagColIndex, int32_t tableIndex);
//TODO refactor, remove
void SStringFree(SString* str);
void SStringCopy(SString* pDest, const SString* pSrc);
SString SStringCreate(const char* str);
int32_t setMeterID(SSqlObj* pSql, SSQLToken* pzTableName); int32_t SStringAlloc(SString* pStr, int32_t size);
int32_t SStringEnsureRemain(SString* pStr, int32_t size);
int32_t setMeterID(SSqlObj* pSql, SSQLToken* pzTableName, int32_t tableIndex);
void tscClearInterpInfo(SSqlCmd* pCmd);
bool tscIsInsertOrImportData(char* sqlstr); bool tscIsInsertOrImportData(char* sqlstr);
/* use for keep current db info temporarily, for handle table with db prefix */ /* use for keep current db info temporarily, for handle table with db prefix */
void tscGetDBInfoFromMeterId(char* meterId, char* db); void tscGetDBInfoFromMeterId(char* meterId, char* db);
void tscGetMetricMetaCacheKey(SSqlCmd* pCmd, char* keyStr); int tscAllocPayload(SSqlCmd* pCmd, int size);
bool tscQueryOnMetric(SSqlCmd* pCmd);
int tscAllocPayloadWithSize(SSqlCmd* pCmd, int size);
void tscFieldInfoSetValFromSchema(SFieldInfo* pFieldInfo, int32_t index, SSchema* pSchema); void tscFieldInfoSetValFromSchema(SFieldInfo* pFieldInfo, int32_t index, SSchema* pSchema);
void tscFieldInfoSetValFromField(SFieldInfo* pFieldInfo, int32_t index, TAOS_FIELD* pField); void tscFieldInfoSetValFromField(SFieldInfo* pFieldInfo, int32_t index, TAOS_FIELD* pField);
void tscFieldInfoSetValue(SFieldInfo* pFieldInfo, int32_t index, int8_t type, char* name, int16_t bytes); void tscFieldInfoSetValue(SFieldInfo* pFieldInfo, int32_t index, int8_t type, const char* name, int16_t bytes);
void tscFieldInfoUpdateVisible(SFieldInfo* pFieldInfo, int32_t index, bool visible);
void tscFieldInfoCalOffset(SSqlCmd* pCmd); void tscFieldInfoCalOffset(SSqlCmd* pCmd);
void tscFieldInfoRenewOffsetForInterResult(SSqlCmd* pCmd); void tscFieldInfoUpdateOffset(SSqlCmd* pCmd);
void tscFieldInfoClone(SFieldInfo* src, SFieldInfo* dst); void tscFieldInfoCopy(SFieldInfo* src, SFieldInfo* dst, const int32_t* indexList, int32_t size);
void tscFieldInfoCopyAll(SFieldInfo* src, SFieldInfo* dst);
TAOS_FIELD* tscFieldInfoGetField(SSqlCmd* pCmd, int32_t index); TAOS_FIELD* tscFieldInfoGetField(SSqlCmd* pCmd, int32_t index);
int16_t tscFieldInfoGetOffset(SSqlCmd* pCmd, int32_t index); int16_t tscFieldInfoGetOffset(SSqlCmd* pCmd, int32_t index);
int32_t tscGetResRowLength(SSqlCmd* pCmd); int32_t tscGetResRowLength(SSqlCmd* pCmd);
void tscClearFieldInfo(SSqlCmd* pCmd); void tscClearFieldInfo(SFieldInfo* pFieldInfo);
void addExprParams(SSqlExpr* pExpr, char* argument, int32_t type, int32_t bytes); void addExprParams(SSqlExpr* pExpr, char* argument, int32_t type, int32_t bytes, int16_t tableIndex);
SSqlExpr* tscSqlExprInsert(SSqlCmd* pCmd, int32_t index, int16_t functionId, SColumnIndex* pColIndex, int16_t type,
int16_t size, int16_t interSize);
SSqlExpr* tscSqlExprInsertEmpty(SSqlCmd* pCmd, int32_t index, int16_t functionId);
SSqlExpr* tscSqlExprInsert(SSqlCmd* pCmd, int32_t index, int16_t functionId, int16_t srcColumnIndex, int16_t type,
int16_t size);
SSqlExpr* tscSqlExprUpdate(SSqlCmd* pCmd, int32_t index, int16_t functionId, int16_t srcColumnIndex, int16_t type, SSqlExpr* tscSqlExprUpdate(SSqlCmd* pCmd, int32_t index, int16_t functionId, int16_t srcColumnIndex, int16_t type,
int16_t size); int16_t size);
SSqlExpr* tscSqlExprGet(SSqlCmd* pCmd, int32_t index); SSqlExpr* tscSqlExprGet(SSqlCmd* pCmd, int32_t index);
void tscSqlExprClone(SSqlExprInfo* src, SSqlExprInfo* dst); void tscSqlExprCopy(SSqlExprInfo* dst, const SSqlExprInfo* src, uint64_t uid);
SColumnBase* tscColumnBaseInfoInsert(SSqlCmd* pCmd, SColumnIndex* colIndex);
void tscColumnFilterInfoCopy(SColumnFilterInfo* dst, const SColumnFilterInfo* src);
void tscColumnBaseCopy(SColumnBase* dst, const SColumnBase* src);
SColumnBase* tscColumnInfoInsert(SSqlCmd* pCmd, int32_t colIndex); void tscColumnBaseInfoCopy(SColumnBaseInfo* dst, const SColumnBaseInfo* src, int16_t tableIndex);
SColumnBase* tscColumnBaseInfoGet(SColumnBaseInfo* pColumnBaseInfo, int32_t index);
void tscColumnBaseInfoUpdateTableIndex(SColumnBaseInfo* pColList, int16_t tableIndex);
void tscColumnInfoClone(SColumnsInfo* src, SColumnsInfo* dst); void tscColumnBaseInfoReserve(SColumnBaseInfo* pColumnBaseInfo, int32_t size);
SColumnBase* tscColumnInfoGet(SSqlCmd* pCmd, int32_t index); void tscColumnBaseInfoDestroy(SColumnBaseInfo* pColumnBaseInfo);
void tscColumnInfoReserve(SSqlCmd* pCmd, int32_t size);
int32_t tscValidateName(SSQLToken* pToken); int32_t tscValidateName(SSQLToken* pToken);
...@@ -127,8 +170,10 @@ void tscIncStreamExecutionCount(void* pStream); ...@@ -127,8 +170,10 @@ void tscIncStreamExecutionCount(void* pStream);
bool tscValidateColumnId(SSqlCmd* pCmd, int32_t colId); bool tscValidateColumnId(SSqlCmd* pCmd, int32_t colId);
// get starter position of metric query condition (query on tags) in SSqlCmd.payload // get starter position of metric query condition (query on tags) in SSqlCmd.payload
char* tsGetMetricQueryCondPos(STagCond* pCond); SCond* tsGetMetricQueryCondPos(STagCond* pCond, uint64_t tableIndex);
void tscTagCondAssign(STagCond* pDst, STagCond* pSrc); void tsSetMetricQueryCond(STagCond* pTagCond, uint64_t uid, const char* str);
void tscTagCondCopy(STagCond* dest, const STagCond* src);
void tscTagCondRelease(STagCond* pCond); void tscTagCondRelease(STagCond* pCond);
void tscTagCondSetQueryCondType(STagCond* pCond, int16_t type); void tscTagCondSetQueryCondType(STagCond* pCond, int16_t type);
...@@ -138,8 +183,54 @@ void tscSetFreeHeatBeat(STscObj* pObj); ...@@ -138,8 +183,54 @@ void tscSetFreeHeatBeat(STscObj* pObj);
bool tscShouldFreeHeatBeat(SSqlObj* pHb); bool tscShouldFreeHeatBeat(SSqlObj* pHb);
void tscCleanSqlCmd(SSqlCmd* pCmd); void tscCleanSqlCmd(SSqlCmd* pCmd);
bool tscShouldFreeAsyncSqlObj(SSqlObj* pSql); bool tscShouldFreeAsyncSqlObj(SSqlObj* pSql);
void tscRemoveAllMeterMetaInfo(SSqlCmd* pCmd, bool removeFromCache);
SMeterMetaInfo* tscGetMeterMetaInfo(SSqlCmd* pCmd, int32_t index);
SMeterMetaInfo* tscGetMeterMetaInfoByUid(SSqlCmd* pCmd, uint64_t uid, int32_t* index);
void tscClearMeterMetaInfo(SMeterMetaInfo* pMeterMetaInfo, bool removeFromCache);
SMeterMetaInfo* tscAddMeterMetaInfo(SSqlCmd* pCmd, const char* name, SMeterMeta* pMeterMeta, SMetricMeta* pMetricMeta,
int16_t numOfTags, int16_t* tags);
SMeterMetaInfo* tscAddEmptyMeterMetaInfo(SSqlCmd* pCmd);
void tscGetMetricMetaCacheKey(SSqlCmd* pCmd, char* keyStr, uint64_t uid);
int tscGetMetricMeta(SSqlObj* pSql);
int tscGetMeterMeta(SSqlObj* pSql, char* meterId, int32_t tableIndex);
int tscGetMeterMetaEx(SSqlObj* pSql, char* meterId, bool createIfNotExists);
void tscResetForNextRetrieve(SSqlRes* pRes);
void tscAddTimestampColumn(SSqlCmd* pCmd, int16_t functionId, int16_t tableIndex);
void tscDoQuery(SSqlObj* pSql); void tscDoQuery(SSqlObj* pSql);
/**
* The create object function must be successful expect for the out of memory issue.
*
* Therefore, the metermeta/metricmeta object is directly passed to the newly created subquery object from the
* previous sql object, instead of retrieving the metermeta/metricmeta from cache.
*
* Because the metermeta/metricmeta may have been released by other threads, resulting in the retrieving failed as
* well as the create function.
*
* @param pSql
* @param vnodeIndex
* @param tableIndex
* @param fp
* @param param
* @param pPrevSql
* @return
*/
SSqlObj* createSubqueryObj(SSqlObj* pSql, int32_t vnodeIndex, int16_t tableIndex, void (*fp)(), void* param,
SSqlObj* pPrevSql);
void addGroupInfoForSubquery(SSqlObj* pParentObj, SSqlObj* pSql, int32_t tableIndex);
void doAddGroupColumnForSubquery(SSqlCmd* pCmd, int32_t tagIndex);
int16_t tscGetJoinTagColIndexByUid(SSqlCmd* pCmd, uint64_t uid);
TAOS* taos_connect_a(char* ip, char* user, char* pass, char* db, uint16_t port, void (*fp)(void*, TAOS_RES*, int),
void* param, void** taos);
void sortRemoveDuplicates(STableDataBlocks* dataBuf); void sortRemoveDuplicates(STableDataBlocks* dataBuf);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -34,8 +34,8 @@ extern "C" { ...@@ -34,8 +34,8 @@ extern "C" {
#include "tglobalcfg.h" #include "tglobalcfg.h"
#include "tlog.h" #include "tlog.h"
#include "tscCache.h" #include "tscCache.h"
#include "tscSQLParser.h"
#include "tsdb.h" #include "tsdb.h"
#include "tsql.h"
#include "tsqlfunction.h" #include "tsqlfunction.h"
#include "tutil.h" #include "tutil.h"
...@@ -63,9 +63,9 @@ enum _sql_cmd { ...@@ -63,9 +63,9 @@ enum _sql_cmd {
TSDB_SQL_ALTER_DB, TSDB_SQL_ALTER_DB,
TSDB_SQL_CREATE_MNODE, TSDB_SQL_CREATE_MNODE,
TSDB_SQL_DROP_MNODE, TSDB_SQL_DROP_MNODE,
TSDB_SQL_CREATE_PNODE, TSDB_SQL_CREATE_DNODE,
TSDB_SQL_DROP_PNODE, TSDB_SQL_DROP_DNODE,
TSDB_SQL_CFG_PNODE, // 20 TSDB_SQL_CFG_DNODE, // 20
TSDB_SQL_CFG_MNODE, TSDB_SQL_CFG_MNODE,
TSDB_SQL_SHOW, TSDB_SQL_SHOW,
TSDB_SQL_RETRIEVE, TSDB_SQL_RETRIEVE,
...@@ -78,15 +78,26 @@ enum _sql_cmd { ...@@ -78,15 +78,26 @@ enum _sql_cmd {
TSDB_SQL_USE_DB, TSDB_SQL_USE_DB,
TSDB_SQL_META, // 30 TSDB_SQL_META, // 30
TSDB_SQL_METRIC, TSDB_SQL_METRIC,
TSDB_SQL_MULTI_META,
TSDB_SQL_HB, TSDB_SQL_HB,
TSDB_SQL_LOCAL, // SQL below for client local TSDB_SQL_LOCAL, // SQL below for client local
TSDB_SQL_DESCRIBE_TABLE, TSDB_SQL_DESCRIBE_TABLE,
TSDB_SQL_RETRIEVE_METRIC, TSDB_SQL_RETRIEVE_METRIC,
TSDB_SQL_METRIC_JOIN_RETRIEVE,
TSDB_SQL_RETRIEVE_TAGS, TSDB_SQL_RETRIEVE_TAGS,
TSDB_SQL_RETRIEVE_EMPTY_RESULT, // build empty result instead of accessing /*
// dnode to fetch result * build empty result instead of accessing dnode to fetch result
TSDB_SQL_RESET_CACHE, // reset the client cache * reset the client cache
*/
TSDB_SQL_RETRIEVE_EMPTY_RESULT,
TSDB_SQL_RESET_CACHE, // 40
TSDB_SQL_SERV_STATUS,
TSDB_SQL_CURRENT_DB,
TSDB_SQL_SERV_VERSION,
TSDB_SQL_CLI_VERSION,
TSDB_SQL_CURRENT_USER,
TSDB_SQL_CFG_LOCAL, TSDB_SQL_CFG_LOCAL,
TSDB_SQL_MAX TSDB_SQL_MAX
...@@ -96,24 +107,35 @@ enum _sql_cmd { ...@@ -96,24 +107,35 @@ enum _sql_cmd {
struct SSqlInfo; struct SSqlInfo;
typedef struct SSqlGroupbyExpr { typedef struct SSqlGroupbyExpr {
int16_t numOfGroupbyCols; int16_t tableIndex;
int16_t tagIndex[TSDB_MAX_TAGS]; /* group by columns information */
int16_t orderIdx; /* order by column index */
int16_t orderType; /* order by type: asc/desc */
} SSqlGroupbyExpr;
/* the structure for sql function in select clause */ int16_t numOfGroupCols;
typedef struct SSqlExpr { SColIndexEx columnInfo[TSDB_MAX_TAGS]; // group by columns information
char aliasName[TSDB_COL_NAME_LEN + 1]; // as aliasName
SColIndex colInfo; int16_t orderIndex; // order by column index
int16_t sqlFuncId; // function id in aAgg array int16_t orderType; // order by type: asc/desc
} SSqlGroupbyExpr;
typedef struct SMeterMetaInfo {
SMeterMeta * pMeterMeta; // metermeta
SMetricMeta *pMetricMeta; // metricmeta
int16_t resType; // return value type char name[TSDB_METER_ID_LEN + 1];
int16_t resBytes; // length of return value int16_t numOfTags; // total required tags in query, including groupby tags
int16_t tagColumnIndex[TSDB_MAX_TAGS]; // clause + tag projection
} SMeterMetaInfo;
int16_t numOfParams; // argument value of each function /* the structure for sql function in select clause */
tVariant param[3]; // parameters are not more than 3 typedef struct SSqlExpr {
char aliasName[TSDB_COL_NAME_LEN + 1]; // as aliasName
SColIndexEx colInfo;
int64_t uid; // refactor use the pointer
int16_t functionId; // function id in aAgg array
int16_t resType; // return value type
int16_t resBytes; // length of return value
int16_t interResBytes; // inter result buffer size
int16_t numOfParams; // argument value of each function
tVariant param[3]; // parameters are not more than 3
} SSqlExpr; } SSqlExpr;
typedef struct SFieldInfo { typedef struct SFieldInfo {
...@@ -121,6 +143,15 @@ typedef struct SFieldInfo { ...@@ -121,6 +143,15 @@ typedef struct SFieldInfo {
int16_t numOfAlloc; // allocated size int16_t numOfAlloc; // allocated size
TAOS_FIELD *pFields; TAOS_FIELD *pFields;
short * pOffset; short * pOffset;
/*
* define if this column is belong to the queried result, it may be add by parser to faciliate
* the query process
*
* NOTE: these hidden columns always locate at the end of the output columns
*/
bool * pVisibleCols;
int32_t numOfHiddenCols; // the number of column not belongs to the queried result columns
} SFieldInfo; } SFieldInfo;
typedef struct SSqlExprInfo { typedef struct SSqlExprInfo {
...@@ -129,87 +160,121 @@ typedef struct SSqlExprInfo { ...@@ -129,87 +160,121 @@ typedef struct SSqlExprInfo {
SSqlExpr *pExprs; SSqlExpr *pExprs;
} SSqlExprInfo; } SSqlExprInfo;
typedef struct SColumnBase { typedef struct SColumnIndex {
int16_t colIndex; int16_t tableIndex;
int16_t columnIndex;
} SColumnIndex;
/* todo refactor: the following data is belong to one struct */ typedef struct SColumnBase {
int16_t filterOn; /* denote if the filter is active */ SColumnIndex colIndex;
int16_t lowerRelOptr; int32_t numOfFilters;
int16_t upperRelOptr; SColumnFilterInfo *filterInfo;
int16_t filterOnBinary; /* denote if current column is binary */
union {
struct {
int64_t lowerBndi;
int64_t upperBndi;
};
struct {
double lowerBndd;
double upperBndd;
};
struct {
int64_t pz;
int64_t len;
};
};
} SColumnBase; } SColumnBase;
typedef struct SColumnsInfo { typedef struct SColumnBaseInfo {
int16_t numOfAlloc; int16_t numOfAlloc;
int16_t numOfCols; int16_t numOfCols;
SColumnBase *pColList; SColumnBase *pColList;
} SColumnsInfo; } SColumnBaseInfo;
struct SLocalReducer; struct SLocalReducer;
// todo move to utility
typedef struct SString {
int32_t alloc;
int32_t n;
char * z;
} SString;
typedef struct SCond {
uint64_t uid;
SString cond;
} SCond;
typedef struct SJoinNode {
char meterId[TSDB_METER_ID_LEN];
uint64_t uid;
int16_t tagCol;
} SJoinNode;
typedef struct SJoinInfo {
bool hasJoin;
SJoinNode left;
SJoinNode right;
} SJoinInfo;
typedef struct STagCond { typedef struct STagCond {
int32_t len; // relation between tbname list and query condition, including : TK_AND or TK_OR
int32_t allocSize; int16_t relType;
int16_t type;
char * pData; // tbname query condition, only support tbname query condition on one table
SCond tbnameCond;
// join condition, only support two tables join currently
SJoinInfo joinInfo;
// for different table, the query condition must be seperated
SCond cond[TSDB_MAX_JOIN_TABLE_NUM];
int16_t numOfTagCond;
} STagCond; } STagCond;
typedef struct SParamInfo {
int32_t idx;
char type;
uint8_t timePrec;
short bytes;
uint32_t offset;
} SParamInfo;
typedef struct STableDataBlocks { typedef struct STableDataBlocks {
char meterId[TSDB_METER_ID_LEN]; char meterId[TSDB_METER_ID_LEN];
int8_t tsSource; int8_t tsSource;
bool ordered;
int64_t vgid; int64_t vgid;
int64_t size; int64_t prevTS;
int64_t prevTS; int32_t numOfMeters;
bool ordered;
int32_t numOfMeters; int32_t rowSize;
int32_t rowSize; uint32_t nAllocSize;
uint32_t nAllocSize; uint32_t size;
union { union {
char *filename; char *filename;
char *pData; char *pData;
}; };
// for parameter ('?') binding
uint32_t numOfAllocedParams;
uint32_t numOfParams;
SParamInfo *params;
} STableDataBlocks; } STableDataBlocks;
typedef struct SDataBlockList { typedef struct SDataBlockList {
int32_t idx; int32_t idx;
int32_t nSize; int32_t nSize;
int32_t nAlloc; int32_t nAlloc;
char * userParam; /* user assigned parameters for async query */ char * userParam; /* user assigned parameters for async query */
void * udfp; /* user defined function pointer, used in async model */ void * udfp; /* user defined function pointer, used in async model */
STableDataBlocks **pData; STableDataBlocks **pData;
} SDataBlockList; } SDataBlockList;
typedef struct { typedef struct {
char name[TSDB_METER_ID_LEN]; SOrderVal order;
SOrderVal order; int command;
int command; int count;// TODO refactor
int count;
int16_t isInsertFromFile; // load data from file or not union {
int16_t metricQuery; // metric query or not bool existsCheck; // check if the table exists
bool existsCheck; int8_t showType; // show command type
};
int8_t isInsertFromFile; // load data from file or not
bool import; // import/insert type
char msgType; char msgType;
char type; uint16_t type; // query type
char intervalTimeUnit; char intervalTimeUnit;
int64_t etime; int64_t etime, stime;
int64_t stime;
int64_t nAggTimeInterval; // aggregation time interval int64_t nAggTimeInterval; // aggregation time interval
int64_t nSlidingTime; // sliding window in mseconds int64_t nSlidingTime; // sliding window in mseconds
SSqlGroupbyExpr groupbyExpr; // group by tags info SSqlGroupbyExpr groupbyExpr; // group by tags info
...@@ -220,28 +285,31 @@ typedef struct { ...@@ -220,28 +285,31 @@ typedef struct {
* *
* In such cases, allocate the memory dynamically, and need to free the memory * In such cases, allocate the memory dynamically, and need to free the memory
*/ */
uint32_t allocSize; uint32_t allocSize;
char * payload; char * payload;
int payloadLen; int payloadLen;
short numOfCols; short numOfCols;
SColumnsInfo colList; SColumnBaseInfo colList;
SFieldInfo fieldsInfo; SFieldInfo fieldsInfo;
SSqlExprInfo exprsInfo; SSqlExprInfo exprsInfo;
int16_t numOfReqTags; // total required tags in query, inlcuding groupby clause + tag projection SLimitVal limit;
int16_t tagColumnIndex[TSDB_MAX_TAGS + 1]; SLimitVal slimit;
SLimitVal limit; int64_t globalLimit;
int64_t globalLimit; STagCond tagCond;
SLimitVal glimit; int16_t vnodeIdx; // vnode index in pMetricMeta for metric query
STagCond tagCond; int16_t interpoType; // interpolate type
int16_t vnodeIdx; // vnode index in pMetricMeta for metric query int16_t numOfTables;
int16_t interpoType; // interpolate type
// submit data blocks branched according to vnode
SDataBlockList *pDataBlocks; // submit data blocks branched according to vnode SDataBlockList * pDataBlocks;
SMeterMeta * pMeterMeta; // metermeta SMeterMetaInfo **pMeterInfo;
SMetricMeta * pMetricMeta; // metricmeta struct STSBuf * tsBuf;
// todo use dynamic allocated memory for defaultVal // todo use dynamic allocated memory for defaultVal
int64_t defaultVal[TSDB_MAX_COLUMNS]; // default value for interpolation int64_t defaultVal[TSDB_MAX_COLUMNS]; // default value for interpolation
// for parameter ('?') binding and batch processing
int32_t batchSize;
int32_t numOfParams;
} SSqlCmd; } SSqlCmd;
typedef struct SResRec { typedef struct SResRec {
...@@ -249,39 +317,40 @@ typedef struct SResRec { ...@@ -249,39 +317,40 @@ typedef struct SResRec {
int numOfTotal; int numOfTotal;
} SResRec; } SResRec;
struct STSBuf;
typedef struct { typedef struct {
uint8_t code; uint8_t code;
int numOfRows; // num of results in current retrieved int numOfRows; // num of results in current retrieved
int numOfTotal; // num of total results int numOfTotal; // num of total results
char * pRsp; char * pRsp;
int rspType; int rspType;
int rspLen; int rspLen;
uint64_t qhandle; uint64_t qhandle;
int64_t useconds; int64_t useconds;
int64_t offset; // offset value from vnode during projection query of stable int64_t offset; // offset value from vnode during projection query of stable
int row; int row;
int16_t numOfnchar; int16_t numOfnchar;
int16_t precision; int16_t precision;
int32_t numOfGroups; int32_t numOfGroups;
SResRec *pGroupRec; SResRec * pGroupRec;
char * data; char * data;
short * bytes; short * bytes;
void ** tsrow; void ** tsrow;
char ** buffer; // Buffer used to put multibytes encoded using unicode (wchar_t)
// Buffer used to put multibytes encoded using unicode (wchar_t)
char ** buffer;
struct SLocalReducer *pLocalReducer; struct SLocalReducer *pLocalReducer;
SColumnIndex * pColumnIndex;
} SSqlRes; } SSqlRes;
typedef struct _tsc_obj { typedef struct _tsc_obj {
void * signature; void * signature;
void * pTimer; void * pTimer;
char mgmtIp[TSDB_USER_LEN]; char mgmtIp[TSDB_USER_LEN];
short mgmtPort; uint16_t mgmtPort;
char user[TSDB_USER_LEN]; char user[TSDB_USER_LEN];
char pass[TSDB_KEY_LEN]; char pass[TSDB_KEY_LEN];
char acctId[TSDB_DB_NAME_LEN]; char acctId[TSDB_DB_NAME_LEN];
char db[TSDB_DB_NAME_LEN]; char db[TSDB_METER_ID_LEN];
char sversion[TSDB_VERSION_LEN]; char sversion[TSDB_VERSION_LEN];
char writeAuth : 1; char writeAuth : 1;
char superAuth : 1; char superAuth : 1;
...@@ -328,7 +397,7 @@ typedef struct _sstream { ...@@ -328,7 +397,7 @@ typedef struct _sstream {
int64_t num; // number of computing count int64_t num; // number of computing count
/* /*
* bookmark the current number of result in computing, * keep the number of current result in computing,
* the value will be set to 0 before set timer for next computing * the value will be set to 0 before set timer for next computing
*/ */
int64_t numOfRes; int64_t numOfRes;
...@@ -336,8 +405,7 @@ typedef struct _sstream { ...@@ -336,8 +405,7 @@ typedef struct _sstream {
int64_t useconds; // total elapsed time int64_t useconds; // total elapsed time
int64_t ctime; // stream created time int64_t ctime; // stream created time
int64_t stime; // stream next executed time int64_t stime; // stream next executed time
int64_t etime; // stream end query time, when time is larger then etime, the int64_t etime; // stream end query time, when time is larger then etime, the stream will be closed
// stream will be closed
int64_t interval; int64_t interval;
int64_t slidingTime; int64_t slidingTime;
int16_t precision; int16_t precision;
...@@ -346,8 +414,7 @@ typedef struct _sstream { ...@@ -346,8 +414,7 @@ typedef struct _sstream {
void (*fp)(); void (*fp)();
void *param; void *param;
// Call backfunction when stream is stopped from client level void (*callback)(void *); // Callback function when stream is stopped from client level
void (*callback)(void *);
struct _sstream *prev, *next; struct _sstream *prev, *next;
} SSqlStream; } SSqlStream;
...@@ -362,15 +429,13 @@ int tsParseSql(SSqlObj *pSql, char *acct, char *db, bool multiVnodeInsertion); ...@@ -362,15 +429,13 @@ int tsParseSql(SSqlObj *pSql, char *acct, char *db, bool multiVnodeInsertion);
void tscInitMsgs(); void tscInitMsgs();
void *tscProcessMsgFromServer(char *msg, void *ahandle, void *thandle); void *tscProcessMsgFromServer(char *msg, void *ahandle, void *thandle);
int tscProcessSql(SSqlObj *pSql); int tscProcessSql(SSqlObj *pSql);
int tscGetMeterMeta(SSqlObj *pSql, char *meterId);
int tscGetMeterMetaEx(SSqlObj *pSql, char *meterId, bool createIfNotExists);
void tscAsyncInsertMultiVnodesProxy(void *param, TAOS_RES *tres, int numOfRows); void tscAsyncInsertMultiVnodesProxy(void *param, TAOS_RES *tres, int numOfRows);
int tscRenewMeterMeta(SSqlObj *pSql, char *meterId); int tscRenewMeterMeta(SSqlObj *pSql, char *meterId);
void tscQueueAsyncRes(SSqlObj *pSql); void tscQueueAsyncRes(SSqlObj *pSql);
int tscGetMetricMeta(SSqlObj *pSql, char *meterId);
void tscQueueAsyncError(void(*fp), void *param); void tscQueueAsyncError(void(*fp), void *param);
int tscProcessLocalCmd(SSqlObj *pSql); int tscProcessLocalCmd(SSqlObj *pSql);
...@@ -381,21 +446,15 @@ int taos_retrieve(TAOS_RES *res); ...@@ -381,21 +446,15 @@ int taos_retrieve(TAOS_RES *res);
* transfer function for metric query in stream computing, the function need to be change * transfer function for metric query in stream computing, the function need to be change
* before send query message to vnode * before send query message to vnode
*/ */
void tscTansformSQLFunctionForMetricQuery(SSqlCmd *pCmd); int32_t tscTansformSQLFunctionForMetricQuery(SSqlCmd *pCmd);
void tscRestoreSQLFunctionForMetricQuery(SSqlCmd *pCmd); void tscRestoreSQLFunctionForMetricQuery(SSqlCmd *pCmd);
/**
* release both metric/meter meta information
* @param pCmd SSqlCmd object that contains the metric/meter meta info
*/
void tscClearSqlMetaInfo(SSqlCmd *pCmd);
void tscClearSqlMetaInfoForce(SSqlCmd *pCmd); void tscClearSqlMetaInfoForce(SSqlCmd *pCmd);
int32_t tscCreateResPointerInfo(SSqlCmd *pCmd, SSqlRes *pRes); int32_t tscCreateResPointerInfo(SSqlCmd *pCmd, SSqlRes *pRes);
void tscDestroyResPointerInfo(SSqlRes *pRes); void tscDestroyResPointerInfo(SSqlRes *pRes);
void tscfreeSqlCmdData(SSqlCmd *pCmd); void tscFreeSqlCmdData(SSqlCmd *pCmd);
/** /**
* only free part of resources allocated during query. * only free part of resources allocated during query.
...@@ -413,40 +472,30 @@ void tscFreeSqlObj(SSqlObj *pObj); ...@@ -413,40 +472,30 @@ void tscFreeSqlObj(SSqlObj *pObj);
void tscCloseTscObj(STscObj *pObj); void tscCloseTscObj(STscObj *pObj);
// void tscProcessMultiVnodesInsert(SSqlObj *pSql);
// support functions for async metric query. void tscProcessMultiVnodesInsertForFile(SSqlObj *pSql);
// we declare them as global visible functions, because we need them to check if a void tscKillMetricQuery(SSqlObj *pSql);
// failed async query in tscMeterMetaCallBack is a metric query or not. void tscInitResObjForLocalQuery(SSqlObj *pObj, int32_t numOfRes, int32_t rowLen);
bool tscIsUpdateQuery(STscObj *pObj);
// expr: (fp == tscRetrieveDataRes or fp == tscRetrieveFromVnodeCallBack) int32_t tscInvalidSQLErrMsg(char *msg, const char *additionalInfo, const char *sql);
// If a query is async query, we simply abort current query process, instead of continuing
//
void tscRetrieveDataRes(void *param, TAOS_RES *tres, int numOfRows);
void tscRetrieveFromVnodeCallBack(void *param, TAOS_RES *tres, int numOfRows);
void tscProcessMultiVnodesInsert(SSqlObj *pSql);
void tscProcessMultiVnodesInsertForFile(SSqlObj *pSql);
void tscKillMetricQuery(SSqlObj *pSql);
void tscInitResObjForLocalQuery(SSqlObj *pObj, int32_t numOfRes, int32_t rowLen);
int32_t tscBuildResultsForEmptyRetrieval(SSqlObj *pSql);
// transfer SSqlInfo to SqlCmd struct // transfer SSqlInfo to SqlCmd struct
int32_t tscToSQLCmd(SSqlObj *pSql, struct SSqlInfo *pInfo); int32_t tscToSQLCmd(SSqlObj *pSql, struct SSqlInfo *pInfo);
void tscQueueAsyncFreeResult(SSqlObj *pSql); void tscQueueAsyncFreeResult(SSqlObj *pSql);
extern void * pVnodeConn; extern void * pVnodeConn;
extern void * pTscMgmtConn; extern void * pTscMgmtConn;
extern void * tscCacheHandle; extern void * tscCacheHandle;
extern uint8_t globalCode; extern uint8_t globalCode;
extern int slaveIndex; extern int slaveIndex;
extern void * tscTmr; extern void * tscTmr;
extern void * tscConnCache; extern void * tscConnCache;
extern void * tscQhandle; extern void * tscQhandle;
extern int tscKeepConn[]; extern int tscKeepConn[];
extern int tsInsertHeadSize; extern int tsInsertHeadSize;
extern int tscNumOfThreads; extern int tscNumOfThreads;
extern uint32_t tsServerIp; extern SIpStrList tscMgmtIpList;
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -9,6 +9,22 @@ extern "C" { ...@@ -9,6 +9,22 @@ extern "C" {
#endif #endif
#undef com_taosdata_jdbc_TSDBJNIConnector_INVALID_CONNECTION_POINTER_VALUE #undef com_taosdata_jdbc_TSDBJNIConnector_INVALID_CONNECTION_POINTER_VALUE
#define com_taosdata_jdbc_TSDBJNIConnector_INVALID_CONNECTION_POINTER_VALUE 0LL #define com_taosdata_jdbc_TSDBJNIConnector_INVALID_CONNECTION_POINTER_VALUE 0LL
/*
* Class: com_taosdata_jdbc_TSDBJNIConnector
* Method:
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setAllocModeImp
(JNIEnv *, jclass, jint, jstring, jboolean);
/*
* Class: com_taosdata_jdbc_TSDBJNIConnector
* Method:
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT void JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_dumpMemoryLeakImp
(JNIEnv *, jclass);
/* /*
* Class: com_taosdata_jdbc_TSDBJNIConnector * Class: com_taosdata_jdbc_TSDBJNIConnector
* Method: initImp * Method: initImp
......
...@@ -13,12 +13,11 @@ ...@@ -13,12 +13,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <stdbool.h>
#include "os.h" #include "os.h"
#include "com_taosdata_jdbc_TSDBJNIConnector.h" #include "com_taosdata_jdbc_TSDBJNIConnector.h"
#include "taos.h" #include "taos.h"
#include "tlog.h" #include "tlog.h"
#include "tscJoinProcess.h"
#include "tsclient.h" #include "tsclient.h"
#include "tscUtil.h" #include "tscUtil.h"
...@@ -62,13 +61,13 @@ jmethodID g_rowdataSetByteArrayFp; ...@@ -62,13 +61,13 @@ jmethodID g_rowdataSetByteArrayFp;
void jniGetGlobalMethod(JNIEnv *env) { void jniGetGlobalMethod(JNIEnv *env) {
// make sure init function executed once // make sure init function executed once
switch (__sync_val_compare_and_swap_32(&__init, 0, 1)) { switch (atomic_val_compare_exchange_32(&__init, 0, 1)) {
case 0: case 0:
break; break;
case 1: case 1:
do { do {
taosMsleep(0); taosMsleep(0);
} while (__sync_val_load_32(&__init) == 1); } while (atomic_load_32(&__init) == 1);
case 2: case 2:
return; return;
} }
...@@ -108,10 +107,24 @@ void jniGetGlobalMethod(JNIEnv *env) { ...@@ -108,10 +107,24 @@ void jniGetGlobalMethod(JNIEnv *env) {
g_rowdataSetByteArrayFp = (*env)->GetMethodID(env, g_rowdataClass, "setByteArray", "(I[B)V"); g_rowdataSetByteArrayFp = (*env)->GetMethodID(env, g_rowdataClass, "setByteArray", "(I[B)V");
(*env)->DeleteLocalRef(env, rowdataClass); (*env)->DeleteLocalRef(env, rowdataClass);
__sync_val_restore_32(&__init, 2); atomic_store_32(&__init, 2);
jniTrace("native method register finished"); jniTrace("native method register finished");
} }
JNIEXPORT void JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setAllocModeImp(JNIEnv *env, jobject jobj, jint jMode, jstring jPath, jboolean jAutoDump) {
if (jPath != NULL) {
const char *path = (*env)->GetStringUTFChars(env, jPath, NULL);
taosSetAllocMode(jMode, path, !!jAutoDump);
(*env)->ReleaseStringUTFChars(env, jPath, path);
} else {
taosSetAllocMode(jMode, NULL, !!jAutoDump);
}
}
JNIEXPORT void JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_dumpMemoryLeakImp(JNIEnv *env, jobject jobj) {
taosDumpMemoryLeak();
}
JNIEXPORT void JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_initImp(JNIEnv *env, jobject jobj, jstring jconfigDir) { JNIEXPORT void JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_initImp(JNIEnv *env, jobject jobj, jstring jconfigDir) {
if (jconfigDir != NULL) { if (jconfigDir != NULL) {
const char *confDir = (*env)->GetStringUTFChars(env, jconfigDir, NULL); const char *confDir = (*env)->GetStringUTFChars(env, jconfigDir, NULL);
...@@ -207,10 +220,10 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_connectImp(JNIEn ...@@ -207,10 +220,10 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_connectImp(JNIEn
ret = (jlong)taos_connect((char *)host, (char *)user, (char *)pass, (char *)dbname, jport); ret = (jlong)taos_connect((char *)host, (char *)user, (char *)pass, (char *)dbname, jport);
if (ret == 0) { if (ret == 0) {
jniError("jobj:%p, taos:%p, connect to tdengine failed, host=%s, user=%s, dbname=%s, port=%d", jobj, (void *)ret, jniError("jobj:%p, conn:%p, connect to database failed, host=%s, user=%s, dbname=%s, port=%d", jobj, (void *)ret,
(char *)host, (char *)user, (char *)dbname, jport); (char *)host, (char *)user, (char *)dbname, jport);
} else { } else {
jniTrace("jobj:%p, taos:%p, connect to tdengine succeed, host=%s, user=%s, dbname=%s, port=%d", jobj, (void *)ret, jniTrace("jobj:%p, conn:%p, connect to database succeed, host=%s, user=%s, dbname=%s, port=%d", jobj, (void *)ret,
(char *)host, (char *)user, (char *)dbname, jport); (char *)host, (char *)user, (char *)dbname, jport);
} }
...@@ -231,7 +244,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_executeQueryImp(J ...@@ -231,7 +244,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_executeQueryImp(J
} }
if (jsql == NULL) { if (jsql == NULL) {
jniError("jobj:%p, taos:%p, sql is null", jobj, tscon); jniError("jobj:%p, conn:%p, sql is null", jobj, tscon);
return JNI_SQL_NULL; return JNI_SQL_NULL;
} }
...@@ -249,7 +262,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_executeQueryImp(J ...@@ -249,7 +262,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_executeQueryImp(J
int code = taos_query(tscon, dst); int code = taos_query(tscon, dst);
if (code != 0) { if (code != 0) {
jniError("jobj:%p, taos:%p, code:%d, msg:%s, sql:%s", jobj, tscon, code, taos_errstr(tscon), dst); jniError("jobj:%p, conn:%p, code:%d, msg:%s, sql:%s", jobj, tscon, code, taos_errstr(tscon), dst);
free(dst); free(dst);
return JNI_TDENGINE_ERROR; return JNI_TDENGINE_ERROR;
} else { } else {
...@@ -258,9 +271,9 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_executeQueryImp(J ...@@ -258,9 +271,9 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_executeQueryImp(J
if (pSql->cmd.command == TSDB_SQL_INSERT) { if (pSql->cmd.command == TSDB_SQL_INSERT) {
affectRows = taos_affected_rows(tscon); affectRows = taos_affected_rows(tscon);
jniTrace("jobj:%p, taos:%p, code:%d, affect rows:%d, sql:%s", jobj, tscon, code, affectRows, dst); jniTrace("jobj:%p, conn:%p, code:%d, affect rows:%d, sql:%s", jobj, tscon, code, affectRows, dst);
} else { } else {
jniTrace("jobj:%p, taos:%p, code:%d, sql:%s", jobj, tscon, code, dst); jniTrace("jobj:%p, conn:%p, code:%d, sql:%s", jobj, tscon, code, dst);
} }
free(dst); free(dst);
...@@ -290,15 +303,17 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_getResultSetImp( ...@@ -290,15 +303,17 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_getResultSetImp(
return JNI_CONNECTION_NULL; return JNI_CONNECTION_NULL;
} }
int num_fields = taos_field_count(tscon); jlong ret = 0;
if (num_fields != 0) {
jlong ret = (jlong)taos_use_result(tscon); if (tscIsUpdateQuery(tscon)) {
jniTrace("jobj:%p, taos:%p, get resultset:%p", jobj, tscon, (void *)ret); ret = 0; // for update query, no result pointer
return ret; jniTrace("jobj:%p, conn:%p, no result", jobj, tscon);
} else {
ret = (jlong) taos_use_result(tscon);
jniTrace("jobj:%p, conn:%p, get resultset:%p", jobj, tscon, (void *) ret);
} }
jniTrace("jobj:%p, taos:%p, no resultset", jobj, tscon); return ret;
return 0;
} }
JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_freeResultSetImp(JNIEnv *env, jobject jobj, jlong con, JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_freeResultSetImp(JNIEnv *env, jobject jobj, jlong con,
...@@ -310,12 +325,12 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_freeResultSetImp( ...@@ -310,12 +325,12 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_freeResultSetImp(
} }
if ((void *)res == NULL) { if ((void *)res == NULL) {
jniError("jobj:%p, taos:%p, resultset is null", jobj, tscon); jniError("jobj:%p, conn:%p, resultset is null", jobj, tscon);
return JNI_RESULT_SET_NULL; return JNI_RESULT_SET_NULL;
} }
taos_free_result((void *)res); taos_free_result((void *)res);
jniTrace("jobj:%p, taos:%p, free resultset:%p", jobj, tscon, (void *)res); jniTrace("jobj:%p, conn:%p, free resultset:%p", jobj, tscon, (void *)res);
return JNI_SUCCESS; return JNI_SUCCESS;
} }
...@@ -329,7 +344,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_getAffectedRowsIm ...@@ -329,7 +344,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_getAffectedRowsIm
jint ret = taos_affected_rows(tscon); jint ret = taos_affected_rows(tscon);
jniTrace("jobj:%p, taos:%p, affect rows:%d", jobj, tscon, (void *)con, ret); jniTrace("jobj:%p, conn:%p, affect rows:%d", jobj, tscon, (void *)con, ret);
return ret; return ret;
} }
...@@ -345,7 +360,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_getSchemaMetaData ...@@ -345,7 +360,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_getSchemaMetaData
TAOS_RES *result = (TAOS_RES *)res; TAOS_RES *result = (TAOS_RES *)res;
if (result == NULL) { if (result == NULL) {
jniError("jobj:%p, taos:%p, resultset is null", jobj, tscon); jniError("jobj:%p, conn:%p, resultset is null", jobj, tscon);
return JNI_RESULT_SET_NULL; return JNI_RESULT_SET_NULL;
} }
...@@ -355,10 +370,10 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_getSchemaMetaData ...@@ -355,10 +370,10 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_getSchemaMetaData
// jobject arrayListObj = (*env)->NewObject(env, g_arrayListClass, g_arrayListConstructFp, ""); // jobject arrayListObj = (*env)->NewObject(env, g_arrayListClass, g_arrayListConstructFp, "");
if (num_fields == 0) { if (num_fields == 0) {
jniError("jobj:%p, taos:%p, resultset:%p, fields size is %d", jobj, tscon, res, num_fields); jniError("jobj:%p, conn:%p, resultset:%p, fields size is %d", jobj, tscon, res, num_fields);
return JNI_NUM_OF_FIELDS_0; return JNI_NUM_OF_FIELDS_0;
} else { } else {
jniTrace("jobj:%p, taos:%p, resultset:%p, fields size is %d", jobj, tscon, res, num_fields); jniTrace("jobj:%p, conn:%p, resultset:%p, fields size is %d", jobj, tscon, res, num_fields);
for (int i = 0; i < num_fields; ++i) { for (int i = 0; i < num_fields; ++i) {
jobject metadataObj = (*env)->NewObject(env, g_metadataClass, g_metadataConstructFp); jobject metadataObj = (*env)->NewObject(env, g_metadataClass, g_metadataConstructFp);
(*env)->SetIntField(env, metadataObj, g_metadataColtypeField, fields[i].type); (*env)->SetIntField(env, metadataObj, g_metadataColtypeField, fields[i].type);
...@@ -401,7 +416,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_fetchRowImp(JNIEn ...@@ -401,7 +416,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_fetchRowImp(JNIEn
TAOS_RES *result = (TAOS_RES *)res; TAOS_RES *result = (TAOS_RES *)res;
if (result == NULL) { if (result == NULL) {
jniError("jobj:%p, taos:%p, resultset is null", jobj, tscon); jniError("jobj:%p, conn:%p, resultset is null", jobj, tscon);
return JNI_RESULT_SET_NULL; return JNI_RESULT_SET_NULL;
} }
...@@ -409,7 +424,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_fetchRowImp(JNIEn ...@@ -409,7 +424,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_fetchRowImp(JNIEn
int num_fields = taos_num_fields(result); int num_fields = taos_num_fields(result);
if (num_fields == 0) { if (num_fields == 0) {
jniError("jobj:%p, taos:%p, resultset:%p, fields size is %d", jobj, tscon, res, num_fields); jniError("jobj:%p, conn:%p, resultset:%p, fields size is %d", jobj, tscon, res, num_fields);
return JNI_NUM_OF_FIELDS_0; return JNI_NUM_OF_FIELDS_0;
} }
...@@ -417,10 +432,10 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_fetchRowImp(JNIEn ...@@ -417,10 +432,10 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_fetchRowImp(JNIEn
if (row == NULL) { if (row == NULL) {
int tserrno = taos_errno(tscon); int tserrno = taos_errno(tscon);
if (tserrno == 0) { if (tserrno == 0) {
jniTrace("jobj:%p, taos:%p, resultset:%p, fields size is %d, fetch row to the end", jobj, tscon, res, num_fields); jniTrace("jobj:%p, conn:%p, resultset:%p, fields size is %d, fetch row to the end", jobj, tscon, res, num_fields);
return JNI_FETCH_END; return JNI_FETCH_END;
} else { } else {
jniTrace("jobj:%p, taos:%p, interruptted query", jobj, tscon); jniTrace("jobj:%p, conn:%p, interruptted query", jobj, tscon);
return JNI_RESULT_SET_NULL; return JNI_RESULT_SET_NULL;
} }
} }
...@@ -484,7 +499,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_closeConnectionIm ...@@ -484,7 +499,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_closeConnectionIm
jniError("jobj:%p, connection is closed", jobj); jniError("jobj:%p, connection is closed", jobj);
return JNI_CONNECTION_NULL; return JNI_CONNECTION_NULL;
} else { } else {
jniTrace("jobj:%p, taos:%p, close connection success", jobj, tscon); jniTrace("jobj:%p, conn:%p, close connection success", jobj, tscon);
taos_close(tscon); taos_close(tscon);
return JNI_SUCCESS; return JNI_SUCCESS;
} }
...@@ -639,7 +654,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_validateCreateTab ...@@ -639,7 +654,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_validateCreateTab
} }
if (jsql == NULL) { if (jsql == NULL) {
jniError("jobj:%p, taos:%p, sql is null", jobj, tscon); jniError("jobj:%p, conn:%p, sql is null", jobj, tscon);
return JNI_SQL_NULL; return JNI_SQL_NULL;
} }
...@@ -660,4 +675,4 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_validateCreateTab ...@@ -660,4 +675,4 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_validateCreateTab
JNIEXPORT jstring JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_getTsCharset(JNIEnv *env, jobject jobj) { JNIEXPORT jstring JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_getTsCharset(JNIEnv *env, jobject jobj) {
return (*env)->NewStringUTF(env, (const char *)tsCharset); return (*env)->NewStringUTF(env, (const char *)tsCharset);
} }
\ No newline at end of file
此差异已折叠。
此差异已折叠。
...@@ -13,14 +13,7 @@ ...@@ -13,14 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <assert.h> #include "os.h"
#include <pthread.h>
#include <semaphore.h>
#include <signal.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "tglobalcfg.h" #include "tglobalcfg.h"
#include "tlog.h" #include "tlog.h"
...@@ -32,7 +25,7 @@ ...@@ -32,7 +25,7 @@
typedef struct _c_hash_t { typedef struct _c_hash_t {
uint32_t ip; uint32_t ip;
short port; uint16_t port;
struct _c_hash_t *prev; struct _c_hash_t *prev;
struct _c_hash_t *next; struct _c_hash_t *next;
void * data; void * data;
...@@ -52,14 +45,14 @@ typedef struct { ...@@ -52,14 +45,14 @@ typedef struct {
void *pTimer; void *pTimer;
} SConnCache; } SConnCache;
int taosHashConn(void *handle, uint32_t ip, short port, char *user) { int taosHashConn(void *handle, uint32_t ip, uint16_t port, char *user) {
SConnCache *pObj = (SConnCache *)handle; SConnCache *pObj = (SConnCache *)handle;
int hash = 0; int hash = 0;
// size_t user_len = strlen(user); // size_t user_len = strlen(user);
hash = ip >> 16; hash = ip >> 16;
hash += (unsigned short)(ip & 0xFFFF); hash += (unsigned short)(ip & 0xFFFF);
hash += (unsigned short)port; hash += port;
while (*user != '\0') { while (*user != '\0') {
hash += *user; hash += *user;
user++; user++;
...@@ -81,7 +74,7 @@ void taosRemoveExpiredNodes(SConnCache *pObj, SConnHash *pNode, int hash, uint64 ...@@ -81,7 +74,7 @@ void taosRemoveExpiredNodes(SConnCache *pObj, SConnHash *pNode, int hash, uint64
pNext = pNode->next; pNext = pNode->next;
pObj->total--; pObj->total--;
pObj->count[hash]--; pObj->count[hash]--;
tscTrace("%p ip:0x%x:%d:%d:%p removed, connections in cache:%d", pNode->data, pNode->ip, pNode->port, hash, pNode, tscTrace("%p ip:0x%x:%hu:%d:%p removed, connections in cache:%d", pNode->data, pNode->ip, pNode->port, hash, pNode,
pObj->count[hash]); pObj->count[hash]);
taosMemPoolFree(pObj->connHashMemPool, (char *)pNode); taosMemPoolFree(pObj->connHashMemPool, (char *)pNode);
pNode = pNext; pNode = pNext;
...@@ -93,7 +86,7 @@ void taosRemoveExpiredNodes(SConnCache *pObj, SConnHash *pNode, int hash, uint64 ...@@ -93,7 +86,7 @@ void taosRemoveExpiredNodes(SConnCache *pObj, SConnHash *pNode, int hash, uint64
pObj->connHashList[hash] = NULL; pObj->connHashList[hash] = NULL;
} }
void *taosAddConnIntoCache(void *handle, void *data, uint32_t ip, short port, char *user) { void *taosAddConnIntoCache(void *handle, void *data, uint32_t ip, uint16_t port, char *user) {
int hash; int hash;
SConnHash * pNode; SConnHash * pNode;
SConnCache *pObj; SConnCache *pObj;
...@@ -102,7 +95,12 @@ void *taosAddConnIntoCache(void *handle, void *data, uint32_t ip, short port, ch ...@@ -102,7 +95,12 @@ void *taosAddConnIntoCache(void *handle, void *data, uint32_t ip, short port, ch
pObj = (SConnCache *)handle; pObj = (SConnCache *)handle;
if (pObj == NULL || pObj->maxSessions == 0) return NULL; if (pObj == NULL || pObj->maxSessions == 0) return NULL;
#ifdef CLUSTER
if (data == NULL || ip == 0) {
#else
if (data == NULL) { if (data == NULL) {
#endif
tscTrace("data:%p ip:%p:%d not valid, not added in cache", data, ip, port); tscTrace("data:%p ip:%p:%d not valid, not added in cache", data, ip, port);
return NULL; return NULL;
} }
...@@ -127,7 +125,7 @@ void *taosAddConnIntoCache(void *handle, void *data, uint32_t ip, short port, ch ...@@ -127,7 +125,7 @@ void *taosAddConnIntoCache(void *handle, void *data, uint32_t ip, short port, ch
pthread_mutex_unlock(&pObj->mutex); pthread_mutex_unlock(&pObj->mutex);
tscTrace("%p ip:0x%x:%d:%d:%p added, connections in cache:%d", data, ip, port, hash, pNode, pObj->count[hash]); tscTrace("%p ip:0x%x:%hu:%d:%p added, connections in cache:%d", data, ip, port, hash, pNode, pObj->count[hash]);
return pObj; return pObj;
} }
...@@ -154,7 +152,7 @@ void taosCleanConnCache(void *handle, void *tmrId) { ...@@ -154,7 +152,7 @@ void taosCleanConnCache(void *handle, void *tmrId) {
taosTmrReset(taosCleanConnCache, pObj->keepTimer * 2, pObj, pObj->tmrCtrl, &pObj->pTimer); taosTmrReset(taosCleanConnCache, pObj->keepTimer * 2, pObj, pObj->tmrCtrl, &pObj->pTimer);
} }
void *taosGetConnFromCache(void *handle, uint32_t ip, short port, char *user) { void *taosGetConnFromCache(void *handle, uint32_t ip, uint16_t port, char *user) {
int hash; int hash;
SConnHash * pNode; SConnHash * pNode;
SConnCache *pObj; SConnCache *pObj;
...@@ -203,7 +201,7 @@ void *taosGetConnFromCache(void *handle, uint32_t ip, short port, char *user) { ...@@ -203,7 +201,7 @@ void *taosGetConnFromCache(void *handle, uint32_t ip, short port, char *user) {
pthread_mutex_unlock(&pObj->mutex); pthread_mutex_unlock(&pObj->mutex);
if (pData) { if (pData) {
tscTrace("%p ip:0x%x:%d:%d:%p retrieved, connections in cache:%d", pData, ip, port, hash, pNode, pObj->count[hash]); tscTrace("%p ip:0x%x:%hu:%d:%p retrieved, connections in cache:%d", pData, ip, port, hash, pNode, pObj->count[hash]);
} }
return pData; return pData;
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <signal.h> #include "os.h"
#include "shash.h" #include "shash.h"
#include "taos.h" #include "taos.h"
...@@ -36,7 +36,7 @@ typedef struct { ...@@ -36,7 +36,7 @@ typedef struct {
TAOS_RES * result; TAOS_RES * result;
} SSub; } SSub;
TAOS_SUB *taos_subscribe(char *host, char *user, char *pass, char *db, char *name, int64_t time, int mseconds) { TAOS_SUB *taos_subscribe(const char *host, const char *user, const char *pass, const char *db, const char *name, int64_t time, int mseconds) {
SSub *pSub; SSub *pSub;
pSub = (SSub *)malloc(sizeof(SSub)); pSub = (SSub *)malloc(sizeof(SSub));
......
此差异已折叠。
此差异已折叠。
...@@ -118,14 +118,15 @@ func (rows *taosSqlRows) ColumnTypeScanType(i int) reflect.Type { ...@@ -118,14 +118,15 @@ func (rows *taosSqlRows) ColumnTypeScanType(i int) reflect.Type {
return rows.rs.columns[i].scanType() return rows.rs.columns[i].scanType()
} }
func (rows *taosSqlRows) Close() (err error) { func (rows *taosSqlRows) Close() error {
mc := rows.mc if rows.mc != nil {
if mc == nil { result := C.taos_use_result(rows.mc.taos)
return nil if result != nil {
C.taos_free_result(result)
}
rows.mc = nil
} }
return nil
rows.mc = nil
return err
} }
func (rows *taosSqlRows) HasNextResultSet() (b bool) { func (rows *taosSqlRows) HasNextResultSet() (b bool) {
......
...@@ -273,6 +273,9 @@ public class TSDBDriver implements java.sql.Driver { ...@@ -273,6 +273,9 @@ public class TSDBDriver implements java.sql.Driver {
String user = ""; String user = "";
for (String queryStr : queryStrings) { for (String queryStr : queryStrings) {
String[] kvPair = queryStr.trim().split("="); String[] kvPair = queryStr.trim().split("=");
if (kvPair.length < 2){
continue;
}
switch (kvPair[0].toLowerCase()) { switch (kvPair[0].toLowerCase()) {
case PROPERTY_KEY_USER: case PROPERTY_KEY_USER:
urlProps.setProperty(PROPERTY_KEY_USER, kvPair[1]); urlProps.setProperty(PROPERTY_KEY_USER, kvPair[1]);
......
...@@ -69,7 +69,7 @@ public enum TSDBError { ...@@ -69,7 +69,7 @@ public enum TSDBError {
TSDB_CODE_INVALID_OPTION(45, "invalid option"), TSDB_CODE_INVALID_OPTION(45, "invalid option"),
TSDB_CODE_NODE_OFFLINE(46, "node offline"), TSDB_CODE_NODE_OFFLINE(46, "node offline"),
TSDB_CODE_SYNC_REQUIRED(47, "sync required"), TSDB_CODE_SYNC_REQUIRED(47, "sync required"),
TSDB_CODE_NO_ENOUGH_PNODES(48, "more dnodes are needed"), TSDB_CODE_NO_ENOUGH_DNODES(48, "more dnodes are needed"),
TSDB_CODE_UNSYNCED(49, "node in unsynced state"), TSDB_CODE_UNSYNCED(49, "node in unsynced state"),
TSDB_CODE_TOO_SLOW(50, "too slow"), TSDB_CODE_TOO_SLOW(50, "too slow"),
TSDB_CODE_OTHERS(51, "others"), TSDB_CODE_OTHERS(51, "others"),
......
文件模式从 100755 更改为 100644
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
文件模式从 100755 更改为 100644
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册