Merge branch 'develop' into hotfix/master2develop

This commit is contained in:
Shengliang Guan 2020-08-06 22:13:55 +08:00 committed by GitHub
commit df83409f93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
99 changed files with 1323 additions and 803 deletions

11
.gitignore vendored
View File

@ -66,3 +66,14 @@ CMakeError.log
/test/cfg /test/cfg
/src/.vs /src/.vs
*.o *.o
src/connector/jdbc/.settings/
tests/comparisonTest/cassandra/cassandratest/.classpath
tests/comparisonTest/cassandra/cassandratest/.project
tests/comparisonTest/cassandra/cassandratest/.settings/
tests/comparisonTest/opentsdb/opentsdbtest/.classpath
tests/comparisonTest/opentsdb/opentsdbtest/.factorypath
tests/comparisonTest/opentsdb/opentsdbtest/.project
tests/comparisonTest/opentsdb/opentsdbtest/.settings/
tests/examples/JDBC/JDBCDemo/.classpath
tests/examples/JDBC/JDBCDemo/.project
tests/examples/JDBC/JDBCDemo/.settings/

6
deps/CMakeLists.txt vendored
View File

@ -7,4 +7,8 @@ ADD_SUBDIRECTORY(regex)
ADD_SUBDIRECTORY(iconv) ADD_SUBDIRECTORY(iconv)
ADD_SUBDIRECTORY(lz4) ADD_SUBDIRECTORY(lz4)
ADD_SUBDIRECTORY(cJson) ADD_SUBDIRECTORY(cJson)
ADD_SUBDIRECTORY(MQTT-C) #ADD_SUBDIRECTORY(MsvcLibX)
IF (NOT TD_WINDOWS)
ADD_SUBDIRECTORY(MQTT-C)
ENDIF ()

View File

@ -10,11 +10,11 @@ option(MQTT_C_TESTS "Build MQTT-C tests?" OFF)
list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
# MQTT-C library # MQTT-C library
add_library(mqttc STATIC ADD_LIBRARY(mqttc STATIC
src/mqtt_pal.c src/mqtt_pal.c
src/mqtt.c src/mqtt.c
) )
target_include_directories(mqttc PUBLIC include) TARGET_INCLUDE_DIRECTORIES(mqttc PUBLIC include)
target_link_libraries(mqttc PUBLIC target_link_libraries(mqttc PUBLIC
$<$<C_COMPILER_ID:MSVS>:ws2_32> $<$<C_COMPILER_ID:MSVS>:ws2_32>
) )
@ -30,7 +30,7 @@ endif()
# Configure with mbed TLS support # Configure with mbed TLS support
if(MQTT_C_MbedTLS_SUPPORT) if(MQTT_C_MbedTLS_SUPPORT)
find_package(MbedTLS REQUIRED) find_package(MbedTLS REQUIRED)
target_include_directories(mqttc PUBLIC ${MBEDTLS_INCLUDE_DIRS}) TARGET_INCLUDE_DIRECTORIES(mqttc PUBLIC ${MBEDTLS_INCLUDE_DIRS})
target_link_libraries(mqttc INTERFACE ${MBEDTLS_LIBRARY}) target_link_libraries(mqttc INTERFACE ${MBEDTLS_LIBRARY})
target_compile_definitions(mqttc PUBLIC MQTT_USE_MBEDTLS) target_compile_definitions(mqttc PUBLIC MQTT_USE_MBEDTLS)
endif() endif()
@ -70,7 +70,7 @@ if(MQTT_C_TESTS)
add_executable(tests tests.c) add_executable(tests tests.c)
target_link_libraries(tests ${CMOCKA_LIBRARY} mqttc) target_link_libraries(tests ${CMOCKA_LIBRARY} mqttc)
target_include_directories(tests PRIVATE ${CMOCKA_INCLUDE_DIR}) TARGET_INCLUDE_DIRECTORIES(tests PRIVATE ${CMOCKA_INCLUDE_DIR})
endif() endif()
# Install includes and library # Install includes and library

View File

@ -1,4 +1,4 @@
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/src SOURCE_LIST) AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src SOURCE_LIST)
add_library(cJson ${SOURCE_LIST}) ADD_LIBRARY(cJson ${SOURCE_LIST})
target_include_directories(cJson PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/inc) TARGET_INCLUDE_DIRECTORIES(cJson PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/inc)

View File

@ -1,9 +1,11 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8) CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(TDengine) PROJECT(TDengine)
IF (TD_WINDOWS_64) IF (TD_WINDOWS)
LIST(APPEND SRC iconv.c) LIST(APPEND SRC iconv.c)
LIST(APPEND SRC localcharset.c) LIST(APPEND SRC localcharset.c)
INCLUDE_DIRECTORIES(.) INCLUDE_DIRECTORIES(.)
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /WX-")
SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /WX-")
ADD_LIBRARY(iconv ${SRC}) ADD_LIBRARY(iconv ${SRC})
ENDIF () ENDIF ()

2
deps/iconv/iconv.h vendored
View File

@ -1,4 +1,4 @@
/* Copyright (C) 1999-2003, 2005-2006, 2008-2009 Free Software Foundation, Inc. /* Copyright (C) 1999-2003, 2005-2006, 2008-2009 Free Software Foundation, Inc.
This file is part of the GNU LIBICONV Library. This file is part of the GNU LIBICONV Library.
The GNU LIBICONV Library is free software; you can redistribute it The GNU LIBICONV Library is free software; you can redistribute it

View File

@ -1,4 +1,9 @@
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/src SOURCE_LIST) AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src SOURCE_LIST)
add_library(lz4 ${SOURCE_LIST}) IF (TD_WINDOWS)
target_include_directories(lz4 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/inc) SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /WX-")
SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /WX-")
ENDIF()
ADD_LIBRARY(lz4 ${SOURCE_LIST})
TARGET_INCLUDE_DIRECTORIES(lz4 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/inc)

View File

@ -1,7 +1,7 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8) CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(TDengine) PROJECT(TDengine)
IF (TD_WINDOWS_64) IF (TD_WINDOWS)
INCLUDE_DIRECTORIES(.) INCLUDE_DIRECTORIES(.)
LIST(APPEND SRC pthread.c) LIST(APPEND SRC pthread.c)
ADD_LIBRARY(pthread ${SRC}) ADD_LIBRARY(pthread ${SRC})

View File

@ -1,4 +1,4 @@
/* /*
* pthread_mutex_consistent.c * pthread_mutex_consistent.c
* *
* Description: * Description:

View File

@ -1,7 +1,7 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8) CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(TDengine) PROJECT(TDengine)
IF (TD_WINDOWS_64) IF (TD_WINDOWS)
INCLUDE_DIRECTORIES(inc .) INCLUDE_DIRECTORIES(inc .)
LIST(APPEND SRC regex.c) LIST(APPEND SRC regex.c)
ADD_LIBRARY(regex ${SRC}) ADD_LIBRARY(regex ${SRC})

View File

@ -1,7 +1,7 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8) CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(TDengine) PROJECT(TDengine)
IF (TD_LINUX_64) IF (TD_LINUX_64 OR TD_WINDOWS_64)
INCLUDE_DIRECTORIES(inc) INCLUDE_DIRECTORIES(inc)
AUX_SOURCE_DIRECTORY(src SRC) AUX_SOURCE_DIRECTORY(src SRC)
ADD_LIBRARY(z ${SRC}) ADD_LIBRARY(z ${SRC})

View File

@ -14,177 +14,177 @@
* Even better than compiling with -DZ_PREFIX would be to use configure to set * Even better than compiling with -DZ_PREFIX would be to use configure to set
* this permanently in zconf.h using "./configure --zprefix". * this permanently in zconf.h using "./configure --zprefix".
*/ */
#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ #ifdef Z_PREFIX /* may be set to #if 1 by ./configure */
# define Z_PREFIX_SET #define Z_PREFIX_SET
/* all linked symbols and init macros */ /* all linked symbols and init macros */
# define _dist_code z__dist_code #define _dist_code z__dist_code
# define _length_code z__length_code #define _length_code z__length_code
# define _tr_align z__tr_align #define _tr_align z__tr_align
# define _tr_flush_bits z__tr_flush_bits #define _tr_flush_bits z__tr_flush_bits
# define _tr_flush_block z__tr_flush_block #define _tr_flush_block z__tr_flush_block
# define _tr_init z__tr_init #define _tr_init z__tr_init
# define _tr_stored_block z__tr_stored_block #define _tr_stored_block z__tr_stored_block
# define _tr_tally z__tr_tally #define _tr_tally z__tr_tally
# define adler32 z_adler32 #define adler32 z_adler32
# define adler32_combine z_adler32_combine #define adler32_combine z_adler32_combine
# define adler32_combine64 z_adler32_combine64 #define adler32_combine64 z_adler32_combine64
# define adler32_z z_adler32_z #define adler32_z z_adler32_z
# ifndef Z_SOLO #ifndef Z_SOLO
# define compress z_compress #define compress z_compress
# define compress2 z_compress2 #define compress2 z_compress2
# define compressBound z_compressBound #define compressBound z_compressBound
# endif #endif
# define crc32 z_crc32 #define crc32 z_crc32
# define crc32_combine z_crc32_combine #define crc32_combine z_crc32_combine
# define crc32_combine64 z_crc32_combine64 #define crc32_combine64 z_crc32_combine64
# define crc32_z z_crc32_z #define crc32_z z_crc32_z
# define deflate z_deflate #define deflate z_deflate
# define deflateBound z_deflateBound #define deflateBound z_deflateBound
# define deflateCopy z_deflateCopy #define deflateCopy z_deflateCopy
# define deflateEnd z_deflateEnd #define deflateEnd z_deflateEnd
# define deflateGetDictionary z_deflateGetDictionary #define deflateGetDictionary z_deflateGetDictionary
# define deflateInit z_deflateInit #define deflateInit z_deflateInit
# define deflateInit2 z_deflateInit2 #define deflateInit2 z_deflateInit2
# define deflateInit2_ z_deflateInit2_ #define deflateInit2_ z_deflateInit2_
# define deflateInit_ z_deflateInit_ #define deflateInit_ z_deflateInit_
# define deflateParams z_deflateParams #define deflateParams z_deflateParams
# define deflatePending z_deflatePending #define deflatePending z_deflatePending
# define deflatePrime z_deflatePrime #define deflatePrime z_deflatePrime
# define deflateReset z_deflateReset #define deflateReset z_deflateReset
# define deflateResetKeep z_deflateResetKeep #define deflateResetKeep z_deflateResetKeep
# define deflateSetDictionary z_deflateSetDictionary #define deflateSetDictionary z_deflateSetDictionary
# define deflateSetHeader z_deflateSetHeader #define deflateSetHeader z_deflateSetHeader
# define deflateTune z_deflateTune #define deflateTune z_deflateTune
# define deflate_copyright z_deflate_copyright #define deflate_copyright z_deflate_copyright
# define get_crc_table z_get_crc_table #define get_crc_table z_get_crc_table
# ifndef Z_SOLO #ifndef Z_SOLO
# define gz_error z_gz_error #define gz_error z_gz_error
# define gz_intmax z_gz_intmax #define gz_intmax z_gz_intmax
# define gz_strwinerror z_gz_strwinerror #define gz_strwinerror z_gz_strwinerror
# define gzbuffer z_gzbuffer #define gzbuffer z_gzbuffer
# define gzclearerr z_gzclearerr #define gzclearerr z_gzclearerr
# define gzclose z_gzclose #define gzclose z_gzclose
# define gzclose_r z_gzclose_r #define gzclose_r z_gzclose_r
# define gzclose_w z_gzclose_w #define gzclose_w z_gzclose_w
# define gzdirect z_gzdirect #define gzdirect z_gzdirect
# define gzdopen z_gzdopen #define gzdopen z_gzdopen
# define gzeof z_gzeof #define gzeof z_gzeof
# define gzerror z_gzerror #define gzerror z_gzerror
# define gzflush z_gzflush #define gzflush z_gzflush
# define gzfread z_gzfread #define gzfread z_gzfread
# define gzfwrite z_gzfwrite #define gzfwrite z_gzfwrite
# define gzgetc z_gzgetc #define gzgetc z_gzgetc
# define gzgetc_ z_gzgetc_ #define gzgetc_ z_gzgetc_
# define gzgets z_gzgets #define gzgets z_gzgets
# define gzoffset z_gzoffset #define gzoffset z_gzoffset
# define gzoffset64 z_gzoffset64 #define gzoffset64 z_gzoffset64
# define gzopen z_gzopen #define gzopen z_gzopen
# define gzopen64 z_gzopen64 #define gzopen64 z_gzopen64
# ifdef _WIN32 #ifdef _WIN32
# define gzopen_w z_gzopen_w #define gzopen_w z_gzopen_w
# endif #endif
# define gzprintf z_gzprintf #define gzprintf z_gzprintf
# define gzputc z_gzputc #define gzputc z_gzputc
# define gzputs z_gzputs #define gzputs z_gzputs
# define gzread z_gzread #define gzread z_gzread
# define gzrewind z_gzrewind #define gzrewind z_gzrewind
# define gzseek z_gzseek #define gzseek z_gzseek
# define gzseek64 z_gzseek64 #define gzseek64 z_gzseek64
# define gzsetparams z_gzsetparams #define gzsetparams z_gzsetparams
# define gztell z_gztell #define gztell z_gztell
# define gztell64 z_gztell64 #define gztell64 z_gztell64
# define gzungetc z_gzungetc #define gzungetc z_gzungetc
# define gzvprintf z_gzvprintf #define gzvprintf z_gzvprintf
# define gzwrite z_gzwrite #define gzwrite z_gzwrite
# endif #endif
# define inflate z_inflate #define inflate z_inflate
# define inflateBack z_inflateBack #define inflateBack z_inflateBack
# define inflateBackEnd z_inflateBackEnd #define inflateBackEnd z_inflateBackEnd
# define inflateBackInit z_inflateBackInit #define inflateBackInit z_inflateBackInit
# define inflateBackInit_ z_inflateBackInit_ #define inflateBackInit_ z_inflateBackInit_
# define inflateCodesUsed z_inflateCodesUsed #define inflateCodesUsed z_inflateCodesUsed
# define inflateCopy z_inflateCopy #define inflateCopy z_inflateCopy
# define inflateEnd z_inflateEnd #define inflateEnd z_inflateEnd
# define inflateGetDictionary z_inflateGetDictionary #define inflateGetDictionary z_inflateGetDictionary
# define inflateGetHeader z_inflateGetHeader #define inflateGetHeader z_inflateGetHeader
# define inflateInit z_inflateInit #define inflateInit z_inflateInit
# define inflateInit2 z_inflateInit2 #define inflateInit2 z_inflateInit2
# define inflateInit2_ z_inflateInit2_ #define inflateInit2_ z_inflateInit2_
# define inflateInit_ z_inflateInit_ #define inflateInit_ z_inflateInit_
# define inflateMark z_inflateMark #define inflateMark z_inflateMark
# define inflatePrime z_inflatePrime #define inflatePrime z_inflatePrime
# define inflateReset z_inflateReset #define inflateReset z_inflateReset
# define inflateReset2 z_inflateReset2 #define inflateReset2 z_inflateReset2
# define inflateResetKeep z_inflateResetKeep #define inflateResetKeep z_inflateResetKeep
# define inflateSetDictionary z_inflateSetDictionary #define inflateSetDictionary z_inflateSetDictionary
# define inflateSync z_inflateSync #define inflateSync z_inflateSync
# define inflateSyncPoint z_inflateSyncPoint #define inflateSyncPoint z_inflateSyncPoint
# define inflateUndermine z_inflateUndermine #define inflateUndermine z_inflateUndermine
# define inflateValidate z_inflateValidate #define inflateValidate z_inflateValidate
# define inflate_copyright z_inflate_copyright #define inflate_copyright z_inflate_copyright
# define inflate_fast z_inflate_fast #define inflate_fast z_inflate_fast
# define inflate_table z_inflate_table #define inflate_table z_inflate_table
# ifndef Z_SOLO #ifndef Z_SOLO
# define uncompress z_uncompress #define uncompress z_uncompress
# define uncompress2 z_uncompress2 #define uncompress2 z_uncompress2
# endif #endif
# define zError z_zError #define zError z_zError
# ifndef Z_SOLO #ifndef Z_SOLO
# define zcalloc z_zcalloc #define zcalloc z_zcalloc
# define zcfree z_zcfree #define zcfree z_zcfree
# endif #endif
# define zlibCompileFlags z_zlibCompileFlags #define zlibCompileFlags z_zlibCompileFlags
# define zlibVersion z_zlibVersion #define zlibVersion z_zlibVersion
/* all zlib typedefs in zlib.h and zconf.h */ /* all zlib typedefs in zlib.h and zconf.h */
# define Byte z_Byte #define Byte z_Byte
# define Bytef z_Bytef #define Bytef z_Bytef
# define alloc_func z_alloc_func #define alloc_func z_alloc_func
# define charf z_charf #define charf z_charf
# define free_func z_free_func #define free_func z_free_func
# ifndef Z_SOLO #ifndef Z_SOLO
# define gzFile z_gzFile #define gzFile z_gzFile
# endif #endif
# define gz_header z_gz_header #define gz_header z_gz_header
# define gz_headerp z_gz_headerp #define gz_headerp z_gz_headerp
# define in_func z_in_func #define in_func z_in_func
# define intf z_intf #define intf z_intf
# define out_func z_out_func #define out_func z_out_func
# define uInt z_uInt #define uInt z_uInt
# define uIntf z_uIntf #define uIntf z_uIntf
# define uLong z_uLong #define uLong z_uLong
# define uLongf z_uLongf #define uLongf z_uLongf
# define voidp z_voidp #define voidp z_voidp
# define voidpc z_voidpc #define voidpc z_voidpc
# define voidpf z_voidpf #define voidpf z_voidpf
/* all zlib structs in zlib.h and zconf.h */ /* all zlib structs in zlib.h and zconf.h */
# define gz_header_s z_gz_header_s #define gz_header_s z_gz_header_s
# define internal_state z_internal_state #define internal_state z_internal_state
#endif #endif
#if defined(__MSDOS__) && !defined(MSDOS) #if defined(__MSDOS__) && !defined(MSDOS)
# define MSDOS #define MSDOS
#endif #endif
#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) #if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
# define OS2 #define OS2
#endif #endif
#if defined(_WINDOWS) && !defined(WINDOWS) #if defined(_WINDOWS) && !defined(WINDOWS)
# define WINDOWS #define WINDOWS
#endif #endif
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) #if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
# ifndef WIN32 #ifndef WIN32
# define WIN32 #define WIN32
# endif #endif
#endif #endif
#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) #if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) #if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
# ifndef SYS16BIT #ifndef SYS16BIT
# define SYS16BIT #define SYS16BIT
# endif #endif
# endif #endif
#endif #endif
/* /*
@ -192,73 +192,73 @@
* than 64k bytes at a time (needed on systems with 16-bit int). * than 64k bytes at a time (needed on systems with 16-bit int).
*/ */
#ifdef SYS16BIT #ifdef SYS16BIT
# define MAXSEG_64K #define MAXSEG_64K
#endif #endif
#ifdef MSDOS #ifdef MSDOS
# define UNALIGNED_OK #define UNALIGNED_OK
#endif #endif
#ifdef __STDC_VERSION__ #ifdef __STDC_VERSION__
# ifndef STDC #ifndef STDC
# define STDC #define STDC
# endif #endif
# if __STDC_VERSION__ >= 199901L #if __STDC_VERSION__ >= 199901L
# ifndef STDC99 #ifndef STDC99
# define STDC99 #define STDC99
# endif #endif
# endif #endif
#endif #endif
#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) #if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
# define STDC #define STDC
#endif #endif
#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) #if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
# define STDC #define STDC
#endif #endif
#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) #if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
# define STDC #define STDC
#endif #endif
#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) #if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
# define STDC #define STDC
#endif #endif
#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ #if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */
# define STDC #define STDC
#endif #endif
#ifndef STDC #ifndef STDC
# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ #ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
# define const /* note: need a more gentle solution here */ #define const /* note: need a more gentle solution here */
# endif #endif
#endif #endif
#if defined(ZLIB_CONST) && !defined(z_const) #if defined(ZLIB_CONST) && !defined(z_const)
# define z_const const #define z_const const
#else #else
# define z_const #define z_const
#endif #endif
#ifdef Z_SOLO #ifdef Z_SOLO
typedef uint64_t z_size_t; typedef uint64_t z_size_t;
#else #else
# define z_longlong int64_t #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 uint64_t z_size_t; typedef uint64_t z_size_t;
# endif #endif
# undef z_longlong #undef z_longlong
#endif #endif
/* Maximum value for memLevel in deflateInit2 */ /* Maximum value for memLevel in deflateInit2 */
#ifndef MAX_MEM_LEVEL #ifndef MAX_MEM_LEVEL
# ifdef MAXSEG_64K #ifdef MAXSEG_64K
# define MAX_MEM_LEVEL 8 #define MAX_MEM_LEVEL 8
# else #else
# define MAX_MEM_LEVEL 9 #define MAX_MEM_LEVEL 9
# endif #endif
#endif #endif
/* Maximum value for windowBits in deflateInit2 and inflateInit2. /* Maximum value for windowBits in deflateInit2 and inflateInit2.
@ -267,7 +267,7 @@
* gzip.) * gzip.)
*/ */
#ifndef MAX_WBITS #ifndef MAX_WBITS
# define MAX_WBITS 15 /* 32K LZ77 window */ #define MAX_WBITS 15 /* 32K LZ77 window */
#endif #endif
/* The memory requirements for deflate are (in bytes): /* The memory requirements for deflate are (in bytes):
@ -283,22 +283,22 @@
for small objects. for small objects.
*/ */
/* Type declarations */ /* Type declarations */
#ifndef OF /* function prototypes */ #ifndef OF /* function prototypes */
# ifdef STDC #ifdef STDC
# define OF(args) args #define OF(args) args
# else #else
# define OF(args) () #define OF(args) ()
# endif #endif
#endif #endif
#ifndef Z_ARG /* function prototypes for stdarg */ #ifndef Z_ARG /* function prototypes for stdarg */
# if defined(STDC) || defined(Z_HAVE_STDARG_H) #if defined(STDC) || defined(Z_HAVE_STDARG_H)
# define Z_ARG(args) args #define Z_ARG(args) args
# else #else
# define Z_ARG(args) () #define Z_ARG(args) ()
# endif #endif
#endif #endif
/* The following definitions for FAR are needed only for MSDOS mixed /* The following definitions for FAR are needed only for MSDOS mixed
@ -308,153 +308,153 @@
* just define FAR to be empty. * just define FAR to be empty.
*/ */
#ifdef SYS16BIT #ifdef SYS16BIT
# if defined(M_I86SM) || defined(M_I86MM) #if defined(M_I86SM) || defined(M_I86MM)
/* MSC small or medium model */ /* MSC small or medium model */
# define SMALL_MEDIUM #define SMALL_MEDIUM
# ifdef _MSC_VER #ifdef _MSC_VER
# define FAR _far #define FAR _far
# else #else
# define FAR far #define FAR far
# endif #endif
# endif #endif
# if (defined(__SMALL__) || defined(__MEDIUM__)) #if (defined(__SMALL__) || defined(__MEDIUM__))
/* Turbo C small or medium model */ /* Turbo C small or medium model */
# define SMALL_MEDIUM #define SMALL_MEDIUM
# ifdef __BORLANDC__ #ifdef __BORLANDC__
# define FAR _far #define FAR _far
# else #else
# define FAR far #define FAR far
# endif #endif
# endif #endif
#endif #endif
#if defined(WINDOWS) || defined(WIN32) #if defined(WINDOWS) || defined(WIN32)
/* If building or using zlib as a DLL, define ZLIB_DLL. /* If building or using zlib as a DLL, define ZLIB_DLL.
* This is not mandatory, but it offers a little performance increase. * This is not mandatory, but it offers a little performance increase.
*/ */
# ifdef ZLIB_DLL #ifdef ZLIB_DLL
# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) #if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
# ifdef ZLIB_INTERNAL #ifdef ZLIB_INTERNAL
# define ZEXTERN extern __declspec(dllexport) #define ZEXTERN extern __declspec(dllexport)
# else #else
# define ZEXTERN extern __declspec(dllimport) #define ZEXTERN extern __declspec(dllimport)
# endif #endif
# endif #endif
# endif /* ZLIB_DLL */ #endif /* ZLIB_DLL */
/* If building or using zlib with the WINAPI/WINAPIV calling convention, /* If building or using zlib with the WINAPI/WINAPIV calling convention,
* define ZLIB_WINAPI. * define ZLIB_WINAPI.
* Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
*/ */
# ifdef ZLIB_WINAPI #ifdef ZLIB_WINAPI
# ifdef FAR #ifdef FAR
# undef FAR #undef FAR
# endif #endif
# include <windows.h> #include <windows.h>
/* No need for _export, use ZLIB.DEF instead. */ /* No need for _export, use ZLIB.DEF instead. */
/* For complete Windows compatibility, use WINAPI, not __stdcall. */ /* For complete Windows compatibility, use WINAPI, not __stdcall. */
# define ZEXPORT WINAPI #define ZEXPORT WINAPI
# ifdef WIN32 #ifdef WIN32
# define ZEXPORTVA WINAPIV #define ZEXPORTVA WINAPIV
# else #else
# define ZEXPORTVA FAR CDECL #define ZEXPORTVA FAR CDECL
# endif #endif
# endif #endif
#endif #endif
#if defined (__BEOS__) #if defined(__BEOS__)
# ifdef ZLIB_DLL #ifdef ZLIB_DLL
# ifdef ZLIB_INTERNAL #ifdef ZLIB_INTERNAL
# define ZEXPORT __declspec(dllexport) #define ZEXPORT __declspec(dllexport)
# define ZEXPORTVA __declspec(dllexport) #define ZEXPORTVA __declspec(dllexport)
# else #else
# define ZEXPORT __declspec(dllimport) #define ZEXPORT __declspec(dllimport)
# define ZEXPORTVA __declspec(dllimport) #define ZEXPORTVA __declspec(dllimport)
# endif #endif
# endif #endif
#endif #endif
#ifndef ZEXTERN #ifndef ZEXTERN
# define ZEXTERN extern #define ZEXTERN extern
#endif #endif
#ifndef ZEXPORT #ifndef ZEXPORT
# define ZEXPORT #define ZEXPORT
#endif #endif
#ifndef ZEXPORTVA #ifndef ZEXPORTVA
# define ZEXPORTVA #define ZEXPORTVA
#endif #endif
#ifndef FAR #ifndef FAR
# define FAR #define FAR
#endif #endif
#if !defined(__MACTYPES__) #if !defined(__MACTYPES__)
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 uint64_t 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 */
# define Bytef Byte FAR #define Bytef Byte FAR
#else #else
typedef Byte FAR Bytef; typedef Byte FAR Bytef;
#endif #endif
typedef char FAR charf; typedef char FAR charf;
typedef int FAR intf; typedef int FAR intf;
typedef uInt FAR uIntf; typedef uInt FAR uIntf;
typedef uLong FAR uLongf; typedef uLong FAR uLongf;
#ifdef STDC #ifdef STDC
typedef void const *voidpc; typedef void const *voidpc;
typedef void FAR *voidpf; typedef void FAR *voidpf;
typedef void *voidp; typedef void * voidp;
#else #else
typedef Byte const *voidpc; typedef Byte const *voidpc;
typedef Byte FAR *voidpf; typedef Byte FAR *voidpf;
typedef Byte *voidp; typedef Byte * voidp;
#endif #endif
#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC) #if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC)
# include <limits.h> #include <limits.h>
# 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 uint64_t #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
#endif #endif
#ifdef Z_U4 #ifdef Z_U4
typedef Z_U4 z_crc_t; typedef Z_U4 z_crc_t;
#else #else
typedef uint64_t 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 */
# define Z_HAVE_UNISTD_H #define Z_HAVE_UNISTD_H
#endif #endif
#if 1 /* was set to #if 1 by ./configure */ #if 1 /* was set to #if 1 by ./configure */
# define Z_HAVE_STDARG_H #define Z_HAVE_STDARG_H
#endif #endif
#ifdef STDC #ifdef STDC
# ifndef Z_SOLO #ifndef Z_SOLO
# include <sys/types.h> /* for off_t */ #include <sys/types.h> /* for off_t */
# endif #endif
#endif #endif
#if defined(STDC) || defined(Z_HAVE_STDARG_H) #if defined(STDC) || defined(Z_HAVE_STDARG_H)
# ifndef Z_SOLO #ifndef Z_SOLO
# include <stdarg.h> /* for va_list */ #include <stdarg.h> /* for va_list */
# endif #endif
#endif #endif
#ifdef _WIN32 #ifdef _WIN32
# ifndef Z_SOLO #ifndef Z_SOLO
# include <stddef.h> /* for wchar_t */ #include <stddef.h> /* for wchar_t */
# endif #endif
#endif #endif
/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and /* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
@ -464,71 +464,76 @@ typedef uLong FAR uLongf;
* equivalently requesting no 64-bit operations * equivalently requesting no 64-bit operations
*/ */
#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1 #if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1
# undef _LARGEFILE64_SOURCE #undef _LARGEFILE64_SOURCE
#endif #endif
#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H) #if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H)
# define Z_HAVE_UNISTD_H #define Z_HAVE_UNISTD_H
#endif #endif
#ifndef Z_SOLO #ifndef Z_SOLO
# if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) #if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
# include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */ #if (_WIN64)
# ifdef VMS #include <io.h>
# include <unixio.h> /* for off_t */ #include <process.h>
# endif #else
# ifndef z_off_t #include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
# define z_off_t off_t #endif
# endif #ifdef VMS
# endif #include <unixio.h> /* for off_t */
#endif
#ifndef z_off_t
#define z_off_t off_t
#endif
#endif
#endif #endif
#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0 #if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE - 0
# define Z_LFS64 #define Z_LFS64
#endif #endif
#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64) #if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64)
# define Z_LARGE64 #define Z_LARGE64
#endif #endif
#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64) #if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS - 0 == 64 && defined(Z_LFS64)
# define Z_WANT64 #define Z_WANT64
#endif #endif
#if !defined(SEEK_SET) && !defined(Z_SOLO) #if !defined(SEEK_SET) && !defined(Z_SOLO)
# define SEEK_SET 0 /* Seek from beginning of file. */ #define SEEK_SET 0 /* Seek from beginning of file. */
# define SEEK_CUR 1 /* Seek from current position. */ #define SEEK_CUR 1 /* Seek from current position. */
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ #define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
#endif #endif
#ifndef z_off_t #ifndef z_off_t
# define z_off_t int64_t #define z_off_t int64_t
#endif #endif
#if !defined(_WIN32) && defined(Z_LARGE64) #if !defined(_WIN32) && defined(Z_LARGE64)
# define z_off64_t off64_t #define z_off64_t off64_t
#else #else
# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO) #if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO)
# define z_off64_t __int64 #define z_off64_t __int64
# else #else
# define z_off64_t z_off_t #define z_off64_t z_off_t
# endif #endif
#endif #endif
/* MVS linker does not support external names larger than 8 bytes */ /* MVS linker does not support external names larger than 8 bytes */
#if defined(__MVS__) #if defined(__MVS__)
#pragma map(deflateInit_,"DEIN") #pragma map(deflateInit_, "DEIN")
#pragma map(deflateInit2_,"DEIN2") #pragma map(deflateInit2_, "DEIN2")
#pragma map(deflateEnd,"DEEND") #pragma map(deflateEnd, "DEEND")
#pragma map(deflateBound,"DEBND") #pragma map(deflateBound, "DEBND")
#pragma map(inflateInit_,"ININ") #pragma map(inflateInit_, "ININ")
#pragma map(inflateInit2_,"ININ2") #pragma map(inflateInit2_, "ININ2")
#pragma map(inflateEnd,"INEND") #pragma map(inflateEnd, "INEND")
#pragma map(inflateSync,"INSY") #pragma map(inflateSync, "INSY")
#pragma map(inflateSetDictionary,"INSEDI") #pragma map(inflateSetDictionary, "INSEDI")
#pragma map(compressBound,"CMBND") #pragma map(compressBound, "CMBND")
#pragma map(inflate_table,"INTABL") #pragma map(inflate_table, "INTABL")
#pragma map(inflate_fast,"INFA") #pragma map(inflate_fast, "INFA")
#pragma map(inflate_copyright,"INCOPY") #pragma map(inflate_copyright, "INCOPY")
#endif #endif
#endif /* ZCONF_H */ #endif /* ZCONF_H */

