提交 c2e91fcb 编写于 作者: S slguan

Adjust code structure

上级 20d340f5
...@@ -23,5 +23,14 @@ tests/script/ ...@@ -23,5 +23,14 @@ tests/script/
tests/pytest/ tests/pytest/
tests/jenkins/ tests/jenkins/
tests/hdfs/ tests/hdfs/
*.iml *.iml
*.class
nmake/
sln/
hdfs/
c/
taoshebei/
taosdalipu/
Target/
*.failed
*.sql
\ No newline at end of file
...@@ -3,16 +3,18 @@ PROJECT(TDengine) ...@@ -3,16 +3,18 @@ PROJECT(TDengine)
SET(CMAKE_C_STANDARD 11) SET(CMAKE_C_STANDARD 11)
SET(CMAKE_VERBOSE_MAKEFILE ON) SET(CMAKE_VERBOSE_MAKEFILE ON)
SET(TD_ROOT_DIR ${PROJECT_SOURCE_DIR})
# #
# If it is a Linux operating system # If need to set debug options
# 1.Generate debug version: # 1.Generate debug version:
# mkdir debug; cd debug; # mkdir debug; cd debug;
# cmake -DCMAKE_BUILD_TYPE=Debug .. # cmake -DCMAKE_BUILD_TYPE=Debug ..
# 2.Generate release version: # 2.Generate release version:
# mkdir release; cd release; # mkdir release; cd release;
# cmake -DCMAKE_BUILD_TYPE=Release .. # cmake -DCMAKE_BUILD_TYPE=Release ..
#
#
# If it is a Windows operating system # If it is a Windows operating system
# 1.Use command line tool of VS2013 or higher version # 1.Use command line tool of VS2013 or higher version
# mkdir build; cd build; # mkdir build; cd build;
...@@ -24,150 +26,170 @@ SET(TD_ROOT_DIR ${PROJECT_SOURCE_DIR}) ...@@ -24,150 +26,170 @@ SET(TD_ROOT_DIR ${PROJECT_SOURCE_DIR})
# open the file named TDengine.sln # open the file named TDengine.sln
# #
# Set macro definitions according to os platform IF (NOT DEFINED TD_CLUSTER)
SET(TD_WINDOWS FALSE) MESSAGE(STATUS "Build the Lite Version")
SET(TD_LINUX FALSE) SET(TD_CLUSTER FALSE)
SET(TD_ARM FALSE) SET(TD_LITE TRUE)
SET(TD_DARWIN FALSE)
IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux") SET(TD_COMMUNITY_DIR ${PROJECT_SOURCE_DIR})
MESSAGE(STATUS "Community directory: " ${TD_COMMUNITY_DIR})
SET(TD_OS_DIR ${PROJECT_SOURCE_DIR}/src/os/linux)
SET(TD_LINUX TRUE)
ADD_DEFINITIONS(-DLINUX)
IF (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") # Set macro definitions according to os platform
SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -malign-double -g -Wno-char-subscripts -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE") SET(TD_LINUX_64 FALSE)
ELSE () SET(TD_LINUX_32 FALSE)
SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -malign-double -g -Wno-char-subscripts -malign-stringops -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE") SET(TD_ARM_64 FALSE)
ENDIF () SET(TD_ARM_32 FALSE)
SET(DEBUG_FLAGS "-O0 -DDEBUG") SET(TD_MIPS_64 FALSE)
SET(RELEASE_FLAGS "-O0") SET(TD_DARWIN_64 FALSE)
SET(TD_WINDOWS_64 FALSE)
ADD_DEFINITIONS(-D_REENTRANT -D__USE_POSIX -D_LIBC_REENTRANT)
IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
IF (${CMAKE_SIZEOF_VOID_P} MATCHES 8) IF (${CMAKE_SIZEOF_VOID_P} MATCHES 8)
MESSAGE(STATUS "The current platform is Linux 64-bit") SET(TD_LINUX_64 TRUE)
SET(TD_OS_DIR ${TD_COMMUNITY_DIR}/src/os/linux)
ADD_DEFINITIONS(-D_M_X64) ADD_DEFINITIONS(-D_M_X64)
MESSAGE(STATUS "The current platform is Linux 64-bit")
ELSE () ELSE ()
SET(TD_LINUX_32 TRUE)
MESSAGE(FATAL_ERROR "The current platform is Linux 32-bit, not supported yet") MESSAGE(FATAL_ERROR "The current platform is Linux 32-bit, not supported yet")
EXIT () EXIT ()
ENDIF () ENDIF ()
ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
SET(CMAKE_GENERATOR "NMake Makefiles" CACHE INTERNAL "" FORCE)
SET(TD_OS_DIR ${PROJECT_SOURCE_DIR}/src/os/windows)
SET(TD_WINDOWS TRUE)
ADD_DEFINITIONS(-DWINDOWS)
ADD_DEFINITIONS(-D__CLEANUP_C)
ADD_DEFINITIONS(-DPTW32_STATIC_LIB)
ADD_DEFINITIONS(-DPTW32_BUILD)
SET(COMMON_FLAGS "/nologo /WX- /Oi /Oy- /Gm- /EHsc /MT /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Gd /errorReport:prompt /analyze-")
SET(DEBUG_FLAGS "/Zi /W3 /GL")
SET(RELEASE_FLAGS "/W0 /GL")
ADD_DEFINITIONS(-D_MBCS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
IF (${CMAKE_SIZEOF_VOID_P} MATCHES 8) IF (${CMAKE_SIZEOF_VOID_P} MATCHES 8)
MESSAGE(STATUS "The current platform is Windows 64-bit") SET(TD_DARWIN_64 TRUE)
SET(TD_OS_DIR ${TD_COMMUNITY_DIR}/src/os/darwin)
MESSAGE(STATUS "The current platform is Darwin 64-bit")
ELSE ()
MESSAGE(FATAL_ERROR "The current platform is Darwin 32-bit, not supported yet")
EXIT ()
ENDIF ()
ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
IF (${CMAKE_SIZEOF_VOID_P} MATCHES 8)
SET(TD_WINDOWS_64 TRUE)
SET(TD_OS_DIR ${TD_COMMUNITY_DIR}/src/os/windows)
ADD_DEFINITIONS(-D_M_X64) ADD_DEFINITIONS(-D_M_X64)
MESSAGE(STATUS "The current platform is Windows 64-bit")
ELSE () ELSE ()
MESSAGE(FATAL_ERROR "The current platform is Windows 32-bit, not supported yet") MESSAGE(FATAL_ERROR "The current platform is Windows 32-bit, not supported yet")
EXIT () EXIT ()
ENDIF () ENDIF ()
ELSE()
MESSAGE(FATAL_ERROR "The current platform is not Linux/Darwin/Windows, stop compile")
EXIT ()
ENDIF ()
ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") FIND_PROGRAM(TD_MVN_INSTALLED mvn)
IF (TD_MVN_INSTALLED)
MESSAGE(STATUS "MVN is installed and JDBC will be compiled")
ELSE ()
MESSAGE(STATUS "MVN is not installed and JDBC is not compiled")
ENDIF ()
SET(TD_OS_DIR ${PROJECT_SOURCE_DIR}/src/os/darwin) #
SET(TD_DARWIN TRUE) # debug flag
ADD_DEFINITIONS(-DDARWIN) #
# ADD_DEFINITIONS(-D_CHECK_HEADER_FILE_)
# ADD_DEFINITIONS(-D_TAOS_MEM_TEST_)
IF (TD_CLUSTER)
ADD_DEFINITIONS(-DCLUSTER)
ADD_DEFINITIONS(-DTSDB_REPLICA_MAX_NUM=3)
ELSE ()
ADD_DEFINITIONS(-DLITE)
ADD_DEFINITIONS(-DTSDB_REPLICA_MAX_NUM=1)
ENDIF ()
IF (TD_LINUX_64)
SET(DEBUG_FLAGS "-O0 -DDEBUG")
SET(RELEASE_FLAGS "-O0")
IF (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -malign-double -g -Wno-char-subscripts -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
ELSE ()
SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -malign-double -g -Wno-char-subscripts -malign-stringops -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
ENDIF ()
ADD_DEFINITIONS(-DLINUX)
ADD_DEFINITIONS(-D_REENTRANT -D__USE_POSIX -D_LIBC_REENTRANT)
ELSEIF (TD_WINDOWS_64)
SET(CMAKE_GENERATOR "NMake Makefiles" CACHE INTERNAL "" FORCE)
SET(COMMON_FLAGS "/nologo /WX- /Oi /Oy- /Gm- /EHsc /MT /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Gd /errorReport:prompt /analyze-")
SET(DEBUG_FLAGS "/Zi /W3 /GL")
SET(RELEASE_FLAGS "/W0 /GL")
ADD_DEFINITIONS(-DWINDOWS)
ADD_DEFINITIONS(-D__CLEANUP_C)
ADD_DEFINITIONS(-DPTW32_STATIC_LIB)
ADD_DEFINITIONS(-DPTW32_BUILD)
ADD_DEFINITIONS(-D_MBCS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
ELSEIF (TD_DARWIN_64)
SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -malign-double -g -Wno-char-subscripts -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE -Wno-unused-variable -Wno-bitfield-constant-conversion") SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -malign-double -g -Wno-char-subscripts -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE -Wno-unused-variable -Wno-bitfield-constant-conversion")
SET(DEBUG_FLAGS "-O0 -DDEBUG") SET(DEBUG_FLAGS "-O0 -DDEBUG")
SET(RELEASE_FLAGS "-O0") SET(RELEASE_FLAGS "-O0")
ADD_DEFINITIONS(-DDARWIN)
ADD_DEFINITIONS(-D_REENTRANT -D__USE_POSIX -D_LIBC_REENTRANT) ADD_DEFINITIONS(-D_REENTRANT -D__USE_POSIX -D_LIBC_REENTRANT)
IF (${CMAKE_SIZEOF_VOID_P} MATCHES 8)
MESSAGE(STATUS "The current platform is Darwin 64-bit")
ADD_DEFINITIONS(-D_M_X64)
ELSE () ELSE ()
MESSAGE(FATAL_ERROR "The current platform is Darwin 32-bit, not supported yet") MESSAGE(FATAL_ERROR "The current platform is not support yet, stop compile")
EXIT () EXIT ()
ENDIF () ENDIF ()
ELSE () # Set compiler options
MESSAGE(FATAL_ERROR "The current platform is not Linux/MAC/Windows, stop compile") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${COMMON_FLAGS} ${DEBUG_FLAGS}")
EXIT () SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${COMMON_FLAGS} ${RELEASE_FLAGS}")
ENDIF ()
# Set compiler options
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${COMMON_FLAGS} ${DEBUG_FLAGS}")
SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${COMMON_FLAGS} ${RELEASE_FLAGS}")
# Set c++ compiler options # Set c++ compiler options
# SET(COMMON_CXX_FLAGS "${COMMON_FLAGS} -std=c++11") # SET(COMMON_CXX_FLAGS "${COMMON_FLAGS} -std=c++11")
# SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${COMMON_CXX_FLAGS} ${DEBUG_FLAGS}") # SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${COMMON_CXX_FLAGS} ${DEBUG_FLAGS}")
# SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${COMMON_CXX_FLAGS} ${RELEASE_FLAGS}") # SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${COMMON_CXX_FLAGS} ${RELEASE_FLAGS}")
IF (${CMAKE_BUILD_TYPE} MATCHES "Debug") IF (${CMAKE_BUILD_TYPE} MATCHES "Debug")
MESSAGE(STATUS "Build Debug Version") MESSAGE(STATUS "Build Debug Version")
ELSEIF (${CMAKE_BUILD_TYPE} MATCHES "Release") ELSEIF (${CMAKE_BUILD_TYPE} MATCHES "Release")
MESSAGE(STATUS "Build Release Version") MESSAGE(STATUS "Build Release Version")
ELSE () ELSE ()
IF (TD_WINDOWS) IF (TD_WINDOWS_64)
SET(CMAKE_BUILD_TYPE "Release") SET(CMAKE_BUILD_TYPE "Release")
MESSAGE(STATUS "Build Release Version") MESSAGE(STATUS "Build Release Version in Windows as default")
ELSE () ELSE ()
SET(CMAKE_BUILD_TYPE "Debug") SET(CMAKE_BUILD_TYPE "Debug")
MESSAGE(STATUS "Build Debug Version") MESSAGE(STATUS "Build Debug Version as default")
ENDIF() ENDIF()
ENDIF () ENDIF ()
FIND_PROGRAM(TD_MVN_INSTALLED mvn)
IF (TD_MVN_INSTALLED)
MESSAGE(STATUS "MVN is installed and JDBC will be compiled")
ELSE ()
MESSAGE(STATUS "MVN is not installed and JDBC is not compiled")
ENDIF ()
#set output directory #set output directory
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/build/lib) SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/build/lib)
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/build/bin) SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/build/bin)
SET(TD_TESTS_OUTPUT_DIR ${PROJECT_BINARY_DIR}/test) SET(TD_TESTS_OUTPUT_DIR ${PROJECT_BINARY_DIR}/test)
MESSAGE(STATUS "Operating system dependency directory: " ${TD_OS_DIR}) MESSAGE(STATUS "Operating system dependency directory: " ${TD_OS_DIR})
MESSAGE(STATUS "Project source directory: " ${PROJECT_SOURCE_DIR}) MESSAGE(STATUS "Project source directory: " ${PROJECT_SOURCE_DIR})
MESSAGE(STATUS "Project binary files output path: " ${PROJECT_BINARY_DIR}) MESSAGE(STATUS "Project binary files output path: " ${PROJECT_BINARY_DIR})
MESSAGE(STATUS "Project executable files output path: " ${EXECUTABLE_OUTPUT_PATH}) MESSAGE(STATUS "Project executable files output path: " ${EXECUTABLE_OUTPUT_PATH})
MESSAGE(STATUS "Project library files output path: " ${LIBRARY_OUTPUT_PATH}) MESSAGE(STATUS "Project library files output path: " ${LIBRARY_OUTPUT_PATH})
ADD_SUBDIRECTORY(deps) IF (TD_LINUX_64)
ADD_SUBDIRECTORY(src) SET(TD_MAKE_INSTALL_SH "${TD_COMMUNITY_DIR}/packaging/tools/make_install.sh")
ADD_SUBDIRECTORY(tests)
IF (TD_LINUX)
SET(TD_MAKE_INSTALL_SH "${TD_ROOT_DIR}/packaging/tools/make_install.sh")
INSTALL(CODE "MESSAGE(\"make install script: ${TD_MAKE_INSTALL_SH}\")") INSTALL(CODE "MESSAGE(\"make install script: ${TD_MAKE_INSTALL_SH}\")")
INSTALL(CODE "execute_process(COMMAND chmod 777 ${TD_MAKE_INSTALL_SH})") INSTALL(CODE "execute_process(COMMAND chmod 777 ${TD_MAKE_INSTALL_SH})")
INSTALL(CODE "execute_process(COMMAND ${TD_MAKE_INSTALL_SH} ${TD_ROOT_DIR} ${PROJECT_BINARY_DIR})") INSTALL(CODE "execute_process(COMMAND ${TD_MAKE_INSTALL_SH} ${TD_COMMUNITY_DIR} ${PROJECT_BINARY_DIR})")
ELSEIF (TD_WINDOWS) ELSEIF (TD_WINDOWS_64)
SET(CMAKE_INSTALL_PREFIX C:/TDengine) SET(CMAKE_INSTALL_PREFIX C:/TDengine)
INSTALL(DIRECTORY ${TD_ROOT_DIR}/src/connector/go DESTINATION connector) INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/src/connector/go DESTINATION connector)
INSTALL(DIRECTORY ${TD_ROOT_DIR}/src/connector/grafana DESTINATION connector) INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/src/connector/grafana DESTINATION connector)
INSTALL(DIRECTORY ${TD_ROOT_DIR}/src/connector/python DESTINATION connector) INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/src/connector/python DESTINATION connector)
INSTALL(DIRECTORY ${TD_ROOT_DIR}/tests/examples DESTINATION .) INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/tests/examples DESTINATION .)
INSTALL(DIRECTORY ${TD_ROOT_DIR}/packaging/cfg DESTINATION .) INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/packaging/cfg DESTINATION .)
INSTALL(FILES ${TD_ROOT_DIR}/src/inc/taos.h DESTINATION include) INSTALL(FILES ${TD_COMMUNITY_DIR}/src/inc/taos.h DESTINATION include)
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.lib DESTINATION driver) INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.lib DESTINATION driver)
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.exp DESTINATION driver) INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.exp DESTINATION driver)
INSTALL(TARGETS taos RUNTIME DESTINATION driver) INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.dll DESTINATION driver)
INSTALL(TARGETS shell RUNTIME DESTINATION .) INSTALL(FILES ${EXECUTABLE_OUTPUT_PATH}/taos.exe DESTINATION .)
#INSTALL(TARGETS taos RUNTIME DESTINATION driver)
#INSTALL(TARGETS shell RUNTIME DESTINATION .)
IF (TD_MVN_INSTALLED) IF (TD_MVN_INSTALLED)
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-1.0.2-dist.jar DESTINATION connector/jdbc) INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-1.0.2-dist.jar DESTINATION connector/jdbc)
ENDIF () ENDIF ()
ENDIF ()
ENDIF () ENDIF ()
ADD_SUBDIRECTORY(deps)
ADD_SUBDIRECTORY(src)
INCLUDE(CPack) INCLUDE(CPack)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8) CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(TDengine) PROJECT(TDengine)
ADD_SUBDIRECTORY(zlib-1.2.11) ADD_SUBDIRECTORY(zlib-1.2.11)
......
CMAKE_MINIMUM_REQUIRED(VERSION 2.8) CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(TDengine) PROJECT(TDengine)
IF (TD_WINDOWS) IF (TD_WINDOWS_64)
LIST(APPEND SRC iconv.c) LIST(APPEND SRC iconv.c)
LIST(APPEND SRC localcharset.c) LIST(APPEND SRC localcharset.c)
INCLUDE_DIRECTORIES(.) INCLUDE_DIRECTORIES(.)
......
CMAKE_MINIMUM_REQUIRED(VERSION 2.8) CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(TDengine) PROJECT(TDengine)
IF (TD_WINDOWS) IF (TD_WINDOWS_64)
LIST(APPEND SRC pthread.c)
INCLUDE_DIRECTORIES(.) INCLUDE_DIRECTORIES(.)
LIST(APPEND SRC pthread.c)
ADD_LIBRARY(pthread ${SRC}) ADD_LIBRARY(pthread ${SRC})
ENDIF () ENDIF ()
CMAKE_MINIMUM_REQUIRED(VERSION 2.8) CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(TDengine) PROJECT(TDengine)
IF (TD_WINDOWS) IF (TD_WINDOWS_64)
LIST(APPEND SRC regex.c)
INCLUDE_DIRECTORIES(inc .) INCLUDE_DIRECTORIES(inc .)
LIST(APPEND SRC regex.c)
ADD_LIBRARY(regex ${SRC}) ADD_LIBRARY(regex ${SRC})
ENDIF () ENDIF ()
CMAKE_MINIMUM_REQUIRED(VERSION 2.8) CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(TDengine) PROJECT(TDengine)
IF (TD_LINUX) IF (TD_LINUX_64)
AUX_SOURCE_DIRECTORY(src SRC)
INCLUDE_DIRECTORIES(inc) INCLUDE_DIRECTORIES(inc)
AUX_SOURCE_DIRECTORY(src SRC)
ADD_LIBRARY(z ${SRC}) ADD_LIBRARY(z ${SRC})
ENDIF () ENDIF ()
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
*/ */
/* @(#) $Id$ */ /* @(#) $Id$ */
//#include <stdint.h>
#ifndef ZCONF_H #ifndef ZCONF_H
#define ZCONF_H #define ZCONF_H
...@@ -238,16 +238,16 @@ ...@@ -238,16 +238,16 @@
#endif #endif
#ifdef Z_SOLO #ifdef Z_SOLO
typedef unsigned long z_size_t; typedef uint64_t z_size_t;
#else #else
# define z_longlong long long # define z_longlong int64_t
# if defined(NO_SIZE_T) # if defined(NO_SIZE_T)
typedef unsigned NO_SIZE_T z_size_t; typedef unsigned NO_SIZE_T z_size_t;
# elif defined(STDC) # elif defined(STDC)
# include <stddef.h> # include <stddef.h>
typedef size_t z_size_t; typedef size_t z_size_t;
# else # else
typedef unsigned long z_size_t; typedef uint64_t z_size_t;
# endif # endif
# undef z_longlong # undef z_longlong
#endif #endif
...@@ -391,7 +391,7 @@ ...@@ -391,7 +391,7 @@
typedef unsigned char Byte; /* 8 bits */ typedef unsigned char Byte; /* 8 bits */
#endif #endif
typedef unsigned int uInt; /* 16 bits or more */ typedef unsigned int uInt; /* 16 bits or more */
typedef unsigned long uLong; /* 32 bits or more */ typedef uint64_t uLong; /* 32 bits or more */
#ifdef SMALL_MEDIUM #ifdef SMALL_MEDIUM
/* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
...@@ -419,7 +419,7 @@ typedef uLong FAR uLongf; ...@@ -419,7 +419,7 @@ typedef uLong FAR uLongf;
# if (UINT_MAX == 0xffffffffUL) # if (UINT_MAX == 0xffffffffUL)
# define Z_U4 unsigned # define Z_U4 unsigned
# elif (ULONG_MAX == 0xffffffffUL) # elif (ULONG_MAX == 0xffffffffUL)
# define Z_U4 unsigned long # define Z_U4 uint64_t
# elif (USHRT_MAX == 0xffffffffUL) # elif (USHRT_MAX == 0xffffffffUL)
# define Z_U4 unsigned short # define Z_U4 unsigned short
# endif # endif
...@@ -428,7 +428,7 @@ typedef uLong FAR uLongf; ...@@ -428,7 +428,7 @@ typedef uLong FAR uLongf;
#ifdef Z_U4 #ifdef Z_U4
typedef Z_U4 z_crc_t; typedef Z_U4 z_crc_t;
#else #else
typedef unsigned long z_crc_t; typedef uint64_t z_crc_t;
#endif #endif
#if 1 /* was set to #if 1 by ./configure */ #if 1 /* was set to #if 1 by ./configure */
...@@ -501,7 +501,7 @@ typedef uLong FAR uLongf; ...@@ -501,7 +501,7 @@ typedef uLong FAR uLongf;
#endif #endif
#ifndef z_off_t #ifndef z_off_t
# define z_off_t long # define z_off_t int64_t
#endif #endif
#if !defined(_WIN32) && defined(Z_LARGE64) #if !defined(_WIN32) && defined(Z_LARGE64)
......
...@@ -999,7 +999,7 @@ ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, ...@@ -999,7 +999,7 @@ ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm,
stream state was inconsistent. stream state was inconsistent.
*/ */
ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm)); ZEXTERN int64_t ZEXPORT inflateMark OF((z_streamp strm));
/* /*
This function returns two values, one in the lower 16 bits of the return This function returns two values, one in the lower 16 bits of the return
value, and the other in the remaining upper bits, obtained by shifting the value, and the other in the remaining upper bits, obtained by shifting the
...@@ -1890,7 +1890,7 @@ ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp)); ...@@ -1890,7 +1890,7 @@ ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp));
ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void)); ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void));
ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int));
ZEXTERN int ZEXPORT inflateValidate OF((z_streamp, int)); ZEXTERN int ZEXPORT inflateValidate OF((z_streamp, int));
ZEXTERN unsigned long ZEXPORT inflateCodesUsed OF ((z_streamp)); ZEXTERN uint64_t ZEXPORT inflateCodesUsed OF ((z_streamp));
ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp)); ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp));
ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp)); ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp));
#if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(Z_SOLO) #if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(Z_SOLO)
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
*/ */
/* @(#) $Id$ */ /* @(#) $Id$ */
#include <stdint.h>
#include "zutil.h" #include "zutil.h"
local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2)); local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
...@@ -26,7 +26,7 @@ local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2)); ...@@ -26,7 +26,7 @@ local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
(thank you to John Reiser for pointing this out) */ (thank you to John Reiser for pointing this out) */
# define CHOP(a) \ # define CHOP(a) \
do { \ do { \
unsigned long tmp = a >> 16; \ uint64_t tmp = a >> 16; \
a &= 0xffffUL; \ a &= 0xffffUL; \
a += (tmp << 4) - tmp; \ a += (tmp << 4) - tmp; \
} while (0) } while (0)
...@@ -65,7 +65,7 @@ uLong ZEXPORT adler32_z(adler, buf, len) ...@@ -65,7 +65,7 @@ uLong ZEXPORT adler32_z(adler, buf, len)
const Bytef *buf; const Bytef *buf;
z_size_t len; z_size_t len;
{ {
unsigned long sum2; uint64_t sum2;
unsigned n; unsigned n;
/* split Adler-32 into component sums */ /* split Adler-32 into component sums */
...@@ -145,8 +145,8 @@ local uLong adler32_combine_(adler1, adler2, len2) ...@@ -145,8 +145,8 @@ local uLong adler32_combine_(adler1, adler2, len2)
uLong adler2; uLong adler2;
z_off64_t len2; z_off64_t len2;
{ {
unsigned long sum1; uint64_t sum1;
unsigned long sum2; uint64_t sum2;
unsigned rem; unsigned rem;
/* for negative len, return invalid adler32 as a clue for debugging */ /* for negative len, return invalid adler32 as a clue for debugging */
...@@ -163,7 +163,7 @@ local uLong adler32_combine_(adler1, adler2, len2) ...@@ -163,7 +163,7 @@ local uLong adler32_combine_(adler1, adler2, len2)
sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem; sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
if (sum1 >= BASE) sum1 -= BASE; if (sum1 >= BASE) sum1 -= BASE;
if (sum1 >= BASE) sum1 -= BASE; if (sum1 >= BASE) sum1 -= BASE;
if (sum2 >= ((unsigned long)BASE << 1)) sum2 -= ((unsigned long)BASE << 1); if (sum2 >= ((uint64_t)BASE << 1)) sum2 -= ((uint64_t)BASE << 1);
if (sum2 >= BASE) sum2 -= BASE; if (sum2 >= BASE) sum2 -= BASE;
return sum1 | (sum2 << 16); return sum1 | (sum2 << 16);
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
*/ */
/* @(#) $Id$ */ /* @(#) $Id$ */
#include <stdint.h>
#define ZLIB_INTERNAL #define ZLIB_INTERNAL
#include "zlib.h" #include "zlib.h"
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
DYNAMIC_CRC_TABLE and MAKECRCH can be #defined to write out crc32.h. DYNAMIC_CRC_TABLE and MAKECRCH can be #defined to write out crc32.h.
*/ */
#include <stdint.h>
#ifdef MAKECRCH #ifdef MAKECRCH
# include <stdio.h> # include <stdio.h>
# ifndef DYNAMIC_CRC_TABLE # ifndef DYNAMIC_CRC_TABLE
...@@ -35,9 +35,9 @@ ...@@ -35,9 +35,9 @@
# define BYFOUR # define BYFOUR
#endif #endif
#ifdef BYFOUR #ifdef BYFOUR
local unsigned long crc32_little OF((unsigned long, local uint64_t crc32_little OF((uint64_t,
const unsigned char FAR *, z_size_t)); const unsigned char FAR *, z_size_t));
local unsigned long crc32_big OF((unsigned long, local uint64_t crc32_big OF((uint64_t,
const unsigned char FAR *, z_size_t)); const unsigned char FAR *, z_size_t));
# define TBLS 8 # define TBLS 8
#else #else
...@@ -45,9 +45,9 @@ ...@@ -45,9 +45,9 @@
#endif /* BYFOUR */ #endif /* BYFOUR */
/* Local functions for crc concatenation */ /* Local functions for crc concatenation */
local unsigned long gf2_matrix_times OF((unsigned long *mat, local uint64_t gf2_matrix_times OF((uint64_t *mat,
unsigned long vec)); uint64_t vec));
local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat)); local void gf2_matrix_square OF((uint64_t *square, uint64_t *mat));
local uLong crc32_combine_ OF((uLong crc1, uLong crc2, z_off64_t len2)); local uLong crc32_combine_ OF((uLong crc1, uLong crc2, z_off64_t len2));
...@@ -170,7 +170,7 @@ local void write_table(out, table) ...@@ -170,7 +170,7 @@ local void write_table(out, table)
for (n = 0; n < 256; n++) for (n = 0; n < 256; n++)
fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ", fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ",
(unsigned long)(table[n]), (uint64_t)(table[n]),
n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", ")); n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", "));
} }
#endif /* MAKECRCH */ #endif /* MAKECRCH */
...@@ -199,8 +199,8 @@ const z_crc_t FAR * ZEXPORT get_crc_table() ...@@ -199,8 +199,8 @@ const z_crc_t FAR * ZEXPORT get_crc_table()
#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1 #define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
/* ========================================================================= */ /* ========================================================================= */
unsigned long ZEXPORT crc32_z(crc, buf, len) uint64_t ZEXPORT crc32_z(crc, buf, len)
unsigned long crc; uint64_t crc;
const unsigned char FAR *buf; const unsigned char FAR *buf;
z_size_t len; z_size_t len;
{ {
...@@ -234,8 +234,8 @@ unsigned long ZEXPORT crc32_z(crc, buf, len) ...@@ -234,8 +234,8 @@ unsigned long ZEXPORT crc32_z(crc, buf, len)
} }
/* ========================================================================= */ /* ========================================================================= */
unsigned long ZEXPORT crc32(crc, buf, len) uint64_t ZEXPORT crc32(crc, buf, len)
unsigned long crc; uint64_t crc;
const unsigned char FAR *buf; const unsigned char FAR *buf;
uInt len; uInt len;
{ {
...@@ -263,8 +263,8 @@ unsigned long ZEXPORT crc32(crc, buf, len) ...@@ -263,8 +263,8 @@ unsigned long ZEXPORT crc32(crc, buf, len)
#define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4 #define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4
/* ========================================================================= */ /* ========================================================================= */
local unsigned long crc32_little(crc, buf, len) local uint64_t crc32_little(crc, buf, len)
unsigned long crc; uint64_t crc;
const unsigned char FAR *buf; const unsigned char FAR *buf;
z_size_t len; z_size_t len;
{ {
...@@ -293,7 +293,7 @@ local unsigned long crc32_little(crc, buf, len) ...@@ -293,7 +293,7 @@ local unsigned long crc32_little(crc, buf, len)
c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
} while (--len); } while (--len);
c = ~c; c = ~c;
return (unsigned long)c; return (uint64_t)c;
} }
/* ========================================================================= */ /* ========================================================================= */
...@@ -303,8 +303,8 @@ local unsigned long crc32_little(crc, buf, len) ...@@ -303,8 +303,8 @@ local unsigned long crc32_little(crc, buf, len)
#define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4 #define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4
/* ========================================================================= */ /* ========================================================================= */
local unsigned long crc32_big(crc, buf, len) local uint64_t crc32_big(crc, buf, len)
unsigned long crc; uint64_t crc;
const unsigned char FAR *buf; const unsigned char FAR *buf;
z_size_t len; z_size_t len;
{ {
...@@ -333,7 +333,7 @@ local unsigned long crc32_big(crc, buf, len) ...@@ -333,7 +333,7 @@ local unsigned long crc32_big(crc, buf, len)
c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
} while (--len); } while (--len);
c = ~c; c = ~c;
return (unsigned long)(ZSWAP32(c)); return (uint64_t)(ZSWAP32(c));
} }
#endif /* BYFOUR */ #endif /* BYFOUR */
...@@ -341,11 +341,11 @@ local unsigned long crc32_big(crc, buf, len) ...@@ -341,11 +341,11 @@ local unsigned long crc32_big(crc, buf, len)
#define GF2_DIM 32 /* dimension of GF(2) vectors (length of CRC) */ #define GF2_DIM 32 /* dimension of GF(2) vectors (length of CRC) */
/* ========================================================================= */ /* ========================================================================= */
local unsigned long gf2_matrix_times(mat, vec) local uint64_t gf2_matrix_times(mat, vec)
unsigned long *mat; uint64_t *mat;
unsigned long vec; uint64_t vec;
{ {
unsigned long sum; uint64_t sum;
sum = 0; sum = 0;
while (vec) { while (vec) {
...@@ -359,8 +359,8 @@ local unsigned long gf2_matrix_times(mat, vec) ...@@ -359,8 +359,8 @@ local unsigned long gf2_matrix_times(mat, vec)
/* ========================================================================= */ /* ========================================================================= */
local void gf2_matrix_square(square, mat) local void gf2_matrix_square(square, mat)
unsigned long *square; uint64_t *square;
unsigned long *mat; uint64_t *mat;
{ {
int n; int n;
...@@ -375,9 +375,9 @@ local uLong crc32_combine_(crc1, crc2, len2) ...@@ -375,9 +375,9 @@ local uLong crc32_combine_(crc1, crc2, len2)
z_off64_t len2; z_off64_t len2;
{ {
int n; int n;
unsigned long row; uint64_t row;
unsigned long even[GF2_DIM]; /* even-power-of-two zeros operator */ uint64_t even[GF2_DIM]; /* even-power-of-two zeros operator */
unsigned long odd[GF2_DIM]; /* odd-power-of-two zeros operator */ uint64_t odd[GF2_DIM]; /* odd-power-of-two zeros operator */
/* degenerate case (also disallow negative lengths) */ /* degenerate case (also disallow negative lengths) */
if (len2 <= 0) if (len2 <= 0)
......
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
*/ */
/* @(#) $Id$ */ /* @(#) $Id$ */
#include <stdint.h>
#include "deflate.h" #include "deflate.h"
const char deflate_copyright[] = const char deflate_copyright[] =
...@@ -430,7 +430,7 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength) ...@@ -430,7 +430,7 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
fill_window(s); fill_window(s);
} }
s->strstart += s->lookahead; s->strstart += s->lookahead;
s->block_start = (long)s->strstart; s->block_start = (int64_t)s->strstart;
s->insert = s->lookahead; s->insert = s->lookahead;
s->lookahead = 0; s->lookahead = 0;
s->match_length = s->prev_length = MIN_MATCH-1; s->match_length = s->prev_length = MIN_MATCH-1;
...@@ -1512,7 +1512,7 @@ local void fill_window(s) ...@@ -1512,7 +1512,7 @@ local void fill_window(s)
zmemcpy(s->window, s->window+wsize, (unsigned)wsize - more); zmemcpy(s->window, s->window+wsize, (unsigned)wsize - more);
s->match_start -= wsize; s->match_start -= wsize;
s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ s->strstart -= wsize; /* we now have strstart >= MAX_DIST */
s->block_start -= (long) wsize; s->block_start -= (int64_t) wsize;
slide_hash(s); slide_hash(s);
more += wsize; more += wsize;
} }
...@@ -1606,7 +1606,7 @@ local void fill_window(s) ...@@ -1606,7 +1606,7 @@ local void fill_window(s)
_tr_flush_block(s, (s->block_start >= 0L ? \ _tr_flush_block(s, (s->block_start >= 0L ? \
(charf *)&s->window[(unsigned)s->block_start] : \ (charf *)&s->window[(unsigned)s->block_start] : \
(charf *)Z_NULL), \ (charf *)Z_NULL), \
(ulg)((long)s->strstart - s->block_start), \ (ulg)((int64_t)s->strstart - s->block_start), \
(last)); \ (last)); \
s->block_start = s->strstart; \ s->block_start = s->strstart; \
flush_pending(s->strm); \ flush_pending(s->strm); \
...@@ -1766,12 +1766,12 @@ local block_state deflate_stored(s, flush) ...@@ -1766,12 +1766,12 @@ local block_state deflate_stored(s, flush)
/* If flushing and all input has been consumed, then done. */ /* If flushing and all input has been consumed, then done. */
if (flush != Z_NO_FLUSH && flush != Z_FINISH && if (flush != Z_NO_FLUSH && flush != Z_FINISH &&
s->strm->avail_in == 0 && (long)s->strstart == s->block_start) s->strm->avail_in == 0 && (int64_t)s->strstart == s->block_start)
return block_done; return block_done;
/* Fill the window with any remaining input. */ /* Fill the window with any remaining input. */
have = s->window_size - s->strstart - 1; have = s->window_size - s->strstart - 1;
if (s->strm->avail_in > have && s->block_start >= (long)s->w_size) { if (s->strm->avail_in > have && s->block_start >= (int64_t)s->w_size) {
/* Slide the window down. */ /* Slide the window down. */
s->block_start -= s->w_size; s->block_start -= s->w_size;
s->strstart -= s->w_size; s->strstart -= s->w_size;
......
...@@ -151,7 +151,7 @@ typedef struct internal_state { ...@@ -151,7 +151,7 @@ typedef struct internal_state {
* hash_shift * MIN_MATCH >= hash_bits * hash_shift * MIN_MATCH >= hash_bits
*/ */
long block_start; int64_t block_start;
/* Window position at the beginning of the current output block. Gets /* Window position at the beginning of the current output block. Gets
* negative when the window is moved backwards. * negative when the window is moved backwards.
*/ */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Copyright (C) 2004, 2010 Mark Adler * Copyright (C) 2004, 2010 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
#include <stdint.h>
#include "gzguts.h" #include "gzguts.h"
/* gzclose() is in a separate file so that it is linked in only if it is used. /* gzclose() is in a separate file so that it is linked in only if it is used.
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Copyright (C) 2004-2017 Mark Adler * Copyright (C) 2004-2017 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
#include <stdint.h>
#include "gzguts.h" #include "gzguts.h"
#if defined(_WIN32) && !defined(__BORLANDC__) && !defined(__MINGW32__) #if defined(_WIN32) && !defined(__BORLANDC__) && !defined(__MINGW32__)
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013, 2016 Mark Adler * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013, 2016 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
#include <stdint.h>
#include "gzguts.h" #include "gzguts.h"
/* Local functions */ /* Local functions */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Copyright (C) 2004-2017 Mark Adler * Copyright (C) 2004-2017 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
#include <stdint.h>
#include "gzguts.h" #include "gzguts.h"
/* Local functions */ /* Local functions */
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
with inffast.c is retained so that optimized assembler-coded versions of with inffast.c is retained so that optimized assembler-coded versions of
inflate_fast() can be used with either inflate.c or infback.c. inflate_fast() can be used with either inflate.c or infback.c.
*/ */
#include <stdint.h>
#include "zutil.h" #include "zutil.h"
#include "inftrees.h" #include "inftrees.h"
#include "inflate.h" #include "inflate.h"
...@@ -173,7 +173,7 @@ struct inflate_state FAR *state; ...@@ -173,7 +173,7 @@ struct inflate_state FAR *state;
do { \ do { \
PULL(); \ PULL(); \
have--; \ have--; \
hold += (unsigned long)(*next++) << bits; \ hold += (uint64_t)(*next++) << bits; \
bits += 8; \ bits += 8; \
} while (0) } while (0)
...@@ -258,7 +258,7 @@ void FAR *out_desc; ...@@ -258,7 +258,7 @@ void FAR *out_desc;
z_const unsigned char FAR *next; /* next input */ z_const unsigned char FAR *next; /* next input */
unsigned char FAR *put; /* next output */ unsigned char FAR *put; /* next output */
unsigned have, left; /* available input and output */ unsigned have, left; /* available input and output */
unsigned long hold; /* bit buffer */ uint64_t hold; /* bit buffer */
unsigned bits; /* bits in bit buffer */ unsigned bits; /* bits in bit buffer */
unsigned copy; /* number of stored or match bytes to copy */ unsigned copy; /* number of stored or match bytes to copy */
unsigned char FAR *from; /* where to copy match bytes from */ unsigned char FAR *from; /* where to copy match bytes from */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Copyright (C) 1995-2017 Mark Adler * Copyright (C) 1995-2017 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
#include <stdint.h>
#include "zutil.h" #include "zutil.h"
#include "inftrees.h" #include "inftrees.h"
#include "inflate.h" #include "inflate.h"
...@@ -64,7 +64,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ ...@@ -64,7 +64,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
unsigned whave; /* valid bytes in the window */ unsigned whave; /* valid bytes in the window */
unsigned wnext; /* window write index */ unsigned wnext; /* window write index */
unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */ unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */
unsigned long hold; /* local strm->hold */ uint64_t hold; /* local strm->hold */
unsigned bits; /* local strm->bits */ unsigned bits; /* local strm->bits */
code const FAR *lcode; /* local strm->lencode */ code const FAR *lcode; /* local strm->lencode */
code const FAR *dcode; /* local strm->distcode */ code const FAR *dcode; /* local strm->distcode */
...@@ -102,9 +102,9 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ ...@@ -102,9 +102,9 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
input data or output space */ input data or output space */
do { do {
if (bits < 15) { if (bits < 15) {
hold += (unsigned long)(*in++) << bits; hold += (uint64_t)(*in++) << bits;
bits += 8; bits += 8;
hold += (unsigned long)(*in++) << bits; hold += (uint64_t)(*in++) << bits;
bits += 8; bits += 8;
} }
here = lcode[hold & lmask]; here = lcode[hold & lmask];
...@@ -124,7 +124,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ ...@@ -124,7 +124,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
op &= 15; /* number of extra bits */ op &= 15; /* number of extra bits */
if (op) { if (op) {
if (bits < op) { if (bits < op) {
hold += (unsigned long)(*in++) << bits; hold += (uint64_t)(*in++) << bits;
bits += 8; bits += 8;
} }
len += (unsigned)hold & ((1U << op) - 1); len += (unsigned)hold & ((1U << op) - 1);
...@@ -133,9 +133,9 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ ...@@ -133,9 +133,9 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
} }
Tracevv((stderr, "inflate: length %u\n", len)); Tracevv((stderr, "inflate: length %u\n", len));
if (bits < 15) { if (bits < 15) {
hold += (unsigned long)(*in++) << bits; hold += (uint64_t)(*in++) << bits;
bits += 8; bits += 8;
hold += (unsigned long)(*in++) << bits; hold += (uint64_t)(*in++) << bits;
bits += 8; bits += 8;
} }
here = dcode[hold & dmask]; here = dcode[hold & dmask];
...@@ -148,10 +148,10 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ ...@@ -148,10 +148,10 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
dist = (unsigned)(here.val); dist = (unsigned)(here.val);
op &= 15; /* number of extra bits */ op &= 15; /* number of extra bits */
if (bits < op) { if (bits < op) {
hold += (unsigned long)(*in++) << bits; hold += (uint64_t)(*in++) << bits;
bits += 8; bits += 8;
if (bits < op) { if (bits < op) {
hold += (unsigned long)(*in++) << bits; hold += (uint64_t)(*in++) << bits;
bits += 8; bits += 8;
} }
} }
......
...@@ -79,7 +79,7 @@ ...@@ -79,7 +79,7 @@
* *
* The history for versions after 1.2.0 are in ChangeLog in zlib distribution. * The history for versions after 1.2.0 are in ChangeLog in zlib distribution.
*/ */
#include <stdint.h>
#include "zutil.h" #include "zutil.h"
#include "inftrees.h" #include "inftrees.h"
#include "inflate.h" #include "inflate.h"
...@@ -507,7 +507,7 @@ unsigned copy; ...@@ -507,7 +507,7 @@ unsigned copy;
do { \ do { \
if (have == 0) goto inf_leave; \ if (have == 0) goto inf_leave; \
have--; \ have--; \
hold += (unsigned long)(*next++) << bits; \ hold += (uint64_t)(*next++) << bits; \
bits += 8; \ bits += 8; \
} while (0) } while (0)
...@@ -627,7 +627,7 @@ int flush; ...@@ -627,7 +627,7 @@ int flush;
z_const unsigned char FAR *next; /* next input */ z_const unsigned char FAR *next; /* next input */
unsigned char FAR *put; /* next output */ unsigned char FAR *put; /* next output */
unsigned have, left; /* available input and output */ unsigned have, left; /* available input and output */
unsigned long hold; /* bit buffer */ uint64_t hold; /* bit buffer */
unsigned bits; /* bits in bit buffer */ unsigned bits; /* bits in bit buffer */
unsigned in, out; /* save starting available input and output */ unsigned in, out; /* save starting available input and output */
unsigned copy; /* number of stored or match bytes to copy */ unsigned copy; /* number of stored or match bytes to copy */
...@@ -1317,7 +1317,7 @@ const Bytef *dictionary; ...@@ -1317,7 +1317,7 @@ const Bytef *dictionary;
uInt dictLength; uInt dictLength;
{ {
struct inflate_state FAR *state; struct inflate_state FAR *state;
unsigned long dictid; uint64_t dictid;
int ret; int ret;
/* check state */ /* check state */
...@@ -1401,7 +1401,7 @@ int ZEXPORT inflateSync(strm) ...@@ -1401,7 +1401,7 @@ int ZEXPORT inflateSync(strm)
z_streamp strm; z_streamp strm;
{ {
unsigned len; /* number of bytes to look at or looked at */ unsigned len; /* number of bytes to look at or looked at */
unsigned long in, out; /* temporary to save total_in and total_out */ uint64_t in, out; /* temporary to save total_in and total_out */
unsigned char buf[4]; /* to restore bit buffer to byte string */ unsigned char buf[4]; /* to restore bit buffer to byte string */
struct inflate_state FAR *state; struct inflate_state FAR *state;
...@@ -1538,7 +1538,7 @@ int check; ...@@ -1538,7 +1538,7 @@ int check;
return Z_OK; return Z_OK;
} }
long ZEXPORT inflateMark(strm) int64_t ZEXPORT inflateMark(strm)
z_streamp strm; z_streamp strm;
{ {
struct inflate_state FAR *state; struct inflate_state FAR *state;
...@@ -1546,16 +1546,16 @@ z_streamp strm; ...@@ -1546,16 +1546,16 @@ z_streamp strm;
if (inflateStateCheck(strm)) if (inflateStateCheck(strm))
return -(1L << 16); return -(1L << 16);
state = (struct inflate_state FAR *)strm->state; state = (struct inflate_state FAR *)strm->state;
return (long)(((unsigned long)((long)state->back)) << 16) + return (int64_t)(((uint64_t)((int64_t)state->back)) << 16) +
(state->mode == COPY ? state->length : (state->mode == COPY ? state->length :
(state->mode == MATCH ? state->was - state->length : 0)); (state->mode == MATCH ? state->was - state->length : 0));
} }
unsigned long ZEXPORT inflateCodesUsed(strm) uint64_t ZEXPORT inflateCodesUsed(strm)
z_streamp strm; z_streamp strm;
{ {
struct inflate_state FAR *state; struct inflate_state FAR *state;
if (inflateStateCheck(strm)) return (unsigned long)-1; if (inflateStateCheck(strm)) return (uint64_t)-1;
state = (struct inflate_state FAR *)strm->state; state = (struct inflate_state FAR *)strm->state;
return (unsigned long)(state->next - state->codes); return (uint64_t)(state->next - state->codes);
} }
...@@ -88,8 +88,8 @@ struct inflate_state { ...@@ -88,8 +88,8 @@ struct inflate_state {
int havedict; /* true if dictionary provided */ int havedict; /* true if dictionary provided */
int flags; /* gzip header method and flags (0 if zlib) */ int flags; /* gzip header method and flags (0 if zlib) */
unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */ unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */
unsigned long check; /* protected copy of check value */ uint64_t check; /* protected copy of check value */
unsigned long total; /* protected copy of output count */ uint64_t total; /* protected copy of output count */
gz_headerp head; /* where to save gzip header information */ gz_headerp head; /* where to save gzip header information */
/* sliding window */ /* sliding window */
unsigned wbits; /* log base 2 of requested window size */ unsigned wbits; /* log base 2 of requested window size */
...@@ -98,7 +98,7 @@ struct inflate_state { ...@@ -98,7 +98,7 @@ struct inflate_state {
unsigned wnext; /* window write index */ unsigned wnext; /* window write index */
unsigned char FAR *window; /* allocated sliding window, if needed */ unsigned char FAR *window; /* allocated sliding window, if needed */
/* bit accumulator */ /* bit accumulator */
unsigned long hold; /* input bit accumulator */ uint64_t hold; /* input bit accumulator */
unsigned bits; /* number of bits in "in" */ unsigned bits; /* number of bits in "in" */
/* for string and stored block copying */ /* for string and stored block copying */
unsigned length; /* literal or length of data to copy */ unsigned length; /* literal or length of data to copy */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Copyright (C) 1995-2017 Mark Adler * Copyright (C) 1995-2017 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
#include <stdint.h>
#include "zutil.h" #include "zutil.h"
#include "inftrees.h" #include "inftrees.h"
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
/* @(#) $Id$ */ /* @(#) $Id$ */
/* #define GEN_TREES_H */ /* #define GEN_TREES_H */
#include <stdint.h>
#include "deflate.h" #include "deflate.h"
#ifdef ZLIB_DEBUG #ifdef ZLIB_DEBUG
...@@ -1038,7 +1038,7 @@ int ZLIB_INTERNAL _tr_tally (s, dist, lc) ...@@ -1038,7 +1038,7 @@ int ZLIB_INTERNAL _tr_tally (s, dist, lc)
if ((s->last_lit & 0x1fff) == 0 && s->level > 2) { if ((s->last_lit & 0x1fff) == 0 && s->level > 2) {
/* Compute an upper bound for the compressed length */ /* Compute an upper bound for the compressed length */
ulg out_length = (ulg)s->last_lit*8L; ulg out_length = (ulg)s->last_lit*8L;
ulg in_length = (ulg)((long)s->strstart - s->block_start); ulg in_length = (ulg)((int64_t)s->strstart - s->block_start);
int dcode; int dcode;
for (dcode = 0; dcode < D_CODES; dcode++) { for (dcode = 0; dcode < D_CODES; dcode++) {
out_length += (ulg)s->dyn_dtree[dcode].Freq * out_length += (ulg)s->dyn_dtree[dcode].Freq *
...@@ -1128,7 +1128,7 @@ local int detect_data_type(s) ...@@ -1128,7 +1128,7 @@ local int detect_data_type(s)
* set bits 0..6, 14..25, and 28..31 * set bits 0..6, 14..25, and 28..31
* 0xf3ffc07f = binary 11110011111111111100000001111111 * 0xf3ffc07f = binary 11110011111111111100000001111111
*/ */
unsigned long black_mask = 0xf3ffc07fUL; uint64_t black_mask = 0xf3ffc07fUL;
int n; int n;
/* Check for non-textual ("black-listed") bytes. */ /* Check for non-textual ("black-listed") bytes. */
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
*/ */
/* @(#) $Id$ */ /* @(#) $Id$ */
#include <stdint.h>
#define ZLIB_INTERNAL #define ZLIB_INTERNAL
#include "zlib.h" #include "zlib.h"
......
...@@ -238,16 +238,16 @@ ...@@ -238,16 +238,16 @@
#endif #endif
#ifdef Z_SOLO #ifdef Z_SOLO
typedef unsigned long z_size_t; typedef uint64_t z_size_t;
#else #else
# define z_longlong long long # define z_longlong int64_t
# if defined(NO_SIZE_T) # if defined(NO_SIZE_T)
typedef unsigned NO_SIZE_T z_size_t; typedef unsigned NO_SIZE_T z_size_t;
# elif defined(STDC) # elif defined(STDC)
# include <stddef.h> # include <stddef.h>
typedef size_t z_size_t; typedef size_t z_size_t;
# else # else
typedef unsigned long z_size_t; typedef uint64_t z_size_t;
# endif # endif
# undef z_longlong # undef z_longlong
#endif #endif
...@@ -391,7 +391,7 @@ ...@@ -391,7 +391,7 @@
typedef unsigned char Byte; /* 8 bits */ typedef unsigned char Byte; /* 8 bits */
#endif #endif
typedef unsigned int uInt; /* 16 bits or more */ typedef unsigned int uInt; /* 16 bits or more */
typedef unsigned long uLong; /* 32 bits or more */ typedef uint64_t uLong; /* 32 bits or more */
#ifdef SMALL_MEDIUM #ifdef SMALL_MEDIUM
/* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
...@@ -419,7 +419,7 @@ typedef uLong FAR uLongf; ...@@ -419,7 +419,7 @@ typedef uLong FAR uLongf;
# if (UINT_MAX == 0xffffffffUL) # if (UINT_MAX == 0xffffffffUL)
# define Z_U4 unsigned # define Z_U4 unsigned
# elif (ULONG_MAX == 0xffffffffUL) # elif (ULONG_MAX == 0xffffffffUL)
# define Z_U4 unsigned long # define Z_U4 uint64_t
# elif (USHRT_MAX == 0xffffffffUL) # elif (USHRT_MAX == 0xffffffffUL)
# define Z_U4 unsigned short # define Z_U4 unsigned short
# endif # endif
...@@ -428,7 +428,7 @@ typedef uLong FAR uLongf; ...@@ -428,7 +428,7 @@ typedef uLong FAR uLongf;
#ifdef Z_U4 #ifdef Z_U4
typedef Z_U4 z_crc_t; typedef Z_U4 z_crc_t;
#else #else
typedef unsigned long z_crc_t; typedef uint64_t z_crc_t;
#endif #endif
#if 1 /* was set to #if 1 by ./configure */ #if 1 /* was set to #if 1 by ./configure */
...@@ -501,7 +501,7 @@ typedef uLong FAR uLongf; ...@@ -501,7 +501,7 @@ typedef uLong FAR uLongf;
#endif #endif
#ifndef z_off_t #ifndef z_off_t
# define z_off_t long # define z_off_t int64_t
#endif #endif
#if !defined(_WIN32) && defined(Z_LARGE64) #if !defined(_WIN32) && defined(Z_LARGE64)
......
...@@ -999,7 +999,7 @@ ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, ...@@ -999,7 +999,7 @@ ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm,
stream state was inconsistent. stream state was inconsistent.
*/ */
ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm)); ZEXTERN int64_t ZEXPORT inflateMark OF((z_streamp strm));
/* /*
This function returns two values, one in the lower 16 bits of the return This function returns two values, one in the lower 16 bits of the return
value, and the other in the remaining upper bits, obtained by shifting the value, and the other in the remaining upper bits, obtained by shifting the
...@@ -1890,7 +1890,7 @@ ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp)); ...@@ -1890,7 +1890,7 @@ ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp));
ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void)); ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void));
ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int));
ZEXTERN int ZEXPORT inflateValidate OF((z_streamp, int)); ZEXTERN int ZEXPORT inflateValidate OF((z_streamp, int));
ZEXTERN unsigned long ZEXPORT inflateCodesUsed OF ((z_streamp)); ZEXTERN uint64_t ZEXPORT inflateCodesUsed OF ((z_streamp));
ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp)); ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp));
ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp)); ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp));
#if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(Z_SOLO) #if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(Z_SOLO)
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
*/ */
/* @(#) $Id$ */ /* @(#) $Id$ */
#include <stdint.h>
#include "zutil.h" #include "zutil.h"
#ifndef Z_SOLO #ifndef Z_SOLO
# include "gzguts.h" # include "gzguts.h"
...@@ -280,7 +280,7 @@ void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) ...@@ -280,7 +280,7 @@ void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, uInt items, uInt size) voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, uInt items, uInt size)
{ {
(void)opaque; (void)opaque;
return _halloc((long)items, size); return _halloc((int64_t)items, size);
} }
void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#endif #endif
#ifdef Z_SOLO #ifdef Z_SOLO
typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */ typedef int64_t ptrdiff_t; /* guess -- will be caught if guess is wrong */
#endif #endif
#ifndef local #ifndef local
...@@ -44,7 +44,7 @@ typedef unsigned char uch; ...@@ -44,7 +44,7 @@ typedef unsigned char uch;
typedef uch FAR uchf; typedef uch FAR uchf;
typedef unsigned short ush; typedef unsigned short ush;
typedef ush FAR ushf; typedef ush FAR ushf;
typedef unsigned long ulg; typedef uint64_t ulg;
extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
/* (size given to avoid silly warnings with Visual C++) */ /* (size given to avoid silly warnings with Visual C++) */
...@@ -89,7 +89,7 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ ...@@ -89,7 +89,7 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) # if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
/* Allow compilation with ANSI keywords only enabled */ /* Allow compilation with ANSI keywords only enabled */
void _Cdecl farfree( void *block ); void _Cdecl farfree( void *block );
void *_Cdecl farmalloc( unsigned long nbytes ); void *_Cdecl farmalloc( uint64_t nbytes );
# else # else
# include <alloc.h> # include <alloc.h>
# endif # endif
......
...@@ -131,10 +131,10 @@ ...@@ -131,10 +131,10 @@
# maxVnodeConnections 10000 # maxVnodeConnections 10000
# start http service in the cluster # start http service in the cluster
# enableHttp 1 # http 1
# start system monitor module in the cluster # start system monitor module in the cluster
# enableMonitor 1 # monitor 1
# number of threads used to process http requests # number of threads used to process http requests
# httpMaxThreads 2 # httpMaxThreads 2
......
#!/bin/bash #!/bin/bash
# #
# Generate deb package for ubuntu # Generate deb package for ubuntu
#set -x # set -x
#curr_dir=$(pwd) #curr_dir=$(pwd)
compile_dir=$1 compile_dir=$1
...@@ -24,7 +24,7 @@ fi ...@@ -24,7 +24,7 @@ fi
mkdir -p ${pkg_dir} mkdir -p ${pkg_dir}
cd ${pkg_dir} cd ${pkg_dir}
versioninfo=$(${script_dir}/../tools/get_version.sh) versioninfo=$(${script_dir}/../tools/get_version.sh ${script_dir}/../../src/util/lite/src/version.c)
libfile="libtaos.so.${versioninfo}" libfile="libtaos.so.${versioninfo}"
# create install dir # create install dir
......
文件模式从 100755 更改为 100644
...@@ -8,7 +8,7 @@ set -e ...@@ -8,7 +8,7 @@ set -e
curr_dir=$(pwd) curr_dir=$(pwd)
script_dir="$(dirname $(readlink -f $0))" script_dir="$(dirname $(readlink -f $0))"
top_dir="$(readlink -m ${script_dir}/..)" top_dir="$(readlink -m ${script_dir}/..)"
versioninfo="${top_dir}/src/util/src/version.c" versioninfo="${top_dir}/src/util/lite/src/version.c"
csudo="" csudo=""
if command -v sudo > /dev/null; then if command -v sudo > /dev/null; then
......
文件模式从 100755 更改为 100644
...@@ -39,7 +39,7 @@ echo topdir: %{_topdir} ...@@ -39,7 +39,7 @@ echo topdir: %{_topdir}
echo version: %{_version} echo version: %{_version}
echo buildroot: %{buildroot} echo buildroot: %{buildroot}
versioninfo=$(%{_compiledir}/../packaging/tools/get_version.sh) versioninfo=$(%{_compiledir}/../packaging/tools/get_version.sh ../../src/util/lite/src/version.c)
libfile="libtaos.so.${versioninfo}" libfile="libtaos.so.${versioninfo}"
# create install path, and cp file # create install path, and cp file
......
...@@ -7,8 +7,7 @@ set -e ...@@ -7,8 +7,7 @@ set -e
# set -x # set -x
# -----------------------Variables definition--------------------- # -----------------------Variables definition---------------------
script_dir=$(dirname $(readlink -m "$0")) verinfo=$(cat $1 | grep " version" | cut -d '"' -f2)
verinfo=$(cat ${script_dir}/../../src/util/src/version.c | grep " version" | cut -d '"' -f2)
verinfo=$(echo $verinfo | tr "\n" " ") verinfo=$(echo $verinfo | tr "\n" " ")
len=$(echo ${#verinfo}) len=$(echo ${#verinfo})
len=$((len-1)) len=$((len-1))
......
...@@ -101,7 +101,7 @@ function install_lib() { ...@@ -101,7 +101,7 @@ function install_lib() {
# Remove links # Remove links
${csudo} rm -f ${lib_link_dir}/libtaos.* || : ${csudo} rm -f ${lib_link_dir}/libtaos.* || :
versioninfo=$(${script_dir}/get_version.sh) versioninfo=$(${script_dir}/get_version.sh ${source_dir}/src/util/lite/src/version.c)
${csudo} cp ${binary_dir}/build/lib/libtaos.so.${versioninfo} ${install_main_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/* ${csudo} cp ${binary_dir}/build/lib/libtaos.so.${versioninfo} ${install_main_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/*
${csudo} ln -sf ${install_main_dir}/driver/libtaos.so.${versioninfo} ${lib_link_dir}/libtaos.so.1 ${csudo} ln -sf ${install_main_dir}/driver/libtaos.so.${versioninfo} ${lib_link_dir}/libtaos.so.1
${csudo} ln -sf ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so ${csudo} ln -sf ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so
......
...@@ -20,7 +20,7 @@ install_dir="${release_dir}/taos-${version}-${package_name}-$(echo ${build_time} ...@@ -20,7 +20,7 @@ install_dir="${release_dir}/taos-${version}-${package_name}-$(echo ${build_time}
# Directories and files. # Directories and files.
bin_files="${build_dir}/bin/taosd ${build_dir}/bin/taos ${build_dir}/bin/taosdemo ${build_dir}/bin/taosdump ${script_dir}/remove.sh" bin_files="${build_dir}/bin/taosd ${build_dir}/bin/taos ${build_dir}/bin/taosdemo ${build_dir}/bin/taosdump ${script_dir}/remove.sh"
versioninfo=$(${script_dir}/get_version.sh) versioninfo=$(${script_dir}/get_version.sh ${code_dir}/util/lite/src/version.c)
lib_files="${build_dir}/lib/libtaos.so.${versioninfo}" lib_files="${build_dir}/lib/libtaos.so.${versioninfo}"
header_files="${code_dir}/inc/taos.h" header_files="${code_dir}/inc/taos.h"
cfg_files="${top_dir}/packaging/cfg/*.cfg" cfg_files="${top_dir}/packaging/cfg/*.cfg"
......
CMAKE_MINIMUM_REQUIRED(VERSION 2.8) CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(TDengine) PROJECT(TDengine)
SET(PRJ_HEADER_PATH ${CMAKE_CURRENT_SOURCE_DIR}/inc)
ADD_SUBDIRECTORY(os) ADD_SUBDIRECTORY(os)
ADD_SUBDIRECTORY(util) ADD_SUBDIRECTORY(util)
ADD_SUBDIRECTORY(rpc) ADD_SUBDIRECTORY(rpc)
......
CMAKE_MINIMUM_REQUIRED(VERSION 2.8) CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(TDengine) PROJECT(TDengine)
INCLUDE_DIRECTORIES(inc)
INCLUDE_DIRECTORIES(jni)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/inc)
INCLUDE_DIRECTORIES(${TD_OS_DIR}/inc)
AUX_SOURCE_DIRECTORY(./src SRC) AUX_SOURCE_DIRECTORY(./src SRC)
INCLUDE_DIRECTORIES(inc jni ${TD_ROOT_DIR}/src/inc ${TD_OS_DIR}/inc)
IF (TD_LINUX)
INCLUDE_DIRECTORIES(${TD_ROOT_DIR}/deps/jni/linux) IF (TD_LINUX_64)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/jni/linux)
# set the static lib name # set the static lib name
ADD_LIBRARY(taos_static STATIC ${SRC}) ADD_LIBRARY(taos_static STATIC ${SRC})
...@@ -23,30 +24,38 @@ IF (TD_LINUX) ...@@ -23,30 +24,38 @@ IF (TD_LINUX)
#set version of .so #set version of .so
#VERSION so version #VERSION so version
#SOVERSION api version #SOVERSION api version
execute_process(COMMAND chmod 777 ${PROJECT_SOURCE_DIR}/../../packaging/tools/get_version.sh) IF (TD_LITE)
execute_process(COMMAND ${PROJECT_SOURCE_DIR}/../../packaging/tools/get_version.sh execute_process(COMMAND chmod 777 ${TD_COMMUNITY_DIR}/packaging/tools/get_version.sh)
execute_process(COMMAND ${TD_COMMUNITY_DIR}/packaging/tools/get_version.sh ${TD_COMMUNITY_DIR}/src/util/src/version.c
OUTPUT_VARIABLE
VERSION_INFO)
MESSAGE(STATUS "build lite version ${VERSION_INFO}")
ELSE ()
execute_process(COMMAND chmod 777 ${TD_COMMUNITY_DIR}/packaging/tools/get_version.sh)
execute_process(COMMAND ${TD_COMMUNITY_DIR}/packaging/tools/get_version.sh ${TD_ENTERPRISE_DIR}/src/util/src/version.c
OUTPUT_VARIABLE OUTPUT_VARIABLE
VERSION_INFO) VERSION_INFO)
MESSAGE(STATUS "build cluster version ${VERSION_INFO}")
ENDIF ()
MESSAGE(STATUS "build version ${VERSION_INFO}") MESSAGE(STATUS "build version ${VERSION_INFO}")
SET_TARGET_PROPERTIES(taos PROPERTIES VERSION ${VERSION_INFO} SOVERSION 1) SET_TARGET_PROPERTIES(taos PROPERTIES VERSION ${VERSION_INFO} SOVERSION 1)
ELSEIF (TD_WINDOWS) ELSEIF (TD_WINDOWS_64)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/jni/windows)
INCLUDE_DIRECTORIES(${TD_ROOT_DIR}/deps/jni/windows) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/jni/windows/win32)
INCLUDE_DIRECTORIES(${TD_ROOT_DIR}/deps/jni/windows/win32) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/pthread)
INCLUDE_DIRECTORIES(${TD_ROOT_DIR}/deps/pthread)
ADD_LIBRARY(taos_static STATIC ${SRC}) ADD_LIBRARY(taos_static STATIC ${SRC})
TARGET_LINK_LIBRARIES(taos_static trpc tutil) TARGET_LINK_LIBRARIES(taos_static trpc tutil)
# generate dynamic library (*.dll) # generate dynamic library (*.dll)
ADD_LIBRARY(taos SHARED ${SRC}) ADD_LIBRARY(taos SHARED ${SRC})
SET_TARGET_PROPERTIES(taos PROPERTIES LINK_FLAGS /DEF:${TD_ROOT_DIR}/src/client/src/taos.def) SET_TARGET_PROPERTIES(taos PROPERTIES LINK_FLAGS /DEF:${TD_COMMUNITY_DIR}/src/client/src/taos.def)
TARGET_LINK_LIBRARIES(taos trpc) TARGET_LINK_LIBRARIES(taos trpc)
ELSEIF (TD_DARWIN) ELSEIF (TD_DARWIN_64)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/jni/linux)
INCLUDE_DIRECTORIES(${TD_ROOT_DIR}/deps/jni/linux)
ADD_LIBRARY(taos_static STATIC ${SRC}) ADD_LIBRARY(taos_static STATIC ${SRC})
TARGET_LINK_LIBRARIES(taos_static trpc tutil pthread m) TARGET_LINK_LIBRARIES(taos_static trpc tutil pthread m)
......
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_TSCJOINPROCESS_H
#define TDENGINE_TSCJOINPROCESS_H
#ifdef __cplusplus
extern "C" {
#endif
#include "tscUtil.h"
#include "tsclient.h"
void tscFetchDatablockFromSubquery(SSqlObj* pSql);
void tscGetQualifiedTSList(SSqlObj* pSql, SJoinSubquerySupporter* p1, SJoinSubquerySupporter* p2, int32_t* num);
void tscSetupOutputColumnIndex(SSqlObj* pSql);
int32_t tscLaunchSecondSubquery(SSqlObj* pSql);
void tscJoinQueryCallback(void* param, TAOS_RES* tres, int code);
SJoinSubquerySupporter* tscCreateJoinSupporter(SSqlObj* pSql, SSubqueryState* pState, int32_t index);
void tscDestroyJoinSupporter(SJoinSubquerySupporter* pSupporter);
#define MEM_BUF_SIZE (1<<20)
#define TS_COMP_BLOCK_PADDING 0xFFFFFFFF
#define TS_COMP_FILE_MAGIC 0x87F5EC4C
#define TS_COMP_FILE_VNODE_MAX 512
typedef struct STSList {
char* rawBuf;
int32_t allocSize;
int32_t threshold;
int32_t len;
} STSList;
typedef struct STSRawBlock {
int32_t vnode;
int64_t tag;
TSKEY* ts;
int32_t len;
} STSRawBlock;
typedef struct STSElem {
TSKEY ts;
int64_t tag;
int32_t vnode;
} STSElem;
typedef struct STSCursor {
int32_t vnodeIndex;
int32_t blockIndex;
int32_t tsIndex;
int32_t order;
} STSCursor;
typedef struct STSBlock {
int64_t tag; // tag value
int32_t numOfElem; // number of elements
int32_t compLen; // size after compressed
int32_t padding; // 0xFFFFFFFF by default, after the payload
char* payload; // actual data that is compressed
} STSBlock;
typedef struct STSVnodeBlockInfo {
int32_t vnode;
/*
* The size of buffer file is not expected to be greater than 2G,
* and the offset of int32_t type is enough
*/
int32_t offset;
int32_t numOfBlocks;
int32_t compLen;
} STSVnodeBlockInfo;
typedef struct STSVnodeBlockInfoEx {
STSVnodeBlockInfo info;
int32_t len; // length before compress
} STSVnodeBlockInfoEx;
typedef struct STSBuf {
FILE* f;
char path[PATH_MAX];
uint32_t fileSize;
STSVnodeBlockInfoEx* pData;
int32_t numOfAlloc;
int32_t numOfVnodes;
char* assistBuf;
int32_t bufSize;
STSBlock block;
STSList tsData; // uncompressed raw ts data
uint64_t numOfTotal;
bool autoDelete;
int32_t tsOrder; // order of timestamp in ts comp buffer
STSCursor cur;
} STSBuf;
typedef struct STSBufFileHeader {
uint32_t magic; // file magic number
uint32_t numOfVnode; // number of vnode stored in current file
uint32_t tsOrder; // timestamp order in current file
} STSBufFileHeader;
STSBuf* tsBufCreate(bool autoDelete);
STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete);
STSBuf* tsBufCreateFromCompBlocks(const char* pData, int32_t numOfBlocks, int32_t len, int32_t tsOrder);
void tsBufDestory(STSBuf* pTSBuf);
void tsBufAppend(STSBuf* pTSBuf, int32_t vnodeId, int64_t tag, const char* pData, int32_t len);
int32_t tsBufMerge(STSBuf* pDestBuf, const STSBuf* pSrcBuf, int32_t vnodeIdx);
STSVnodeBlockInfo* tsBufGetVnodeBlockInfo(STSBuf* pTSBuf, int32_t vnodeId);
void tsBufFlush(STSBuf* pTSBuf);
void tsBufResetPos(STSBuf* pTSBuf);
STSElem tsBufGetElem(STSBuf* pTSBuf);
bool tsBufNextPos(STSBuf* pTSBuf);
STSElem tsBufGetElemStartPos(STSBuf* pTSBuf, int32_t vnodeId, int64_t tag);
STSCursor tsBufGetCursor(STSBuf* pTSBuf);
void tsBufSetTraverseOrder(STSBuf* pTSBuf, int32_t order);
void tsBufSetCursor(STSBuf* pTSBuf, STSCursor* pCur);
STSBuf* tsBufClone(STSBuf* pTSBuf);
/**
* display all data in comp block file, for debug purpose only
* @param pTSBuf
*/
void tsBufDisplay(STSBuf* pTSBuf);
#ifdef __cplusplus
}
#endif
#endif // TDENGINE_TSCJOINPROCESS_H
...@@ -52,72 +52,51 @@ enum { ...@@ -52,72 +52,51 @@ enum {
}; };
typedef struct SLocalReducer { typedef struct SLocalReducer {
SLocalDataSource **pLocalDataSrc; SLocalDataSource ** pLocalDataSrc;
int32_t numOfBuffer; int32_t numOfBuffer;
int32_t numOfCompleted; int32_t numOfCompleted;
int32_t numOfVnode; int32_t numOfVnode;
SLoserTreeInfo * pLoserTree;
SLoserTreeInfo *pLoserTree;
char * prevRowOfInput; char * prevRowOfInput;
tFilePage * pResultBuf;
tFilePage *pResultBuf;
int32_t nResultBufSize; int32_t nResultBufSize;
char * pBufForInterpo; // intermediate buffer for interpolation
char *pBufForInterpo; // intermediate buffer for interpolation tFilePage * pTempBuffer;
tFilePage *pTempBuffer;
struct SQLFunctionCtx *pCtx; struct SQLFunctionCtx *pCtx;
int32_t rowSize; // size of each intermediate result. int32_t rowSize; // size of each intermediate result.
int32_t status; // denote it is in reduce process, in reduce process, it int32_t status; // denote it is in reduce process, in reduce process, it
// cannot be released bool hasPrevRow; // cannot be released
bool hasPrevRow;
bool hasUnprocessedRow; bool hasUnprocessedRow;
tOrderDescriptor * pDesc;
tOrderDescriptor *pDesc;
tColModel * resColModel; tColModel * resColModel;
tExtMemBuffer ** pExtMemBuffer; // disk-based buffer tExtMemBuffer ** pExtMemBuffer; // disk-based buffer
SInterpolationInfo interpolationInfo; // interpolation support structure SInterpolationInfo interpolationInfo; // interpolation support structure
char * pFinalRes; // result data after interpo
char *pFinalRes; // result data after interpo tFilePage * discardData;
SResultInfo * pResInfo;
tFilePage *discardData;
bool discard; bool discard;
int32_t offset; // limit offset value
int32_t offset;
} SLocalReducer; } SLocalReducer;
typedef struct SSubqueryState {
/*
* the number of completed retrieval subquery, once this value equals to numOfVnodes,
* all retrieval are completed.Local merge is launched.
*/
int32_t numOfCompleted;
int32_t numOfTotal; // number of total sub-queries
int32_t code; // code from subqueries
uint64_t numOfRetrievedRows; // total number of points in this query
} SSubqueryState;
typedef struct SRetrieveSupport { typedef struct SRetrieveSupport {
tExtMemBuffer ** pExtMemBuffer; // for build loser tree tExtMemBuffer ** pExtMemBuffer; // for build loser tree
tOrderDescriptor *pOrderDescriptor; tOrderDescriptor *pOrderDescriptor;
tColModel * pFinalColModel; // colModel for final result tColModel * pFinalColModel; // colModel for final result
SSubqueryState * pState;
/*
* shared by all subqueries
* It is the number of completed retrieval subquery.
* once this value equals to numOfVnodes, all retrieval are completed.
* Local merge is launched.
*/
int32_t *numOfFinished;
int32_t numOfVnodes; // total number of vnode
int32_t vnodeIdx; // index of current vnode in vnode list int32_t vnodeIdx; // index of current vnode in vnode list
/*
* shared by all subqueries
* denote the status of query on vnode, if code!=0, all following
* retrieval on vnode are aborted.
*/
int32_t *code;
SSqlObj * pParentSqlObj; SSqlObj * pParentSqlObj;
tFilePage *localBuffer; // temp buffer, there is a buffer for each vnode to tFilePage * localBuffer; // temp buffer, there is a buffer for each vnode to
// save data
uint64_t *numOfTotalRetrievedPoints; // total number of points in this query
// retrieved from server
uint32_t numOfRetry; // record the number of retry times uint32_t numOfRetry; // record the number of retry times
pthread_mutex_t queryMutex; pthread_mutex_t queryMutex;
} SRetrieveSupport; } SRetrieveSupport;
......
...@@ -23,18 +23,20 @@ extern "C" { ...@@ -23,18 +23,20 @@ extern "C" {
/* /*
* @date 2018/09/30 * @date 2018/09/30
*/ */
#include <limits.h>
#include <stdio.h> #include <stdio.h>
#include "tsdb.h"
#include "tsclient.h"
#include "textbuffer.h" #include "textbuffer.h"
#include "tsclient.h"
#include "tsdb.h"
#include "tscSecondaryMerge.h"
#define UTIL_METER_IS_METRIC(cmd) (((cmd)->pMeterMeta != NULL) && ((cmd)->pMeterMeta->meterType == TSDB_METER_METRIC)) #define UTIL_METER_IS_METRIC(cmd) (((cmd)->pMeterMeta != NULL) && ((cmd)->pMeterMeta->meterType == TSDB_METER_METRIC))
#define UTIL_METER_IS_NOMRAL_METER(cmd) (!(UTIL_METER_IS_METRIC(cmd))) #define UTIL_METER_IS_NOMRAL_METER(cmd) (!(UTIL_METER_IS_METRIC(cmd)))
#define UTIL_METER_IS_CREATE_FROM_METRIC(cmd) \ #define UTIL_METER_IS_CREATE_FROM_METRIC(cmd) \
(((cmd)->pMeterMeta != NULL) && ((cmd)->pMeterMeta->meterType == TSDB_METER_MTABLE)) (((cmd)->pMeterMeta != NULL) && ((cmd)->pMeterMeta->meterType == TSDB_METER_MTABLE))
#define TSDB_COL_IS_TAG(f) (((f)&TSDB_COL_TAG) != 0)
typedef struct SParsedColElem { typedef struct SParsedColElem {
int16_t colIndex; int16_t colIndex;
int16_t offset; int16_t offset;
...@@ -47,15 +49,36 @@ typedef struct SParsedDataColInfo { ...@@ -47,15 +49,36 @@ typedef struct SParsedDataColInfo {
bool hasVal[TSDB_MAX_COLUMNS]; bool hasVal[TSDB_MAX_COLUMNS];
} SParsedDataColInfo; } SParsedDataColInfo;
STableDataBlocks* tscCreateDataBlock(int32_t size); typedef struct SJoinSubquerySupporter {
SSubqueryState* pState;
SSqlObj* pObj; // parent SqlObj
bool hasMore; // has data from vnode to fetch
int32_t subqueryIndex; // index of sub query
int64_t interval; // interval time
SLimitVal limit; // limit info
uint64_t uid; // query meter uid
SColumnBaseInfo colList; // previous query information
SSqlExprInfo exprsInfo;
SFieldInfo fieldsInfo;
STagCond tagCond;
SSqlGroupbyExpr groupbyExpr;
struct STSBuf* pTSBuf;
FILE* f;
char path[PATH_MAX];
} SJoinSubquerySupporter;
void tscDestroyDataBlock(STableDataBlocks* pDataBlock); void tscDestroyDataBlock(STableDataBlocks* pDataBlock);
STableDataBlocks* tscCreateDataBlock(int32_t size);
void tscAppendDataBlock(SDataBlockList* pList, STableDataBlocks* pBlocks); void tscAppendDataBlock(SDataBlockList* pList, STableDataBlocks* pBlocks);
SParamInfo* tscAddParamToDataBlock(STableDataBlocks* pDataBlock, char type, uint8_t timePrec, short bytes, uint32_t offset);
SDataBlockList* tscCreateBlockArrayList(); SDataBlockList* tscCreateBlockArrayList();
void* tscDestroyBlockArrayList(SDataBlockList* pList); void* tscDestroyBlockArrayList(SDataBlockList* pList);
int32_t tscCopyDataBlockToPayload(SSqlObj* pSql, STableDataBlocks* pDataBlock); int32_t tscCopyDataBlockToPayload(SSqlObj* pSql, STableDataBlocks* pDataBlock);
void tscFreeUnusedDataBlocks(SDataBlockList* pList); void tscFreeUnusedDataBlocks(SDataBlockList* pList);
void tscMergeTableDataBlocks(SSqlObj* pSql, SDataBlockList* pDataList); int32_t tscMergeTableDataBlocks(SSqlObj* pSql, SDataBlockList* pDataList);
STableDataBlocks* tscGetDataBlockFromList(void* pHashList, SDataBlockList* pDataBlockList, int64_t id, int32_t size, STableDataBlocks* tscGetDataBlockFromList(void* pHashList, SDataBlockList* pDataBlockList, int64_t id, int32_t size,
int32_t startOffset, int32_t rowSize, char* tableId); int32_t startOffset, int32_t rowSize, char* tableId);
STableDataBlocks* tscCreateDataBlockEx(size_t size, int32_t rowSize, int32_t startOffset, char* name); STableDataBlocks* tscCreateDataBlockEx(size_t size, int32_t rowSize, int32_t startOffset, char* name);
...@@ -63,9 +86,6 @@ STableDataBlocks* tscCreateDataBlockEx(size_t size, int32_t rowSize, int32_t sta ...@@ -63,9 +86,6 @@ STableDataBlocks* tscCreateDataBlockEx(size_t size, int32_t rowSize, int32_t sta
SVnodeSidList* tscGetVnodeSidList(SMetricMeta* pMetricmeta, int32_t vnodeIdx); SVnodeSidList* tscGetVnodeSidList(SMetricMeta* pMetricmeta, int32_t vnodeIdx);
SMeterSidExtInfo* tscGetMeterSidInfo(SVnodeSidList* pSidList, int32_t idx); SMeterSidExtInfo* tscGetMeterSidInfo(SVnodeSidList* pSidList, int32_t idx);
bool tscProjectionQueryOnMetric(SSqlObj* pSql);
bool tscIsTwoStageMergeMetricQuery(SSqlObj* pSql);
/** /**
* *
* for the projection query on metric or point interpolation query on metric, * for the projection query on metric or point interpolation query on metric,
...@@ -73,52 +93,71 @@ bool tscIsTwoStageMergeMetricQuery(SSqlObj* pSql); ...@@ -73,52 +93,71 @@ bool tscIsTwoStageMergeMetricQuery(SSqlObj* pSql);
* *
* @param pSql sql object * @param pSql sql object
* @return * @return
*
*/ */
bool tscIsFirstProjQueryOnMetric(SSqlObj* pSql);
bool tscIsPointInterpQuery(SSqlCmd* pCmd); bool tscIsPointInterpQuery(SSqlCmd* pCmd);
void tscClearInterpInfo(SSqlCmd* pCmd); bool tscIsTWAQuery(SSqlCmd* pCmd);
bool tscProjectionQueryOnMetric(SSqlCmd* pCmd);
bool tscIsTwoStageMergeMetricQuery(SSqlCmd* pCmd);
bool tscQueryOnMetric(SSqlCmd* pCmd);
bool tscQueryMetricTags(SSqlCmd* pCmd);
bool tscIsSelectivityWithTagQuery(SSqlCmd* pCmd);
void tscAddSpecialColumnForSelect(SSqlCmd* pCmd, int32_t outputColIndex, int16_t functionId, SColumnIndex* pIndex,
SSchema* pColSchema, int16_t isTag);
int32_t setMeterID(SSqlObj* pSql, SSQLToken* pzTableName); void addRequiredTagColumn(SSqlCmd* pCmd, int32_t tagColIndex, int32_t tableIndex);
void SStringFree(SString* str);
void SStringCopy(SString* pDest, const SString* pSrc);
SString SStringCreate(const char* str);
int32_t SStringAlloc(SString* pStr, int32_t size);
int32_t SStringEnsureRemain(SString* pStr, int32_t size);
int32_t setMeterID(SSqlObj* pSql, SSQLToken* pzTableName, int32_t tableIndex);
void tscClearInterpInfo(SSqlCmd* pCmd);
bool tscIsInsertOrImportData(char* sqlstr); bool tscIsInsertOrImportData(char* sqlstr);
/* use for keep current db info temporarily, for handle table with db prefix */ /* use for keep current db info temporarily, for handle table with db prefix */
void tscGetDBInfoFromMeterId(char* meterId, char* db); void tscGetDBInfoFromMeterId(char* meterId, char* db);
void tscGetMetricMetaCacheKey(SSqlCmd* pCmd, char* keyStr); int tscAllocPayload(SSqlCmd* pCmd, int size);
bool tscQueryOnMetric(SSqlCmd* pCmd);
int tscAllocPayloadWithSize(SSqlCmd* pCmd, int size);
void tscFieldInfoSetValFromSchema(SFieldInfo* pFieldInfo, int32_t index, SSchema* pSchema); void tscFieldInfoSetValFromSchema(SFieldInfo* pFieldInfo, int32_t index, SSchema* pSchema);
void tscFieldInfoSetValFromField(SFieldInfo* pFieldInfo, int32_t index, TAOS_FIELD* pField); void tscFieldInfoSetValFromField(SFieldInfo* pFieldInfo, int32_t index, TAOS_FIELD* pField);
void tscFieldInfoSetValue(SFieldInfo* pFieldInfo, int32_t index, int8_t type, char* name, int16_t bytes); void tscFieldInfoSetValue(SFieldInfo* pFieldInfo, int32_t index, int8_t type, char* name, int16_t bytes);
void tscFieldInfoUpdateVisible(SFieldInfo* pFieldInfo, int32_t index, bool visible);
void tscFieldInfoCalOffset(SSqlCmd* pCmd); void tscFieldInfoCalOffset(SSqlCmd* pCmd);
void tscFieldInfoRenewOffsetForInterResult(SSqlCmd* pCmd); void tscFieldInfoUpdateOffset(SSqlCmd* pCmd);
void tscFieldInfoClone(SFieldInfo* src, SFieldInfo* dst); void tscFieldInfoCopy(SFieldInfo* src, SFieldInfo* dst, const int32_t* indexList, int32_t size);
void tscFieldInfoCopyAll(SFieldInfo* src, SFieldInfo* dst);
TAOS_FIELD* tscFieldInfoGetField(SSqlCmd* pCmd, int32_t index); TAOS_FIELD* tscFieldInfoGetField(SSqlCmd* pCmd, int32_t index);
int16_t tscFieldInfoGetOffset(SSqlCmd* pCmd, int32_t index); int16_t tscFieldInfoGetOffset(SSqlCmd* pCmd, int32_t index);
int32_t tscGetResRowLength(SSqlCmd* pCmd); int32_t tscGetResRowLength(SSqlCmd* pCmd);
void tscClearFieldInfo(SSqlCmd* pCmd); void tscClearFieldInfo(SFieldInfo* pFieldInfo);
void addExprParams(SSqlExpr* pExpr, char* argument, int32_t type, int32_t bytes); void addExprParams(SSqlExpr* pExpr, char* argument, int32_t type, int32_t bytes, int16_t tableIndex);
SSqlExpr* tscSqlExprInsert(SSqlCmd* pCmd, int32_t index, int16_t functionId, int16_t srcColumnIndex, int16_t type, SSqlExpr* tscSqlExprInsert(SSqlCmd* pCmd, int32_t index, int16_t functionId, SColumnIndex* pColIndex, int16_t type,
int16_t size); int16_t size, /*int16_t colId,*/ int16_t interSize);
SSqlExpr* tscSqlExprUpdate(SSqlCmd* pCmd, int32_t index, int16_t functionId, int16_t srcColumnIndex, int16_t type, SSqlExpr* tscSqlExprUpdate(SSqlCmd* pCmd, int32_t index, int16_t functionId, int16_t srcColumnIndex, int16_t type,
int16_t size); int16_t size);
SSqlExpr* tscSqlExprGet(SSqlCmd* pCmd, int32_t index); SSqlExpr* tscSqlExprGet(SSqlCmd* pCmd, int32_t index);
void tscSqlExprClone(SSqlExprInfo* src, SSqlExprInfo* dst); void tscSqlExprCopy(SSqlExprInfo* dst, const SSqlExprInfo* src, uint64_t uid);
SColumnBase* tscColumnBaseInfoInsert(SSqlCmd* pCmd, SColumnIndex* colIndex);
void tscColumnFilterInfoCopy(SColumnFilterInfo* dst, const SColumnFilterInfo* src);
void tscColumnBaseCopy(SColumnBase* dst, const SColumnBase* src);
SColumnBase* tscColumnInfoInsert(SSqlCmd* pCmd, int32_t colIndex); void tscColumnBaseInfoCopy(SColumnBaseInfo* dst, const SColumnBaseInfo* src, int16_t tableIndex);
SColumnBase* tscColumnBaseInfoGet(SColumnBaseInfo* pColumnBaseInfo, int32_t index);
void tscColumnBaseInfoUpdateTableIndex(SColumnBaseInfo* pColList, int16_t tableIndex);
void tscColumnInfoClone(SColumnsInfo* src, SColumnsInfo* dst); void tscColumnBaseInfoReserve(SColumnBaseInfo* pColumnBaseInfo, int32_t size);
SColumnBase* tscColumnInfoGet(SSqlCmd* pCmd, int32_t index); void tscColumnBaseInfoDestroy(SColumnBaseInfo* pColumnBaseInfo);
void tscColumnInfoReserve(SSqlCmd* pCmd, int32_t size);
int32_t tscValidateName(SSQLToken* pToken); int32_t tscValidateName(SSQLToken* pToken);
...@@ -127,8 +166,10 @@ void tscIncStreamExecutionCount(void* pStream); ...@@ -127,8 +166,10 @@ void tscIncStreamExecutionCount(void* pStream);
bool tscValidateColumnId(SSqlCmd* pCmd, int32_t colId); bool tscValidateColumnId(SSqlCmd* pCmd, int32_t colId);
// get starter position of metric query condition (query on tags) in SSqlCmd.payload // get starter position of metric query condition (query on tags) in SSqlCmd.payload
char* tsGetMetricQueryCondPos(STagCond* pCond); SCond* tsGetMetricQueryCondPos(STagCond* pCond, uint64_t tableIndex);
void tscTagCondAssign(STagCond* pDst, STagCond* pSrc); void tsSetMetricQueryCond(STagCond* pTagCond, uint64_t uid, const char* str);
void tscTagCondCopy(STagCond* dest, const STagCond* src);
void tscTagCondRelease(STagCond* pCond); void tscTagCondRelease(STagCond* pCond);
void tscTagCondSetQueryCondType(STagCond* pCond, int16_t type); void tscTagCondSetQueryCondType(STagCond* pCond, int16_t type);
...@@ -138,8 +179,54 @@ void tscSetFreeHeatBeat(STscObj* pObj); ...@@ -138,8 +179,54 @@ void tscSetFreeHeatBeat(STscObj* pObj);
bool tscShouldFreeHeatBeat(SSqlObj* pHb); bool tscShouldFreeHeatBeat(SSqlObj* pHb);
void tscCleanSqlCmd(SSqlCmd* pCmd); void tscCleanSqlCmd(SSqlCmd* pCmd);
bool tscShouldFreeAsyncSqlObj(SSqlObj* pSql); bool tscShouldFreeAsyncSqlObj(SSqlObj* pSql);
void tscRemoveAllMeterMetaInfo(SSqlCmd* pCmd, bool removeFromCache);
SMeterMetaInfo* tscGetMeterMetaInfo(SSqlCmd* pCmd, int32_t index);
SMeterMetaInfo* tscGetMeterMetaInfoByUid(SSqlCmd* pCmd, uint64_t uid, int32_t* index);
void tscClearMeterMetaInfo(SMeterMetaInfo* pMeterMetaInfo, bool removeFromCache);
SMeterMetaInfo* tscAddMeterMetaInfo(SSqlCmd* pCmd, const char* name, SMeterMeta* pMeterMeta, SMetricMeta* pMetricMeta,
int16_t numOfTags, int16_t* tags);
SMeterMetaInfo* tscAddEmptyMeterMetaInfo(SSqlCmd* pCmd);
void tscGetMetricMetaCacheKey(SSqlCmd* pCmd, char* keyStr, uint64_t uid);
int tscGetMetricMeta(SSqlObj* pSql);
int tscGetMeterMeta(SSqlObj* pSql, char* meterId, int32_t tableIndex);
int tscGetMeterMetaEx(SSqlObj* pSql, char* meterId, bool createIfNotExists);
void tscResetForNextRetrieve(SSqlRes* pRes);
void tscAddTimestampColumn(SSqlCmd* pCmd, int16_t functionId, int16_t tableIndex);
void tscDoQuery(SSqlObj* pSql); void tscDoQuery(SSqlObj* pSql);
/**
* The create object function must be successful expect for the out of memory issue.
*
* Therefore, the metermeta/metricmeta object is directly passed to the newly created subquery object from the
* previous sql object, instead of retrieving the metermeta/metricmeta from cache.
*
* Because the metermeta/metricmeta may have been released by other threads, resulting in the retrieving failed as
* well as the create function.
*
* @param pSql
* @param vnodeIndex
* @param tableIndex
* @param fp
* @param param
* @param pPrevSql
* @return
*/
SSqlObj* createSubqueryObj(SSqlObj* pSql, int32_t vnodeIndex, int16_t tableIndex, void (*fp)(), void* param,
SSqlObj* pPrevSql);
void addGroupInfoForSubquery(SSqlObj* pParentObj, SSqlObj* pSql, int32_t tableIndex);
void doAddGroupColumnForSubquery(SSqlCmd* pCmd, int32_t tagIndex);
int16_t tscGetJoinTagColIndexByUid(SSqlCmd* pCmd, uint64_t uid);
TAOS* taos_connect_a(char* ip, char* user, char* pass, char* db, int port, void (*fp)(void*, TAOS_RES*, int),
void* param, void** taos);
void sortRemoveDuplicates(STableDataBlocks* dataBuf); void sortRemoveDuplicates(STableDataBlocks* dataBuf);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -63,9 +63,9 @@ enum _sql_cmd { ...@@ -63,9 +63,9 @@ enum _sql_cmd {
TSDB_SQL_ALTER_DB, TSDB_SQL_ALTER_DB,
TSDB_SQL_CREATE_MNODE, TSDB_SQL_CREATE_MNODE,
TSDB_SQL_DROP_MNODE, TSDB_SQL_DROP_MNODE,
TSDB_SQL_CREATE_PNODE, TSDB_SQL_CREATE_DNODE,
TSDB_SQL_DROP_PNODE, TSDB_SQL_DROP_DNODE,
TSDB_SQL_CFG_PNODE, // 20 TSDB_SQL_CFG_DNODE, // 20
TSDB_SQL_CFG_MNODE, TSDB_SQL_CFG_MNODE,
TSDB_SQL_SHOW, TSDB_SQL_SHOW,
TSDB_SQL_RETRIEVE, TSDB_SQL_RETRIEVE,
...@@ -78,15 +78,21 @@ enum _sql_cmd { ...@@ -78,15 +78,21 @@ enum _sql_cmd {
TSDB_SQL_USE_DB, TSDB_SQL_USE_DB,
TSDB_SQL_META, // 30 TSDB_SQL_META, // 30
TSDB_SQL_METRIC, TSDB_SQL_METRIC,
TSDB_SQL_MULTI_META,
TSDB_SQL_HB, TSDB_SQL_HB,
TSDB_SQL_LOCAL, // SQL below for client local TSDB_SQL_LOCAL, // SQL below for client local
TSDB_SQL_DESCRIBE_TABLE, TSDB_SQL_DESCRIBE_TABLE,
TSDB_SQL_RETRIEVE_METRIC, TSDB_SQL_RETRIEVE_METRIC,
TSDB_SQL_METRIC_JOIN_RETRIEVE,
TSDB_SQL_RETRIEVE_TAGS, TSDB_SQL_RETRIEVE_TAGS,
TSDB_SQL_RETRIEVE_EMPTY_RESULT, // build empty result instead of accessing /*
// dnode to fetch result * build empty result instead of accessing dnode to fetch result
TSDB_SQL_RESET_CACHE, // reset the client cache * reset the client cache
*/
TSDB_SQL_RETRIEVE_EMPTY_RESULT,
TSDB_SQL_RESET_CACHE,
TSDB_SQL_CFG_LOCAL, TSDB_SQL_CFG_LOCAL,
TSDB_SQL_MAX TSDB_SQL_MAX
...@@ -96,22 +102,33 @@ enum _sql_cmd { ...@@ -96,22 +102,33 @@ enum _sql_cmd {
struct SSqlInfo; struct SSqlInfo;
typedef struct SSqlGroupbyExpr { typedef struct SSqlGroupbyExpr {
int16_t numOfGroupbyCols; int16_t tableIndex;
int16_t tagIndex[TSDB_MAX_TAGS]; /* group by columns information */
int16_t orderIdx; /* order by column index */ int16_t numOfGroupCols;
int16_t orderType; /* order by type: asc/desc */ SColIndexEx columnInfo[TSDB_MAX_TAGS]; // group by columns information
int16_t orderIndex; // order by column index
int16_t orderType; // order by type: asc/desc
} SSqlGroupbyExpr; } SSqlGroupbyExpr;
typedef struct SMeterMetaInfo {
SMeterMeta * pMeterMeta; // metermeta
SMetricMeta *pMetricMeta; // metricmeta
char name[TSDB_METER_ID_LEN + 1];
int16_t numOfTags; // total required tags in query, including groupby tags
int16_t tagColumnIndex[TSDB_MAX_TAGS]; // clause + tag projection
} SMeterMetaInfo;
/* the structure for sql function in select clause */ /* the structure for sql function in select clause */
typedef struct SSqlExpr { typedef struct SSqlExpr {
char aliasName[TSDB_COL_NAME_LEN + 1]; // as aliasName char aliasName[TSDB_COL_NAME_LEN + 1]; // as aliasName
SColIndexEx colInfo;
SColIndex colInfo; int64_t uid; // refactor use the pointer
int16_t sqlFuncId; // function id in aAgg array int16_t functionId; // function id in aAgg array
int16_t resType; // return value type int16_t resType; // return value type
int16_t resBytes; // length of return value int16_t resBytes; // length of return value
int16_t interResBytes; // inter result buffer size
int16_t numOfParams; // argument value of each function int16_t numOfParams; // argument value of each function
tVariant param[3]; // parameters are not more than 3 tVariant param[3]; // parameters are not more than 3
} SSqlExpr; } SSqlExpr;
...@@ -121,6 +138,15 @@ typedef struct SFieldInfo { ...@@ -121,6 +138,15 @@ typedef struct SFieldInfo {
int16_t numOfAlloc; // allocated size int16_t numOfAlloc; // allocated size
TAOS_FIELD *pFields; TAOS_FIELD *pFields;
short * pOffset; short * pOffset;
/*
* define if this column is belong to the queried result, it may be add by parser to faciliate
* the query process
*
* NOTE: these hidden columns always locate at the end of the output columns
*/
bool * pVisibleCols;
int32_t numOfHiddenCols; // the number of column not belongs to the queried result columns
} SFieldInfo; } SFieldInfo;
typedef struct SSqlExprInfo { typedef struct SSqlExprInfo {
...@@ -129,63 +155,94 @@ typedef struct SSqlExprInfo { ...@@ -129,63 +155,94 @@ typedef struct SSqlExprInfo {
SSqlExpr *pExprs; SSqlExpr *pExprs;
} SSqlExprInfo; } SSqlExprInfo;
typedef struct SColumnBase { typedef struct SColumnIndex {
int16_t colIndex; int16_t tableIndex;
int16_t columnIndex;
/* todo refactor: the following data is belong to one struct */ } SColumnIndex;
int16_t filterOn; /* denote if the filter is active */
int16_t lowerRelOptr;
int16_t upperRelOptr;
int16_t filterOnBinary; /* denote if current column is binary */
union { typedef struct SColumnBase {
struct { SColumnIndex colIndex;
int64_t lowerBndi; int32_t numOfFilters;
int64_t upperBndi; SColumnFilterInfo *filterInfo;
};
struct {
double lowerBndd;
double upperBndd;
};
struct {
int64_t pz;
int64_t len;
};
};
} SColumnBase; } SColumnBase;
typedef struct SColumnsInfo { typedef struct SColumnBaseInfo {
int16_t numOfAlloc; int16_t numOfAlloc;
int16_t numOfCols; int16_t numOfCols;
SColumnBase *pColList; SColumnBase *pColList;
} SColumnsInfo; } SColumnBaseInfo;
struct SLocalReducer; struct SLocalReducer;
// todo move to utility
typedef struct SString {
int32_t alloc;
int32_t n;
char * z;
} SString;
typedef struct SCond {
uint64_t uid;
SString cond;
} SCond;
typedef struct SJoinNode {
char meterId[TSDB_METER_ID_LEN];
uint64_t uid;
int16_t tagCol;
} SJoinNode;
typedef struct SJoinInfo {
bool hasJoin;
SJoinNode left;
SJoinNode right;
} SJoinInfo;
typedef struct STagCond { typedef struct STagCond {
int32_t len; // relation between tbname list and query condition, including : TK_AND or TK_OR
int32_t allocSize; int16_t relType;
int16_t type;
char * pData; // tbname query condition, only support tbname query condition on one table
SCond tbnameCond;
// join condition, only support two tables join currently
SJoinInfo joinInfo;
// for different table, the query condition must be seperated
SCond cond[TSDB_MAX_JOIN_TABLE_NUM];
int16_t numOfTagCond;
} STagCond; } STagCond;
typedef struct SParamInfo {
int32_t idx;
char type;
uint8_t timePrec;
short bytes;
uint32_t offset;
} SParamInfo;
typedef struct STableDataBlocks { typedef struct STableDataBlocks {
char meterId[TSDB_METER_ID_LEN]; char meterId[TSDB_METER_ID_LEN];
int8_t tsSource; int8_t tsSource;
bool ordered;
int64_t vgid; int64_t vgid;
int64_t size;
int64_t prevTS; int64_t prevTS;
bool ordered;
int32_t numOfMeters; int32_t numOfMeters;
int32_t rowSize; int32_t rowSize;
uint32_t nAllocSize; uint32_t nAllocSize;
uint32_t size;
union { union {
char *filename; char *filename;
char *pData; char *pData;
}; };
// for parameter ('?') binding
uint32_t numOfAllocedParams;
uint32_t numOfParams;
SParamInfo* params;
} STableDataBlocks; } STableDataBlocks;
typedef struct SDataBlockList { typedef struct SDataBlockList {
...@@ -198,18 +255,22 @@ typedef struct SDataBlockList { ...@@ -198,18 +255,22 @@ typedef struct SDataBlockList {
} SDataBlockList; } SDataBlockList;
typedef struct { typedef struct {
char name[TSDB_METER_ID_LEN];
SOrderVal order; SOrderVal order;
int command; int command;
// TODO refactor
int count; int count;
int16_t isInsertFromFile; // load data from file or not int16_t isInsertFromFile; // load data from file or not
int16_t metricQuery; // metric query or not
union {
bool existsCheck; bool existsCheck;
int8_t showType;
};
char msgType; char msgType;
char type; uint16_t type;
char intervalTimeUnit; char intervalTimeUnit;
int64_t etime; int64_t etime, stime;
int64_t stime;
int64_t nAggTimeInterval; // aggregation time interval int64_t nAggTimeInterval; // aggregation time interval
int64_t nSlidingTime; // sliding window in mseconds int64_t nSlidingTime; // sliding window in mseconds
SSqlGroupbyExpr groupbyExpr; // group by tags info SSqlGroupbyExpr groupbyExpr; // group by tags info
...@@ -224,24 +285,27 @@ typedef struct { ...@@ -224,24 +285,27 @@ typedef struct {
char * payload; char * payload;
int payloadLen; int payloadLen;
short numOfCols; short numOfCols;
SColumnsInfo colList; SColumnBaseInfo colList;
SFieldInfo fieldsInfo; SFieldInfo fieldsInfo;
SSqlExprInfo exprsInfo; SSqlExprInfo exprsInfo;
int16_t numOfReqTags; // total required tags in query, inlcuding groupby clause + tag projection
int16_t tagColumnIndex[TSDB_MAX_TAGS + 1];
SLimitVal limit; SLimitVal limit;
SLimitVal slimit;
int64_t globalLimit; int64_t globalLimit;
SLimitVal glimit;
STagCond tagCond; STagCond tagCond;
int16_t vnodeIdx; // vnode index in pMetricMeta for metric query int16_t vnodeIdx; // vnode index in pMetricMeta for metric query
int16_t interpoType; // interpolate type int16_t interpoType; // interpolate type
int16_t numOfTables;
SDataBlockList *pDataBlocks; // submit data blocks branched according to vnode // submit data blocks branched according to vnode
SMeterMeta * pMeterMeta; // metermeta SDataBlockList * pDataBlocks;
SMetricMeta * pMetricMeta; // metricmeta SMeterMetaInfo **pMeterInfo;
struct STSBuf * tsBuf;
// todo use dynamic allocated memory for defaultVal // todo use dynamic allocated memory for defaultVal
int64_t defaultVal[TSDB_MAX_COLUMNS]; // default value for interpolation int64_t defaultVal[TSDB_MAX_COLUMNS]; // default value for interpolation
// for parameter ('?') binding and batch processing
int32_t batchSize;
int32_t numOfParams;
} SSqlCmd; } SSqlCmd;
typedef struct SResRec { typedef struct SResRec {
...@@ -249,6 +313,8 @@ typedef struct SResRec { ...@@ -249,6 +313,8 @@ typedef struct SResRec {
int numOfTotal; int numOfTotal;
} SResRec; } SResRec;
struct STSBuf;
typedef struct { typedef struct {
uint8_t code; uint8_t code;
int numOfRows; // num of results in current retrieved int numOfRows; // num of results in current retrieved
...@@ -263,14 +329,13 @@ typedef struct { ...@@ -263,14 +329,13 @@ typedef struct {
int16_t numOfnchar; int16_t numOfnchar;
int16_t precision; int16_t precision;
int32_t numOfGroups; int32_t numOfGroups;
SResRec *pGroupRec; SResRec * pGroupRec;
char * data; char * data;
short * bytes; short * bytes;
void ** tsrow; void ** tsrow;
char ** buffer; // Buffer used to put multibytes encoded using unicode (wchar_t)
// Buffer used to put multibytes encoded using unicode (wchar_t)
char ** buffer;
struct SLocalReducer *pLocalReducer; struct SLocalReducer *pLocalReducer;
SColumnIndex * pColumnIndex;
} SSqlRes; } SSqlRes;
typedef struct _tsc_obj { typedef struct _tsc_obj {
...@@ -328,7 +393,7 @@ typedef struct _sstream { ...@@ -328,7 +393,7 @@ typedef struct _sstream {
int64_t num; // number of computing count int64_t num; // number of computing count
/* /*
* bookmark the current number of result in computing, * keep the number of current result in computing,
* the value will be set to 0 before set timer for next computing * the value will be set to 0 before set timer for next computing
*/ */
int64_t numOfRes; int64_t numOfRes;
...@@ -336,8 +401,7 @@ typedef struct _sstream { ...@@ -336,8 +401,7 @@ typedef struct _sstream {
int64_t useconds; // total elapsed time int64_t useconds; // total elapsed time
int64_t ctime; // stream created time int64_t ctime; // stream created time
int64_t stime; // stream next executed time int64_t stime; // stream next executed time
int64_t etime; // stream end query time, when time is larger then etime, the int64_t etime; // stream end query time, when time is larger then etime, the stream will be closed
// stream will be closed
int64_t interval; int64_t interval;
int64_t slidingTime; int64_t slidingTime;
int16_t precision; int16_t precision;
...@@ -346,8 +410,7 @@ typedef struct _sstream { ...@@ -346,8 +410,7 @@ typedef struct _sstream {
void (*fp)(); void (*fp)();
void *param; void *param;
// Call backfunction when stream is stopped from client level void (*callback)(void *); // Callback function when stream is stopped from client level
void (*callback)(void *);
struct _sstream *prev, *next; struct _sstream *prev, *next;
} SSqlStream; } SSqlStream;
...@@ -363,14 +426,12 @@ int tsParseSql(SSqlObj *pSql, char *acct, char *db, bool multiVnodeInsertion); ...@@ -363,14 +426,12 @@ int tsParseSql(SSqlObj *pSql, char *acct, char *db, bool multiVnodeInsertion);
void tscInitMsgs(); void tscInitMsgs();
void *tscProcessMsgFromServer(char *msg, void *ahandle, void *thandle); void *tscProcessMsgFromServer(char *msg, void *ahandle, void *thandle);
int tscProcessSql(SSqlObj *pSql); int tscProcessSql(SSqlObj *pSql);
int tscGetMeterMeta(SSqlObj *pSql, char *meterId);
int tscGetMeterMetaEx(SSqlObj *pSql, char *meterId, bool createIfNotExists);
void tscAsyncInsertMultiVnodesProxy(void *param, TAOS_RES *tres, int numOfRows); void tscAsyncInsertMultiVnodesProxy(void *param, TAOS_RES *tres, int numOfRows);
int tscRenewMeterMeta(SSqlObj *pSql, char *meterId); int tscRenewMeterMeta(SSqlObj *pSql, char *meterId);
void tscQueueAsyncRes(SSqlObj *pSql); void tscQueueAsyncRes(SSqlObj *pSql);
int tscGetMetricMeta(SSqlObj *pSql, char *meterId);
void tscQueueAsyncError(void(*fp), void *param); void tscQueueAsyncError(void(*fp), void *param);
int tscProcessLocalCmd(SSqlObj *pSql); int tscProcessLocalCmd(SSqlObj *pSql);
...@@ -381,7 +442,7 @@ int taos_retrieve(TAOS_RES *res); ...@@ -381,7 +442,7 @@ int taos_retrieve(TAOS_RES *res);
* transfer function for metric query in stream computing, the function need to be change * transfer function for metric query in stream computing, the function need to be change
* before send query message to vnode * before send query message to vnode
*/ */
void tscTansformSQLFunctionForMetricQuery(SSqlCmd *pCmd); int32_t tscTansformSQLFunctionForMetricQuery(SSqlCmd *pCmd);
void tscRestoreSQLFunctionForMetricQuery(SSqlCmd *pCmd); void tscRestoreSQLFunctionForMetricQuery(SSqlCmd *pCmd);
/** /**
...@@ -395,7 +456,7 @@ void tscClearSqlMetaInfoForce(SSqlCmd *pCmd); ...@@ -395,7 +456,7 @@ void tscClearSqlMetaInfoForce(SSqlCmd *pCmd);
int32_t tscCreateResPointerInfo(SSqlCmd *pCmd, SSqlRes *pRes); int32_t tscCreateResPointerInfo(SSqlCmd *pCmd, SSqlRes *pRes);
void tscDestroyResPointerInfo(SSqlRes *pRes); void tscDestroyResPointerInfo(SSqlRes *pRes);
void tscfreeSqlCmdData(SSqlCmd *pCmd); void tscFreeSqlCmdData(SSqlCmd *pCmd);
/** /**
* only free part of resources allocated during query. * only free part of resources allocated during query.
...@@ -413,17 +474,6 @@ void tscFreeSqlObj(SSqlObj *pObj); ...@@ -413,17 +474,6 @@ void tscFreeSqlObj(SSqlObj *pObj);
void tscCloseTscObj(STscObj *pObj); void tscCloseTscObj(STscObj *pObj);
//
// support functions for async metric query.
// we declare them as global visible functions, because we need them to check if a
// failed async query in tscMeterMetaCallBack is a metric query or not.
// expr: (fp == tscRetrieveDataRes or fp == tscRetrieveFromVnodeCallBack)
// If a query is async query, we simply abort current query process, instead of continuing
//
void tscRetrieveDataRes(void *param, TAOS_RES *tres, int numOfRows);
void tscRetrieveFromVnodeCallBack(void *param, TAOS_RES *tres, int numOfRows);
void tscProcessMultiVnodesInsert(SSqlObj *pSql); void tscProcessMultiVnodesInsert(SSqlObj *pSql);
void tscProcessMultiVnodesInsertForFile(SSqlObj *pSql); void tscProcessMultiVnodesInsertForFile(SSqlObj *pSql);
void tscKillMetricQuery(SSqlObj *pSql); void tscKillMetricQuery(SSqlObj *pSql);
...@@ -446,7 +496,7 @@ extern void * tscQhandle; ...@@ -446,7 +496,7 @@ extern void * tscQhandle;
extern int tscKeepConn[]; extern int tscKeepConn[];
extern int tsInsertHeadSize; extern int tsInsertHeadSize;
extern int tscNumOfThreads; extern int tscNumOfThreads;
extern uint32_t tsServerIp; extern SIpStrList tscMgmtIpList;
#ifdef __cplusplus #ifdef __cplusplus
} }
......
文件模式从 100755 更改为 100644
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "com_taosdata_jdbc_TSDBJNIConnector.h" #include "com_taosdata_jdbc_TSDBJNIConnector.h"
#include "taos.h" #include "taos.h"
#include "tlog.h" #include "tlog.h"
#include "tscJoinProcess.h"
#include "tsclient.h" #include "tsclient.h"
#include "tscUtil.h" #include "tscUtil.h"
......
此差异已折叠。
...@@ -40,7 +40,7 @@ static void tscProcessAsyncRetrieveImpl(void *param, TAOS_RES *tres, int numOfRo ...@@ -40,7 +40,7 @@ static void tscProcessAsyncRetrieveImpl(void *param, TAOS_RES *tres, int numOfRo
*/ */
static void tscProcessAsyncFetchRowsProxy(void *param, TAOS_RES *tres, int numOfRows); static void tscProcessAsyncFetchRowsProxy(void *param, TAOS_RES *tres, int numOfRows);
void taos_query_a(TAOS *taos, char *sqlstr, void (*fp)(void *, TAOS_RES *, int), void *param) { void taos_query_a(TAOS *taos, const char *sqlstr, void (*fp)(void *, TAOS_RES *, int), void *param) {
STscObj *pObj = (STscObj *)taos; STscObj *pObj = (STscObj *)taos;
if (pObj == NULL || pObj->signature != pObj) { if (pObj == NULL || pObj->signature != pObj) {
tscError("bug!!! pObj:%p", pObj); tscError("bug!!! pObj:%p", pObj);
...@@ -72,13 +72,14 @@ void taos_query_a(TAOS *taos, char *sqlstr, void (*fp)(void *, TAOS_RES *, int), ...@@ -72,13 +72,14 @@ void taos_query_a(TAOS *taos, char *sqlstr, void (*fp)(void *, TAOS_RES *, int),
pSql->fp = fp; pSql->fp = fp;
pSql->param = param; pSql->param = param;
if (tscAllocPayloadWithSize(pCmd, TSDB_DEFAULT_PAYLOAD_SIZE) != TSDB_CODE_SUCCESS) { if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, TSDB_DEFAULT_PAYLOAD_SIZE)) {
tscError("%p failed to alloc payload", pSql); tscError("failed to malloc payload");
tfree(pSql);
tscQueueAsyncError(fp, param); tscQueueAsyncError(fp, param);
free(pSql);
return; return;
} }
pSql->sqlstr = malloc(sqlLen + 1); pSql->sqlstr = malloc(sqlLen + 1);
if (pSql->sqlstr == NULL) { if (pSql->sqlstr == NULL) {
tscError("%p failed to malloc sql string buffer", pSql); tscError("%p failed to malloc sql string buffer", pSql);
...@@ -116,9 +117,9 @@ static void tscProcessAsyncFetchRowsProxy(void *param, TAOS_RES *tres, int numOf ...@@ -116,9 +117,9 @@ static void tscProcessAsyncFetchRowsProxy(void *param, TAOS_RES *tres, int numOf
SSqlCmd *pCmd = &pSql->cmd; SSqlCmd *pCmd = &pSql->cmd;
// sequentially retrieve data from remain vnodes first, query vnode specified by vnodeIdx // sequentially retrieve data from remain vnodes first, query vnode specified by vnodeIdx
if (numOfRows == 0 && tscProjectionQueryOnMetric(pSql)) { if (numOfRows == 0 && tscProjectionQueryOnMetric(pCmd)) {
// vnode is denoted by vnodeIdx, continue to query vnode specified by vnodeIdx // vnode is denoted by vnodeIdx, continue to query vnode specified by vnodeIdx
assert(pCmd->vnodeIdx >= 1); assert(pCmd->vnodeIdx >= 0);
/* reach the maximum number of output rows, abort */ /* reach the maximum number of output rows, abort */
if (pCmd->globalLimit > 0 && pRes->numOfTotal >= pCmd->globalLimit) { if (pCmd->globalLimit > 0 && pRes->numOfTotal >= pCmd->globalLimit) {
...@@ -128,14 +129,14 @@ static void tscProcessAsyncFetchRowsProxy(void *param, TAOS_RES *tres, int numOf ...@@ -128,14 +129,14 @@ static void tscProcessAsyncFetchRowsProxy(void *param, TAOS_RES *tres, int numOf
/* update the limit value according to current retrieval results */ /* update the limit value according to current retrieval results */
pCmd->limit.limit = pCmd->globalLimit - pRes->numOfTotal; pCmd->limit.limit = pCmd->globalLimit - pRes->numOfTotal;
pCmd->limit.offset = pRes->offset;
if ((++(pSql->cmd.vnodeIdx)) <= pCmd->pMetricMeta->numOfVnodes) { if ((++(pCmd->vnodeIdx)) < tscGetMeterMetaInfo(pCmd, 0)->pMetricMeta->numOfVnodes) {
pCmd->command = TSDB_SQL_SELECT; // reset flag to launch query first. tscTrace("%p retrieve data from next vnode:%d", pSql, pCmd->vnodeIdx);
pRes->row = 0; pSql->cmd.command = TSDB_SQL_SELECT; // reset flag to launch query first.
pRes->numOfRows = 0;
pCmd->type = 0;
tscResetForNextRetrieve(pRes);
pSql->fp = tscProcessAsyncRetrieveNextVnode; pSql->fp = tscProcessAsyncRetrieveNextVnode;
tscProcessSql(pSql); tscProcessSql(pSql);
return; return;
...@@ -213,14 +214,12 @@ void taos_fetch_rows_a(TAOS_RES *taosa, void (*fp)(void *, TAOS_RES *, int), voi ...@@ -213,14 +214,12 @@ void taos_fetch_rows_a(TAOS_RES *taosa, void (*fp)(void *, TAOS_RES *, int), voi
pSql->fp = tscProcessAsyncFetchRowsProxy; pSql->fp = tscProcessAsyncFetchRowsProxy;
pSql->param = param; pSql->param = param;
tscResetForNextRetrieve(pRes);
pRes->row = 0;
pRes->numOfRows = 0;
pCmd->type = 0;
if (pCmd->command != TSDB_SQL_RETRIEVE_METRIC && pCmd->command < TSDB_SQL_LOCAL) { if (pCmd->command != TSDB_SQL_RETRIEVE_METRIC && pCmd->command < TSDB_SQL_LOCAL) {
pCmd->command = (pCmd->command > TSDB_SQL_MGMT) ? TSDB_SQL_RETRIEVE : TSDB_SQL_FETCH; pCmd->command = (pCmd->command > TSDB_SQL_MGMT) ? TSDB_SQL_RETRIEVE : TSDB_SQL_FETCH;
} }
tscProcessSql(pSql); tscProcessSql(pSql);
} }
...@@ -246,9 +245,7 @@ void taos_fetch_row_a(TAOS_RES *taosa, void (*fp)(void *, TAOS_RES *, TAOS_ROW), ...@@ -246,9 +245,7 @@ void taos_fetch_row_a(TAOS_RES *taosa, void (*fp)(void *, TAOS_RES *, TAOS_ROW),
pSql->param = param; pSql->param = param;
if (pRes->row >= pRes->numOfRows) { if (pRes->row >= pRes->numOfRows) {
pRes->row = 0; tscResetForNextRetrieve(pRes);
pRes->numOfRows = 0;
pCmd->type = 0;
pSql->fp = tscProcessAsyncRetrieve; pSql->fp = tscProcessAsyncRetrieve;
pCmd->command = (pCmd->command > TSDB_SQL_MGMT) ? TSDB_SQL_RETRIEVE : TSDB_SQL_FETCH; pCmd->command = (pCmd->command > TSDB_SQL_MGMT) ? TSDB_SQL_RETRIEVE : TSDB_SQL_FETCH;
tscProcessSql(pSql); tscProcessSql(pSql);
...@@ -269,7 +266,7 @@ void tscProcessAsyncRetrieve(void *param, TAOS_RES *tres, int numOfRows) { ...@@ -269,7 +266,7 @@ void tscProcessAsyncRetrieve(void *param, TAOS_RES *tres, int numOfRows) {
if (numOfRows == 0) { if (numOfRows == 0) {
// sequentially retrieve data from remain vnodes. // sequentially retrieve data from remain vnodes.
if (tscProjectionQueryOnMetric(pSql)) { if (tscProjectionQueryOnMetric(pCmd)) {
/* /*
* vnode is denoted by vnodeIdx, continue to query vnode specified by vnodeIdx till all vnode have been retrieved * vnode is denoted by vnodeIdx, continue to query vnode specified by vnodeIdx till all vnode have been retrieved
*/ */
...@@ -284,13 +281,10 @@ void tscProcessAsyncRetrieve(void *param, TAOS_RES *tres, int numOfRows) { ...@@ -284,13 +281,10 @@ void tscProcessAsyncRetrieve(void *param, TAOS_RES *tres, int numOfRows) {
/* update the limit value according to current retrieval results */ /* update the limit value according to current retrieval results */
pCmd->limit.limit = pCmd->globalLimit - pRes->numOfTotal; pCmd->limit.limit = pCmd->globalLimit - pRes->numOfTotal;
if ((++pCmd->vnodeIdx) <= pCmd->pMetricMeta->numOfVnodes) { if ((++pCmd->vnodeIdx) <= tscGetMeterMetaInfo(pCmd, 0)->pMetricMeta->numOfVnodes) {
pCmd->command = TSDB_SQL_SELECT; // reset flag to launch query first. pSql->cmd.command = TSDB_SQL_SELECT; // reset flag to launch query first.
pRes->row = 0;
pRes->numOfRows = 0;
pCmd->type = 0;
tscResetForNextRetrieve(pRes);
pSql->fp = tscProcessAsyncContinueRetrieve; pSql->fp = tscProcessAsyncContinueRetrieve;
tscProcessSql(pSql); tscProcessSql(pSql);
return; return;
...@@ -465,8 +459,8 @@ void tscMeterMetaCallBack(void *param, TAOS_RES *res, int code) { ...@@ -465,8 +459,8 @@ void tscMeterMetaCallBack(void *param, TAOS_RES *res, int code) {
tscTrace("%p renew meterMeta successfully, command:%d, code:%d, thandle:%p, retry:%d", tscTrace("%p renew meterMeta successfully, command:%d, code:%d, thandle:%p, retry:%d",
pSql, pSql->cmd.command, pSql->res.code, pSql->thandle, pSql->retry); pSql, pSql->cmd.command, pSql->res.code, pSql->thandle, pSql->retry);
assert(pSql->cmd.pMeterMeta == NULL); assert(tscGetMeterMetaInfo(&pSql->cmd, 0)->pMeterMeta == NULL);
tscGetMeterMeta(pSql, pSql->cmd.name); tscGetMeterMeta(pSql, tscGetMeterMetaInfo(&pSql->cmd, 0)->name, 0);
code = tscSendMsgToServer(pSql); code = tscSendMsgToServer(pSql);
if (code != 0) { if (code != 0) {
...@@ -486,21 +480,23 @@ void tscMeterMetaCallBack(void *param, TAOS_RES *res, int code) { ...@@ -486,21 +480,23 @@ void tscMeterMetaCallBack(void *param, TAOS_RES *res, int code) {
if (pSql->pStream == NULL) { if (pSql->pStream == NULL) {
// check if it is a sub-query of metric query first, if true, enter another routine // check if it is a sub-query of metric query first, if true, enter another routine
// todo refactor if ((pSql->cmd.type & TSDB_QUERY_TYPE_STABLE_SUBQUERY) == TSDB_QUERY_TYPE_STABLE_SUBQUERY) {
if (pSql->fp == tscRetrieveDataRes || pSql->fp == tscRetrieveFromVnodeCallBack) { SMeterMetaInfo* pMeterMetaInfo = tscGetMeterMetaInfo(pCmd, 0);
assert(pCmd->pMeterMeta->numOfTags != 0 && pCmd->vnodeIdx > 0 && pSql->param != NULL); assert(pMeterMetaInfo->pMeterMeta->numOfTags != 0 && pCmd->vnodeIdx >= 0 && pSql->param != NULL);
SRetrieveSupport *trs = (SRetrieveSupport *)pSql->param; SRetrieveSupport *trs = (SRetrieveSupport *)pSql->param;
SSqlObj * pParObj = trs->pParentSqlObj; SSqlObj * pParObj = trs->pParentSqlObj;
assert(pParObj->signature == pParObj && trs->vnodeIdx == pCmd->vnodeIdx && pSql->cmd.pMeterMeta->numOfTags != 0); assert(pParObj->signature == pParObj && trs->vnodeIdx == pCmd->vnodeIdx &&
pMeterMetaInfo->pMeterMeta->numOfTags != 0);
tscTrace("%p get metricMeta during metric query successfully", pSql); tscTrace("%p get metricMeta during metric query successfully", pSql);
code = tscGetMeterMeta(pSql, pSql->cmd.name); code = tscGetMeterMeta(pSql, tscGetMeterMetaInfo(&pSql->cmd, 0)->name, 0);
pRes->code = code; pRes->code = code;
if (code == TSDB_CODE_ACTION_IN_PROGRESS) return; if (code == TSDB_CODE_ACTION_IN_PROGRESS) return;
code = tscGetMetricMeta(pSql, pSql->cmd.name); code = tscGetMetricMeta(pSql);
pRes->code = code; pRes->code = code;
if (code == TSDB_CODE_ACTION_IN_PROGRESS) return; if (code == TSDB_CODE_ACTION_IN_PROGRESS) return;
...@@ -508,14 +504,17 @@ void tscMeterMetaCallBack(void *param, TAOS_RES *res, int code) { ...@@ -508,14 +504,17 @@ void tscMeterMetaCallBack(void *param, TAOS_RES *res, int code) {
code = tsParseSql(pSql, pObj->acctId, pObj->db, false); code = tsParseSql(pSql, pObj->acctId, pObj->db, false);
if (code == TSDB_CODE_ACTION_IN_PROGRESS) return; if (code == TSDB_CODE_ACTION_IN_PROGRESS) return;
} }
} else { // stream computing } else { // stream computing
code = tscGetMeterMeta(pSql, pSql->cmd.name); SMeterMetaInfo *pMeterMetaInfo = tscGetMeterMetaInfo(pCmd, 0);
code = tscGetMeterMeta(pSql, pMeterMetaInfo->name, 0);
pRes->code = code; pRes->code = code;
if (code == TSDB_CODE_ACTION_IN_PROGRESS) return; if (code == TSDB_CODE_ACTION_IN_PROGRESS) return;
if (code == TSDB_CODE_SUCCESS && UTIL_METER_IS_METRIC(pCmd)) { pMeterMetaInfo = tscGetMeterMetaInfo(pCmd, 0);
code = tscGetMetricMeta(pSql, pSql->cmd.name); if (code == TSDB_CODE_SUCCESS && UTIL_METER_IS_METRIC(pMeterMetaInfo)) {
code = tscGetMetricMeta(pSql);
pRes->code = code; pRes->code = code;
if (code == TSDB_CODE_ACTION_IN_PROGRESS) return; if (code == TSDB_CODE_ACTION_IN_PROGRESS) return;
......
...@@ -102,7 +102,12 @@ void *taosAddConnIntoCache(void *handle, void *data, uint32_t ip, short port, ch ...@@ -102,7 +102,12 @@ void *taosAddConnIntoCache(void *handle, void *data, uint32_t ip, short port, ch
pObj = (SConnCache *)handle; pObj = (SConnCache *)handle;
if (pObj == NULL || pObj->maxSessions == 0) return NULL; if (pObj == NULL || pObj->maxSessions == 0) return NULL;
#ifdef CLUSTER
if (data == NULL || ip == 0) {
#else
if (data == NULL) { if (data == NULL) {
#endif
tscTrace("data:%p ip:%p:%d not valid, not added in cache", data, ip, port); tscTrace("data:%p ip:%p:%d not valid, not added in cache", data, ip, port);
return NULL; return NULL;
} }
......
此差异已折叠。
此差异已折叠。
...@@ -16,8 +16,6 @@ ...@@ -16,8 +16,6 @@
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <taos.h>
#include <tsclient.h>
#include "taosmsg.h" #include "taosmsg.h"
#include "tcache.h" #include "tcache.h"
...@@ -40,11 +38,31 @@ static int32_t getToStringLength(char *pData, int32_t length, int32_t type) { ...@@ -40,11 +38,31 @@ static int32_t getToStringLength(char *pData, int32_t length, int32_t type) {
return length; return length;
case TSDB_DATA_TYPE_NCHAR: case TSDB_DATA_TYPE_NCHAR:
return length; return length;
case TSDB_DATA_TYPE_DOUBLE: case TSDB_DATA_TYPE_DOUBLE: {
#ifdef _TD_ARM_32_
double dv = 0;
*(int64_t*)(&dv) = *(int64_t*)pData;
len = sprintf(buf, "%f", dv);
#else
len = sprintf(buf, "%lf", *(double *)pData); len = sprintf(buf, "%lf", *(double *)pData);
#endif
if (strncasecmp("nan", buf, 3) == 0) {
len = 4;
}
}
break; break;
case TSDB_DATA_TYPE_FLOAT: case TSDB_DATA_TYPE_FLOAT: {
#ifdef _TD_ARM_32_
float fv = 0;
*(int32_t*)(&fv) = *(int32_t*)pData;
len = sprintf(buf, "%f", fv);
#else
len = sprintf(buf, "%f", *(float *)pData); len = sprintf(buf, "%f", *(float *)pData);
#endif
if (strncasecmp("nan", buf, 3) == 0) {
len = 4;
}
}
break; break;
case TSDB_DATA_TYPE_TIMESTAMP: case TSDB_DATA_TYPE_TIMESTAMP:
case TSDB_DATA_TYPE_BIGINT: case TSDB_DATA_TYPE_BIGINT:
...@@ -69,9 +87,10 @@ static int32_t getToStringLength(char *pData, int32_t length, int32_t type) { ...@@ -69,9 +87,10 @@ static int32_t getToStringLength(char *pData, int32_t length, int32_t type) {
* length((uint64_t) 123456789011) > 12, greater than sizsof(uint64_t) * length((uint64_t) 123456789011) > 12, greater than sizsof(uint64_t)
*/ */
static int32_t tscMaxLengthOfTagsFields(SSqlObj *pSql) { static int32_t tscMaxLengthOfTagsFields(SSqlObj *pSql) {
SMeterMeta *pMeta = pSql->cmd.pMeterMeta; SMeterMeta *pMeta = tscGetMeterMetaInfo(&pSql->cmd, 0)->pMeterMeta;
if (pMeta->meterType != TSDB_METER_MTABLE) { if (pMeta->meterType == TSDB_METER_METRIC || pMeta->meterType == TSDB_METER_OTABLE ||
pMeta->meterType == TSDB_METER_STABLE) {
return 0; return 0;
} }
...@@ -98,7 +117,8 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) { ...@@ -98,7 +117,8 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
// one column for each row // one column for each row
SSqlCmd * pCmd = &pSql->cmd; SSqlCmd * pCmd = &pSql->cmd;
SMeterMeta *pMeta = pCmd->pMeterMeta; SMeterMetaInfo *pMeterMetaInfo = tscGetMeterMetaInfo(pCmd, 0);
SMeterMeta * pMeta = pMeterMetaInfo->pMeterMeta;
/* /*
* tagValueCnt is to denote the number of tags columns for meter, not metric. and is to show the column data. * tagValueCnt is to denote the number of tags columns for meter, not metric. and is to show the column data.
...@@ -109,7 +129,7 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) { ...@@ -109,7 +129,7 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
int32_t numOfRows = pMeta->numOfColumns; int32_t numOfRows = pMeta->numOfColumns;
int32_t totalNumOfRows = numOfRows + pMeta->numOfTags; int32_t totalNumOfRows = numOfRows + pMeta->numOfTags;
if (UTIL_METER_IS_METRIC(pCmd)) { if (UTIL_METER_IS_METRIC(pMeterMetaInfo)) {
numOfRows = pMeta->numOfColumns + pMeta->numOfTags; numOfRows = pMeta->numOfColumns + pMeta->numOfTags;
} }
...@@ -141,7 +161,7 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) { ...@@ -141,7 +161,7 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
} }
} }
if (UTIL_METER_IS_METRIC(pCmd)) { if (UTIL_METER_IS_METRIC(pMeterMetaInfo)) {
return 0; return 0;
} }
...@@ -182,11 +202,25 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) { ...@@ -182,11 +202,25 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
case TSDB_DATA_TYPE_NCHAR: case TSDB_DATA_TYPE_NCHAR:
taosUcs4ToMbs(pTagValue, pSchema[i].bytes, target); taosUcs4ToMbs(pTagValue, pSchema[i].bytes, target);
break; break;
case TSDB_DATA_TYPE_FLOAT: case TSDB_DATA_TYPE_FLOAT: {
#ifdef _TD_ARM_32_
float fv = 0;
*(int32_t*)(&fv) = *(int32_t*)pTagValue;
sprintf(target, "%f", fv);
#else
sprintf(target, "%f", *(float *)pTagValue); sprintf(target, "%f", *(float *)pTagValue);
#endif
}
break; break;
case TSDB_DATA_TYPE_DOUBLE: case TSDB_DATA_TYPE_DOUBLE: {
#ifdef _TD_ARM_32_
double dv = 0;
*(int64_t*)(&dv) = *(int64_t*)pTagValue;
sprintf(target, "%lf", dv);
#else
sprintf(target, "%lf", *(double *)pTagValue); sprintf(target, "%lf", *(double *)pTagValue);
#endif
}
break; break;
case TSDB_DATA_TYPE_TINYINT: case TSDB_DATA_TYPE_TINYINT:
sprintf(target, "%d", *(int8_t *)pTagValue); sprintf(target, "%d", *(int8_t *)pTagValue);
...@@ -240,7 +274,7 @@ static int32_t tscBuildMeterSchemaResultFields(SSqlObj *pSql, int32_t numOfCols, ...@@ -240,7 +274,7 @@ static int32_t tscBuildMeterSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
} }
static int32_t tscProcessDescribeTable(SSqlObj *pSql) { static int32_t tscProcessDescribeTable(SSqlObj *pSql) {
assert(pSql->cmd.pMeterMeta != NULL); assert(tscGetMeterMetaInfo(&pSql->cmd, 0)->pMeterMeta != NULL);
const int32_t NUM_OF_DESCRIBE_TABLE_COLUMNS = 4; const int32_t NUM_OF_DESCRIBE_TABLE_COLUMNS = 4;
const int32_t TYPE_COLUMN_LENGTH = 16; const int32_t TYPE_COLUMN_LENGTH = 16;
...@@ -261,15 +295,17 @@ static int32_t tscProcessDescribeTable(SSqlObj *pSql) { ...@@ -261,15 +295,17 @@ static int32_t tscProcessDescribeTable(SSqlObj *pSql) {
static int tscBuildMetricTagProjectionResult(SSqlObj *pSql) { static int tscBuildMetricTagProjectionResult(SSqlObj *pSql) {
// the result structure has been completed in sql parse, so we // the result structure has been completed in sql parse, so we
// only need to reorganize the results in the column format // only need to reorganize the results in the column format
SSqlCmd *pCmd = &pSql->cmd; SSqlCmd * pCmd = &pSql->cmd;
SSqlRes *pRes = &pSql->res; SSqlRes * pRes = &pSql->res;
SMeterMetaInfo *pMeterMetaInfo = tscGetMeterMetaInfo(pCmd, 0);
SMetricMeta *pMetricMeta = pCmd->pMetricMeta; SMetricMeta *pMetricMeta = pMeterMetaInfo->pMetricMeta;
SSchema * pSchema = tsGetTagSchema(pCmd->pMeterMeta); SSchema * pSchema = tsGetTagSchema(pMeterMetaInfo->pMeterMeta);
int32_t vOffset[TSDB_MAX_COLUMNS] = {0}; int32_t vOffset[TSDB_MAX_COLUMNS] = {0};
for (int32_t f = 1; f < pCmd->numOfReqTags; ++f) {
int16_t tagColumnIndex = pCmd->tagColumnIndex[f - 1]; for (int32_t f = 1; f < pMeterMetaInfo->numOfTags; ++f) {
int16_t tagColumnIndex = pMeterMetaInfo->tagColumnIndex[f - 1];
if (tagColumnIndex == -1) { if (tagColumnIndex == -1) {
vOffset[f] = vOffset[f - 1] + TSDB_METER_NAME_LEN; vOffset[f] = vOffset[f - 1] + TSDB_METER_NAME_LEN;
} else { } else {
...@@ -290,10 +326,10 @@ static int tscBuildMetricTagProjectionResult(SSqlObj *pSql) { ...@@ -290,10 +326,10 @@ static int tscBuildMetricTagProjectionResult(SSqlObj *pSql) {
SMeterSidExtInfo *pSidExt = tscGetMeterSidInfo(pSidList, j); SMeterSidExtInfo *pSidExt = tscGetMeterSidInfo(pSidList, j);
for (int32_t k = 0; k < pCmd->fieldsInfo.numOfOutputCols; ++k) { for (int32_t k = 0; k < pCmd->fieldsInfo.numOfOutputCols; ++k) {
SColIndex *pColIndex = &tscSqlExprGet(pCmd, k)->colInfo; SColIndexEx *pColIndex = &tscSqlExprGet(pCmd, k)->colInfo;
int32_t offsetId = pColIndex->colIdx; int16_t offsetId = pColIndex->colIdx;
assert(pColIndex->isTag); assert((pColIndex->flag & TSDB_COL_TAG) != 0);
char * val = pSidExt->tags + vOffset[offsetId]; char * val = pSidExt->tags + vOffset[offsetId];
TAOS_FIELD *pField = tscFieldInfoGetField(pCmd, k); TAOS_FIELD *pField = tscFieldInfoGetField(pCmd, k);
...@@ -312,7 +348,7 @@ static int tscBuildMetricTagSqlFunctionResult(SSqlObj *pSql) { ...@@ -312,7 +348,7 @@ static int tscBuildMetricTagSqlFunctionResult(SSqlObj *pSql) {
SSqlCmd *pCmd = &pSql->cmd; SSqlCmd *pCmd = &pSql->cmd;
SSqlRes *pRes = &pSql->res; SSqlRes *pRes = &pSql->res;
SMetricMeta *pMetricMeta = pCmd->pMetricMeta; SMetricMeta *pMetricMeta = tscGetMeterMetaInfo(pCmd, 0)->pMetricMeta;
int32_t totalNumOfResults = 1; // count function only produce one result int32_t totalNumOfResults = 1; // count function only produce one result
int32_t rowLen = tscGetResRowLength(pCmd); int32_t rowLen = tscGetResRowLength(pCmd);
...@@ -323,7 +359,7 @@ static int tscBuildMetricTagSqlFunctionResult(SSqlObj *pSql) { ...@@ -323,7 +359,7 @@ static int tscBuildMetricTagSqlFunctionResult(SSqlObj *pSql) {
for (int32_t k = 0; k < pCmd->fieldsInfo.numOfOutputCols; ++k) { for (int32_t k = 0; k < pCmd->fieldsInfo.numOfOutputCols; ++k) {
SSqlExpr *pExpr = tscSqlExprGet(pCmd, i); SSqlExpr *pExpr = tscSqlExprGet(pCmd, i);
if (pExpr->colInfo.colIdx == -1 && pExpr->sqlFuncId == TSDB_FUNC_COUNT) { if (pExpr->colInfo.colIdx == -1 && pExpr->functionId == TSDB_FUNC_COUNT) {
TAOS_FIELD *pField = tscFieldInfoGetField(pCmd, k); TAOS_FIELD *pField = tscFieldInfoGetField(pCmd, k);
memcpy(pRes->data + tscFieldInfoGetOffset(pCmd, i) * totalNumOfResults + pField->bytes * rowIdx, memcpy(pRes->data + tscFieldInfoGetOffset(pCmd, i) * totalNumOfResults + pField->bytes * rowIdx,
...@@ -342,7 +378,7 @@ static int tscBuildMetricTagSqlFunctionResult(SSqlObj *pSql) { ...@@ -342,7 +378,7 @@ static int tscBuildMetricTagSqlFunctionResult(SSqlObj *pSql) {
static int tscProcessQueryTags(SSqlObj *pSql) { static int tscProcessQueryTags(SSqlObj *pSql) {
SSqlCmd *pCmd = &pSql->cmd; SSqlCmd *pCmd = &pSql->cmd;
SMeterMeta *pMeterMeta = pCmd->pMeterMeta; SMeterMeta *pMeterMeta = tscGetMeterMetaInfo(pCmd, 0)->pMeterMeta;
if (pMeterMeta == NULL || pMeterMeta->numOfTags == 0 || pMeterMeta->numOfColumns == 0) { if (pMeterMeta == NULL || pMeterMeta->numOfTags == 0 || pMeterMeta->numOfColumns == 0) {
strcpy(pCmd->payload, "invalid table"); strcpy(pCmd->payload, "invalid table");
pSql->res.code = TSDB_CODE_INVALID_TABLE; pSql->res.code = TSDB_CODE_INVALID_TABLE;
...@@ -350,7 +386,7 @@ static int tscProcessQueryTags(SSqlObj *pSql) { ...@@ -350,7 +386,7 @@ static int tscProcessQueryTags(SSqlObj *pSql) {
} }
SSqlExpr *pExpr = tscSqlExprGet(pCmd, 0); SSqlExpr *pExpr = tscSqlExprGet(pCmd, 0);
if (pExpr->sqlFuncId == TSDB_FUNC_COUNT) { if (pExpr->functionId == TSDB_FUNC_COUNT) {
return tscBuildMetricTagSqlFunctionResult(pSql); return tscBuildMetricTagSqlFunctionResult(pSql);
} else { } else {
return tscBuildMetricTagProjectionResult(pSql); return tscBuildMetricTagProjectionResult(pSql);
...@@ -367,6 +403,10 @@ int tscProcessLocalCmd(SSqlObj *pSql) { ...@@ -367,6 +403,10 @@ int tscProcessLocalCmd(SSqlObj *pSql) {
} else if (pCmd->command == TSDB_SQL_RETRIEVE_TAGS) { } else if (pCmd->command == TSDB_SQL_RETRIEVE_TAGS) {
pSql->res.code = (uint8_t)tscProcessQueryTags(pSql); pSql->res.code = (uint8_t)tscProcessQueryTags(pSql);
} else if (pCmd->command == TSDB_SQL_RETRIEVE_EMPTY_RESULT) { } else if (pCmd->command == TSDB_SQL_RETRIEVE_EMPTY_RESULT) {
/*
* pass the qhandle check, in order to call partial release function to
* free allocated resources and remove the SqlObj from linked list
*/
pSql->res.qhandle = 0x1; // pass the qhandle check pSql->res.qhandle = 0x1; // pass the qhandle check
pSql->res.numOfRows = 0; pSql->res.numOfRows = 0;
} else if (pCmd->command == TSDB_SQL_RESET_CACHE) { } else if (pCmd->command == TSDB_SQL_RESET_CACHE) {
...@@ -376,7 +416,7 @@ int tscProcessLocalCmd(SSqlObj *pSql) { ...@@ -376,7 +416,7 @@ int tscProcessLocalCmd(SSqlObj *pSql) {
tscError("%p not support command:%d", pSql, pCmd->command); tscError("%p not support command:%d", pSql, pCmd->command);
} }
//keep the code in local variable in order to avoid invalid read in case of async query // keep the code in local variable in order to avoid invalid read in case of async query
int32_t code = pSql->res.code; int32_t code = pSql->res.code;
if (pSql->fp != NULL) { // callback function if (pSql->fp != NULL) { // callback function
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
...@@ -15,13 +15,9 @@ ...@@ -15,13 +15,9 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
#include <assert.h>
#include <errno.h>
#include <stdarg.h> #include <stdarg.h>
#include "os.h" #include "os.h"
...@@ -119,31 +115,29 @@ void tSQLExprListDestroy(tSQLExprList *pList) { ...@@ -119,31 +115,29 @@ void tSQLExprListDestroy(tSQLExprList *pList) {
free(pList); free(pList);
} }
tSQLExpr *tSQLExprIdValueCreate(SSQLToken *pToken, int32_t optrType) { tSQLExpr *tSQLExprIdValueCreate(SSQLToken *pAliasToken, int32_t optrType) {
tSQLExpr *nodePtr = calloc(1, sizeof(tSQLExpr)); tSQLExpr *nodePtr = calloc(1, sizeof(tSQLExpr));
if (optrType == TK_INTEGER || optrType == TK_STRING || optrType == TK_FLOAT || optrType == TK_BOOL) { if (optrType == TK_INTEGER || optrType == TK_STRING || optrType == TK_FLOAT || optrType == TK_BOOL) {
toTSDBType(pToken->type); toTSDBType(pAliasToken->type);
tVariantCreate(&nodePtr->val, pToken); tVariantCreate(&nodePtr->val, pAliasToken);
nodePtr->nSQLOptr = optrType; nodePtr->nSQLOptr = optrType;
} else if (optrType == TK_NOW) { } else if (optrType == TK_NOW) {
// default use microsecond // default use microsecond
nodePtr->val.i64Key = taosGetTimestamp(TSDB_TIME_PRECISION_MICRO); nodePtr->val.i64Key = taosGetTimestamp(TSDB_TIME_PRECISION_MICRO);
nodePtr->val.nType = TSDB_DATA_TYPE_BIGINT; nodePtr->val.nType = TSDB_DATA_TYPE_BIGINT;
nodePtr->nSQLOptr = TK_TIMESTAMP; nodePtr->nSQLOptr = TK_TIMESTAMP; // TK_TIMESTAMP used to denote the time value is in microsecond
// TK_TIMESTAMP used to denote the time value is in microsecond
} else if (optrType == TK_VARIABLE) { } else if (optrType == TK_VARIABLE) {
int32_t ret = getTimestampInUsFromStr(pToken->z, pToken->n, &nodePtr->val.i64Key); int32_t ret = getTimestampInUsFromStr(pAliasToken->z, pAliasToken->n, &nodePtr->val.i64Key);
UNUSED(ret); UNUSED(ret);
nodePtr->val.nType = TSDB_DATA_TYPE_BIGINT; nodePtr->val.nType = TSDB_DATA_TYPE_BIGINT;
nodePtr->nSQLOptr = TK_TIMESTAMP; nodePtr->nSQLOptr = TK_TIMESTAMP;
} else { // must be field id if not numbers } else { // it must be the column name (tk_id) if it is not the number
assert(optrType == TK_ALL || optrType == TK_ID); assert(optrType == TK_ID || optrType == TK_ALL);
if (pAliasToken != NULL) {
if (pToken != NULL) { // it must be the column name (tk_id) nodePtr->colInfo = *pAliasToken;
nodePtr->colInfo = *pToken;
} }
nodePtr->nSQLOptr = optrType; nodePtr->nSQLOptr = optrType;
...@@ -273,11 +267,10 @@ tSQLExpr *tSQLExprCreate(tSQLExpr *pLeft, tSQLExpr *pRight, int32_t optrType) { ...@@ -273,11 +267,10 @@ tSQLExpr *tSQLExprCreate(tSQLExpr *pLeft, tSQLExpr *pRight, int32_t optrType) {
return pExpr; return pExpr;
} }
void tSQLExprDestroy(tSQLExpr *pExpr) { void tSQLExprNodeDestroy(tSQLExpr *pExpr) {
if (pExpr == NULL) return; if (pExpr == NULL) {
return;
tSQLExprDestroy(pExpr->pLeft); }
tSQLExprDestroy(pExpr->pRight);
if (pExpr->nSQLOptr == TK_STRING) { if (pExpr->nSQLOptr == TK_STRING) {
tVariantDestroy(&pExpr->val); tVariantDestroy(&pExpr->val);
...@@ -288,6 +281,17 @@ void tSQLExprDestroy(tSQLExpr *pExpr) { ...@@ -288,6 +281,17 @@ void tSQLExprDestroy(tSQLExpr *pExpr) {
free(pExpr); free(pExpr);
} }
void tSQLExprDestroy(tSQLExpr *pExpr) {
if (pExpr == NULL) {
return;
}
tSQLExprDestroy(pExpr->pLeft);
tSQLExprDestroy(pExpr->pRight);
tSQLExprNodeDestroy(pExpr);
}
static void *tVariantListExpand(tVariantList *pList) { static void *tVariantListExpand(tVariantList *pList) {
if (pList->nAlloc <= pList->nExpr) { // if (pList->nAlloc <= pList->nExpr) { //
int32_t newSize = (pList->nAlloc << 1) + 4; int32_t newSize = (pList->nAlloc << 1) + 4;
...@@ -420,6 +424,44 @@ void setDBName(SSQLToken *pCpxName, SSQLToken *pDB) { ...@@ -420,6 +424,44 @@ void setDBName(SSQLToken *pCpxName, SSQLToken *pDB) {
pCpxName->n = pDB->n; pCpxName->n = pDB->n;
} }
int32_t getTimestampInUsFromStrImpl(int64_t val, char unit, int64_t *result) {
*result = val;
switch (unit) {
case 's':
(*result) *= MILLISECOND_PER_SECOND;
break;
case 'm':
(*result) *= MILLISECOND_PER_MINUTE;
break;
case 'h':
(*result) *= MILLISECOND_PER_HOUR;
break;
case 'd':
(*result) *= MILLISECOND_PER_DAY;
break;
case 'w':
(*result) *= MILLISECOND_PER_WEEK;
break;
case 'n':
(*result) *= MILLISECOND_PER_MONTH;
break;
case 'y':
(*result) *= MILLISECOND_PER_YEAR;
break;
case 'a':
break;
default: {
;
return -1;
}
}
/* get the value in microsecond */
(*result) *= 1000L;
return 0;
}
void tSQLSetColumnInfo(TAOS_FIELD *pField, SSQLToken *pName, TAOS_FIELD *pType) { void tSQLSetColumnInfo(TAOS_FIELD *pField, SSQLToken *pName, TAOS_FIELD *pType) {
int32_t maxLen = sizeof(pField->name) / sizeof(pField->name[0]); int32_t maxLen = sizeof(pField->name) / sizeof(pField->name[0]);
/* truncate the column name */ /* truncate the column name */
...@@ -462,7 +504,7 @@ void tSQLSetColumnType(TAOS_FIELD *pField, SSQLToken *type) { ...@@ -462,7 +504,7 @@ void tSQLSetColumnType(TAOS_FIELD *pField, SSQLToken *type) {
/* /*
* extract the select info out of sql string * extract the select info out of sql string
*/ */
SQuerySQL *tSetQuerySQLElems(SSQLToken *pSelectToken, tSQLExprList *pSelection, SSQLToken *pFrom, tSQLExpr *pWhere, SQuerySQL *tSetQuerySQLElems(SSQLToken *pSelectToken, tSQLExprList *pSelection, tVariantList *pFrom, tSQLExpr *pWhere,
tVariantList *pGroupby, tVariantList *pSortOrder, SSQLToken *pInterval, tVariantList *pGroupby, tVariantList *pSortOrder, SSQLToken *pInterval,
SSQLToken *pSliding, tVariantList *pFill, SLimitVal *pLimit, SLimitVal *pGLimit) { SSQLToken *pSliding, tVariantList *pFill, SLimitVal *pLimit, SLimitVal *pGLimit) {
assert(pSelection != NULL && pFrom != NULL && pInterval != NULL && pLimit != NULL && pGLimit != NULL); assert(pSelection != NULL && pFrom != NULL && pInterval != NULL && pLimit != NULL && pGLimit != NULL);
...@@ -472,13 +514,13 @@ SQuerySQL *tSetQuerySQLElems(SSQLToken *pSelectToken, tSQLExprList *pSelection, ...@@ -472,13 +514,13 @@ SQuerySQL *tSetQuerySQLElems(SSQLToken *pSelectToken, tSQLExprList *pSelection,
pQuery->selectToken.n = strlen(pQuery->selectToken.z); // all later sql string are belonged to the stream sql pQuery->selectToken.n = strlen(pQuery->selectToken.z); // all later sql string are belonged to the stream sql
pQuery->pSelection = pSelection; pQuery->pSelection = pSelection;
pQuery->from = *pFrom; pQuery->from = pFrom;
pQuery->pGroupby = pGroupby; pQuery->pGroupby = pGroupby;
pQuery->pSortOrder = pSortOrder; pQuery->pSortOrder = pSortOrder;
pQuery->pWhere = pWhere; pQuery->pWhere = pWhere;
pQuery->limit = *pLimit; pQuery->limit = *pLimit;
pQuery->glimit = *pGLimit; pQuery->slimit = *pGLimit;
pQuery->interval = *pInterval; pQuery->interval = *pInterval;
pQuery->sliding = *pSliding; pQuery->sliding = *pSliding;
...@@ -532,6 +574,9 @@ void destroyQuerySql(SQuerySQL *pSql) { ...@@ -532,6 +574,9 @@ void destroyQuerySql(SQuerySQL *pSql) {
tVariantListDestroy(pSql->pGroupby); tVariantListDestroy(pSql->pGroupby);
pSql->pGroupby = NULL; pSql->pGroupby = NULL;
tVariantListDestroy(pSql->from);
pSql->from = NULL;
tVariantListDestroy(pSql->fillType); tVariantListDestroy(pSql->fillType);
free(pSql); free(pSql);
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "os.h" #include "os.h"
#include "taosmsg.h" #include "taosmsg.h"
#include "tschemautil.h" #include "tschemautil.h"
#include "tsqldef.h"
#include "ttypes.h" #include "ttypes.h"
#include "tutil.h" #include "tutil.h"
...@@ -71,7 +72,7 @@ struct SSchema* tsGetSchema(SMeterMeta* pMeta) { ...@@ -71,7 +72,7 @@ struct SSchema* tsGetSchema(SMeterMeta* pMeta) {
if (pMeta == NULL) { if (pMeta == NULL) {
return NULL; return NULL;
} }
return tsGetSchemaColIdx(pMeta, 0); return tsGetColumnSchema(pMeta, 0);
} }
struct SSchema* tsGetTagSchema(SMeterMeta* pMeta) { struct SSchema* tsGetTagSchema(SMeterMeta* pMeta) {
...@@ -79,24 +80,32 @@ struct SSchema* tsGetTagSchema(SMeterMeta* pMeta) { ...@@ -79,24 +80,32 @@ struct SSchema* tsGetTagSchema(SMeterMeta* pMeta) {
return NULL; return NULL;
} }
return tsGetSchemaColIdx(pMeta, pMeta->numOfColumns); return tsGetColumnSchema(pMeta, pMeta->numOfColumns);
} }
struct SSchema* tsGetSchemaColIdx(SMeterMeta* pMeta, int32_t startCol) { struct SSchema* tsGetColumnSchema(SMeterMeta* pMeta, int32_t startCol) {
if (pMeta->pSchema == 0) { return (SSchema*)(((char*)pMeta + sizeof(SMeterMeta)) + startCol * sizeof(SSchema));
pMeta->pSchema = sizeof(SMeterMeta);
}
return (SSchema*)(((char*)pMeta + pMeta->pSchema) + startCol * sizeof(SSchema));
} }
/**
* the MeterMeta data format in memory is as follows:
*
* +--------------------+
* |SMeterMeta Body data| sizeof(SMeterMeta)
* +--------------------+
* |Schema data | numOfTotalColumns * sizeof(SSchema)
* +--------------------+
* |Tags data | tag_col_1.bytes + tag_col_2.bytes + ....
* +--------------------+
*
* @param pMeta
* @return
*/
char* tsGetTagsValue(SMeterMeta* pMeta) { char* tsGetTagsValue(SMeterMeta* pMeta) {
if (pMeta->tags == 0) {
int32_t numOfTotalCols = pMeta->numOfColumns + pMeta->numOfTags; int32_t numOfTotalCols = pMeta->numOfColumns + pMeta->numOfTags;
pMeta->tags = sizeof(SMeterMeta) + numOfTotalCols * sizeof(SSchema); uint32_t offset = sizeof(SMeterMeta) + numOfTotalCols * sizeof(SSchema);
}
return ((char*)pMeta + pMeta->tags); return ((char*)pMeta + offset);
} }
bool tsMeterMetaIdentical(SMeterMeta* p1, SMeterMeta* p2) { bool tsMeterMetaIdentical(SMeterMeta* p1, SMeterMeta* p2) {
...@@ -111,7 +120,7 @@ bool tsMeterMetaIdentical(SMeterMeta* p1, SMeterMeta* p2) { ...@@ -111,7 +120,7 @@ bool tsMeterMetaIdentical(SMeterMeta* p1, SMeterMeta* p2) {
size_t size = sizeof(SMeterMeta) + p1->numOfColumns * sizeof(SSchema); size_t size = sizeof(SMeterMeta) + p1->numOfColumns * sizeof(SSchema);
for (int32_t i = 0; i < p1->numOfTags; ++i) { for (int32_t i = 0; i < p1->numOfTags; ++i) {
SSchema* pColSchema = tsGetSchemaColIdx(p1, i + p1->numOfColumns); SSchema* pColSchema = tsGetColumnSchema(p1, i + p1->numOfColumns);
size += pColSchema->bytes; size += pColSchema->bytes;
} }
...@@ -142,7 +151,33 @@ void extractMeterName(char* meterId, char* name) { ...@@ -142,7 +151,33 @@ void extractMeterName(char* meterId, char* name) {
copySegment(name, r, TS_PATH_DELIMITER[0]); copySegment(name, r, TS_PATH_DELIMITER[0]);
} }
void extractDBName(char* meterId, char* name) { SSQLToken extractDBName(char* meterId, char* name) {
char* r = skipSegments(meterId, TS_PATH_DELIMITER[0], 1); char* r = skipSegments(meterId, TS_PATH_DELIMITER[0], 1);
copySegment(name, r, TS_PATH_DELIMITER[0]); copySegment(name, r, TS_PATH_DELIMITER[0]);
SSQLToken token = {.z = name, .n = strlen(name), .type = TK_STRING};
return token;
}
/*
* tablePrefix.columnName
* extract table name and save it in pTable, with only column name in pToken
*/
void extractTableNameFromToken(SSQLToken* pToken, SSQLToken* pTable) {
const char sep = TS_PATH_DELIMITER[0];
if (pToken == pTable || pToken == NULL || pTable == NULL) {
return;
}
char* r = strnchr(pToken->z, sep, pToken->n, false);
if (r != NULL) { // record the table name token
pTable->n = r - pToken->z;
pTable->z = pToken->z;
r += 1;
pToken->n -= (r - pToken->z);
pToken->z = r;
}
} }
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
...@@ -36,7 +36,7 @@ typedef struct { ...@@ -36,7 +36,7 @@ typedef struct {
TAOS_RES * result; TAOS_RES * result;
} SSub; } SSub;
TAOS_SUB *taos_subscribe(char *host, char *user, char *pass, char *db, char *name, int64_t time, int mseconds) { TAOS_SUB *taos_subscribe(const char *host, const char *user, const char *pass, const char *db, const char *name, int64_t time, int mseconds) {
SSub *pSub; SSub *pSub;
pSub = (SSub *)malloc(sizeof(SSub)); pSub = (SSub *)malloc(sizeof(SSub));
......
...@@ -88,11 +88,25 @@ void taos_init_imp() { ...@@ -88,11 +88,25 @@ void taos_init_imp() {
tsReadGlobalConfig(); tsReadGlobalConfig();
tsPrintGlobalConfig(); tsPrintGlobalConfig();
tscTrace("starting to initialize TAOS client ..."); tscTrace("starting to initialize TAOS client ...");
tscTrace("Local IP address is:%s", tsLocalIp); tscTrace("Local IP address is:%s", tsLocalIp);
} }
#ifdef CLUSTER
tscMgmtIpList.numOfIps = 2;
strcpy(tscMgmtIpList.ipstr[0], tsMasterIp);
tscMgmtIpList.ip[0] = inet_addr(tsMasterIp);
strcpy(tscMgmtIpList.ipstr[1], tsMasterIp);
tscMgmtIpList.ip[1] = inet_addr(tsMasterIp);
if (tsSecondIp[0]) {
tscMgmtIpList.numOfIps = 3;
strcpy(tscMgmtIpList.ipstr[2], tsSecondIp);
tscMgmtIpList.ip[2] = inet_addr(tsSecondIp);
}
#endif
tscInitMsgs(); tscInitMsgs();
slaveIndex = rand(); slaveIndex = rand();
int queueSize = tsMaxVnodeConnections + tsMaxMeterConnections + tsMaxMgmtConnections + tsMaxMgmtConnections; int queueSize = tsMaxVnodeConnections + tsMaxMeterConnections + tsMaxMgmtConnections + tsMaxMgmtConnections;
...@@ -106,6 +120,10 @@ void taos_init_imp() { ...@@ -106,6 +120,10 @@ void taos_init_imp() {
if (tscNumOfThreads < 2) tscNumOfThreads = 2; if (tscNumOfThreads < 2) tscNumOfThreads = 2;
tscQhandle = taosInitScheduler(queueSize, tscNumOfThreads, "tsc"); tscQhandle = taosInitScheduler(queueSize, tscNumOfThreads, "tsc");
if (NULL == tscQhandle) {
tscError("failed to init scheduler");
return;
}
memset(&rpcInit, 0, sizeof(rpcInit)); memset(&rpcInit, 0, sizeof(rpcInit));
rpcInit.localIp = tsLocalIp; rpcInit.localIp = tsLocalIp;
...@@ -126,7 +144,14 @@ void taos_init_imp() { ...@@ -126,7 +144,14 @@ void taos_init_imp() {
return; return;
} }
for (int i = 0; i < tscNumOfThreads; ++i) taosOpenRpcChann(pVnodeConn, i, rpcInit.sessionsPerChann); for (int i = 0; i < tscNumOfThreads; ++i) {
int retVal = taosOpenRpcChann(pVnodeConn, i, rpcInit.sessionsPerChann);
if (0 != retVal) {
tError("TSC-vnode, failed to open rpc chann");
taosCloseRpc(pVnodeConn);
return;
}
}
memset(&rpcInit, 0, sizeof(rpcInit)); memset(&rpcInit, 0, sizeof(rpcInit));
rpcInit.localIp = tsLocalIp; rpcInit.localIp = tsLocalIp;
...@@ -148,10 +173,9 @@ void taos_init_imp() { ...@@ -148,10 +173,9 @@ void taos_init_imp() {
} }
tscTmr = taosTmrInit(tsMaxMgmtConnections * 2, 200, 60000, "TSC"); tscTmr = taosTmrInit(tsMaxMgmtConnections * 2, 200, 60000, "TSC");
if (tscEmbedded == 0) { if(0 == tscEmbedded){
taosTmrReset(tscCheckDiskUsage, 10, NULL, tscTmr, &tscCheckDiskUsageTmr); taosTmrReset(tscCheckDiskUsage, 10, NULL, tscTmr, &tscCheckDiskUsageTmr);
} }
int64_t refreshTime = tsMetricMetaKeepTimer < tsMeterMetaKeepTimer ? tsMetricMetaKeepTimer : tsMeterMetaKeepTimer; int64_t refreshTime = tsMetricMetaKeepTimer < tsMeterMetaKeepTimer ? tsMetricMetaKeepTimer : tsMeterMetaKeepTimer;
refreshTime = refreshTime > 2 ? 2 : refreshTime; refreshTime = refreshTime > 2 ? 2 : refreshTime;
refreshTime = refreshTime < 1 ? 1 : refreshTime; refreshTime = refreshTime < 1 ? 1 : refreshTime;
...@@ -188,6 +212,7 @@ int taos_options(TSDB_OPTION option, const void *arg, ...) { ...@@ -188,6 +212,7 @@ int taos_options(TSDB_OPTION option, const void *arg, ...) {
tsCfgStatusStr[cfg_configDir->cfgStatus], (char *)cfg_configDir->ptr); tsCfgStatusStr[cfg_configDir->cfgStatus], (char *)cfg_configDir->ptr);
} }
break; break;
case TSDB_OPTION_SHELL_ACTIVITY_TIMER: case TSDB_OPTION_SHELL_ACTIVITY_TIMER:
if (cfg_activetimer && cfg_activetimer->cfgStatus <= TSDB_CFG_CSTATUS_OPTION) { if (cfg_activetimer && cfg_activetimer->cfgStatus <= TSDB_CFG_CSTATUS_OPTION) {
tsShellActivityTimer = atoi((char *)arg); tsShellActivityTimer = atoi((char *)arg);
...@@ -200,6 +225,7 @@ int taos_options(TSDB_OPTION option, const void *arg, ...) { ...@@ -200,6 +225,7 @@ int taos_options(TSDB_OPTION option, const void *arg, ...) {
tsCfgStatusStr[cfg_activetimer->cfgStatus], (int32_t *)cfg_activetimer->ptr); tsCfgStatusStr[cfg_activetimer->cfgStatus], (int32_t *)cfg_activetimer->ptr);
} }
break; break;
case TSDB_OPTION_LOCALE: { // set locale case TSDB_OPTION_LOCALE: { // set locale
pStr = (char *)arg; pStr = (char *)arg;
...@@ -223,8 +249,7 @@ int taos_options(TSDB_OPTION option, const void *arg, ...) { ...@@ -223,8 +249,7 @@ int taos_options(TSDB_OPTION option, const void *arg, ...) {
if (locale != NULL) { if (locale != NULL) {
tscPrint("locale set, prev locale:%s, new locale:%s", tsLocale, locale); tscPrint("locale set, prev locale:%s, new locale:%s", tsLocale, locale);
cfg_locale->cfgStatus = TSDB_CFG_CSTATUS_OPTION; cfg_locale->cfgStatus = TSDB_CFG_CSTATUS_OPTION;
} else { } else { // set the user-specified localed failed, use default LC_CTYPE as current locale
/* set the user-specified localed failed, use default LC_CTYPE as current locale */
locale = setlocale(LC_CTYPE, tsLocale); locale = setlocale(LC_CTYPE, tsLocale);
tscPrint("failed to set locale:%s, current locale:%s", pStr, tsLocale); tscPrint("failed to set locale:%s, current locale:%s", pStr, tsLocale);
} }
......
此差异已折叠。
...@@ -69,7 +69,7 @@ public enum TSDBError { ...@@ -69,7 +69,7 @@ public enum TSDBError {
TSDB_CODE_INVALID_OPTION(45, "invalid option"), TSDB_CODE_INVALID_OPTION(45, "invalid option"),
TSDB_CODE_NODE_OFFLINE(46, "node offline"), TSDB_CODE_NODE_OFFLINE(46, "node offline"),
TSDB_CODE_SYNC_REQUIRED(47, "sync required"), TSDB_CODE_SYNC_REQUIRED(47, "sync required"),
TSDB_CODE_NO_ENOUGH_PNODES(48, "more dnodes are needed"), TSDB_CODE_NO_ENOUGH_DNODES(48, "more dnodes are needed"),
TSDB_CODE_UNSYNCED(49, "node in unsynced state"), TSDB_CODE_UNSYNCED(49, "node in unsynced state"),
TSDB_CODE_TOO_SLOW(50, "too slow"), TSDB_CODE_TOO_SLOW(50, "too slow"),
TSDB_CODE_OTHERS(51, "others"), TSDB_CODE_OTHERS(51, "others"),
......
文件模式从 100755 更改为 100644
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
...@@ -123,7 +123,7 @@ typedef struct tExtMemBuffer { ...@@ -123,7 +123,7 @@ typedef struct tExtMemBuffer {
EXT_BUFFER_FLUSH_MODEL flushModel; EXT_BUFFER_FLUSH_MODEL flushModel;
} tExtMemBuffer; } tExtMemBuffer;
void getExtTmpfilePath(const char *fileNamePattern, int64_t serialNumber, int32_t seg, int32_t slot, char *dstPath); void getTmpfilePath(const char *fileNamePattern, char *dstPath);
/* /*
* create ext-memory buffer * create ext-memory buffer
...@@ -253,10 +253,10 @@ int32_t compare_a(tOrderDescriptor *, int32_t numOfRow1, int32_t s1, char *data1 ...@@ -253,10 +253,10 @@ int32_t compare_a(tOrderDescriptor *, int32_t numOfRow1, int32_t s1, char *data1
int32_t compare_d(tOrderDescriptor *, int32_t numOfRow1, int32_t s1, char *data1, int32_t numOfRow2, int32_t s2, int32_t compare_d(tOrderDescriptor *, int32_t numOfRow1, int32_t s1, char *data1, int32_t numOfRow2, int32_t s2,
char *data2); char *data2);
void tMemBucketCreate(tMemBucket **pBucket, int32_t totalSlots, int32_t nBufferSize, int16_t nElemSize, tMemBucket* tMemBucketCreate(int32_t totalSlots, int32_t nBufferSize, int16_t nElemSize,
int16_t dataType, tOrderDescriptor *pDesc); int16_t dataType, tOrderDescriptor *pDesc);
void tMemBucketDestroy(tMemBucket **pBucket); void tMemBucketDestroy(tMemBucket *pBucket);
void tMemBucketPut(tMemBucket *pBucket, void *data, int32_t numOfRows); void tMemBucketPut(tMemBucket *pBucket, void *data, int32_t numOfRows);
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册