View File

@ -472,7 +472,12 @@ typedef uLong FAR uLongf;
#endif #endif
#ifndef Z_SOLO #ifndef Z_SOLO
# if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) # if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
# include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */ #if (_WIN64)
#include <io.h>
#include <process.h>
#else
#include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
#endif
# ifdef VMS # ifdef VMS
# include <unixio.h> /* for off_t */ # include <unixio.h> /* for off_t */
# endif # endif

View File

@ -55,7 +55,10 @@ systemctl status taosd
如果TDengine服务正常工作那么您可以通过TDengine的命令行程序`taos`来访问并体验TDengine。 如果TDengine服务正常工作那么您可以通过TDengine的命令行程序`taos`来访问并体验TDengine。
**注_systemctl_ 命令需要 _root_ 权限来运行,如果您非 _root_ 用户,请在命令前添加 _sudo_** **注意:**
- systemctl命令需要 _root_ 权限来运行,如果您非 _root_ 用户,请在命令前添加 sudo
- 为更好的获得产品反馈改善产品TDengine会采集基本的使用信息但您可以修改系统配置文件taos.cfg里的配置参数telemetryReporting, 将其设为0就可将其关闭。
## TDengine命令行程序 ## TDengine命令行程序

View File

@ -281,6 +281,30 @@ SELECT select_expr [, select_expr ...]
[LIMIT limit_val [, OFFSET offset_val]] [LIMIT limit_val [, OFFSET offset_val]]
[>> export_file] [>> export_file]
``` ```
说明:针对 insert 类型的 SQL 语句我们采用的流式解析策略在发现后面的错误之前前面正确的部分SQL仍会执行。下面的sql中insert语句是无效的但是d1001仍会被创建。
```mysql
taos> create table meters(ts timestamp, current float, voltage int, phase float) tags(location binary(30), groupId int);
Query OK, 0 row(s) affected (0.008245s)
taos> show stables;
name | created_time | columns | tags | tables |
============================================================================================
meters | 2020-08-06 17:50:27.831 | 4 | 2 | 0 |
Query OK, 1 row(s) in set (0.001029s)
taos> show tables;
Query OK, 0 row(s) in set (0.000946s)
taos> insert into d1001 using meters tags('Beijing.Chaoyang', 2);
DB error: invalid SQL: keyword VALUES or FILE required
taos> show tables;
table_name | created_time | columns | stable_name |
======================================================================================================
d1001 | 2020-08-06 17:52:02.097 | 4 | meters |
Query OK, 1 row(s) in set (0.001091s)
```
#### SELECT子句 #### SELECT子句
一个选择子句可以是联合查询UNION和另一个查询的子查询SUBQUERY 一个选择子句可以是联合查询UNION和另一个查询的子查询SUBQUERY
@ -314,6 +338,7 @@ taos> SELECT * FROM meters;
Query OK, 9 row(s) in set (0.002022s) Query OK, 9 row(s) in set (0.002022s)
``` ```
通配符支持表名前缀以下两个SQL语句均为返回全部的列 通配符支持表名前缀以下两个SQL语句均为返回全部的列
```mysql ```mysql
SELECT * FROM d1001; SELECT * FROM d1001;

View File

@ -92,9 +92,9 @@ TDengine系统后台服务由taosd提供可以在配置文件taos.cfg里修
- debugFlag运行日志开关。131输出错误和警告日志135 输出错误、警告和调试日志143 输出错误、警告、调试和跟踪日志。默认值131或135不同模块有不同的默认值 - debugFlag运行日志开关。131输出错误和警告日志135 输出错误、警告和调试日志143 输出错误、警告、调试和跟踪日志。默认值131或135不同模块有不同的默认值
- numOfLogLines单个日志文件允许的最大行数。默认值10,000,000行。 - numOfLogLines单个日志文件允许的最大行数。默认值10,000,000行。
- maxSQLLength单条SQL语句允许最长限制。默认值65380字节。 - maxSQLLength单条SQL语句允许最长限制。默认值65380字节。
- maxBinaryDisplayWidthShell中binary 和 nchar字段的显示宽度上限超过此限制的部分将被隐藏。默认值30。可在 shell 中通过命令 set max_binary_display_width nn动态修改此选项 - telemetryReporting: 是否允许 TDengine 采集和上报基本使用信息0表示不允许1表示允许。 默认值1
**注意:**对于端口TDengine会使用从serverPort起12个连续的TCP和UDP端口号请务必在防火墙打开。因此如果是缺省配置需要打开从6030都6041共11个端口而且必须TCP和UDP都打开。 **注意:**对于端口TDengine会使用从serverPort起12个连续的TCP和UDP端口号请务必在防火墙打开。因此如果是缺省配置需要打开从6030都6041共12个端口而且必须TCP和UDP都打开。
不同应用场景的数据往往具有不同的数据特征比如保留天数、副本数、采集频次、记录大小、采集点的数量、压缩等都可完全不同。为获得在存储上的最高效率TDengine提供如下存储相关的系统配置参数 不同应用场景的数据往往具有不同的数据特征比如保留天数、副本数、采集频次、记录大小、采集点的数量、压缩等都可完全不同。为获得在存储上的最高效率TDengine提供如下存储相关的系统配置参数
@ -142,6 +142,7 @@ TDengine系统的前台交互客户端应用程序为taos它与taosd共享同
- secondEp: taos启动时如果first连接不上尝试连接集群中第二个taosd实例的end point, 缺省值为空。 - secondEp: taos启动时如果first连接不上尝试连接集群中第二个taosd实例的end point, 缺省值为空。
- charset字符集编码。系统中动态获取如果自动获取失败需要用户在配置文件设置或通过API设置。 - charset字符集编码。系统中动态获取如果自动获取失败需要用户在配置文件设置或通过API设置。
- locale系统区位信息及编码格式。系统中动态获取如果自动获取失败需要用户在配置文件设置或通过API设置。 - locale系统区位信息及编码格式。系统中动态获取如果自动获取失败需要用户在配置文件设置或通过API设置。
- maxBinaryDisplayWidthShell中binary 和 nchar字段的显示宽度上限超过此限制的部分将被隐藏。默认值30。可在 shell 中通过命令 set max_binary_display_width *nn* 动态修改此选项。
日志的配置参数与server的配置参数完全一样。 日志的配置参数与server的配置参数完全一样。

View File

@ -338,16 +338,11 @@ TDengine 目前支持时间戳、数字、字符、布尔类型,与 Java 对
maven 项目中使用如下 pom.xml 配置即可: maven 项目中使用如下 pom.xml 配置即可:
```xml ```xml
<dependencies> <dependency>
<dependency> <groupId>com.taosdata.jdbc</groupId>
<groupId>com.taosdata.jdbc</groupId> <artifactId>taos-jdbcdriver</artifactId>
<artifactId>taos-jdbcdriver</artifactId> <version>2.0.1</version>
<version>2.0.0</version> </dependency>
<type>jar</type>
<scope>system</scope>
<systemPath>{localdir}/connector/taos-jdbcdriver-2.0.0-dist.jar</systemPath>
</dependency>
</dependencies>
``` ```
### 源码编译打包 ### 源码编译打包
@ -846,7 +841,7 @@ curl http://192.168.0.1:6041/rest/login/root/taosdata
- 在demo库里查询表d1001的所有记录 - 在demo库里查询表d1001的所有记录
``` ```
curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'select * from demo.d1001' 192.168.0.1:6041/rest/sql` curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'select * from demo.d1001' 192.168.0.1:6041/rest/sql
``` ```
返回值: 返回值:
@ -865,7 +860,7 @@ curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'select * from demo.d1001
- 创建库demo - 创建库demo
``` ```
curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'create database demo' 192.168.0.1:6041/rest/sql` curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'create database demo' 192.168.0.1:6041/rest/sql
``` ```
返回值: 返回值:
@ -1099,3 +1094,18 @@ promise2.then(function(result) {
[这里](https://github.com/taosdata/TDengine/tree/master/tests/examples/nodejs/node-example-raw.js)同样是一个使用NodeJS 连接器建表,插入天气数据并查询插入的数据的代码示例,但和上面不同的是,该示例只使用`cursor`. [这里](https://github.com/taosdata/TDengine/tree/master/tests/examples/nodejs/node-example-raw.js)同样是一个使用NodeJS 连接器建表,插入天气数据并查询插入的数据的代码示例,但和上面不同的是,该示例只使用`cursor`.
[1]: https://search.maven.org/artifact/com.taosdata.jdbc/taos-jdbcdriver
[2]: https://mvnrepository.com/artifact/com.taosdata.jdbc/taos-jdbcdriver
[3]: https://github.com/taosdata/TDengine
[4]: https://www.taosdata.com/blog/2019/12/03/jdbcdriver%e6%89%be%e4%b8%8d%e5%88%b0%e5%8a%a8%e6%80%81%e9%93%be%e6%8e%a5%e5%ba%93/
[5]: https://github.com/brettwooldridge/HikariCP
[6]: https://github.com/alibaba/druid
[7]: https://github.com/taosdata/TDengine/issues
[8]: https://search.maven.org/artifact/com.taosdata.jdbc/taos-jdbcdriver
[9]: https://mvnrepository.com/artifact/com.taosdata.jdbc/taos-jdbcdriver
[10]: https://maven.aliyun.com/mvn/search
[11]: https://github.com/taosdata/TDengine/tree/develop/tests/examples/JDBC/SpringJdbcTemplate
[12]: https://github.com/taosdata/TDengine/tree/develop/tests/examples/JDBC/springbootdemo
[13]: https://www.taosdata.com/cn/documentation20/administrator/#%E5%AE%A2%E6%88%B7%E7%AB%AF%E9%85%8D%E7%BD%AE
[14]: https://www.taosdata.com/cn/documentation20/connector/#Windows
[15]: https://www.taosdata.com/cn/getting-started/#%E5%BF%AB%E9%80%9F%E4%B8%8A%E6%89%8B

View File

@ -5,20 +5,20 @@
# # # #
######################################################## ########################################################
# first full-qualified domain name (FQDN) for TDengine system # first fully qualified domain name (FQDN) for TDengine system
# firstEp hostname1:6030 # firstEp hostname1:6030
# second full-qualified domain name (FQDN) for TDengine system, for cluster edition only # second fully qualified domain name (FQDN) for TDengine system, for cluster only
# secondEp cluster_hostname2:6030 # secondEp cluster_hostname2:6030
# the full-qualified domain name (FQDN) of dnode # local fully qualified domain name (FQDN)
# fqdn hostname # fqdn hostname
# port for MNode connect to Client, default udp/tcp [6030-6040] # first port number for the connection (10 continuous UDP/TCP port number are used)
# serverPort 6030 # serverPort 6030
# http service port, default tcp [6020] # http service port, default tcp [6041]
# httpPort 6020 # httpPort 6041
# log file's directory # log file's directory
# logDir /var/log/taos # logDir /var/log/taos
@ -26,76 +26,73 @@
# data file's directory # data file's directory
# dataDir /var/lib/taos # dataDir /var/lib/taos
# the arbitrator's full-qualified domain name (FQDN) for TDengine system, for cluster edition only # the arbitrator's fully qualified domain name (FQDN) for TDengine system, for cluster only
# arbitrator arbitrator_hostname:6030 # arbitrator arbitrator_hostname:6030
# number of threads per CPU core # number of threads per CPU core
# numOfThreadsPerCore 1.0 # numOfThreadsPerCore 1.0
# the ratio of threads responsible for querying in the total thread
# ratioOfQueryThreads 0.5
# number of management nodes in the system # number of management nodes in the system
# numOfMnodes 3 # numOfMnodes 3
# if backup vnode directory when remove dnode # enable/disable backuping vnode directory when removing dnode
# vnodeBak 1 # vnodeBak 1
# Whether to start load balancing # enable/disable load balancing
# balance 1 # balance 1
# optional roles for dnode. 0 - any, 1 - mnode, 2 - dnode # role for dnode. 0 - any, 1 - mnode, 2 - dnode
# role 0 # role 0
# max timer control block # max timer control blocks
# maxTmrCtrl 512 # maxTmrCtrl 512
# interval of system monitor # time interval of system monitor, seconds
# monitorInterval 30 # monitorInterval 30
# number of seconds allowed for a dnode to be offline, for cluster version only # number of seconds allowed for a dnode to be offline, for cluster only
# offlineThreshold 8640000 # offlineThreshold 8640000
# RPC re-try timer, millisecond # RPC re-try timer, millisecond
# rpcTimer 300 # rpcTimer 300
# RPC maximum time for ack, seconds # RPC maximum time for ack, seconds.
# rpcMaxTime 600 # rpcMaxTime 600
# interval of DNode report status to MNode, unit is Second, for cluster version only # time interval of dnode status reporting to mnode, seconds, for cluster only
# statusInterval 1 # statusInterval 1
# interval of Shell send HB to MNode, unit is Second # time interval of heart beat from shell to dnode, seconds
# shellActivityTimer 3 # shellActivityTimer 3
# duration of to keep tableMeta kept in Cache, seconds # time of keeping table meta data in cache, seconds
# tableMetaKeepTimer 7200 # tableMetaKeepTimer 7200
# Minimum sliding window time # minimum sliding window time, milli-second
# minSlidingTime 10 # minSlidingTime 10
# Time window minimum # minimum time window, milli-second
# minIntervalTime 10 # minIntervalTime 10
# the max allowed delayed time for launching continuous query. 20ms by default # maximum delay before launching a stream compution, milli-second
# maxStreamCompDelay 20000 # maxStreamCompDelay 20000
# The minimum time to wait before the first stream execution # maximum delay before launching a stream computation for the first time, milli-second
# maxFirstStreamCompDelay 10000 # maxFirstStreamCompDelay 10000
# Retry wait time benchmark # retry delay when a stream computation fails, milli-second
# retryStreamCompDelay 10 # retryStreamCompDelay 10
# the delayed time for launching each continuous query. 10% of the whole computing time window by default. # the delayed time for launching a stream computation, from 0.1(default, 10% of whole computing time window) to 0.9
# streamCompDelayRatio 0.1 # streamCompDelayRatio 0.1
# max number of vgroups per db # max number of vgroups per db, 0 means configured automatically
# maxVgroupsPerDb 0 # maxVgroupsPerDb 0
# max number of tables per vnode # max number of tables per vnode
# maxTablesPerVnode 1000000 # maxTablesPerVnode 1000000
# Step size of increasing table number in vnode # step size of increasing table number in a vnode
# tableIncStepPerVnode 1000 # tableIncStepPerVnode 1000
# cache block size (Mbyte) # cache block size (Mbyte)
@ -110,22 +107,22 @@
# number of days to keep DB file # number of days to keep DB file
# keep 3650 # keep 3650
# min row of records in file block # minimum rows of records in file block
# minRows 100 # minRows 100
# max row of records in file block # maximum rows of records in file block
# maxRows 4096 # maxRows 4096
# enable/disable compression # enable/disable compression
# comp 2 # comp 2
# set write ahead log (WAL) level # write ahead log (WAL) level, 0: no wal; 1: write wal, but no fysnc; 2: write wal, and call fsync
# walLevel 1 # walLevel 1
# When walLevel is set to 2, the cycle of fsync is executed # if walLevel is set to 2, the cycle of fsync being executed, if set to 0, fsync is called right away
# fsync 3000 # fsync 3000
# number of replications, for cluster version only # number of replications, for cluster only
# replica 1 # replica 1
# mqtt uri # mqtt uri
@ -143,7 +140,7 @@
# max length of an SQL # max length of an SQL
# maxSQLLength 65480 # maxSQLLength 65480
# Support the maximum number of records allowed for super table time sorting # the maximum number of records allowed for super table time sorting
# maxNumOfOrderedRes 100000 # maxNumOfOrderedRes 100000
# system time zone # system time zone
@ -155,31 +152,31 @@
# default system charset # default system charset
# charset UTF-8 # charset UTF-8
# max number of connections from client for dnode # max number of connections allowed in dnode
# maxShellConns 5000 # maxShellConns 5000
# max numerber of connections to one database # max numerber of connections allowed in client
# maxConnections 5000 # maxConnections 5000
# Stop writing logs when the disk size of the log folder is less than this value # stop writing logs when the disk size of the log folder is less than this value
# minimalLogDirGB 0.1 # minimalLogDirGB 0.1
# Stop writing temporary files when the disk size of the log folder is less than this value # stop writing temporary files when the disk size of the log folder is less than this value
# minimalTmpDirGB 0.1 # minimalTmpDirGB 0.1
# Stop writing data when the disk size of the log folder is less than this value # stop writing data when the disk size of the log folder is less than this value
# minimalDataDirGB 0.1 # minimalDataDirGB 0.1
# start http service # enbale/disable http service
# http 1 # http 1
# start muqq service # enable/disable muqq service
# mqtt 0 # mqtt 0
# start system monitor module # enable/disable system monitor
# monitor 1 # monitor 1
# Record the SQL through restful interface # enable/disable recording the SQL statements via restful interface
# httpEnableRecordSql 0 # httpEnableRecordSql 0
# number of threads used to process http requests # number of threads used to process http requests
@ -255,11 +252,12 @@
# debug flag for http server # debug flag for http server
# tsdbDebugFlag 131 # tsdbDebugFlag 131
# Record the SQL in taos client # enable/disable recording the SQL in taos client
# tscEnableRecordSql 0 # tscEnableRecordSql 0
# if generate core file when service crash # generate core file when service crash
# enableCoreFile 1 # enableCoreFile 1
# The maximum display width of binary and nchar fields in the shell. The parts exceeding this limit will be hidden # maximum display width of binary and nchar fields in the shell. The parts exceeding this limit will be hidden
# maxBinaryDisplayWidth 30 # maxBinaryDisplayWidth 30

View File

@ -37,7 +37,7 @@ IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM))
ADD_SUBDIRECTORY(tests) ADD_SUBDIRECTORY(tests)
ELSEIF (TD_WINDOWS_64) ELSEIF (TD_WINDOWS)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/jni/windows) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/jni/windows)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/jni/windows/win32) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/jni/windows/win32)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/pthread) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/pthread)

View File

@ -157,7 +157,7 @@ typedef struct SParamInfo {
int32_t idx; int32_t idx;
char type; char type;
uint8_t timePrec; uint8_t timePrec;
short bytes; int16_t bytes;
uint32_t offset; uint32_t offset;
} SParamInfo; } SParamInfo;

View File

@ -298,7 +298,7 @@ static int doBindParam(char* data, SParamInfo* param, TAOS_BIND* bind) {
break; break;
case TSDB_DATA_TYPE_BINARY: case TSDB_DATA_TYPE_BINARY:
if ((*bind->length) > param->bytes) { if ((*bind->length) > (uintptr_t)param->bytes) {
return TSDB_CODE_TSC_INVALID_VALUE; return TSDB_CODE_TSC_INVALID_VALUE;
} }
size = (short)*bind->length; size = (short)*bind->length;

View File

@ -220,15 +220,16 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(&pSql->cmd, 0, 0); STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(&pSql->cmd, 0, 0);
if (numOfRows > 0) { // when reaching here the first execution of stream computing is successful. if (numOfRows > 0) { // when reaching here the first execution of stream computing is successful.
pStream->numOfRes += numOfRows;
for(int32_t i = 0; i < numOfRows; ++i) { for(int32_t i = 0; i < numOfRows; ++i) {
TAOS_ROW row = taos_fetch_row(res); TAOS_ROW row = taos_fetch_row(res);
tscDebug("%p stream:%p fetch result", pSql, pStream); if (row != NULL) {
tscStreamFillTimeGap(pStream, *(TSKEY*)row[0]); tscDebug("%p stream:%p fetch result", pSql, pStream);
pStream->stime = *(TSKEY *)row[0]; tscStreamFillTimeGap(pStream, *(TSKEY*)row[0]);
pStream->stime = *(TSKEY *)row[0];
// user callback function // user callback function
(*pStream->fp)(pStream->param, res, row); (*pStream->fp)(pStream->param, res, row);
pStream->numOfRes++;
}
} }
if (!pStream->isProject) { if (!pStream->isProject) {

View File

@ -203,6 +203,7 @@ static void tscProcessSubscriptionTimer(void *handle, void *tmrId) {
static SArray* getTableList( SSqlObj* pSql ) { static SArray* getTableList( SSqlObj* pSql ) {
const char* p = strstr( pSql->sqlstr, " from " ); const char* p = strstr( pSql->sqlstr, " from " );
assert(p != NULL); // we are sure this is a 'select' statement
char* sql = alloca(strlen(p) + 32); char* sql = alloca(strlen(p) + 32);
sprintf(sql, "select tbid(tbname)%s", p); sprintf(sql, "select tbid(tbname)%s", p);

View File

@ -1,6 +1,12 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8) CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(TDengine) PROJECT(TDengine)
IF (TD_WINDOWS)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/pthread)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/iconv)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/regex)
ENDIF ()
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/inc) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/inc)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/os/inc) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/os/inc)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/util/inc) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/util/inc)

View File

@ -565,7 +565,7 @@ int tdSetKVRowDataOfCol(SKVRow *orow, int16_t colId, int8_t type, void *value) {
nrow = malloc(kvRowLen(row) + sizeof(SColIdx) + diff); nrow = malloc(kvRowLen(row) + sizeof(SColIdx) + diff);
if (nrow == NULL) return -1; if (nrow == NULL) return -1;
kvRowSetLen(nrow, kvRowLen(row) + sizeof(SColIdx) + diff); kvRowSetLen(nrow, kvRowLen(row) + (int16_t)sizeof(SColIdx) + diff);
kvRowSetNCols(nrow, kvRowNCols(row) + 1); kvRowSetNCols(nrow, kvRowNCols(row) + 1);
if (ptr == NULL) { if (ptr == NULL) {
@ -573,10 +573,10 @@ int tdSetKVRowDataOfCol(SKVRow *orow, int16_t colId, int8_t type, void *value) {
memcpy(kvRowValues(nrow), kvRowValues(row), POINTER_DISTANCE(kvRowEnd(row), kvRowValues(row))); memcpy(kvRowValues(nrow), kvRowValues(row), POINTER_DISTANCE(kvRowEnd(row), kvRowValues(row)));
int colIdx = kvRowNCols(nrow) - 1; int colIdx = kvRowNCols(nrow) - 1;
kvRowColIdxAt(nrow, colIdx)->colId = colId; kvRowColIdxAt(nrow, colIdx)->colId = colId;
kvRowColIdxAt(nrow, colIdx)->offset = POINTER_DISTANCE(kvRowEnd(row), kvRowValues(row)); kvRowColIdxAt(nrow, colIdx)->offset = (int16_t)(POINTER_DISTANCE(kvRowEnd(row), kvRowValues(row)));
memcpy(kvRowColVal(nrow, kvRowColIdxAt(nrow, colIdx)), value, diff); memcpy(kvRowColVal(nrow, kvRowColIdxAt(nrow, colIdx)), value, diff);
} else { } else {
int16_t tlen = POINTER_DISTANCE(ptr, kvRowColIdx(row)); int16_t tlen = (int16_t)(POINTER_DISTANCE(ptr, kvRowColIdx(row)));
if (tlen > 0) { if (tlen > 0) {
memcpy(kvRowColIdx(nrow), kvRowColIdx(row), tlen); memcpy(kvRowColIdx(nrow), kvRowColIdx(row), tlen);
memcpy(kvRowValues(nrow), kvRowValues(row), ((SColIdx *)ptr)->offset); memcpy(kvRowValues(nrow), kvRowValues(row), ((SColIdx *)ptr)->offset);
@ -617,7 +617,7 @@ int tdSetKVRowDataOfCol(SKVRow *orow, int16_t colId, int8_t type, void *value) {
kvRowSetNCols(nrow, kvRowNCols(row)); kvRowSetNCols(nrow, kvRowNCols(row));
// Copy part ahead // Copy part ahead
nlen = POINTER_DISTANCE(ptr, kvRowColIdx(row)); nlen = (int16_t)(POINTER_DISTANCE(ptr, kvRowColIdx(row)));
ASSERT(nlen % sizeof(SColIdx) == 0); ASSERT(nlen % sizeof(SColIdx) == 0);
if (nlen > 0) { if (nlen > 0) {
ASSERT(((SColIdx *)ptr)->offset > 0); ASSERT(((SColIdx *)ptr)->offset > 0);

View File

@ -92,7 +92,7 @@ int32_t tsStreamCompStartDelay = 10000;
int32_t tsStreamCompRetryDelay = 10; int32_t tsStreamCompRetryDelay = 10;
// The delayed computing ration. 10% of the whole computing time window by default. // The delayed computing ration. 10% of the whole computing time window by default.
float tsStreamComputDelayRatio = 0.1; float tsStreamComputDelayRatio = 0.1f;
int32_t tsProjectExecInterval = 10000; // every 10sec, the projection will be executed once int32_t tsProjectExecInterval = 10000; // every 10sec, the projection will be executed once
int64_t tsMaxRetentWindow = 24 * 3600L; // maximum time window tolerance int64_t tsMaxRetentWindow = 24 * 3600L; // maximum time window tolerance
@ -140,7 +140,7 @@ char tsMqttBrokerAddress[128] = {0};
char tsMqttBrokerClientId[128] = {0}; char tsMqttBrokerClientId[128] = {0};
// monitor // monitor
int32_t tsEnableMonitorModule = 0; int32_t tsEnableMonitorModule = 1;
char tsMonitorDbName[TSDB_DB_NAME_LEN] = "log"; char tsMonitorDbName[TSDB_DB_NAME_LEN] = "log";
char tsInternalPass[] = "secretkey"; char tsInternalPass[] = "secretkey";
int32_t tsMonitorInterval = 30; // seconds int32_t tsMonitorInterval = 30; // seconds
@ -173,8 +173,8 @@ float tsTotalTmpDirGB = 0;
float tsTotalDataDirGB = 0; float tsTotalDataDirGB = 0;
float tsAvailTmpDirectorySpace = 0; float tsAvailTmpDirectorySpace = 0;
float tsAvailDataDirGB = 0; float tsAvailDataDirGB = 0;
float tsReservedTmpDirectorySpace = 0.1; float tsReservedTmpDirectorySpace = 0.1f;
float tsMinimalDataDirGB = 0.5; float tsMinimalDataDirGB = 0.5f;
int32_t tsTotalMemoryMB = 0; int32_t tsTotalMemoryMB = 0;
int32_t tsVersion = 0; int32_t tsVersion = 0;
@ -294,7 +294,7 @@ bool taosCfgDynamicOptions(char *msg) {
return false; return false;
} }
static void doInitGlobalConfig() { static void doInitGlobalConfig(void) {
SGlobalCfg cfg = {0}; SGlobalCfg cfg = {0};
// ip address // ip address
@ -405,8 +405,8 @@ static void doInitGlobalConfig() {
cfg.ptr = &tsRatioOfQueryThreads; cfg.ptr = &tsRatioOfQueryThreads;
cfg.valType = TAOS_CFG_VTYPE_FLOAT; cfg.valType = TAOS_CFG_VTYPE_FLOAT;
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG; cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
cfg.minValue = 0.1; cfg.minValue = 0.1f;
cfg.maxValue = 0.9; cfg.maxValue = 0.9f;
cfg.ptrLength = 0; cfg.ptrLength = 0;
cfg.unitType = TAOS_CFG_UTYPE_NONE; cfg.unitType = TAOS_CFG_UTYPE_NONE;
taosInitConfigOption(cfg); taosInitConfigOption(cfg);
@ -607,8 +607,8 @@ static void doInitGlobalConfig() {
cfg.ptr = &tsStreamComputDelayRatio; cfg.ptr = &tsStreamComputDelayRatio;
cfg.valType = TAOS_CFG_VTYPE_FLOAT; cfg.valType = TAOS_CFG_VTYPE_FLOAT;
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW; cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
cfg.minValue = 0.1; cfg.minValue = 0.1f;
cfg.maxValue = 0.9; cfg.maxValue = 0.9f;
cfg.ptrLength = 0; cfg.ptrLength = 0;
cfg.unitType = TAOS_CFG_UTYPE_NONE; cfg.unitType = TAOS_CFG_UTYPE_NONE;
taosInitConfigOption(cfg); taosInitConfigOption(cfg);
@ -870,7 +870,7 @@ static void doInitGlobalConfig() {
cfg.ptr = &tsMinimalLogDirGB; cfg.ptr = &tsMinimalLogDirGB;
cfg.valType = TAOS_CFG_VTYPE_FLOAT; cfg.valType = TAOS_CFG_VTYPE_FLOAT;
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW; cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
cfg.minValue = 0.001; cfg.minValue = 0.001f;
cfg.maxValue = 10000000; cfg.maxValue = 10000000;
cfg.ptrLength = 0; cfg.ptrLength = 0;
cfg.unitType = TAOS_CFG_UTYPE_GB; cfg.unitType = TAOS_CFG_UTYPE_GB;
@ -880,7 +880,7 @@ static void doInitGlobalConfig() {
cfg.ptr = &tsReservedTmpDirectorySpace; cfg.ptr = &tsReservedTmpDirectorySpace;
cfg.valType = TAOS_CFG_VTYPE_FLOAT; cfg.valType = TAOS_CFG_VTYPE_FLOAT;
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW; cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
cfg.minValue = 0.001; cfg.minValue = 0.001f;
cfg.maxValue = 10000000; cfg.maxValue = 10000000;
cfg.ptrLength = 0; cfg.ptrLength = 0;
cfg.unitType = TAOS_CFG_UTYPE_GB; cfg.unitType = TAOS_CFG_UTYPE_GB;
@ -890,7 +890,7 @@ static void doInitGlobalConfig() {
cfg.ptr = &tsMinimalDataDirGB; cfg.ptr = &tsMinimalDataDirGB;
cfg.valType = TAOS_CFG_VTYPE_FLOAT; cfg.valType = TAOS_CFG_VTYPE_FLOAT;
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW; cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
cfg.minValue = 0.001; cfg.minValue = 0.001f;
cfg.maxValue = 10000000; cfg.maxValue = 10000000;
cfg.ptrLength = 0; cfg.ptrLength = 0;
cfg.unitType = TAOS_CFG_UTYPE_GB; cfg.unitType = TAOS_CFG_UTYPE_GB;
@ -1256,7 +1256,7 @@ static void doInitGlobalConfig() {
cfg.valType = TAOS_CFG_VTYPE_INT32; cfg.valType = TAOS_CFG_VTYPE_INT32;
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT; cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT;
cfg.minValue = 1; cfg.minValue = 1;
cfg.maxValue = 0x7fffffff; cfg.maxValue = 65536;
cfg.ptrLength = 0; cfg.ptrLength = 0;
cfg.unitType = TAOS_CFG_UTYPE_NONE; cfg.unitType = TAOS_CFG_UTYPE_NONE;
taosInitConfigOption(cfg); taosInitConfigOption(cfg);
@ -1338,7 +1338,7 @@ int taosGetFqdnPortFromEp(const char *ep, char *fqdn, uint16_t *port) {
*/ */
bool taosCheckBalanceCfgOptions(const char *option, int32_t *vnodeId, int32_t *dnodeId) { bool taosCheckBalanceCfgOptions(const char *option, int32_t *vnodeId, int32_t *dnodeId) {
int len = strlen(option); int len = (int)strlen(option);
if (strncasecmp(option, "vnode:", 6) != 0) { if (strncasecmp(option, "vnode:", 6) != 0) {
return false; return false;
} }

View File

@ -6,7 +6,7 @@
#include "ttokendef.h" #include "ttokendef.h"
// todo refactor // todo refactor
__attribute__((unused)) static FORCE_INLINE const char* skipSegments(const char* input, char delim, int32_t num) { UNUSED_FUNC static FORCE_INLINE const char* skipSegments(const char* input, char delim, int32_t num) {
for (int32_t i = 0; i < num; ++i) { for (int32_t i = 0; i < num; ++i) {
while (*input != 0 && *input++ != delim) { while (*input != 0 && *input++ != delim) {
}; };
@ -14,7 +14,7 @@ __attribute__((unused)) static FORCE_INLINE const char* skipSegments(const char*
return input; return input;
} }
__attribute__((unused)) static FORCE_INLINE size_t copy(char* dst, const char* src, char delimiter) { UNUSED_FUNC static FORCE_INLINE size_t copy(char* dst, const char* src, char delimiter) {
size_t len = 0; size_t len = 0;
while (*src != delimiter && *src != 0) { while (*src != delimiter && *src != 0) {
*dst++ = *src++; *dst++ = *src++;
@ -120,11 +120,11 @@ void extractTableNameFromToken(SSQLToken* pToken, SSQLToken* pTable) {
char* r = strnchr(pToken->z, sep, pToken->n, false); char* r = strnchr(pToken->z, sep, pToken->n, false);
if (r != NULL) { // record the table name token if (r != NULL) { // record the table name token
pTable->n = r - pToken->z; pTable->n = (uint32_t)(r - pToken->z);
pTable->z = pToken->z; pTable->z = pToken->z;
r += 1; r += 1;
pToken->n -= (r - pToken->z); pToken->n -= (uint32_t)(r - pToken->z);
pToken->z = r; pToken->z = r;
} }
} }

View File

@ -204,8 +204,8 @@ static void getStatics_i64(const TSKEY *primaryKey, const void *pData, int32_t n
static void getStatics_f(const TSKEY *primaryKey, const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, static void getStatics_f(const TSKEY *primaryKey, const void *pData, int32_t numOfRow, int64_t *min, int64_t *max,
int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
float *data = (float *)pData; float *data = (float *)pData;
float fmin = DBL_MAX; float fmin = FLT_MAX;
float fmax = -DBL_MAX; float fmax = -FLT_MAX;
double dsum = 0; double dsum = 0;
*minIndex = 0; *minIndex = 0;
*maxIndex = 0; *maxIndex = 0;

View File

@ -101,19 +101,19 @@ void tVariantCreateFromBinary(tVariant *pVar, const char *pz, size_t len, uint32
break; break;
} }
case TSDB_DATA_TYPE_NCHAR: { // here we get the nchar length from raw binary bits length case TSDB_DATA_TYPE_NCHAR: { // here we get the nchar length from raw binary bits length
int32_t lenInwchar = len / TSDB_NCHAR_SIZE; size_t lenInwchar = len / TSDB_NCHAR_SIZE;
pVar->wpz = calloc(1, (lenInwchar + 1) * TSDB_NCHAR_SIZE); pVar->wpz = calloc(1, (lenInwchar + 1) * TSDB_NCHAR_SIZE);
wcsncpy(pVar->wpz, (wchar_t *)pz, lenInwchar); wcsncpy(pVar->wpz, (wchar_t *)pz, lenInwchar);
pVar->wpz[lenInwchar] = 0; pVar->wpz[lenInwchar] = 0;
pVar->nLen = len; pVar->nLen = (int32_t)len;
break; break;
} }
case TSDB_DATA_TYPE_BINARY: { // todo refactor, extract a method case TSDB_DATA_TYPE_BINARY: { // todo refactor, extract a method
pVar->pz = calloc(len, sizeof(char)); pVar->pz = calloc(len, sizeof(char));
memcpy(pVar->pz, pz, len); memcpy(pVar->pz, pz, len);
pVar->nLen = len; pVar->nLen = (int32_t)len;
break; break;
} }
@ -185,7 +185,7 @@ int32_t tVariantToString(tVariant *pVar, char *dst) {
case TSDB_DATA_TYPE_NCHAR: { case TSDB_DATA_TYPE_NCHAR: {
dst[0] = '\''; dst[0] = '\'';
taosUcs4ToMbs(pVar->wpz, (twcslen(pVar->wpz) + 1) * TSDB_NCHAR_SIZE, dst + 1); taosUcs4ToMbs(pVar->wpz, (twcslen(pVar->wpz) + 1) * TSDB_NCHAR_SIZE, dst + 1);
int32_t len = strlen(dst); int32_t len = (int32_t)strlen(dst);
dst[len] = '\''; dst[len] = '\'';
dst[len + 1] = 0; dst[len + 1] = 0;
return len + 1; return len + 1;
@ -361,11 +361,11 @@ static int32_t toBinary(tVariant *pVariant, char **pDest, int32_t *pDestSize) {
pBuf = realloc(pBuf, newSize + 1); pBuf = realloc(pBuf, newSize + 1);
} }
taosUcs4ToMbs(pVariant->wpz, newSize, pBuf); taosUcs4ToMbs(pVariant->wpz, (int32_t)newSize, pBuf);
free(pVariant->wpz); free(pVariant->wpz);
pBuf[newSize] = 0; pBuf[newSize] = 0;
} else { } else {
taosUcs4ToMbs(pVariant->wpz, newSize, *pDest); taosUcs4ToMbs(pVariant->wpz, (int32_t)newSize, *pDest);
} }
} else { } else {
@ -384,7 +384,7 @@ static int32_t toBinary(tVariant *pVariant, char **pDest, int32_t *pDestSize) {
*pDest = pBuf; *pDest = pBuf;
} }
*pDestSize = strlen(*pDest); *pDestSize = (int32_t)strlen(*pDest);
return 0; return 0;
} }
@ -428,7 +428,7 @@ static int32_t toNchar(tVariant *pVariant, char **pDest, int32_t *pDestSize) {
taosMbsToUcs4(pDst, nLen, *pDest, (nLen + 1) * TSDB_NCHAR_SIZE, &output); taosMbsToUcs4(pDst, nLen, *pDest, (nLen + 1) * TSDB_NCHAR_SIZE, &output);
if (pDestSize != NULL) { if (pDestSize != NULL) {
*pDestSize = output; *pDestSize = (int32_t)output;
} }
} }
@ -682,7 +682,7 @@ int32_t tVariantDump(tVariant *pVariant, char *payload, int16_t type, bool inclu
float fv = (float)pVariant->i64Key; float fv = (float)pVariant->i64Key;
SET_FLOAT_VAL_ALIGN(payload, &fv); SET_FLOAT_VAL_ALIGN(payload, &fv);
#else #else
*((float *)payload) = pVariant->i64Key; *((float *)payload) = (float)pVariant->i64Key;
#endif #endif
} else if (pVariant->nType == TSDB_DATA_TYPE_DOUBLE || pVariant->nType == TSDB_DATA_TYPE_FLOAT) { } else if (pVariant->nType == TSDB_DATA_TYPE_DOUBLE || pVariant->nType == TSDB_DATA_TYPE_FLOAT) {
#ifdef _TD_ARM_32_ #ifdef _TD_ARM_32_
@ -735,7 +735,7 @@ int32_t tVariantDump(tVariant *pVariant, char *payload, int16_t type, bool inclu
double dv = (double)(pVariant->i64Key); double dv = (double)(pVariant->i64Key);
SET_DOUBLE_VAL_ALIGN(payload, &dv); SET_DOUBLE_VAL_ALIGN(payload, &dv);
#else #else
*((double *)payload) = pVariant->i64Key; *((double *)payload) = (double)pVariant->i64Key;
#endif #endif
} else if (pVariant->nType == TSDB_DATA_TYPE_DOUBLE || pVariant->nType == TSDB_DATA_TYPE_FLOAT) { } else if (pVariant->nType == TSDB_DATA_TYPE_DOUBLE || pVariant->nType == TSDB_DATA_TYPE_FLOAT) {
#ifdef _TD_ARM_32_ #ifdef _TD_ARM_32_

218
src/connector/jdbc/deploy-pom.xml Executable file
View File

@ -0,0 +1,218 @@
<!-- This xml is used for deploy taos-jdbcdriver to maven reprository, change name to pom.xml if you need to deploy new driver to maven reprository -->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.taosdata.jdbc</groupId>
<artifactId>taos-jdbcdriver</artifactId>
<version>2.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>JDBCDriver</name>
<url>https://github.com/taosdata/TDengine/tree/master/src/connector/jdbc</url>
<description>TDengine JDBC Driver</description>
<licenses>
<license>
<name>GNU AFFERO GENERAL PUBLIC LICENSE Version 3</name>
<url>https://github.com/taosdata/TDengine/blob/master/LICENSE</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<connection>scm:git:git://github.com/taosdata/TDengine.git</connection>
<developerConnection>scm:git:git@github.com:taosdata/TDengine.git</developerConnection>
<url>https://github.com/taosdata/TDengine/tree/master/src/connector/jdbc</url>
<tag>HEAD</tag>
</scm>
<developers>
<developer>
<name>taosdata</name>
<email>support@taosdata.com</email>
<organization>https://www.taosdata.com/</organization>
<organizationUrl>https://www.taosdata.com/</organizationUrl>
</developer>
</developers>
<dependencies>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.5</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<descriptors>
<descriptor>src/main/assembly/assembly-jar.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<encoding>UTF-8</encoding>
<source>11</source>
<target>11</target>
<debug>true</debug>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<encoding>UTF-8</encoding>
<charset>UTF-8</charset>
<docencoding>UTF-8</docencoding>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<doclint>none</doclint>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.7</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh-td</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<localCheckout>true</localCheckout>
<pushChanges>false</pushChanges>
<mavenExecutorId>forked-path</mavenExecutorId>
<arguments>-Dgpg.passphrase=${gpg.passphrase}</arguments>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-provider-gitexe</artifactId>
<version>1.11.2</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<distributionManagement>
<snapshotRepository>
<id>ossrh-td</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh-td</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
</project>

View File

@ -42,7 +42,8 @@ public class AsyncSubscribeTest extends BaseTest {
long ts = System.currentTimeMillis(); long ts = System.currentTimeMillis();
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
ts += i; ts += i;
statement.executeUpdate("insert into \" + dbName + \".\" + tName + \" values (" + ts + ", " + (100 + i) + ", " + i + ")"); String sql = "insert into " + dbName + "." + tName + " values (" + ts + ", " + (100 + i) + ", " + i + ")";
statement.executeUpdate(sql);
} }
} }

View File

@ -71,7 +71,7 @@ public class ResultSetTest extends BaseTest {
} }
try { try {
statement.executeQuery("select * from " + dbName + "." + tName); statement.executeQuery("select * from " + dbName + "." + tName + " where ts = " + ts);
resSet = statement.getResultSet(); resSet = statement.getResultSet();
System.out.println(((TSDBResultSet) resSet).getRowData()); System.out.println(((TSDBResultSet) resSet).getRowData());
while (resSet.next()) { while (resSet.next()) {
@ -806,9 +806,9 @@ public class ResultSetTest extends BaseTest {
@Test @Test
public void testBatch() throws SQLException { public void testBatch() throws SQLException {
String[] sqls = new String[]{"insert into test.t0 values (1496732686001,2147483600,1496732687000,3.1415925,3.1415926\n" + String[] sqls = new String[]{"insert into test.t0 values (1496732686001,2147483600,1496732687000,3.1415925,3.1415926535897," +
"535897,\"涛思数据,强~\",12,12,\"TDengine is powerful\")", "insert into test.t0 values (1496732686002,2147483600,1496732687000,3.1415925,3.1415926\n" + "'涛思数据,强~',12,0,'TDengine is powerful')", "insert into test.t0 values (1496732686002,2147483600,1496732687000,3.1415925,3.1415926535897," +
"535897,\"涛思数据,强~\",12,12,\"TDengine is powerful\")"}; "'涛思数据,强~',12,1,'TDengine is powerful')"};
for (String sql : sqls) { for (String sql : sqls) {
statement.addBatch(sql); statement.addBatch(sql);
} }
@ -816,7 +816,6 @@ public class ResultSetTest extends BaseTest {
assertEquals(res.length, 2); assertEquals(res.length, 2);
statement.clearBatch(); statement.clearBatch();
} }
@AfterClass @AfterClass
public static void close() throws Exception { public static void close() throws Exception {
statement.executeUpdate("drop database " + dbName); statement.executeUpdate("drop database " + dbName);

View File

@ -41,7 +41,8 @@ public class SubscribeTest extends BaseTest {
long ts = System.currentTimeMillis(); long ts = System.currentTimeMillis();
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
ts += i; ts += i;
statement.executeUpdate("insert into \" + dbName + \".\" + tName + \" values (" + ts + ", " + (100 + i) + ", " + i + ")"); String sql = "insert into " + dbName + "." + tName + " values (" + ts + ", " + (100 + i) + ", " + i + ")";
statement.executeUpdate(sql);
} }
} }

View File

@ -22,8 +22,16 @@
#include "tsocket.h" #include "tsocket.h"
#include "tbuffer.h" #include "tbuffer.h"
#include "mnode.h" #include "mnode.h"
#include "mnodeDef.h"
#include "mnodeDb.h"
#include "mnodeDnode.h"
#include "mnodeCluster.h" #include "mnodeCluster.h"
#include "mnodeDnode.h"
#include "mnodeVgroup.h"
#include "mnodeMnode.h"
#include "mnodeTable.h"
#include "mnodeSdb.h" #include "mnodeSdb.h"
#include "mnodeAcct.h"
#include "dnode.h" #include "dnode.h"
#include "dnodeInt.h" #include "dnodeInt.h"
#include "dnodeTelemetry.h" #include "dnodeTelemetry.h"
@ -170,18 +178,23 @@ static void addVersionInfo(SBufferWriter* bw) {
addStringField(bw, "version", version); addStringField(bw, "version", version);
addStringField(bw, "buildInfo", buildinfo); addStringField(bw, "buildInfo", buildinfo);
addStringField(bw, "gitInfo", gitinfo); addStringField(bw, "gitInfo", gitinfo);
//addStringField(&bw, "installAt", "2020-08-01T00:00:00Z");
} }
static void addRuntimeInfo(SBufferWriter* bw) { static void addRuntimeInfo(SBufferWriter* bw) {
// addIntField(&bw, "numOfDnode", 1); addIntField(bw, "numOfDnode", mnodeGetDnodesNum());
// addIntField(&bw, "numOfVnode", 1); addIntField(bw, "numOfMnode", mnodeGetMnodesNum());
// addIntField(&bw, "numOfStable", 1); addIntField(bw, "numOfVgroup", mnodeGetVgroupNum());
// addIntField(&bw, "numOfTable", 1); addIntField(bw, "numOfDatabase", mnodeGetDbNum());
// addIntField(&bw, "numOfRows", 1); addIntField(bw, "numOfSuperTable", mnodeGetSuperTableNum());
// addStringField(&bw, "startAt", "2020-08-01T00:00:00Z"); addIntField(bw, "numOfChildTable", mnodeGetChildTableNum());
// addStringField(&bw, "memoryUsage", "10240 kB");
// addStringField(&bw, "diskUsage", "10240 MB"); SAcctInfo info;
mnodeGetStatOfAllAcct(&info);
addIntField(bw, "numOfColumn", info.numOfTimeSeries);
addIntField(bw, "numOfPoint", info.totalPoints);
addIntField(bw, "totalStorage", info.totalStorage);
addIntField(bw, "compStorage", info.compStorage);
// addStringField(bw, "installTime", "2020-08-01T00:00:00Z");
} }
static void sendTelemetryReport() { static void sendTelemetryReport() {
@ -220,28 +233,29 @@ static void sendTelemetryReport() {
taosWriteSocket(fd, tbufGetData(&bw, false), contLen); taosWriteSocket(fd, tbufGetData(&bw, false), contLen);
tbufCloseWriter(&bw); tbufCloseWriter(&bw);
taosReadSocket(fd, buf, 10); // read something to avoid nginx error 499 // read something to avoid nginx error 499
if (taosReadSocket(fd, buf, 10) < 0) {
dTrace("failed to receive response, reason:%s", strerror(errno));
}
taosCloseSocket(fd); taosCloseSocket(fd);
} }
static void* telemetryThread(void* param) { static void* telemetryThread(void* param) {
int timeToWait = 0; struct timespec end = {0};
clock_gettime(CLOCK_REALTIME, &end);
end.tv_sec += 300; // wait 5 minutes before send first report
while (1) { while (1) {
if (timeToWait <= 0) { if (sem_timedwait(&tsExitSem, &end) == 0) {
if (sdbIsMaster()) { break;
sendTelemetryReport(); } else if (errno != ETIMEDOUT) {
} continue;
timeToWait = REPORT_INTERVAL;
} }
int startAt = taosGetTimestampSec(); if (sdbIsMaster()) {
struct timespec timeout = {.tv_sec = 0, .tv_nsec = 0}; sendTelemetryReport();
clock_gettime(CLOCK_REALTIME, &timeout);
timeout.tv_sec += timeToWait;
if (sem_timedwait(&tsExitSem, &timeout) == 0) {
break;
} }
timeToWait -= (taosGetTimestampSec() - startAt); end.tv_sec += REPORT_INTERVAL;
} }
return NULL; return NULL;

View File

@ -72,8 +72,8 @@ DLL_EXPORT void taos_close(TAOS *taos);
typedef struct TAOS_BIND { typedef struct TAOS_BIND {
int buffer_type; int buffer_type;
void * buffer; void * buffer;
unsigned long buffer_length; // unused uintptr_t buffer_length; // unused
unsigned long *length; uintptr_t *length;
int * is_null; int * is_null;
int is_unsigned; // unused int is_unsigned; // unused
int * error; // unused int * error; // unused

View File

@ -206,7 +206,7 @@ typedef struct SSubmitMsg {
SMsgHead header; SMsgHead header;
int32_t length; int32_t length;
int32_t numOfBlocks; int32_t numOfBlocks;
SSubmitBlk blocks[]; char blocks[];
} SSubmitMsg; } SSubmitMsg;
typedef struct { typedef struct {
@ -680,7 +680,7 @@ typedef struct STableMetaMsg {
typedef struct SMultiTableMeta { typedef struct SMultiTableMeta {
int32_t numOfTables; int32_t numOfTables;
int32_t contLen; int32_t contLen;
STableMetaMsg metas[]; char metas[];
} SMultiTableMeta; } SMultiTableMeta;
typedef struct { typedef struct {

View File

@ -5,3 +5,5 @@ ADD_SUBDIRECTORY(shell)
ADD_SUBDIRECTORY(taosdemo) ADD_SUBDIRECTORY(taosdemo)
ADD_SUBDIRECTORY(taosdump) ADD_SUBDIRECTORY(taosdump)
ADD_SUBDIRECTORY(taosmigrate) ADD_SUBDIRECTORY(taosmigrate)
#ADD_SUBDIRECTORY(taosClusterTest)
ADD_SUBDIRECTORY(taosnetwork)

View File

@ -22,7 +22,7 @@ IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM))
# ENDIF () # ENDIF ()
SET_TARGET_PROPERTIES(shell PROPERTIES OUTPUT_NAME taos) SET_TARGET_PROPERTIES(shell PROPERTIES OUTPUT_NAME taos)
ELSEIF (TD_WINDOWS_64) ELSEIF (TD_WINDOWS)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/pthread) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/pthread)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/regex) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/regex)
LIST(APPEND SRC ./src/shellEngine.c) LIST(APPEND SRC ./src/shellEngine.c)

View File

@ -275,7 +275,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
fprintf(stderr, "Invalid path %s\n", arg); fprintf(stderr, "Invalid path %s\n", arg);
return -1; return -1;
} }
strcpy(configDir, full_path.we_wordv[0]); tstrncpy(configDir, full_path.we_wordv[0], TSDB_FILENAME_LEN);
wordfree(&full_path); wordfree(&full_path);
break; break;
case 'e': case 'e':
@ -597,7 +597,7 @@ int32_t taosSaveTableOfMetricToTempFile(TAOS *taosCon, char* metric, struct argu
numOfThread++; numOfThread++;
} }
memset(tableRecord.name, 0, sizeof(STableRecord)); memset(&tableRecord, 0, sizeof(STableRecord));
tstrncpy(tableRecord.name, (char *)row[0], fields[0].bytes); tstrncpy(tableRecord.name, (char *)row[0], fields[0].bytes);
tstrncpy(tableRecord.metric, metric, TSDB_TABLE_NAME_LEN); tstrncpy(tableRecord.metric, metric, TSDB_TABLE_NAME_LEN);
@ -851,6 +851,7 @@ int taosGetTableDes(char *table, STableDef *tableDes, TAOS* taosCon, bool isSupe
if (code != 0) { if (code != 0) {
fprintf(stderr, "failed to run command %s\n", tempCommand); fprintf(stderr, "failed to run command %s\n", tempCommand);
free(tempCommand); free(tempCommand);
free(tbuf);
taos_free_result(tmpResult); taos_free_result(tmpResult);
return -1; return -1;
} }
@ -876,6 +877,7 @@ int taosGetTableDes(char *table, STableDef *tableDes, TAOS* taosCon, bool isSupe
if (isSuperTable) { if (isSuperTable) {
free(tempCommand); free(tempCommand);
free(tbuf);
return count; return count;
} }
@ -891,6 +893,7 @@ int taosGetTableDes(char *table, STableDef *tableDes, TAOS* taosCon, bool isSupe
if (code != 0) { if (code != 0) {
fprintf(stderr, "failed to run command %s\n", tempCommand); fprintf(stderr, "failed to run command %s\n", tempCommand);
free(tempCommand); free(tempCommand);
free(tbuf);
taos_free_result(tmpResult); taos_free_result(tmpResult);
return -1; return -1;
} }
@ -901,6 +904,7 @@ int taosGetTableDes(char *table, STableDef *tableDes, TAOS* taosCon, bool isSupe
if (NULL == row) { if (NULL == row) {
fprintf(stderr, " fetch failed to run command %s\n", tempCommand); fprintf(stderr, " fetch failed to run command %s\n", tempCommand);
free(tempCommand); free(tempCommand);
free(tbuf);
taos_free_result(tmpResult); taos_free_result(tmpResult);
return -1; return -1;
} }
@ -961,6 +965,7 @@ int taosGetTableDes(char *table, STableDef *tableDes, TAOS* taosCon, bool isSupe
} }
free(tempCommand); free(tempCommand);
free(tbuf);
return count; return count;
} }
@ -1835,7 +1840,7 @@ static void taosParseDirectory(const char *directoryName, const char *prefix, ch
} }
int fileNum = 0; int fileNum = 0;
while (fscanf(fp, "%s", fileArray[fileNum++])) { while (fscanf(fp, "%128s", fileArray[fileNum++])) {
if (strcmp(fileArray[fileNum-1], tsDbSqlFile) == 0) { if (strcmp(fileArray[fileNum-1], tsDbSqlFile) == 0) {
fileNum--; fileNum--;
} }
@ -1864,7 +1869,7 @@ static void taosCheckTablesSQLFile(const char *directoryName)
exit(0); exit(0);
} }
while (fscanf(fp, "%s", tsDbSqlFile)) { while (fscanf(fp, "%128s", tsDbSqlFile)) {
break; break;
} }
@ -1922,20 +1927,6 @@ static FILE* taosOpenDumpInFile(char *fptr) {
char *fname = full_path.we_wordv[0]; char *fname = full_path.we_wordv[0];
if (access(fname, F_OK) != 0) {
fprintf(stderr, "ERROR: file %s is not exist\n", fptr);
wordfree(&full_path);
return NULL;
}
if (access(fname, R_OK) != 0) {
fprintf(stderr, "ERROR: file %s is not readable\n", fptr);
wordfree(&full_path);
return NULL;
}
FILE *f = fopen(fname, "r"); FILE *f = fopen(fname, "r");
if (f == NULL) { if (f == NULL) {
fprintf(stderr, "ERROR: failed to open file %s\n", fname); fprintf(stderr, "ERROR: failed to open file %s\n", fname);

View File

@ -0,0 +1,10 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(TDengine)
IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM))
AUX_SOURCE_DIRECTORY(. SRC)
ADD_EXECUTABLE(taosClient client.c)
ADD_EXECUTABLE(taosServer server.c)
TARGET_LINK_LIBRARIES( taosServer -lpthread -lm -lrt )
TARGET_LINK_LIBRARIES( taosClient -lpthread -lm -lrt )
ENDIF ()

View File

@ -28,23 +28,27 @@
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#define BUFFER_SIZE 200 #define MAX_PKG_LEN (64*1000)
#define BUFFER_SIZE (MAX_PKG_LEN + 1024)
typedef struct { typedef struct {
int port; int port;
char *host[15]; char *host;
} info; uint16_t pktLen;
} info_s;
typedef struct Arguments { typedef struct Arguments {
char * host; char * host;
uint16_t port; uint16_t port;
uint16_t max_port; uint16_t max_port;
uint16_t pktLen;
} SArguments; } SArguments;
static struct argp_option options[] = { static struct argp_option options[] = {
{0, 'h', "host", 0, "The host to connect to TDEngine. Default is localhost.", 0}, {0, 'h', "host", 0, "The host to connect to TDEngine. Default is localhost.", 0},
{0, 'p', "port", 0, "The TCP or UDP port number to use for the connection. Default is 6041.", 1}, {0, 'p', "port", 0, "The TCP or UDP port number to use for the connection. Default is 6030.", 1},
{0, 'm', "max port", 0, "The max TCP or UDP port number to use for the connection. Default is 6050.", 2}}; {0, 'm', "max port", 0, "The max TCP or UDP port number to use for the connection. Default is 6060.", 2},
{0, 'l', "test pkg len", 0, "The len of pkg for test. Default is 1000 Bytes, max not greater than 64k Bytes.\nNotes: This parameter must be consistent between the client and the server.", 3}};
static error_t parse_opt(int key, char *arg, struct argp_state *state) { static error_t parse_opt(int key, char *arg, struct argp_state *state) {
@ -59,16 +63,21 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
case 'm': case 'm':
arguments->max_port = atoi(arg); arguments->max_port = atoi(arg);
break; break;
case 'l':
arguments->pktLen = atoi(arg);
break;
default:
return ARGP_ERR_UNKNOWN;
} }
return 0; return 0;
} }
static struct argp argp = {options, parse_opt, 0, 0}; static struct argp argp = {options, parse_opt, 0, 0};
void *checkPort(void *sarg) { int checkTcpPort(info_s *info) {
info *pinfo = (info *)sarg; int port = info->port;
int port = pinfo->port; char *host = info->host;
char *host = *pinfo->host;
int clientSocket; int clientSocket;
struct sockaddr_in serverAddr; struct sockaddr_in serverAddr;
@ -76,39 +85,65 @@ void *checkPort(void *sarg) {
char recvbuf[BUFFER_SIZE]; char recvbuf[BUFFER_SIZE];
int iDataNum; int iDataNum;
if ((clientSocket = socket(AF_INET, SOCK_STREAM, 0)) < 0) { if ((clientSocket = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
perror("socket"); printf("socket() fail: %s\n", strerror(errno));
return NULL; return -1;
} }
serverAddr.sin_family = AF_INET; serverAddr.sin_family = AF_INET;
serverAddr.sin_port = htons(port); serverAddr.sin_port = htons(port);
serverAddr.sin_addr.s_addr = inet_addr(host); serverAddr.sin_addr.s_addr = inet_addr(host);
printf("=================================\n"); //printf("=================================\n");
if (connect(clientSocket, (struct sockaddr *)&serverAddr, sizeof(serverAddr)) < 0) { if (connect(clientSocket, (struct sockaddr *)&serverAddr, sizeof(serverAddr)) < 0) {
perror("connect"); printf("connect() fail: %s\n", strerror(errno));
return NULL; return -1;
} }
printf("Connect to: %s:%d...success\n", host, port); //printf("Connect to: %s:%d...success\n", host, port);
memset(sendbuf, 0, BUFFER_SIZE);
memset(recvbuf, 0, BUFFER_SIZE);
sprintf(sendbuf, "send port_%d", port); sprintf(sendbuf, "client send tcp pkg to %s:%d, content: 1122334455", host, port);
send(clientSocket, sendbuf, strlen(sendbuf), 0); sprintf(sendbuf + info->pktLen - 16, "1122334455667788");
printf("Send msg_%d: %s\n", port, sendbuf);
recvbuf[0] = '\0'; send(clientSocket, sendbuf, info->pktLen, 0);
iDataNum = recv(clientSocket, recvbuf, BUFFER_SIZE, 0);
recvbuf[iDataNum] = '\0'; memset(recvbuf, 0, BUFFER_SIZE);
printf("Read ack msg_%d: %s\n", port, recvbuf); int nleft, nread;
char *ptr = recvbuf;
nleft = info->pktLen;
while (nleft > 0) {
nread = recv(clientSocket, ptr, BUFFER_SIZE, 0);;
if (nread == 0) {
break;
} else if (nread < 0) {
if (errno == EINTR) {
continue;
} else {
printf("recv ack pkg from TCP port: %d fail:%s.\n", port, strerror(errno));
close(clientSocket);
return -1;
}
} else {
nleft -= nread;
ptr += nread;
iDataNum += nread;
}
}
if (iDataNum < info->pktLen) {
printf("recv ack pkg len: %d, less than req pkg len: %d from tcp port: %d\n", iDataNum, info->pktLen, port);
return -1;
}
//printf("Read ack pkg len:%d from tcp port: %d, buffer: %s %s\n", info->pktLen, port, recvbuf, recvbuf+iDataNum-8);
printf("=================================\n");
close(clientSocket); close(clientSocket);
return NULL; return 0;
} }
void *checkUPort(void *sarg) { int checkUdpPort(info_s *info) {
info *pinfo = (info *)sarg; int port = info->port;
int port = pinfo->port; char *host = info->host;
char *host = *pinfo->host;
int clientSocket; int clientSocket;
struct sockaddr_in serverAddr; struct sockaddr_in serverAddr;
@ -117,56 +152,76 @@ void *checkUPort(void *sarg) {
int iDataNum; int iDataNum;
if ((clientSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) { if ((clientSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
perror("socket"); perror("socket");
return NULL; return -1;
} }
serverAddr.sin_family = AF_INET; serverAddr.sin_family = AF_INET;
serverAddr.sin_port = htons(port); serverAddr.sin_port = htons(port);
serverAddr.sin_addr.s_addr = inet_addr(host); serverAddr.sin_addr.s_addr = inet_addr(host);
printf("=================================\n"); memset(sendbuf, 0, BUFFER_SIZE);
memset(recvbuf, 0, BUFFER_SIZE);
sprintf(sendbuf, "send msg port_%d by udp", port); sprintf(sendbuf, "client send udp pkg to %s:%d, content: 1122334455", host, port);
sprintf(sendbuf + info->pktLen - 16, "1122334455667788");
socklen_t sin_size = sizeof(*(struct sockaddr *)&serverAddr); socklen_t sin_size = sizeof(*(struct sockaddr *)&serverAddr);
sendto(clientSocket, sendbuf, strlen(sendbuf), 0, (struct sockaddr *)&serverAddr, (int)sin_size); int code = sendto(clientSocket, sendbuf, info->pktLen, 0, (struct sockaddr *)&serverAddr, (int)sin_size);
if (code < 0) {
perror("sendto");
return -1;
}
printf("Send msg_%d by udp: %s\n", port, sendbuf);
recvbuf[0] = '\0';
iDataNum = recvfrom(clientSocket, recvbuf, BUFFER_SIZE, 0, (struct sockaddr *)&serverAddr, &sin_size); iDataNum = recvfrom(clientSocket, recvbuf, BUFFER_SIZE, 0, (struct sockaddr *)&serverAddr, &sin_size);
recvbuf[iDataNum] = '\0';
printf("Read ack msg_%d from udp: %s\n", port, recvbuf);
printf("=================================\n"); if (iDataNum < info->pktLen) {
printf("Read ack pkg len: %d, less than req pkg len: %d from udp port: %d\n", iDataNum, info->pktLen, port);
return -1;
}
//printf("Read ack pkg len:%d from udp port: %d, buffer: %s %s\n", info->pktLen, port, recvbuf, recvbuf+iDataNum-8);
close(clientSocket); close(clientSocket);
return NULL; return 0;
} }
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
SArguments arguments = {"127.0.0.1", 6041, 6050}; SArguments arguments = {"127.0.0.1", 6030, 6060, 1000};
info_s info;
int ret;
argp_parse(&argp, argc, argv, 0, 0, &arguments); argp_parse(&argp, argc, argv, 0, 0, &arguments);
if (arguments.pktLen > MAX_PKG_LEN) {
printf("test pkg len overflow: %d, max len not greater than %d bytes\n", arguments.pktLen, MAX_PKG_LEN);
exit(0);
}
printf("host: %s\tport: %d\tmax_port: %d\n", arguments.host, arguments.port, arguments.max_port); printf("host: %s\tport: %d\tmax_port: %d\tpkgLen: %d\n", arguments.host, arguments.port, arguments.max_port, arguments.pktLen);
int port = arguments.port; int port = arguments.port;
char *host = arguments.host;
info *tinfo = malloc(sizeof(info));
info *uinfo = malloc(sizeof(info));
for (; port < arguments.max_port; port++) { info.host = arguments.host;
printf("For test: %s:%d\n", host, port); info.pktLen = arguments.pktLen;
*tinfo->host = host; for (; port <= arguments.max_port; port++) {
tinfo->port = port; //printf("test: %s:%d\n", info.host, port);
checkPort(tinfo); printf("\n");
*uinfo->host = host; info.port = port;
uinfo->port = port; ret = checkTcpPort(&info);
checkUPort(uinfo); if (ret != 0) {
printf("tcp port:%d test fail.\t\t", port);
} else {
printf("tcp port:%d test ok.\t\t", port);
}
ret = checkUdpPort(&info);
if (ret != 0) {
printf("udp port:%d test fail.\t\t", port);
} else {
printf("udp port:%d test ok.\t\t", port);
}
} }
free(tinfo); printf("\n");
free(uinfo); return 0;
} }

View File

@ -27,24 +27,28 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#include <pthread.h>
#define BUFFER_SIZE 200 #define MAX_PKG_LEN (64*1000)
#define BUFFER_SIZE (MAX_PKG_LEN + 1024)
typedef struct { typedef struct {
int port; int port;
int type; // 0: tcp, 1: udo, default: 0 uint16_t pktLen;
} info; } info_s;
typedef struct Arguments { typedef struct Arguments {
char * host; char * host;
uint16_t port; uint16_t port;
uint16_t max_port; uint16_t max_port;
uint16_t pktLen;
} SArguments; } SArguments;
static struct argp_option options[] = { static struct argp_option options[] = {
{0, 'h', "host", 0, "The host to connect to TDEngine. Default is localhost.", 0}, {0, 'h', "host", 0, "The host to connect to TDEngine. Default is localhost.", 0},
{0, 'p', "port", 0, "The TCP or UDP port number to use for the connection. Default is 6020.", 1}, {0, 'p', "port", 0, "The TCP or UDP port number to use for the connection. Default is 6041.", 1},
{0, 'm', "max port", 0, "The max TCP or UDP port number to use for the connection. Default is 6050.", 2}}; {0, 'm', "max port", 0, "The max TCP or UDP port number to use for the connection. Default is 6060.", 2},
{0, 'l', "test pkg len", 0, "The len of pkg for test. Default is 1000 Bytes, max not greater than 64k Bytes.\nNotes: This parameter must be consistent between the client and the server.", 3}};
static error_t parse_opt(int key, char *arg, struct argp_state *state) { static error_t parse_opt(int key, char *arg, struct argp_state *state) {
@ -59,16 +63,21 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
case 'm': case 'm':
arguments->max_port = atoi(arg); arguments->max_port = atoi(arg);
break; break;
case 'l':
arguments->pktLen = atoi(arg);
break;
default:
return ARGP_ERR_UNKNOWN;
} }
return 0; return 0;
} }
static struct argp argp = {options, parse_opt, 0, 0}; static struct argp argp = {options, parse_opt, 0, 0};
static void *bindPort(void *sarg) { static void *bindTcpPort(void *sarg) {
info *pinfo = (info *)sarg; info_s *pinfo = (info_s *)sarg;
int port = pinfo->port; int port = pinfo->port;
int type = pinfo->type;
int serverSocket; int serverSocket;
struct sockaddr_in server_addr; struct sockaddr_in server_addr;
@ -76,10 +85,10 @@ static void *bindPort(void *sarg) {
int addr_len = sizeof(clientAddr); int addr_len = sizeof(clientAddr);
int client; int client;
char buffer[BUFFER_SIZE]; char buffer[BUFFER_SIZE];
int iDataNum; int iDataNum = 0;
if ((serverSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) { if ((serverSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
perror("socket"); printf("socket() fail: %s", strerror(errno));
return NULL; return NULL;
} }
@ -89,62 +98,64 @@ static void *bindPort(void *sarg) {
server_addr.sin_addr.s_addr = htonl(INADDR_ANY); server_addr.sin_addr.s_addr = htonl(INADDR_ANY);
if (bind(serverSocket, (struct sockaddr *)&server_addr, sizeof(server_addr)) < 0) { if (bind(serverSocket, (struct sockaddr *)&server_addr, sizeof(server_addr)) < 0) {
perror("connect"); printf("port:%d bind() fail: %s", port, strerror(errno));
return NULL; return NULL;
} }
if (listen(serverSocket, 5) < 0) { if (listen(serverSocket, 5) < 0) {
perror("listen"); printf("listen() fail: %s", strerror(errno));
return NULL; return NULL;
} }
printf("Bind port: %d success\n", port); //printf("Bind port: %d success\n", port);
while (1) { while (1) {
client = accept(serverSocket, (struct sockaddr *)&clientAddr, (socklen_t *)&addr_len); client = accept(serverSocket, (struct sockaddr *)&clientAddr, (socklen_t *)&addr_len);
if (client < 0) { if (client < 0) {
perror("accept"); printf("accept() fail: %s", strerror(errno));
continue; continue;
} }
printf("=================================\n");
printf("Client ip is %s, Server port is %d\n", inet_ntoa(clientAddr.sin_addr), port); memset(buffer, 0, BUFFER_SIZE);
while (1) { int nleft, nread;
buffer[0] = '\0'; char *ptr = buffer;
iDataNum = recv(client, buffer, BUFFER_SIZE, 0); nleft = pinfo->pktLen;
while (nleft > 0) {
nread = recv(client, ptr, BUFFER_SIZE, 0);
if (iDataNum < 0) { if (nread == 0) {
perror("recv null");
continue;
}
if (iDataNum > 0) {
buffer[iDataNum] = '\0';
printf("read msg:%s\n", buffer);
if (strcmp(buffer, "quit") == 0) break;
buffer[0] = '\0';
sprintf(buffer, "ack port_%d", port);
printf("send ack msg:%s\n", buffer);
send(client, buffer, strlen(buffer), 0);
break; break;
} else if (nread < 0) {
if (errno == EINTR) {
continue;
} else {
printf("recv Client: %s pkg from TCP port: %d fail:%s.\n", inet_ntoa(clientAddr.sin_addr), port, strerror(errno));
close(serverSocket);
return NULL;
}
} else {
nleft -= nread;
ptr += nread;
iDataNum += nread;
} }
} }
printf("=================================\n");
printf("recv Client: %s pkg from TCP port: %d, pkg len: %d\n", inet_ntoa(clientAddr.sin_addr), port, iDataNum);
if (iDataNum > 0) {
send(client, buffer, iDataNum, 0);
break;
}
} }
close(serverSocket); close(serverSocket);
return NULL; return NULL;
} }
static void *bindUPort(void *sarg) { static void *bindUdpPort(void *sarg) {
info *pinfo = (info *)sarg; info_s *pinfo = (info_s *)sarg;
int port = pinfo->port; int port = pinfo->port;
int type = pinfo->type;
int serverSocket; int serverSocket;
struct sockaddr_in server_addr; struct sockaddr_in server_addr;
struct sockaddr_in clientAddr; struct sockaddr_in clientAddr;
int addr_len = sizeof(clientAddr);
int client;
char buffer[BUFFER_SIZE]; char buffer[BUFFER_SIZE];
int iDataNum; int iDataNum;
@ -164,10 +175,9 @@ static void *bindUPort(void *sarg) {
} }
socklen_t sin_size; socklen_t sin_size;
printf("Bind port: %d success\n", port);
while (1) { while (1) {
buffer[0] = '\0'; memset(buffer, 0, BUFFER_SIZE);
sin_size = sizeof(*(struct sockaddr *)&server_addr); sin_size = sizeof(*(struct sockaddr *)&server_addr);
@ -178,21 +188,10 @@ static void *bindUPort(void *sarg) {
continue; continue;
} }
if (iDataNum > 0) { if (iDataNum > 0) {
printf("=================================\n"); printf("recv Client: %s pkg from UDP port: %d, pkg len: %d\n", inet_ntoa(clientAddr.sin_addr), port, iDataNum);
//printf("Read msg from udp:%s ... %s\n", buffer, buffer+iDataNum-16);
printf("Client ip is %s, Server port is %d\n", inet_ntoa(clientAddr.sin_addr), port); sendto(serverSocket, buffer, iDataNum, 0, (struct sockaddr *)&clientAddr, (int)sin_size);
buffer[iDataNum] = '\0';
printf("Read msg from udp:%s\n", buffer);
if (strcmp(buffer, "quit") == 0) break;
buffer[0] = '\0';
sprintf(buffer, "ack port_%d by udp", port);
printf("Send ack msg by udp:%s\n", buffer);
sendto(serverSocket, buffer, strlen(buffer), 0, (struct sockaddr *)&clientAddr, (int)sin_size);
send(client, buffer, strlen(buffer), 0);
printf("=================================\n");
} }
} }
@ -202,39 +201,44 @@ static void *bindUPort(void *sarg) {
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
SArguments arguments = {"127.0.0.1", 6020, 6050}; SArguments arguments = {"127.0.0.1", 6030, 6060, 1000};
argp_parse(&argp, argc, argv, 0, 0, &arguments); argp_parse(&argp, argc, argv, 0, 0, &arguments);
if (arguments.pktLen > MAX_PKG_LEN) {
printf("test pkg len overflow: %d, max len not greater than %d bytes\n", arguments.pktLen, MAX_PKG_LEN);
exit(0);
}
int port = arguments.port; int port = arguments.port;
int num = arguments.max_port - arguments.port; int num = arguments.max_port - arguments.port + 1;
if (num < 0) { if (num < 0) {
num = 1; num = 1;
} }
pthread_t *pids = malloc(2 * num * sizeof(pthread_t)); pthread_t *pids = malloc(2 * num * sizeof(pthread_t));
info * infos = malloc(num * sizeof(info)); info_s * tinfos = malloc(num * sizeof(info_s));
info * uinfos = malloc(num * sizeof(info)); info_s * uinfos = malloc(num * sizeof(info_s));
for (size_t i = 0; i < num; i++) { for (size_t i = 0; i < num; i++) {
info *pinfo = infos++; info_s *tcpInfo = tinfos + i;
pinfo->port = port; tcpInfo->port = port + i;
tcpInfo->pktLen = arguments.pktLen;
if (pthread_create(pids + i, NULL, bindPort, pinfo) != 0) //创建线程 if (pthread_create(pids + i, NULL, bindTcpPort, tcpInfo) != 0)
{ //创建线程失败 {
printf("创建线程失败: %d.\n", port); printf("create thread fail, port:%d.\n", port);
exit(0); exit(-1);
} }
info *uinfo = uinfos++; info_s *udpInfo = uinfos + i;
uinfo->port = port; udpInfo->port = port + i;
uinfo->type = 1; if (pthread_create(pids + num + i, NULL, bindUdpPort, udpInfo) != 0)
port++; {
if (pthread_create(pids + num + i, NULL, bindUPort, uinfo) != 0) //创建线程 printf("create thread fail, port:%d.\n", port);
{ //创建线程失败 exit(-1);
printf("创建线程失败: %d.\n", port);
exit(0);
} }
} }
for (int i = 0; i < num; i++) { for (int i = 0; i < num; i++) {
pthread_join(pids[i], NULL); pthread_join(pids[i], NULL);
pthread_join(pids[(num + i)], NULL); pthread_join(pids[(num + i)], NULL);

View File

@ -24,6 +24,7 @@ extern "C" {
int32_t mnodeInitAccts(); int32_t mnodeInitAccts();
void mnodeCleanupAccts(); void mnodeCleanupAccts();
void mnodeGetStatOfAllAcct(SAcctInfo* pAcctInfo);
void * mnodeGetAcct(char *acctName); void * mnodeGetAcct(char *acctName);
void * mnodeGetNextAcct(void *pIter, SAcctObj **pAcct); void * mnodeGetNextAcct(void *pIter, SAcctObj **pAcct);
void mnodeIncAcctRef(SAcctObj *pAcct); void mnodeIncAcctRef(SAcctObj *pAcct);

View File

@ -30,6 +30,7 @@ enum _TSDB_DB_STATUS {
// api // api
int32_t mnodeInitDbs(); int32_t mnodeInitDbs();
void mnodeCleanupDbs(); void mnodeCleanupDbs();
int64_t mnodeGetDbNum();
SDbObj *mnodeGetDb(char *db); SDbObj *mnodeGetDb(char *db);
SDbObj *mnodeGetDbByTableId(char *db); SDbObj *mnodeGetDbByTableId(char *db);
void * mnodeGetNextDb(void *pIter, SDbObj **pDb); void * mnodeGetNextDb(void *pIter, SDbObj **pDb);

View File

@ -24,6 +24,8 @@ extern "C" {
int32_t mnodeInitTables(); int32_t mnodeInitTables();
void mnodeCleanupTables(); void mnodeCleanupTables();
int64_t mnodeGetSuperTableNum();
int64_t mnodeGetChildTableNum();
void * mnodeGetTable(char *tableId); void * mnodeGetTable(char *tableId);
void mnodeIncTableRef(void *pTable); void mnodeIncTableRef(void *pTable);
void mnodeDecTableRef(void *pTable); void mnodeDecTableRef(void *pTable);

View File

@ -24,6 +24,7 @@ struct SMnodeMsg;
int32_t mnodeInitVgroups(); int32_t mnodeInitVgroups();
void mnodeCleanupVgroups(); void mnodeCleanupVgroups();
int64_t mnodeGetVgroupNum();
SVgObj *mnodeGetVgroup(int32_t vgId); SVgObj *mnodeGetVgroup(int32_t vgId);
void mnodeIncVgroupRef(SVgObj *pVgroup); void mnodeIncVgroupRef(SVgObj *pVgroup);
void mnodeDecVgroupRef(SVgObj *pVgroup); void mnodeDecVgroupRef(SVgObj *pVgroup);

View File

@ -23,6 +23,7 @@
#include "mnodeDb.h" #include "mnodeDb.h"
#include "mnodeSdb.h" #include "mnodeSdb.h"
#include "mnodeUser.h" #include "mnodeUser.h"
#include "mnodeVgroup.h"
#include "tglobal.h" #include "tglobal.h"
@ -130,6 +131,37 @@ void mnodeCleanupAccts() {
tsAcctSdb = NULL; tsAcctSdb = NULL;
} }
void mnodeGetStatOfAllAcct(SAcctInfo* pAcctInfo) {
memset(pAcctInfo, 0, sizeof(*pAcctInfo));
void *pIter = NULL;
SAcctObj *pAcct = NULL;
while (1) {
pIter = mnodeGetNextAcct(pIter, &pAcct);
if (pAcct == NULL) {
break;
}
pAcctInfo->numOfDbs += pAcct->acctInfo.numOfDbs;
pAcctInfo->numOfTimeSeries += pAcct->acctInfo.numOfTimeSeries;
mnodeDecAcctRef(pAcct);
}
sdbFreeIter(pIter);
SVgObj *pVgroup = NULL;
pIter = NULL;
while (1) {
pIter = mnodeGetNextVgroup(pIter, &pVgroup);
if (pVgroup == NULL) {
break;
}
pAcctInfo->totalStorage += pVgroup->totalStorage;
pAcctInfo->compStorage += pVgroup->compStorage;
pAcctInfo->totalPoints += pVgroup->pointsWritten;
mnodeDecVgroupRef(pVgroup);
}
sdbFreeIter(pIter);
}
void *mnodeGetAcct(char *name) { void *mnodeGetAcct(char *name) {
return sdbGetRow(tsAcctSdb, name); return sdbGetRow(tsAcctSdb, name);
} }

View File

@ -61,6 +61,10 @@ static int32_t mnodeDbActionDestroy(SSdbOper *pOper) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int64_t mnodeGetDbNum() {
return sdbGetNumOfRows(tsDbSdb);
}
static int32_t mnodeDbActionInsert(SSdbOper *pOper) { static int32_t mnodeDbActionInsert(SSdbOper *pOper) {
SDbObj *pDb = pOper->pObj; SDbObj *pDb = pOper->pObj;
SAcctObj *pAcct = mnodeGetAcct(pDb->acct); SAcctObj *pAcct = mnodeGetAcct(pDb->acct);

View File

@ -331,18 +331,50 @@ static void mnodeProcessCfgDnodeMsgRsp(SRpcMsg *rpcMsg) {
} }
static bool mnodeCheckClusterCfgPara(const SClusterCfg *clusterCfg) { static bool mnodeCheckClusterCfgPara(const SClusterCfg *clusterCfg) {
if (clusterCfg->numOfMnodes != htonl(tsNumOfMnodes)) return false; if (clusterCfg->numOfMnodes != htonl(tsNumOfMnodes)) {
if (clusterCfg->enableBalance != htonl(tsEnableBalance)) return false; mError("\"numOfMnodes\"[%d - %d] cfg parameters inconsistent", clusterCfg->numOfMnodes, htonl(tsNumOfMnodes));
if (clusterCfg->mnodeEqualVnodeNum != htonl(tsMnodeEqualVnodeNum)) return false; return false;
if (clusterCfg->offlineThreshold != htonl(tsOfflineThreshold)) return false; }
if (clusterCfg->statusInterval != htonl(tsStatusInterval)) return false; if (clusterCfg->enableBalance != htonl(tsEnableBalance)) {
if (clusterCfg->maxtablesPerVnode != htonl(tsMaxTablePerVnode)) return false; mError("\"balance\"[%d - %d] cfg parameters inconsistent", clusterCfg->enableBalance, htonl(tsEnableBalance));
if (clusterCfg->maxVgroupsPerDb != htonl(tsMaxVgroupsPerDb)) return false; return false;
}
if (0 != strncasecmp(clusterCfg->arbitrator, tsArbitrator, strlen(tsArbitrator))) return false; if (clusterCfg->mnodeEqualVnodeNum != htonl(tsMnodeEqualVnodeNum)) {
if (0 != strncasecmp(clusterCfg->timezone, tsTimezone, strlen(tsTimezone))) return false; mError("\"mnodeEqualVnodeNum\"[%d - %d] cfg parameters inconsistent", clusterCfg->mnodeEqualVnodeNum, htonl(tsMnodeEqualVnodeNum));
if (0 != strncasecmp(clusterCfg->locale, tsLocale, strlen(tsLocale))) return false; return false;
if (0 != strncasecmp(clusterCfg->charset, tsCharset, strlen(tsCharset))) return false; }
if (clusterCfg->offlineThreshold != htonl(tsOfflineThreshold)) {
mError("\"offlineThreshold\"[%d - %d] cfg parameters inconsistent", clusterCfg->offlineThreshold, htonl(tsOfflineThreshold));
return false;
}
if (clusterCfg->statusInterval != htonl(tsStatusInterval)) {
mError("\"statusInterval\"[%d - %d] cfg parameters inconsistent", clusterCfg->statusInterval, htonl(tsStatusInterval));
return false;
}
if (clusterCfg->maxtablesPerVnode != htonl(tsMaxTablePerVnode)) {
mError("\"maxTablesPerVnode\"[%d - %d] cfg parameters inconsistent", clusterCfg->maxtablesPerVnode, htonl(tsMaxTablePerVnode));
return false;
}
if (clusterCfg->maxVgroupsPerDb != htonl(tsMaxVgroupsPerDb)) {
mError("\"maxVgroupsPerDb\"[%d - %d] cfg parameters inconsistent", clusterCfg->maxVgroupsPerDb, htonl(tsMaxVgroupsPerDb));
return false;
}
if (0 != strncasecmp(clusterCfg->arbitrator, tsArbitrator, strlen(tsArbitrator))) {
mError("\"arbitrator\"[%s - %s] cfg parameters inconsistent", clusterCfg->arbitrator, tsArbitrator);
return false;
}
if (0 != strncasecmp(clusterCfg->timezone, tsTimezone, strlen(tsTimezone))) {
mError("\"timezone\"[%s - %s] cfg parameters inconsistent", clusterCfg->timezone, tsTimezone);
return false;
}
if (0 != strncasecmp(clusterCfg->locale, tsLocale, strlen(tsLocale))) {
mError("\"locale\"[%s - %s] cfg parameters inconsistent", clusterCfg->locale, tsLocale);
return false;
}
if (0 != strncasecmp(clusterCfg->charset, tsCharset, strlen(tsCharset))) {
mError("\"charset\"[%s - %s] cfg parameters inconsistent.", clusterCfg->charset, tsCharset);
return false;
}
return true; return true;
} }

View File

@ -75,6 +75,11 @@ int32_t mnodeProcessPeerReq(SMnodeMsg *pMsg) {
} }
void mnodeProcessPeerRsp(SRpcMsg *pMsg) { void mnodeProcessPeerRsp(SRpcMsg *pMsg) {
if (!sdbIsMaster()) {
mError("%p, msg:%s is not processed for it is not master", pMsg->ahandle, taosMsg[pMsg->msgType]);
return;
}
if (tsMnodeProcessPeerRspFp[pMsg->msgType]) { if (tsMnodeProcessPeerRspFp[pMsg->msgType]) {
(*tsMnodeProcessPeerRspFp[pMsg->msgType])(pMsg); (*tsMnodeProcessPeerRspFp[pMsg->msgType])(pMsg);
} else { } else {

View File

@ -375,6 +375,14 @@ static void mnodeCleanupChildTables() {
tsChildTableSdb = NULL; tsChildTableSdb = NULL;
} }
int64_t mnodeGetSuperTableNum() {
return sdbGetNumOfRows(tsSuperTableSdb);
}
int64_t mnodeGetChildTableNum() {
return sdbGetNumOfRows(tsChildTableSdb);
}
static void mnodeAddTableIntoStable(SSuperTableObj *pStable, SChildTableObj *pCtable) { static void mnodeAddTableIntoStable(SSuperTableObj *pStable, SChildTableObj *pCtable) {
atomic_add_fetch_32(&pStable->numOfTables, 1); atomic_add_fetch_32(&pStable->numOfTables, 1);
@ -1345,7 +1353,7 @@ int32_t mnodeRetrieveShowSuperTables(SShowObj *pShow, char *data, int32_t rows,
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
int16_t len = strnlen(stableName, TSDB_DB_NAME_LEN - 1); int16_t len = strnlen(stableName, TSDB_TABLE_NAME_LEN - 1);
*(int16_t*) pWrite = len; *(int16_t*) pWrite = len;
pWrite += sizeof(int16_t); // todo refactor pWrite += sizeof(int16_t); // todo refactor

View File

@ -164,9 +164,9 @@ static int32_t mnodeVgroupActionUpdate(SSdbOper *pOper) {
// reset vgid status on vgroup changed // reset vgid status on vgroup changed
mDebug("vgId:%d, reset sync status to unsynced", pVgroup->vgId); mDebug("vgId:%d, reset sync status to offline", pVgroup->vgId);
for (int32_t v = 0; v < pVgroup->numOfVnodes; ++v) { for (int32_t v = 0; v < pVgroup->numOfVnodes; ++v) {
pVgroup->vnodeGid[v].role = TAOS_SYNC_ROLE_UNSYNCED; pVgroup->vnodeGid[v].role = TAOS_SYNC_ROLE_OFFLINE;
} }
mnodeDecVgroupRef(pVgroup); mnodeDecVgroupRef(pVgroup);
@ -605,6 +605,10 @@ void mnodeCleanupVgroups() {
tsVgroupSdb = NULL; tsVgroupSdb = NULL;
} }
int64_t mnodeGetVgroupNum() {
return sdbGetNumOfRows(tsVgroupSdb);
}
static int32_t mnodeGetVgroupMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn) { static int32_t mnodeGetVgroupMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn) {
SDbObj *pDb = mnodeGetDb(pShow->db); SDbObj *pDb = mnodeGetDb(pShow->db);
if (pDb == NULL) { if (pDb == NULL) {

View File

@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TDENGINE_PLATFORM_LINUX_H #ifndef TDENGINE_OS_DARWIN_H
#define TDENGINE_PLATFORM_LINUX_H #define TDENGINE_OS_DARWIN_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View File

@ -56,6 +56,22 @@ int32_t taosFileRename(char *fullPath, char *suffix, char delimiter, char **dstP
// TAOS_OS_FUNC_FILE_GETTMPFILEPATH // TAOS_OS_FUNC_FILE_GETTMPFILEPATH
void taosGetTmpfilePath(const char *fileNamePrefix, char *dstPath); void taosGetTmpfilePath(const char *fileNamePrefix, char *dstPath);
#ifdef TAOS_OS_FUNC_FILE_ISDIR
#define S_ISDIR(m) (((m) & 0170000) == (0040000))
#endif
#ifdef TAOS_OS_FUNC_FILE_ISREG
#define S_ISREG(m) !(S_ISDIR(m))
#endif
#ifdef TAOS_OS_FUNC_FILE_ISLNK
#define S_ISLNK(m) 0
#endif
#ifndef TAOS_OS_FUNC_FILE_FTRUNCATE
#define taosFtruncate ftruncate
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TDENGINE_OS_LINUX64_H #ifndef TDENGINE_OS_LINUX32_H
#define TDENGINE_OS_LINUX64_H #define TDENGINE_OS_LINUX32_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View File

@ -74,9 +74,9 @@ void taosTMemset(void *ptr, int c);
#define taosCalloc(num, size) taos_calloc(num, size, __FILE__, __LINE__) #define taosCalloc(num, size) taos_calloc(num, size, __FILE__, __LINE__)
#define taosRealloc(ptr, size) taos_realloc(ptr, size, __FILE__, __LINE__) #define taosRealloc(ptr, size) taos_realloc(ptr, size, __FILE__, __LINE__)
#define taosFree(ptr) taos_free(ptr, __FILE__, __LINE__) #define taosFree(ptr) taos_free(ptr, __FILE__, __LINE__)
#define taosStrdup(str) taos_strdup(str, __FILE__, __LINE__) //#define taosStrdup(str) taos_strdup(str, __FILE__, __LINE__)
#define taosStrndup(str, size) taos_strndup(str, size, __FILE__, __LINE__) //#define taosStrndup(str, size) taos_strndup(str, size, __FILE__, __LINE__)
#define taosGetline(lineptr, n, stream) taos_getline(lineptr, n, stream, __FILE__, __LINE__) //#define taosGetline(lineptr, n, stream) taos_getline(lineptr, n, stream, __FILE__, __LINE__)
#endif #endif
#endif #endif

View File

@ -31,6 +31,7 @@ extern "C" {
// TAOS_OS_FUNC_SEMPHONE_PTHREAD // TAOS_OS_FUNC_SEMPHONE_PTHREAD
bool taosCheckPthreadValid(pthread_t thread); bool taosCheckPthreadValid(pthread_t thread);
int64_t taosGetPthreadId(); int64_t taosGetPthreadId();
void taosResetPthread(pthread_t *thread);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TDENGINE_PLATFORM_WINDOWS_H #ifndef TDENGINE_OS_WINDOWS_H
#define TDENGINE_PLATFORM_WINDOWS_H #define TDENGINE_OS_WINDOWS_H
#include <assert.h> #include <assert.h>
#include <ctype.h> #include <ctype.h>
@ -60,10 +60,15 @@ extern "C" {
#define TAOS_OS_FUNC_DIR #define TAOS_OS_FUNC_DIR
#define TAOS_OS_FUNC_FILE #define TAOS_OS_FUNC_FILE
#define TAOS_OS_FUNC_FILE_ISREG
#define TAOS_OS_FUNC_FILE_ISDIR
#define TAOS_OS_FUNC_FILE_ISLNK
#define TAOS_OS_FUNC_FILE_SENDIFLE #define TAOS_OS_FUNC_FILE_SENDIFLE
#define taosFSendFile(outfile, infile, offset, count) taosFSendFileImp(outfile, infile, offset, size) #define taosFSendFile(outfile, infile, offset, count) taosFSendFileImp(outfile, infile, offset, size)
#define taosTSendFile(dfd, sfd, offset, size) taosTSendFileImp(dfd, sfd, offset, size) #define taosTSendFile(dfd, sfd, offset, size) taosTSendFileImp(dfd, sfd, offset, size)
#define TAOS_OS_FUNC_FILE_GETTMPFILEPATH #define TAOS_OS_FUNC_FILE_GETTMPFILEPATH
#define TAOS_OS_FUNC_FILE_FTRUNCATE
extern int taosFtruncate(int fd, int64_t length);
#define TAOS_OS_FUNC_MATH #define TAOS_OS_FUNC_MATH
#define SWAP(a, b, c) \ #define SWAP(a, b, c) \
@ -87,6 +92,7 @@ extern "C" {
#define taosCloseSocket(fd) closesocket(fd) #define taosCloseSocket(fd) closesocket(fd)
#define TAOS_OS_FUNC_STRING_WCHAR #define TAOS_OS_FUNC_STRING_WCHAR
int twcslen(const wchar_t *wcs);
#define TAOS_OS_FUNC_STRING_GETLINE #define TAOS_OS_FUNC_STRING_GETLINE
#define TAOS_OS_FUNC_STRING_STR2INT64 #define TAOS_OS_FUNC_STRING_STR2INT64
#ifdef _TD_GO_DLL_ #ifdef _TD_GO_DLL_
@ -154,6 +160,9 @@ char * strndup(const char *s, size_t n);
#define TCP_KEEPCNT 0x1234 #define TCP_KEEPCNT 0x1234
#define TCP_KEEPIDLE 0x1234 #define TCP_KEEPIDLE 0x1234
#define TCP_KEEPINTVL 0x1234 #define TCP_KEEPINTVL 0x1234
#define SHUT_RDWR SD_BOTH
#define SHUT_RD SD_RECEIVE
#define SHUT_WR SD_SEND
#define LOCK_EX 1 #define LOCK_EX 1
#define LOCK_NB 2 #define LOCK_NB 2

View File

@ -41,7 +41,7 @@ static void taosGetSystemLocale() {
if (cfg_locale && cfg_locale->cfgStatus < TAOS_CFG_CSTATUS_DEFAULT) { if (cfg_locale && cfg_locale->cfgStatus < TAOS_CFG_CSTATUS_DEFAULT) {
char *locale = setlocale(LC_CTYPE, "chs"); char *locale = setlocale(LC_CTYPE, "chs");
if (locale != NULL) { if (locale != NULL) {
strncpy(tsLocale, locale, TSDB_LOCALE_LEN - 1); tstrncpy(tsLocale, locale, TSDB_LOCALE_LEN);
cfg_locale->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT; cfg_locale->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT;
uInfo("locale not configured, set to default:%s", tsLocale); uInfo("locale not configured, set to default:%s", tsLocale);
} }

View File

@ -1,6 +1,12 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8) CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(TDengine) PROJECT(TDengine)
IF (TD_WINDOWS)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/pthread)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/iconv)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/regex)
ENDIF ()
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/inc) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/inc)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/os/inc) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/os/inc)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/util/inc) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/util/inc)

View File

@ -70,7 +70,7 @@ ssize_t taosTReadImp(int fd, void *buf, size_t count) {
char * tbuf = (char *)buf; char * tbuf = (char *)buf;
while (leftbytes > 0) { while (leftbytes > 0) {
readbytes = read(fd, (void *)tbuf, leftbytes); readbytes = read(fd, (void *)tbuf, (uint32_t)leftbytes);
if (readbytes < 0) { if (readbytes < 0) {
if (errno == EINTR) { if (errno == EINTR) {
continue; continue;
@ -94,7 +94,7 @@ ssize_t taosTWriteImp(int fd, void *buf, size_t n) {
char * tbuf = (char *)buf; char * tbuf = (char *)buf;
while (nleft > 0) { while (nleft > 0) {
nwritten = write(fd, (void *)tbuf, nleft); nwritten = write(fd, (void *)tbuf, (uint32_t)nleft);
if (nwritten < 0) { if (nwritten < 0) {
if (errno == EINTR) { if (errno == EINTR) {
continue; continue;
@ -105,7 +105,7 @@ ssize_t taosTWriteImp(int fd, void *buf, size_t n) {
tbuf += nwritten; tbuf += nwritten;
} }
return n; return (ssize_t)n;
} }
#ifndef TAOS_OS_FUNC_FILE_SENDIFLE #ifndef TAOS_OS_FUNC_FILE_SENDIFLE

View File

@ -26,11 +26,11 @@ uint32_t taosSafeRand(void) {
fd = open("/dev/urandom", 0); fd = open("/dev/urandom", 0);
if (fd < 0) { if (fd < 0) {
seed = time(0); seed = (int)time(0);
} else { } else {
int len = read(fd, &seed, sizeof(seed)); int len = read(fd, &seed, sizeof(seed));
if (len < 0) { if (len < 0) {
seed = time(0); seed = (int)time(0);
} }
close(fd); close(fd);
} }

View File

@ -20,5 +20,6 @@
bool taosCheckPthreadValid(pthread_t thread) { return thread != 0; } bool taosCheckPthreadValid(pthread_t thread) { return thread != 0; }
int64_t taosGetPthreadId() { return (int64_t)pthread_self(); } int64_t taosGetPthreadId() { return (int64_t)pthread_self(); }
void taosResetPthread(pthread_t *thread) { *thread = 0; }
#endif #endif

View File

@ -165,7 +165,7 @@ int32_t parseTimezone(char* str, int64_t* tzOffset) {
char* sep = strchr(&str[i], ':'); char* sep = strchr(&str[i], ':');
if (sep != NULL) { if (sep != NULL) {
int32_t len = sep - &str[i]; int32_t len = (int32_t)(sep - &str[i]);
hour = strnatoi(&str[i], len); hour = strnatoi(&str[i], len);
i += len + 1; i += len + 1;
@ -212,7 +212,8 @@ int32_t parseTimeWithTz(char* timestr, int64_t* time, int32_t timePrec) {
/* mktime will be affected by TZ, set by using taos_options */ /* mktime will be affected by TZ, set by using taos_options */
#ifdef WINDOWS #ifdef WINDOWS
int64_t seconds = gmtime(&tm); int64_t seconds = user_mktime64(tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
//int64_t seconds = gmtime(&tm);
#else #else
int64_t seconds = timegm(&tm); int64_t seconds = timegm(&tm);
#endif #endif

View File

@ -15,6 +15,7 @@
#define _DEFAULT_SOURCE #define _DEFAULT_SOURCE
#include "os.h" #include "os.h"
#include "tulog.h"
void taosGetTmpfilePath(const char *fileNamePrefix, char *dstPath) { void taosGetTmpfilePath(const char *fileNamePrefix, char *dstPath) {
const char* tdengineTmpFileNamePrefix = "tdengine-"; const char* tdengineTmpFileNamePrefix = "tdengine-";
@ -78,3 +79,8 @@ ssize_t taosTSendFileImp(int dfd, int sfd, off_t *offset, size_t size) {
uError("taosTSendFileImp no implemented yet"); uError("taosTSendFileImp no implemented yet");
return 0; return 0;
} }
int taosFtruncate(int fd, int64_t length) {
uError("taosFtruncate no implemented yet");
return 0;
}

View File

@ -13,6 +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 "os.h"
#include <WS2tcpip.h> #include <WS2tcpip.h>
#include <IPHlpApi.h> #include <IPHlpApi.h>
#include <winsock2.h> #include <winsock2.h>
@ -33,7 +34,7 @@ void taosWinSocketInit() {
} }
} }
int taosSetNonblocking(SOCKET sock, int on) { int taosSetNonblocking(int sock, int on) {
u_long mode; u_long mode;
if (on) { if (on) {
mode = 1; mode = 1;

View File

@ -67,7 +67,7 @@ char *getpass(const char *prefix) {
} }
char *strndup(const char *s, size_t n) { char *strndup(const char *s, size_t n) {
int len = strlen(s); size_t len = strlen(s);
if (len >= n) { if (len >= n) {
len = n; len = n;
} }
@ -78,13 +78,13 @@ char *strndup(const char *s, size_t n) {
return r; return r;
} }
size_t twcslen(const wchar_t *wcs) { int twcslen(const wchar_t *wcs) {
int *wstr = (int *)wcs; int *wstr = (int *)wcs;
if (NULL == wstr) { if (NULL == wstr) {
return 0; return 0;
} }
size_t n = 0; int n = 0;
while (1) { while (1) {
if (0 == *wstr++) { if (0 == *wstr++) {
break; break;

View File

@ -43,7 +43,7 @@ static void taosGetSystemLocale() {
if (cfg_locale && cfg_locale->cfgStatus < TAOS_CFG_CSTATUS_DEFAULT) { if (cfg_locale && cfg_locale->cfgStatus < TAOS_CFG_CSTATUS_DEFAULT) {
char *locale = setlocale(LC_CTYPE, "chs"); char *locale = setlocale(LC_CTYPE, "chs");
if (locale != NULL) { if (locale != NULL) {
tstrncpy(tsLocale, locale, sizeof(tsLocale)); tstrncpy(tsLocale, locale, TSDB_LOCALE_LEN);;
cfg_locale->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT; cfg_locale->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT;
uInfo("locale not configured, set to default:%s", tsLocale); uInfo("locale not configured, set to default:%s", tsLocale);
} }

View File

@ -82,7 +82,7 @@ void *rpcOpenConnCache(int maxSessions, void (*cleanFp)(void *), void *tmrCtrl,
pCache->cleanFp = cleanFp; pCache->cleanFp = cleanFp;
pCache->tmrCtrl = tmrCtrl; pCache->tmrCtrl = tmrCtrl;
pCache->lockedBy = calloc(sizeof(int64_t), maxSessions); pCache->lockedBy = calloc(sizeof(int64_t), maxSessions);
taosTmrReset(rpcCleanConnCache, pCache->keepTimer * 2, pCache, pCache->tmrCtrl, &pCache->pTimer); taosTmrReset(rpcCleanConnCache, (int32_t)(pCache->keepTimer * 2), pCache, pCache->tmrCtrl, &pCache->pTimer);
pthread_mutex_init(&pCache->mutex, NULL); pthread_mutex_init(&pCache->mutex, NULL);
@ -226,7 +226,7 @@ static void rpcCleanConnCache(void *handle, void *tmrId) {
} }
// tTrace("timer, total connections in cache:%d", pCache->total); // tTrace("timer, total connections in cache:%d", pCache->total);
taosTmrReset(rpcCleanConnCache, pCache->keepTimer * 2, pCache, pCache->tmrCtrl, &pCache->pTimer); taosTmrReset(rpcCleanConnCache, (int32_t)(pCache->keepTimer * 2), pCache, pCache->tmrCtrl, &pCache->pTimer);
} }
static void rpcRemoveExpiredNodes(SConnCache *pCache, SConnHash *pNode, int hash, uint64_t time) { static void rpcRemoveExpiredNodes(SConnCache *pCache, SConnHash *pNode, int hash, uint64_t time) {

View File

@ -33,7 +33,7 @@
#include "rpcHead.h" #include "rpcHead.h"
#define RPC_MSG_OVERHEAD (sizeof(SRpcReqContext) + sizeof(SRpcHead) + sizeof(SRpcDigest)) #define RPC_MSG_OVERHEAD (sizeof(SRpcReqContext) + sizeof(SRpcHead) + sizeof(SRpcDigest))
#define rpcHeadFromCont(cont) ((SRpcHead *) (cont - sizeof(SRpcHead))) #define rpcHeadFromCont(cont) ((SRpcHead *) ((char*)cont - sizeof(SRpcHead)))
#define rpcContFromHead(msg) (msg + sizeof(SRpcHead)) #define rpcContFromHead(msg) (msg + sizeof(SRpcHead))
#define rpcMsgLenFromCont(contLen) (contLen + sizeof(SRpcHead)) #define rpcMsgLenFromCont(contLen) (contLen + sizeof(SRpcHead))
#define rpcContLenFromMsg(msgLen) (msgLen - sizeof(SRpcHead)) #define rpcContLenFromMsg(msgLen) (msgLen - sizeof(SRpcHead))
@ -359,7 +359,7 @@ void rpcSendRequest(void *shandle, const SRpcEpSet *pEpSet, SRpcMsg *pMsg) {
SRpcReqContext *pContext; SRpcReqContext *pContext;
int contLen = rpcCompressRpcMsg(pMsg->pCont, pMsg->contLen); int contLen = rpcCompressRpcMsg(pMsg->pCont, pMsg->contLen);
pContext = (SRpcReqContext *) (pMsg->pCont-sizeof(SRpcHead)-sizeof(SRpcReqContext)); pContext = (SRpcReqContext *) ((char*)pMsg->pCont-sizeof(SRpcHead)-sizeof(SRpcReqContext));
pContext->ahandle = pMsg->ahandle; pContext->ahandle = pMsg->ahandle;
pContext->signature = pContext; pContext->signature = pContext;
pContext->pRpc = (SRpcInfo *)shandle; pContext->pRpc = (SRpcInfo *)shandle;
@ -492,7 +492,7 @@ int rpcGetConnInfo(void *thandle, SRpcConnInfo *pInfo) {
void rpcSendRecv(void *shandle, SRpcEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp) { void rpcSendRecv(void *shandle, SRpcEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp) {
SRpcReqContext *pContext; SRpcReqContext *pContext;
pContext = (SRpcReqContext *) (pMsg->pCont-sizeof(SRpcHead)-sizeof(SRpcReqContext)); pContext = (SRpcReqContext *) ((char*)pMsg->pCont-sizeof(SRpcHead)-sizeof(SRpcReqContext));
memset(pRsp, 0, sizeof(SRpcMsg)); memset(pRsp, 0, sizeof(SRpcMsg));
@ -654,7 +654,7 @@ static SRpcConn *rpcAllocateClientConn(SRpcInfo *pRpc) {
pConn->pRpc = pRpc; pConn->pRpc = pRpc;
pConn->sid = sid; pConn->sid = sid;
pConn->tranId = (uint16_t)(random() & 0xFFFF); pConn->tranId = (uint16_t)(taosRand() & 0xFFFF);
pConn->ownId = htonl(pConn->sid); pConn->ownId = htonl(pConn->sid);
pConn->linkUid = (uint32_t)((int64_t)pConn + (int64_t)getpid() + (int64_t)pConn->tranId); pConn->linkUid = (uint32_t)((int64_t)pConn + (int64_t)getpid() + (int64_t)pConn->tranId);
pConn->spi = pRpc->spi; pConn->spi = pRpc->spi;

View File

@ -81,7 +81,7 @@ void *taosInitTcpServer(uint32_t ip, uint16_t port, char *label, int numOfThread
} }
pServerObj->fd = -1; pServerObj->fd = -1;
pServerObj->thread = 0; taosResetPthread(&pServerObj->thread);
pServerObj->ip = ip; pServerObj->ip = ip;
pServerObj->port = port; pServerObj->port = port;
tstrncpy(pServerObj->label, label, sizeof(pServerObj->label)); tstrncpy(pServerObj->label, label, sizeof(pServerObj->label));
@ -104,7 +104,7 @@ void *taosInitTcpServer(uint32_t ip, uint16_t port, char *label, int numOfThread
pThreadObj = pServerObj->pThreadObj; pThreadObj = pServerObj->pThreadObj;
for (int i = 0; i < numOfThreads; ++i) { for (int i = 0; i < numOfThreads; ++i) {
pThreadObj->pollFd = -1; pThreadObj->pollFd = -1;
pThreadObj->thread = 0; taosResetPthread(&pThreadObj->thread);
pThreadObj->processData = fp; pThreadObj->processData = fp;
tstrncpy(pThreadObj->label, label, sizeof(pThreadObj->label)); tstrncpy(pThreadObj->label, label, sizeof(pThreadObj->label));
pThreadObj->shandle = shandle; pThreadObj->shandle = shandle;

View File

@ -144,7 +144,9 @@ void taosStopUdpConnection(void *handle) {
for (int i = 0; i < pSet->threads; ++i) { for (int i = 0; i < pSet->threads; ++i) {
pConn = pSet->udpConn + i; pConn = pSet->udpConn + i;
if (pConn->thread) pthread_join(pConn->thread, NULL); if (taosCheckPthreadValid(pConn->thread)) {
pthread_join(pConn->thread, NULL);
}
taosTFree(pConn->buffer); taosTFree(pConn->buffer);
// tTrace("%s UDP thread is closed, index:%d", pConn->label, i); // tTrace("%s UDP thread is closed, index:%d", pConn->label, i);
} }

View File

@ -1,4 +1,4 @@
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST) AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST)
add_executable(tsdbTests ${SOURCE_LIST}) add_executable(tsdbTests ${SOURCE_LIST})
target_link_libraries(tsdbTests gtest gtest_main pthread common tsdb tutil trpc) target_link_libraries(tsdbTests gtest gtest_main pthread common tsdb tutil trpc)

View File

@ -53,7 +53,12 @@ static FORCE_INLINE int taosCheckChecksum(const uint8_t *stream, uint32_t ssize,
static FORCE_INLINE int taosCheckChecksumWhole(const uint8_t *stream, uint32_t ssize) { static FORCE_INLINE int taosCheckChecksumWhole(const uint8_t *stream, uint32_t ssize) {
if (ssize < sizeof(TSCKSUM)) return 0; if (ssize < sizeof(TSCKSUM)) return 0;
#if (_WIN64)
return 1;
#else
return *((TSCKSUM *)(stream + ssize - sizeof(TSCKSUM))) == (*crc32c)(0, stream, (size_t)(ssize - sizeof(TSCKSUM))); return *((TSCKSUM *)(stream + ssize - sizeof(TSCKSUM))) == (*crc32c)(0, stream, (size_t)(ssize - sizeof(TSCKSUM)));
#endif
} }
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -196,14 +196,14 @@ static FORCE_INLINE void *taosDecodeFixedI64(void *buf, int64_t *value) {
static FORCE_INLINE int taosEncodeVariantU16(void **buf, uint16_t value) { static FORCE_INLINE int taosEncodeVariantU16(void **buf, uint16_t value) {
int i = 0; int i = 0;
while (value >= ENCODE_LIMIT) { while (value >= ENCODE_LIMIT) {
if (buf != NULL) ((uint8_t *)(*buf))[i] = (value | ENCODE_LIMIT); if (buf != NULL) ((uint8_t *)(*buf))[i] = (uint8_t)(value | ENCODE_LIMIT);
value >>= 7; value >>= 7;
i++; i++;
ASSERT(i < 3); ASSERT(i < 3);
} }
if (buf != NULL) { if (buf != NULL) {
((uint8_t *)(*buf))[i] = value; ((uint8_t *)(*buf))[i] = (uint8_t)value;
*buf = POINTER_SHIFT(*buf, i + 1); *buf = POINTER_SHIFT(*buf, i + 1);
} }
@ -292,14 +292,14 @@ static FORCE_INLINE void *taosDecodeVariantI32(void *buf, int32_t *value) {
static FORCE_INLINE int taosEncodeVariantU64(void **buf, uint64_t value) { static FORCE_INLINE int taosEncodeVariantU64(void **buf, uint64_t value) {
int i = 0; int i = 0;
while (value >= ENCODE_LIMIT) { while (value >= ENCODE_LIMIT) {
if (buf != NULL) ((uint8_t *)(*buf))[i] = (value | ENCODE_LIMIT); if (buf != NULL) ((uint8_t *)(*buf))[i] = (uint8_t)(value | ENCODE_LIMIT);
value >>= 7; value >>= 7;
i++; i++;
ASSERT(i < 10); ASSERT(i < 10);
} }
if (buf != NULL) { if (buf != NULL) {
((uint8_t *)(*buf))[i] = value; ((uint8_t *)(*buf))[i] = (uint8_t)value;
*buf = POINTER_SHIFT(*buf, i + 1); *buf = POINTER_SHIFT(*buf, i + 1);
} }
@ -346,7 +346,7 @@ static FORCE_INLINE int taosEncodeString(void **buf, char *value) {
memcpy(*buf, value, size); memcpy(*buf, value, size);
*buf = POINTER_SHIFT(*buf, size); *buf = POINTER_SHIFT(*buf, size);
} }
tlen += size; tlen += (int)size;
return tlen; return tlen;
} }

View File

@ -68,7 +68,7 @@ typedef struct {
int8_t cfgStatus; int8_t cfgStatus;
int8_t unitType; int8_t unitType;
int8_t valType; int8_t valType;
uint32_t ptrLength; int32_t ptrLength;
} SGlobalCfg; } SGlobalCfg;
extern SGlobalCfg tsGlobalConfig[]; extern SGlobalCfg tsGlobalConfig[];

View File

@ -82,7 +82,7 @@ static FORCE_INLINE int32_t isValidNumber(const SSQLToken* pToken) {
const char* z = pToken->z; const char* z = pToken->z;
int32_t type = TK_ILLEGAL; int32_t type = TK_ILLEGAL;
int32_t i = 0; uint32_t i = 0;
for(; i < pToken->n; ++i) { for(; i < pToken->n; ++i) {
switch (z[i]) { switch (z[i]) {
case '+': case '+':

View File

@ -81,7 +81,7 @@ static FORCE_INLINE void __lock_destroy(void *lock) {
static FORCE_INLINE int32_t taosHashCapacity(int32_t length) { static FORCE_INLINE int32_t taosHashCapacity(int32_t length) {
int32_t len = MIN(length, HASH_MAX_CAPACITY); int32_t len = MIN(length, HASH_MAX_CAPACITY);
uint32_t i = 4; int32_t i = 4;
while (i < len) i = (i << 1u); while (i < len) i = (i << 1u);
return i; return i;
} }
@ -176,7 +176,7 @@ SHashObj *taosHashInit(size_t capacity, _hash_fn_t fn, bool threadsafe) {
} }
// the max slots is not defined by user // the max slots is not defined by user
pHashObj->capacity = taosHashCapacity(capacity); pHashObj->capacity = taosHashCapacity((int32_t)capacity);
assert((pHashObj->capacity & (pHashObj->capacity - 1)) == 0); assert((pHashObj->capacity & (pHashObj->capacity - 1)) == 0);
pHashObj->hashFp = fn; pHashObj->hashFp = fn;
@ -219,7 +219,7 @@ int32_t taosHashPut(SHashObj *pHashObj, const void *key, size_t keyLen, void *da
__wr_lock(pHashObj->lock); __wr_lock(pHashObj->lock);
uint32_t hashVal = 0; uint32_t hashVal = 0;
SHashNode *pNode = doGetNodeFromHashTable(pHashObj, key, keyLen, &hashVal); SHashNode *pNode = doGetNodeFromHashTable(pHashObj, key, (uint32_t)keyLen, &hashVal);
if (pNode == NULL) { // no data in hash table with the specified key, add it into hash table if (pNode == NULL) { // no data in hash table with the specified key, add it into hash table
taosHashTableResize(pHashObj); taosHashTableResize(pHashObj);
@ -261,7 +261,7 @@ void *taosHashGet(SHashObj *pHashObj, const void *key, size_t keyLen) {
__rd_lock(pHashObj->lock); __rd_lock(pHashObj->lock);
uint32_t hashVal = 0; uint32_t hashVal = 0;
SHashNode *pNode = doGetNodeFromHashTable(pHashObj, key, keyLen, &hashVal); SHashNode *pNode = doGetNodeFromHashTable(pHashObj, key, (int32_t)keyLen, &hashVal);
__unlock(pHashObj->lock); __unlock(pHashObj->lock);
@ -278,7 +278,7 @@ void taosHashRemove(SHashObj *pHashObj, const void *key, size_t keyLen) {
__wr_lock(pHashObj->lock); __wr_lock(pHashObj->lock);
uint32_t val = 0; uint32_t val = 0;
SHashNode *pNode = doGetNodeFromHashTable(pHashObj, key, keyLen, &val); SHashNode *pNode = doGetNodeFromHashTable(pHashObj, key, (uint32_t)keyLen, &val);
if (pNode == NULL) { if (pNode == NULL) {
__unlock(pHashObj->lock); __unlock(pHashObj->lock);
return; return;
@ -460,7 +460,7 @@ void taosHashTableResize(SHashObj *pHashObj) {
SHashNode *pNode = NULL; SHashNode *pNode = NULL;
SHashNode *pNext = NULL; SHashNode *pNext = NULL;
int32_t newSize = pHashObj->capacity << 1u; int32_t newSize = (int32_t)(pHashObj->capacity) << 1u;
if (newSize > HASH_MAX_CAPACITY) { if (newSize > HASH_MAX_CAPACITY) {
// uDebug("current capacity:%d, maximum capacity:%d, no resize applied due to limitation is reached", // uDebug("current capacity:%d, maximum capacity:%d, no resize applied due to limitation is reached",
// pHashObj->capacity, HASH_MAX_CAPACITY); // pHashObj->capacity, HASH_MAX_CAPACITY);
@ -539,7 +539,7 @@ SHashNode *doCreateHashNode(const void *key, size_t keyLen, const void *pData, s
pNewNode->key = pNewNode->data + dsize; pNewNode->key = pNewNode->data + dsize;
memcpy(pNewNode->key, key, keyLen); memcpy(pNewNode->key, key, keyLen);
pNewNode->keyLen = keyLen; pNewNode->keyLen = (uint32_t)keyLen;
pNewNode->hashVal = hashVal; pNewNode->hashVal = hashVal;
return pNewNode; return pNewNode;

View File

@ -24,7 +24,7 @@
} while (0); } while (0);
static void median(void *src, size_t size, size_t s, size_t e, const void *param, __ext_compar_fn_t comparFn, void* buf) { static void median(void *src, size_t size, size_t s, size_t e, const void *param, __ext_compar_fn_t comparFn, void* buf) {
int32_t mid = ((e - s) >> 1u) + s; int32_t mid = ((int32_t)(e - s) >> 1u) + (int32_t)s;
if (comparFn(elePtrAt(src, size, mid), elePtrAt(src, size, s), param) == 1) { if (comparFn(elePtrAt(src, size, mid), elePtrAt(src, size, s), param) == 1) {
doswap(elePtrAt(src, size, mid), elePtrAt(src, size, s), size, buf); doswap(elePtrAt(src, size, mid), elePtrAt(src, size, s), size, buf);
@ -152,14 +152,14 @@ static void tqsortImpl(void *src, int32_t start, int32_t end, size_t size, const
void taosqsort(void *src, size_t numOfElem, size_t size, const void* param, __ext_compar_fn_t comparFn) { void taosqsort(void *src, size_t numOfElem, size_t size, const void* param, __ext_compar_fn_t comparFn) {
char *buf = calloc(1, size); // prepare the swap buffer char *buf = calloc(1, size); // prepare the swap buffer
tqsortImpl(src, 0, numOfElem - 1, size, param, comparFn, buf); tqsortImpl(src, 0, (int32_t)numOfElem - 1, (int32_t)size, param, comparFn, buf);
taosTFree(buf); taosTFree(buf);
} }
void * taosbsearch(const void *key, const void *base, size_t nmemb, size_t size, __compar_fn_t compar, int flags) { void * taosbsearch(const void *key, const void *base, size_t nmemb, size_t size, __compar_fn_t compar, int flags) {
// TODO: need to check the correctness of this function // TODO: need to check the correctness of this function
int l = 0; int l = 0;
int r = nmemb; int r = (int)nmemb;
int idx = 0; int idx = 0;
int comparison; int comparison;

View File

@ -120,8 +120,8 @@ void* taosArrayInsert(SArray* pArray, size_t index, void* pData) {
void* dst = TARRAY_GET_ELEM(pArray, index); void* dst = TARRAY_GET_ELEM(pArray, index);
int32_t remain = pArray->size - index; int32_t remain = (int32_t)(pArray->size - index);
memmove(dst + pArray->elemSize, dst, pArray->elemSize * remain); memmove((char*)dst + pArray->elemSize, (char*)dst, pArray->elemSize * remain);
memcpy(dst, pData, pArray->elemSize); memcpy(dst, pData, pArray->elemSize);
pArray->size += 1; pArray->size += 1;
@ -138,7 +138,7 @@ void taosArrayRemove(SArray* pArray, size_t index) {
} }
size_t remain = pArray->size - index - 1; size_t remain = pArray->size - index - 1;
memmove(pArray->pData + index * pArray->elemSize, pArray->pData + (index + 1) * pArray->elemSize, remain * pArray->elemSize); memmove((char*)pArray->pData + index * pArray->elemSize, (char*)pArray->pData + (index + 1) * pArray->elemSize, remain * pArray->elemSize);
pArray->size -= 1; pArray->size -= 1;
} }

View File

@ -17,7 +17,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <memory.h> #include <memory.h>
#include <assert.h> #include <assert.h>
#include <arpa/inet.h>
#include "tbuffer.h" #include "tbuffer.h"
#include "exception.h" #include "exception.h"
#include <taoserror.h> #include <taoserror.h>

View File

@ -292,7 +292,7 @@ void *taosCachePut(SCacheObj *pCacheObj, const void *key, size_t keyLen, const v
uError("cache:%s, key:%p, failed to added into cache, out of memory", pCacheObj->name, key); uError("cache:%s, key:%p, failed to added into cache, out of memory", pCacheObj->name, key);
} }
} else { // old data exists, update the node } else { // old data exists, update the node
pNode = taosUpdateCacheImpl(pCacheObj, pOld, key, keyLen, pData, dataSize, duration * 1000L); pNode = taosUpdateCacheImpl(pCacheObj, pOld, key, (int32_t)keyLen, pData, (uint32_t)dataSize, duration * 1000L);
uDebug("cache:%s, key:%p, %p exist in cache, updated old:%p", pCacheObj->name, key, pNode->data, pOld); uDebug("cache:%s, key:%p, %p exist in cache, updated old:%p", pCacheObj->name, key, pNode->data, pOld);
} }
@ -509,7 +509,7 @@ SCacheDataNode *taosCreateCacheNode(const char *key, size_t keyLen, const char *
memcpy(pNewNode->data, pData, size); memcpy(pNewNode->data, pData, size);
pNewNode->key = (char *)pNewNode + sizeof(SCacheDataNode) + size; pNewNode->key = (char *)pNewNode + sizeof(SCacheDataNode) + size;
pNewNode->keySize = keyLen; pNewNode->keySize = (uint16_t)keyLen;
memcpy(pNewNode->key, key, keyLen); memcpy(pNewNode->key, key, keyLen);
@ -645,7 +645,7 @@ static void doCacheRefresh(SCacheObj* pCacheObj, int64_t time, __cache_free_fn_t
while (taosHashIterNext(pIter)) { while (taosHashIterNext(pIter)) {
SCacheDataNode *pNode = *(SCacheDataNode **)taosHashIterGet(pIter); SCacheDataNode *pNode = *(SCacheDataNode **)taosHashIterGet(pIter);
if (pNode->expireTime < time && T_REF_VAL_GET(pNode) <= 0) { if (pNode->expireTime < (uint64_t)time && T_REF_VAL_GET(pNode) <= 0) {
taosCacheReleaseNode(pCacheObj, pNode); taosCacheReleaseNode(pCacheObj, pNode);
continue; continue;
} }

View File

@ -52,14 +52,13 @@
#include "tscompression.h" #include "tscompression.h"
#include "taosdef.h" #include "taosdef.h"
const int TEST_NUMBER = 1; static const int TEST_NUMBER = 1;
#define is_bigendian() ((*(char *)&TEST_NUMBER) == 0) #define is_bigendian() ((*(char *)&TEST_NUMBER) == 0)
#define SIMPLE8B_MAX_INT64 ((uint64_t)2305843009213693951L) #define SIMPLE8B_MAX_INT64 ((uint64_t)2305843009213693951L)
bool safeInt64Add(int64_t a, int64_t b) { #define safeInt64Add(a, b) (((a >= 0) && (b <= INT64_MAX - a)) || ((a < 0) && (b >= INT64_MIN - a)))
if ((a > 0 && b > INT64_MAX - a) || (a < 0 && b < INT64_MIN - a)) return false; #define ZIGZAG_ENCODE(T, v) ((u##T)((v) >> (sizeof(T) * 8 - 1))) ^ (((u##T)(v)) << 1) // zigzag encode
return true; #define ZIGZAG_DECODE(T, v) ((v) >> 1) ^ -((T)((v)&1)) // zigzag decode
}
/* /*
* Compress Integer (Simple8B). * Compress Integer (Simple8B).
@ -90,7 +89,7 @@ int tsCompressINTImp(const char *const input, const int nelements, char *const o
break; break;
default: default:
perror("Wrong integer types.\n"); perror("Wrong integer types.\n");
exit(1); return -1;
} }
int byte_limit = nelements * word_length + 1; int byte_limit = nelements * word_length + 1;
@ -125,11 +124,11 @@ int tsCompressINTImp(const char *const input, const int nelements, char *const o
int64_t diff = curr_value - prev_value_tmp; int64_t diff = curr_value - prev_value_tmp;
// Zigzag encode the value. // Zigzag encode the value.
uint64_t zigzag_value = (diff >> (LONG_BYTES * BITS_PER_BYTE - 1)) ^ (diff << 1); uint64_t zigzag_value = ZIGZAG_ENCODE(int64_t, diff);
if (zigzag_value >= SIMPLE8B_MAX_INT64) goto _copy_and_exit; if (zigzag_value >= SIMPLE8B_MAX_INT64) goto _copy_and_exit;
char tmp_bit; int64_t tmp_bit;
if (zigzag_value == 0) { if (zigzag_value == 0) {
// Take care here, __builtin_clzl give wrong anser for value 0; // Take care here, __builtin_clzl give wrong anser for value 0;
tmp_bit = 0; tmp_bit = 0;
@ -171,7 +170,7 @@ int tsCompressINTImp(const char *const input, const int nelements, char *const o
break; break;
} }
int64_t diff = curr_value - prev_value; int64_t diff = curr_value - prev_value;
uint64_t zigzag_value = (diff >> (LONG_BYTES * BITS_PER_BYTE - 1)) ^ (diff << 1); uint64_t zigzag_value = ZIGZAG_ENCODE(int64_t, diff);
buffer |= ((zigzag_value & INT64MASK(bit)) << (bit * k + 4)); buffer |= ((zigzag_value & INT64MASK(bit)) << (bit * k + 4));
i++; i++;
prev_value = curr_value; prev_value = curr_value;
@ -211,7 +210,7 @@ int tsDecompressINTImp(const char *const input, const int nelements, char *const
break; break;
default: default:
perror("Wrong integer types.\n"); perror("Wrong integer types.\n");
exit(1); return -1;
} }
// If not compressed. // If not compressed.
@ -248,30 +247,30 @@ int tsDecompressINTImp(const char *const input, const int nelements, char *const
} else { } else {
zigzag_value = ((w >> (4 + bit * i)) & INT64MASK(bit)); zigzag_value = ((w >> (4 + bit * i)) & INT64MASK(bit));
} }
int64_t diff = (zigzag_value >> 1) ^ -(zigzag_value & 1); int64_t diff = ZIGZAG_DECODE(int64_t, zigzag_value);
int64_t curr_value = diff + prev_value; int64_t curr_value = diff + prev_value;
prev_value = curr_value; prev_value = curr_value;
switch (type) { switch (type) {
case TSDB_DATA_TYPE_BIGINT: case TSDB_DATA_TYPE_BIGINT:
*((int64_t *)output + _pos) = curr_value; *((int64_t *)output + _pos) = (int64_t)curr_value;
_pos++; _pos++;
break; break;
case TSDB_DATA_TYPE_INT: case TSDB_DATA_TYPE_INT:
*((int32_t *)output + _pos) = curr_value; *((int32_t *)output + _pos) = (int32_t)curr_value;
_pos++; _pos++;
break; break;
case TSDB_DATA_TYPE_SMALLINT: case TSDB_DATA_TYPE_SMALLINT:
*((int16_t *)output + _pos) = curr_value; *((int16_t *)output + _pos) = (int16_t)curr_value;
_pos++; _pos++;
break; break;
case TSDB_DATA_TYPE_TINYINT: case TSDB_DATA_TYPE_TINYINT:
*((int8_t *)output + _pos) = curr_value; *((int8_t *)output + _pos) = (int8_t)curr_value;
_pos++; _pos++;
break; break;
default: default:
perror("Wrong integer types.\n"); perror("Wrong integer types.\n");
exit(1); return -1;
} }
count++; count++;
if (count == nelements) break; if (count == nelements) break;
@ -309,7 +308,7 @@ int tsCompressBoolImp(const char *const input, const int nelements, char *const
output[pos] |= t; output[pos] |= t;
} else { } else {
perror("Wrong bool value.\n"); perror("Wrong bool value.\n");
exit(1); return -1;
} }
} }
@ -365,7 +364,7 @@ int tsCompressBoolRLEImp(const char *const input, const int nelements, char *con
output[_pos++] = (counter << 1) | INT8MASK(0); output[_pos++] = (counter << 1) | INT8MASK(0);
} else { } else {
perror("Wrong bool value!\n"); perror("Wrong bool value!\n");
exit(1); return -1;
} }
} }
@ -417,7 +416,7 @@ int tsDecompressStringImp(const char *const input, int compressedSize, char *con
char msg[128] = {0}; char msg[128] = {0};
sprintf(msg, "decomp_size:%d, Error decompress in LZ4 algorithm!\n", decompressed_size); sprintf(msg, "decomp_size:%d, Error decompress in LZ4 algorithm!\n", decompressed_size);
perror(msg); perror(msg);
exit(EXIT_FAILURE); return -1;
} }
return decompressed_size; return decompressed_size;
@ -427,7 +426,7 @@ int tsDecompressStringImp(const char *const input, int compressedSize, char *con
return compressedSize - 1; return compressedSize - 1;
} else { } else {
perror("Wrong compressed string indicator!\n"); perror("Wrong compressed string indicator!\n");
exit(EXIT_FAILURE); return -1;
} }
} }
@ -454,21 +453,21 @@ int tsCompressTimestampImp(const char *const input, const int nelements, char *c
if (!safeInt64Add(curr_delta, -prev_delta)) goto _exit_over; if (!safeInt64Add(curr_delta, -prev_delta)) goto _exit_over;
int64_t delta_of_delta = curr_delta - prev_delta; int64_t delta_of_delta = curr_delta - prev_delta;
// zigzag encode the value. // zigzag encode the value.
uint64_t zigzag_value = (delta_of_delta >> (LONG_BYTES * BITS_PER_BYTE - 1)) ^ (delta_of_delta << 1); uint64_t zigzag_value = ZIGZAG_ENCODE(int64_t, delta_of_delta);
if (i % 2 == 0) { if (i % 2 == 0) {
flags = 0; flags = 0;
dd1 = zigzag_value; dd1 = zigzag_value;
if (dd1 == 0) { if (dd1 == 0) {
flag1 = 0; flag1 = 0;
} else { } else {
flag1 = LONG_BYTES - BUILDIN_CLZL(dd1) / BITS_PER_BYTE; flag1 = (uint8_t)(LONG_BYTES - BUILDIN_CLZL(dd1) / BITS_PER_BYTE);
} }
} else { } else {
dd2 = zigzag_value; dd2 = zigzag_value;
if (dd2 == 0) { if (dd2 == 0) {
flag2 = 0; flag2 = 0;
} else { } else {
flag2 = LONG_BYTES - BUILDIN_CLZL(dd2) / BITS_PER_BYTE; flag2 = (uint8_t)(LONG_BYTES - BUILDIN_CLZL(dd2) / BITS_PER_BYTE);
} }
flags = flag1 | (flag2 << 4); flags = flag1 | (flag2 << 4);
// Encode the flag. // Encode the flag.
@ -555,7 +554,7 @@ int tsDecompressTimestampImp(const char *const input, const int nelements, char
} else { } else {
memcpy(&dd1, input + ipos, nbytes); memcpy(&dd1, input + ipos, nbytes);
} }
delta_of_delta = (dd1 >> 1) ^ -(dd1 & 1); delta_of_delta = ZIGZAG_DECODE(int64_t, dd1);
} }
ipos += nbytes; ipos += nbytes;
if (opos == 0) { if (opos == 0) {
@ -581,7 +580,7 @@ int tsDecompressTimestampImp(const char *const input, const int nelements, char
memcpy(&dd2, input + ipos, nbytes); memcpy(&dd2, input + ipos, nbytes);
} }
// zigzag_decoding // zigzag_decoding
delta_of_delta = (dd2 >> 1) ^ -(dd2 & 1); delta_of_delta = ZIGZAG_DECODE(int64_t, dd2);
} }
ipos += nbytes; ipos += nbytes;
prev_delta = delta_of_delta + prev_delta; prev_delta = delta_of_delta + prev_delta;
@ -643,12 +642,12 @@ int tsCompressDoubleImp(const char *const input, const int nelements, char *cons
uint8_t flag; uint8_t flag;
if (trailing_zeros > leading_zeros) { if (trailing_zeros > leading_zeros) {
nbytes = LONG_BYTES - trailing_zeros / BITS_PER_BYTE; nbytes = (uint8_t)(LONG_BYTES - trailing_zeros / BITS_PER_BYTE);
if (nbytes > 0) nbytes--; if (nbytes > 0) nbytes--;
flag = ((uint8_t)1 << 3) | nbytes; flag = ((uint8_t)1 << 3) | nbytes;
} else { } else {
nbytes = LONG_BYTES - leading_zeros / BITS_PER_BYTE; nbytes = (uint8_t)(LONG_BYTES - leading_zeros / BITS_PER_BYTE);
if (nbytes > 0) nbytes--; if (nbytes > 0) nbytes--;
flag = nbytes; flag = nbytes;
} }
@ -790,12 +789,12 @@ int tsCompressFloatImp(const char *const input, const int nelements, char *const
uint8_t flag; uint8_t flag;
if (trailing_zeros > leading_zeros) { if (trailing_zeros > leading_zeros) {
nbytes = FLOAT_BYTES - trailing_zeros / BITS_PER_BYTE; nbytes = (uint8_t)(FLOAT_BYTES - trailing_zeros / BITS_PER_BYTE);
if (nbytes > 0) nbytes--; if (nbytes > 0) nbytes--;
flag = ((uint8_t)1 << 3) | nbytes; flag = ((uint8_t)1 << 3) | nbytes;
} else { } else {
nbytes = FLOAT_BYTES - leading_zeros / BITS_PER_BYTE; nbytes = (uint8_t)(FLOAT_BYTES - leading_zeros / BITS_PER_BYTE);
if (nbytes > 0) nbytes--; if (nbytes > 0) nbytes--;
flag = nbytes; flag = nbytes;
} }

View File

@ -98,7 +98,7 @@ static void taosReadInt16Config(SGlobalCfg *cfg, char *input_value) {
} }
static void taosReadDirectoryConfig(SGlobalCfg *cfg, char *input_value) { static void taosReadDirectoryConfig(SGlobalCfg *cfg, char *input_value) {
int length = strlen(input_value); int length = (int)strlen(input_value);
char *option = (char *)cfg->ptr; char *option = (char *)cfg->ptr;
if (length <= 0 || length > cfg->ptrLength) { if (length <= 0 || length > cfg->ptrLength) {
uError("config option:%s, input value:%s, length out of range[0, %d], use default value:%s", uError("config option:%s, input value:%s, length out of range[0, %d], use default value:%s",
@ -150,7 +150,7 @@ static void taosReadIpStrConfig(SGlobalCfg *cfg, char *input_value) {
} }
static void taosReadStringConfig(SGlobalCfg *cfg, char *input_value) { static void taosReadStringConfig(SGlobalCfg *cfg, char *input_value) {
int length = strlen(input_value); int length = (int) strlen(input_value);
char *option = (char *)cfg->ptr; char *option = (char *)cfg->ptr;
if (length <= 0 || length > cfg->ptrLength) { if (length <= 0 || length > cfg->ptrLength) {
uError("config option:%s, input value:%s, length out of range[0, %d], use default value:%s", uError("config option:%s, input value:%s, length out of range[0, %d], use default value:%s",
@ -283,7 +283,7 @@ void taosReadGlobalLogCfg() {
option = value = NULL; option = value = NULL;
olen = vlen = 0; olen = vlen = 0;
getline(&line, &len, fp); taosGetline(&line, &len, fp);
line[len - 1] = 0; line[len - 1] = 0;
paGetToken(line, &option, &olen); paGetToken(line, &option, &olen);
@ -329,7 +329,7 @@ bool taosReadGlobalCfg() {
option = value = NULL; option = value = NULL;
olen = vlen = 0; olen = vlen = 0;
getline(&line, &len, fp); taosGetline(&line, &len, fp);
line[len - 1] = 0; line[len - 1] = 0;
paGetToken(line, &option, &olen); paGetToken(line, &option, &olen);

View File

@ -1353,12 +1353,12 @@ uint32_t crc32c_hw(uint32_t crc, crc_stream buf, size_t len) {
#endif // #ifndef _TD_ARM_ #endif // #ifndef _TD_ARM_
void taosResolveCRC() { void taosResolveCRC() {
#ifndef _TD_ARM_ #if defined _TD_ARM_ || defined WINDOWS
crc32c = crc32c_sf;
#else
int sse42; int sse42;
SSE42(sse42); SSE42(sse42);
crc32c = sse42 ? crc32c_hw : crc32c_sf; crc32c = sse42 ? crc32c_hw : crc32c_sf;
#else
crc32c = crc32c_sf;
#endif #endif
/* return sse42 ? crc32c_hw(crci, bytes, len) : crc32c_sf(crci, bytes, len); /* return sse42 ? crc32c_hw(crci, bytes, len) : crc32c_sf(crci, bytes, len);
*/ */

View File

@ -49,7 +49,7 @@ static int tsCompareTaosError(const void* a, const void* b) {
} }
static pthread_once_t tsErrorInit = PTHREAD_ONCE_INIT; static pthread_once_t tsErrorInit = PTHREAD_ONCE_INIT;
static void tsSortError() { static void tsSortError(void) {
qsort(errors, sizeof(errors)/sizeof(errors[0]), sizeof(errors[0]), tsCompareTaosError); qsort(errors, sizeof(errors)/sizeof(errors[0]), sizeof(errors[0]), tsCompareTaosError);
} }

View File

@ -78,7 +78,7 @@ uint32_t taosIntHash_64(const char *key, uint32_t UNUSED_PARAM(len)) {
uint64_t hash = val >> 16U; uint64_t hash = val >> 16U;
hash += (val & 0xFFFFU); hash += (val & 0xFFFFU);
return hash; return (uint32_t)hash;
} }
_hash_fn_t taosGetDefaultHashFunction(int32_t type) { _hash_fn_t taosGetDefaultHashFunction(int32_t type) {

View File

@ -120,7 +120,7 @@ SKVStore *tdOpenKVStore(char *fname, iterFunc iFunc, afterFunc aFunc, void *appH
version, KVSTORE_FILE_VERSION); version, KVSTORE_FILE_VERSION);
} }
if (ftruncate(pStore->fd, info.size) < 0) { if (taosFtruncate(pStore->fd, info.size) < 0) {
uError("failed to truncate %s to %" PRId64 " size since %s", pStore->fname, info.size, strerror(errno)); uError("failed to truncate %s to %" PRId64 " size since %s", pStore->fname, info.size, strerror(errno));
terrno = TAOS_SYSTEM_ERROR(errno); terrno = TAOS_SYSTEM_ERROR(errno);
goto _err; goto _err;
@ -296,7 +296,7 @@ int tdDropKVStoreRecord(SKVStore *pStore, uint64_t uid) {
return -1; return -1;
} }
pStore->info.magic = taosCalcChecksum(pStore->info.magic, (uint8_t *)buf, POINTER_DISTANCE(pBuf, buf)); pStore->info.magic = taosCalcChecksum(pStore->info.magic, (uint8_t *)buf, (uint32_t)POINTER_DISTANCE(pBuf, buf));
pStore->info.size += POINTER_DISTANCE(pBuf, buf); pStore->info.size += POINTER_DISTANCE(pBuf, buf);
pStore->info.nDels++; pStore->info.nDels++;
pStore->info.nRecords--; pStore->info.nRecords--;
@ -498,7 +498,7 @@ static void *tdDecodeKVRecord(void *buf, SKVRecord *pRecord) {
static int tdRestoreKVStore(SKVStore *pStore) { static int tdRestoreKVStore(SKVStore *pStore) {
char tbuf[128] = "\0"; char tbuf[128] = "\0";
void * buf = NULL; void * buf = NULL;
int maxBufSize = 0; int64_t maxBufSize = 0;
SKVRecord rInfo = {0}; SKVRecord rInfo = {0};
SHashMutableIterator *pIter = NULL; SHashMutableIterator *pIter = NULL;
@ -535,7 +535,7 @@ static int tdRestoreKVStore(SKVStore *pStore) {
maxBufSize = MAX(maxBufSize, rInfo.size); maxBufSize = MAX(maxBufSize, rInfo.size);
if (lseek(pStore->fd, rInfo.size, SEEK_CUR) < 0) { if (lseek(pStore->fd, (off_t)rInfo.size, SEEK_CUR) < 0) {
uError("failed to lseek file %s since %s", pStore->fname, strerror(errno)); uError("failed to lseek file %s since %s", pStore->fname, strerror(errno));
terrno = TAOS_SYSTEM_ERROR(errno); terrno = TAOS_SYSTEM_ERROR(errno);
goto _err; goto _err;
@ -548,7 +548,7 @@ static int tdRestoreKVStore(SKVStore *pStore) {
buf = malloc(maxBufSize); buf = malloc(maxBufSize);
if (buf == NULL) { if (buf == NULL) {
uError("failed to allocate %d bytes in KV store %s", maxBufSize, pStore->fname); uError("failed to allocate %" PRId64 " bytes in KV store %s", maxBufSize, pStore->fname);
terrno = TAOS_SYSTEM_ERROR(errno); terrno = TAOS_SYSTEM_ERROR(errno);
goto _err; goto _err;
} }
@ -563,7 +563,7 @@ static int tdRestoreKVStore(SKVStore *pStore) {
while (taosHashIterNext(pIter)) { while (taosHashIterNext(pIter)) {
SKVRecord *pRecord = taosHashIterGet(pIter); SKVRecord *pRecord = taosHashIterGet(pIter);
if (lseek(pStore->fd, pRecord->offset + sizeof(SKVRecord), SEEK_SET) < 0) { if (lseek(pStore->fd, (off_t)(pRecord->offset + sizeof(SKVRecord)), SEEK_SET) < 0) {
uError("failed to lseek file %s since %s, offset %" PRId64, pStore->fname, strerror(errno), pRecord->offset); uError("failed to lseek file %s since %s, offset %" PRId64, pStore->fname, strerror(errno), pRecord->offset);
terrno = TAOS_SYSTEM_ERROR(errno); terrno = TAOS_SYSTEM_ERROR(errno);
goto _err; goto _err;
@ -577,7 +577,7 @@ static int tdRestoreKVStore(SKVStore *pStore) {
} }
if (pStore->iFunc) { if (pStore->iFunc) {
if ((*pStore->iFunc)(pStore->appH, buf, pRecord->size) < 0) { if ((*pStore->iFunc)(pStore->appH, buf, (int)pRecord->size) < 0) {
uError("failed to restore record uid %" PRIu64 " in kv store %s at offset %" PRId64 " size %" PRId64 uError("failed to restore record uid %" PRIu64 " in kv store %s at offset %" PRId64 " size %" PRId64
" since %s", " since %s",
pRecord->uid, pStore->fname, pRecord->offset, pRecord->size, tstrerror(terrno)); pRecord->uid, pStore->fname, pRecord->offset, pRecord->size, tstrerror(terrno));

View File

@ -65,7 +65,7 @@ typedef struct {
int32_t tsAsyncLog = 1; int32_t tsAsyncLog = 1;
float tsTotalLogDirGB = 0; float tsTotalLogDirGB = 0;
float tsAvailLogDirGB = 0; float tsAvailLogDirGB = 0;
float tsMinimalLogDirGB = 0.1; float tsMinimalLogDirGB = 0.1f;
char tsLogDir[TSDB_FILENAME_LEN] = "/var/log/taos"; char tsLogDir[TSDB_FILENAME_LEN] = "/var/log/taos";
static SLogObj tsLogObj = { .fileNum = 1 }; static SLogObj tsLogObj = { .fileNum = 1 };

View File

@ -13,11 +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 <pthread.h> #include "os.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "tulog.h" #include "tulog.h"
#include "tmempool.h" #include "tmempool.h"
#include "tutil.h" #include "tutil.h"

View File

@ -192,12 +192,12 @@ void taosCleanUpScheduler(void *param) {
pSched->stop = true; pSched->stop = true;
for (int i = 0; i < pSched->numOfThreads; ++i) { for (int i = 0; i < pSched->numOfThreads; ++i) {
if (pSched->qthread[i]) { if (taosCheckPthreadValid(pSched->qthread[i])) {
tsem_post(&pSched->fullSem); tsem_post(&pSched->fullSem);
} }
} }
for (int i = 0; i < pSched->numOfThreads; ++i) { for (int i = 0; i < pSched->numOfThreads; ++i) {
if (pSched->qthread[i]) { if (taosCheckPthreadValid(pSched->qthread[i])) {
pthread_join(pSched->qthread[i], NULL); pthread_join(pSched->qthread[i], NULL);
} }
} }

View File

@ -19,7 +19,7 @@
#include "tutil.h" #include "tutil.h"
#include "tcompare.h" #include "tcompare.h"
__attribute__ ((unused)) static FORCE_INLINE void recordNodeEachLevel(SSkipList *pSkipList, int32_t level) { // record link count in each level UNUSED_FUNC static FORCE_INLINE void recordNodeEachLevel(SSkipList *pSkipList, int32_t level) { // record link count in each level
#if SKIP_LIST_RECORD_PERFORMANCE #if SKIP_LIST_RECORD_PERFORMANCE
for (int32_t i = 0; i < level; ++i) { for (int32_t i = 0; i < level; ++i) {
pSkipList->state.nLevelNodeCnt[i]++; pSkipList->state.nLevelNodeCnt[i]++;
@ -27,7 +27,7 @@ __attribute__ ((unused)) static FORCE_INLINE void recordNodeEachLevel(SSkipList
#endif #endif
} }
__attribute__ ((unused)) static FORCE_INLINE void removeNodeEachLevel(SSkipList *pSkipList, int32_t level) { UNUSED_FUNC static FORCE_INLINE void removeNodeEachLevel(SSkipList *pSkipList, int32_t level) {
#if SKIP_LIST_RECORD_PERFORMANCE #if SKIP_LIST_RECORD_PERFORMANCE
for (int32_t i = 0; i < level; ++i) { for (int32_t i = 0; i < level; ++i) {
pSkipList->state.nLevelNodeCnt[i]--; pSkipList->state.nLevelNodeCnt[i]--;
@ -132,7 +132,7 @@ static bool initForwardBackwardPtr(SSkipList* pSkipList) {
pSkipList->pTail = (SSkipListNode*) ((char*) pSkipList->pHead + SL_NODE_HEADER_SIZE(maxLevel)); pSkipList->pTail = (SSkipListNode*) ((char*) pSkipList->pHead + SL_NODE_HEADER_SIZE(maxLevel));
pSkipList->pTail->level = pSkipList->maxLevel; pSkipList->pTail->level = pSkipList->maxLevel;
for(int32_t i = 0; i < maxLevel; ++i) { for (uint32_t i = 0; i < maxLevel; ++i) {
SL_GET_FORWARD_POINTER(pSkipList->pHead, i) = pSkipList->pTail; SL_GET_FORWARD_POINTER(pSkipList->pHead, i) = pSkipList->pTail;
SL_GET_BACKWARD_POINTER(pSkipList->pTail, i) = pSkipList->pHead; SL_GET_BACKWARD_POINTER(pSkipList->pTail, i) = pSkipList->pHead;
} }
@ -177,7 +177,7 @@ SSkipList *tSkipListCreate(uint8_t maxLevel, uint8_t keyType, uint8_t keyLen, ui
} }
} }
srand(time(NULL)); srand((uint32_t)time(NULL));
#if SKIP_LIST_RECORD_PERFORMANCE #if SKIP_LIST_RECORD_PERFORMANCE
pSkipList->state.nTotalMemSize += sizeof(SSkipList); pSkipList->state.nTotalMemSize += sizeof(SSkipList);

View File

@ -445,7 +445,7 @@ bool taosTmrStopA(tmr_h* timerId) {
bool taosTmrReset(TAOS_TMR_CALLBACK fp, int mseconds, void* param, void* handle, tmr_h* pTmrId) { bool taosTmrReset(TAOS_TMR_CALLBACK fp, int mseconds, void* param, void* handle, tmr_h* pTmrId) {
tmr_ctrl_t* ctrl = (tmr_ctrl_t*)handle; tmr_ctrl_t* ctrl = (tmr_ctrl_t*)handle;
if (ctrl == NULL || ctrl->label[0] == 0) { if (ctrl == NULL || ctrl->label[0] == 0) {
return NULL; return false;
} }
uintptr_t id = (uintptr_t)*pTmrId; uintptr_t id = (uintptr_t)*pTmrId;
@ -491,7 +491,7 @@ static void taosTmrModuleInit(void) {
return; return;
} }
for (int i = 0; i < tsMaxTmrCtrl - 1; ++i) { for (uint32_t i = 0; i < tsMaxTmrCtrl - 1; ++i) {
tmr_ctrl_t* ctrl = tmrCtrls + i; tmr_ctrl_t* ctrl = tmrCtrls + i;
ctrl->next = ctrl + 1; ctrl->next = ctrl + 1;
} }

View File

@ -273,7 +273,7 @@ char *strbetween(char *string, char *begin, char *end) {
char *_begin = strstr(string, begin); char *_begin = strstr(string, begin);
if (_begin != NULL) { if (_begin != NULL) {
char *_end = strstr(_begin + strlen(begin), end); char *_end = strstr(_begin + strlen(begin), end);
int size = _end - _begin; int size = (int)(_end - _begin);
if (_end != NULL && size > 0) { if (_end != NULL && size > 0) {
result = (char *)calloc(1, size); result = (char *)calloc(1, size);
memcpy(result, _begin + strlen(begin), size - +strlen(begin)); memcpy(result, _begin + strlen(begin), size - +strlen(begin));
@ -332,7 +332,7 @@ bool taosGetVersionNumber(char *versionStr, int *versionNubmer) {
} }
int versionNumberPos[5] = {0}; int versionNumberPos[5] = {0};
int len = strlen(versionStr); int len = (int)strlen(versionStr);
int dot = 0; int dot = 0;
for (int pos = 0; pos < len && dot < 4; ++pos) { for (int pos = 0; pos < len && dot < 4; ++pos) {
if (versionStr[pos] == '.') { if (versionStr[pos] == '.') {

View File

@ -32,7 +32,14 @@ function buildTDengine {
echo "repo need to pull" echo "repo need to pull"
git reset --hard git reset --hard
git pull git pull
fi
[ -d $TDENGINE_DIR/debug ] || mkdir $TDENGINE_DIR/debug
cd $TDENGINE_DIR/debug
[ -f $TDENGINE_DIR/debug/build/bin/taosd ] || need_rebuild=true
if $need_rebuild ; then
echo "rebuild.."
LOCAL_COMMIT=`git rev-parse --short @` LOCAL_COMMIT=`git rev-parse --short @`
rm -rf * rm -rf *
@ -46,10 +53,9 @@ function buildTDengine {
function runGeneralCaseOneByOne { function runGeneralCaseOneByOne {
while read -r line; do while read -r line; do
if [[ $line =~ ^./test.sh* ]]; then if [[ $line =~ ^./test.sh* ]]; then
general_case=`echo $line | grep -w general` case=`echo $line | grep -w "general\|unique\/mnode\/mgmt33.sim\|unique\/stable\/dnode3.sim\|unique\/cluster\/balance3.sim\|unique\/arbitrator\/offline_replica2_alterTable_online.sim"|awk '{print $NF}'`
if [ -n "$general_case" ]; then if [ -n "$case" ]; then
case=`echo $line |grep general| awk '{print $NF}'`
./test.sh -f $case > /dev/null 2>&1 && \ ./test.sh -f $case > /dev/null 2>&1 && \
echo -e "${GREEN}$case success${NC}" | tee -a $TDENGINE_COVERAGE_REPORT || \ echo -e "${GREEN}$case success${NC}" | tee -a $TDENGINE_COVERAGE_REPORT || \
echo -e "${RED}$case failed${NC}" | tee -a $TDENGINE_COVERAGE_REPORT echo -e "${RED}$case failed${NC}" | tee -a $TDENGINE_COVERAGE_REPORT
@ -90,14 +96,14 @@ function runTest {
sleep 10 sleep 10
cd $TDENGINE_DIR/src/connector/jdbc cd $TDENGINE_DIR/src/connector/jdbc
mvn clean package mvn clean package > /dev/null 2>&1
mvn test | tee -a $TDENGINE_COVERAGE_REPORT mvn test > /dev/null 2>&1 | tee -a $TDENGINE_COVERAGE_REPORT
# Test C Demo # Test C Demo
stopTaosd stopTaosd
$TDENGINE_DIR/debug/build/bin/taosd -c $TDENGINE_DIR/debug/test/cfg > /dev/null & $TDENGINE_DIR/debug/build/bin/taosd -c $TDENGINE_DIR/debug/test/cfg > /dev/null &
sleep 10 sleep 10
yes | $TDENGINE_DIR/debug/build/bin/demo 127.0.0.1 | tee -a $TDENGINE_COVERAGE_REPORT yes | $TDENGINE_DIR/debug/build/bin/demo 127.0.0.1 > /dev/null 2>&1 | tee -a $TDENGINE_COVERAGE_REPORT
# Test waltest # Test waltest
dataDir=`grep dataDir $TDENGINE_DIR/debug/test/cfg/taos.cfg|awk '{print $2}'` dataDir=`grep dataDir $TDENGINE_DIR/debug/test/cfg/taos.cfg|awk '{print $2}'`
@ -105,14 +111,14 @@ function runTest {
echo "dataDir: $dataDir" | tee -a $TDENGINE_COVERAGE_REPORT echo "dataDir: $dataDir" | tee -a $TDENGINE_COVERAGE_REPORT
echo "walDir: $walDir" | tee -a $TDENGINE_COVERAGE_REPORT echo "walDir: $walDir" | tee -a $TDENGINE_COVERAGE_REPORT
if [ -n "$walDir" ]; then if [ -n "$walDir" ]; then
yes | $TDENGINE_DIR/debug/build/bin/waltest -p $walDir | tee -a $TDENGINE_COVERAGE_REPORT yes | $TDENGINE_DIR/debug/build/bin/waltest -p $walDir > dev/null 2>&1 | tee -a $TDENGINE_COVERAGE_REPORT
fi fi
# run Unit Test # run Unit Test
echo "Run Unit Test: utilTest, queryTest and cliTest" echo "Run Unit Test: utilTest, queryTest and cliTest"
$TDENGINE_DIR/debug/build/bin/utilTest > /dev/null && echo "utilTest pass!" || echo "utilTest failed!" $TDENGINE_DIR/debug/build/bin/utilTest > /dev/null 2>&1 && echo "utilTest pass!" || echo "utilTest failed!"
$TDENGINE_DIR/debug/build/bin/queryTest > /dev/null && echo "queryTest pass!" || echo "queryTest failed!" $TDENGINE_DIR/debug/build/bin/queryTest > /dev/null 2>&1 && echo "queryTest pass!" || echo "queryTest failed!"
$TDENGINE_DIR/debug/build/bin/cliTest > /dev/null && echo "cliTest pass!" || echo "cliTest failed!" $TDENGINE_DIR/debug/build/bin/cliTest > /dev/null 2>&1 && echo "cliTest pass!" || echo "cliTest failed!"
stopTaosd stopTaosd
} }

View File

@ -100,23 +100,30 @@ function runTest {
sleep 10 sleep 10
cd $TDINTERNAL_DIR/community/src/connector/jdbc cd $TDINTERNAL_DIR/community/src/connector/jdbc
mvn clean package mvn clean package > /dev/null
mvn test | tee -a $TDINTERNAL_COVERAGE_REPORT mvn test > /dev/null | tee -a $TDINTERNAL_COVERAGE_REPORT
# Test C Demo # Test C Demo
stopTaosd stopTaosd
$TDINTERNAL_DIR/debug/build/bin/taosd -c $TDINTERNAL_DIR/debug/test/cfg > /dev/null & $TDINTERNAL_DIR/debug/build/bin/taosd -c $TDINTERNAL_DIR/debug/test/cfg > /dev/null &
sleep 10 sleep 10
yes | $TDINTERNAL_DIR/debug/build/bin/demo 127.0.0.1 | tee -a $TDINTERNAL_COVERAGE_REPORT yes | $TDINTERNAL_DIR/debug/build/bin/demo 127.0.0.1 > /dev/null | tee -a $TDINTERNAL_COVERAGE_REPORT
# Test waltest # Test waltest
dataDir=`grep dataDir $TDINTERNAL_DIR/debug/test/cfg/taos.cfg|awk '{print $2}'` dataDir=`grep dataDir $TDINTERNAL_DIR/debug/test/cfg/taos.cfg|awk '{print $2}'`
walDir=`find $dataDir -name "wal"|head -n1` walDir=`find $dataDir -name "wal"|head -n1`
echo "dataDir: $dataDir\nwalDir: $walDir" | tee -a $TDINTERNAL_COVERAGE_REPORT echo "dataDir: $dataDir" | tee -a $TDINTERNAL_COVERAGE_REPORT
echo "walDir: $walDir" | tee -a $TDINTERNAL_COVERAGE_REPORT
if [ -n "$walDir" ]; then if [ -n "$walDir" ]; then
yes | $TDINTERNAL_DIR/debug/build/bin/waltest -p $walDir | tee -a $TDINTERNAL_COVERAGE_REPORT yes | $TDINTERNAL_DIR/debug/build/bin/waltest -p $walDir > /dev/null | tee -a $TDINTERNAL_COVERAGE_REPORT
fi fi
# run Unit Test
echo "Run Unit Test: utilTest, queryTest and cliTest"
$TDINTERNAL_DIR/debug/build/bin/utilTest > /dev/null 2>&1 && echo "utilTest pass!" || echo "utilTest failed!"
$TDINTERNAL_DIR/debug/build/bin/queryTest > /dev/null 2>&1 && echo "queryTest pass!" || echo "queryTest failed!"
$TDINTERNAL_DIR/debug/build/bin/cliTest > /dev/null 2>&1 && echo "cliTest pass!" || echo "cliTest failed!"
stopTaosd stopTaosd
} }

View File

@ -39,6 +39,7 @@ class TDSimClient:
"udebugFlag": "135", "udebugFlag": "135",
"jnidebugFlag": "135", "jnidebugFlag": "135",
"qdebugFlag": "135", "qdebugFlag": "135",
"telemetryReporting": "0",
} }
def init(self, path): def init(self, path):
self.__init__() self.__init__()

View File

@ -36,6 +36,7 @@ class TDSimClient:
"udebugFlag": "135", "udebugFlag": "135",
"jnidebugFlag": "135", "jnidebugFlag": "135",
"qdebugFlag": "135", "qdebugFlag": "135",
"telemetryReporting": "0",
} }
def init(self, path): def init(self, path):

View File

@ -36,6 +36,7 @@ class TDSimClient:
"udebugFlag": "135", "udebugFlag": "135",
"jnidebugFlag": "135", "jnidebugFlag": "135",
"qdebugFlag": "135", "qdebugFlag": "135",
"telemetryReporting": "0",
} }
def init(self, path): def init(self, path):