提交 c2e91fcb 编写于 作者: S slguan

Adjust code structure

上级 20d340f5
......@@ -23,5 +23,14 @@ tests/script/
tests/pytest/
tests/jenkins/
tests/hdfs/
*.iml
*.class
nmake/
sln/
hdfs/
c/
taoshebei/
taosdalipu/
Target/
*.failed
*.sql
\ No newline at end of file
......@@ -3,171 +3,193 @@ PROJECT(TDengine)
SET(CMAKE_C_STANDARD 11)
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:
# mkdir debug; cd debug;
# mkdir debug; cd debug;
# cmake -DCMAKE_BUILD_TYPE=Debug ..
# 2.Generate release version:
# mkdir release; cd release;
# cmake -DCMAKE_BUILD_TYPE=Release ..
# mkdir release; cd release;
# cmake -DCMAKE_BUILD_TYPE=Release ..
#
#
# If it is a Windows operating system
# 1.Use command line tool of VS2013 or higher version
# mkdir build; cd build;
# cmake -G "NMake Makefiles" ..
# nmake install
# 2.Use the VS development interface tool
# 2.Use the VS development interface tool
# mkdir build; cd build;
# cmake -A x64 ..
# open the file named TDengine.sln
#
# Set macro definitions according to os platform
SET(TD_WINDOWS FALSE)
SET(TD_LINUX FALSE)
SET(TD_ARM FALSE)
SET(TD_DARWIN FALSE)
IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
SET(TD_OS_DIR ${PROJECT_SOURCE_DIR}/src/os/linux)
SET(TD_LINUX TRUE)
ADD_DEFINITIONS(-DLINUX)
IF (NOT DEFINED TD_CLUSTER)
MESSAGE(STATUS "Build the Lite Version")
SET(TD_CLUSTER FALSE)
SET(TD_LITE TRUE)
SET(TD_COMMUNITY_DIR ${PROJECT_SOURCE_DIR})
MESSAGE(STATUS "Community directory: " ${TD_COMMUNITY_DIR})
# Set macro definitions according to os platform
SET(TD_LINUX_64 FALSE)
SET(TD_LINUX_32 FALSE)
SET(TD_ARM_64 FALSE)
SET(TD_ARM_32 FALSE)
SET(TD_MIPS_64 FALSE)
SET(TD_DARWIN_64 FALSE)
SET(TD_WINDOWS_64 FALSE)
IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
IF (${CMAKE_SIZEOF_VOID_P} MATCHES 8)
SET(TD_LINUX_64 TRUE)
SET(TD_OS_DIR ${TD_COMMUNITY_DIR}/src/os/linux)
ADD_DEFINITIONS(-D_M_X64)
MESSAGE(STATUS "The current platform is Linux 64-bit")
ELSE ()
SET(TD_LINUX_32 TRUE)
MESSAGE(FATAL_ERROR "The current platform is Linux 32-bit, not supported yet")
EXIT ()
ENDIF ()
ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
IF (${CMAKE_SIZEOF_VOID_P} MATCHES 8)
SET(TD_DARWIN_64 TRUE)
SET(TD_OS_DIR ${TD_COMMUNITY_DIR}/src/os/darwin)
MESSAGE(STATUS "The current platform is Darwin 64-bit")
ELSE ()
MESSAGE(FATAL_ERROR "The current platform is Darwin 32-bit, not supported yet")
EXIT ()
ENDIF ()
ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
IF (${CMAKE_SIZEOF_VOID_P} MATCHES 8)
SET(TD_WINDOWS_64 TRUE)
SET(TD_OS_DIR ${TD_COMMUNITY_DIR}/src/os/windows)
ADD_DEFINITIONS(-D_M_X64)
MESSAGE(STATUS "The current platform is Windows 64-bit")
ELSE ()
MESSAGE(FATAL_ERROR "The current platform is Windows 32-bit, not supported yet")
EXIT ()
ENDIF ()
ELSE()
MESSAGE(FATAL_ERROR "The current platform is not Linux/Darwin/Windows, stop compile")
EXIT ()
ENDIF ()
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")
FIND_PROGRAM(TD_MVN_INSTALLED mvn)
IF (TD_MVN_INSTALLED)
MESSAGE(STATUS "MVN is installed and JDBC will be compiled")
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")
MESSAGE(STATUS "MVN is not installed and JDBC is not compiled")
ENDIF ()
SET(DEBUG_FLAGS "-O0 -DDEBUG")
SET(RELEASE_FLAGS "-O0")
ADD_DEFINITIONS(-D_REENTRANT -D__USE_POSIX -D_LIBC_REENTRANT)
IF (${CMAKE_SIZEOF_VOID_P} MATCHES 8)
MESSAGE(STATUS "The current platform is Linux 64-bit")
ADD_DEFINITIONS(-D_M_X64)
#
# debug flag
#
# 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 ()
MESSAGE(FATAL_ERROR "The current platform is Linux 32-bit, not supported yet")
EXIT ()
ADD_DEFINITIONS(-DLITE)
ADD_DEFINITIONS(-DTSDB_REPLICA_MAX_NUM=1)
ENDIF ()
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)
MESSAGE(STATUS "The current platform is Windows 64-bit")
ADD_DEFINITIONS(-D_M_X64)
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(DEBUG_FLAGS "-O0 -DDEBUG")
SET(RELEASE_FLAGS "-O0")
ADD_DEFINITIONS(-DDARWIN)
ADD_DEFINITIONS(-D_REENTRANT -D__USE_POSIX -D_LIBC_REENTRANT)
ELSE ()
MESSAGE(FATAL_ERROR "The current platform is Windows 32-bit, not supported yet")
MESSAGE(FATAL_ERROR "The current platform is not support yet, stop compile")
EXIT ()
ENDIF ()
ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# 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(TD_OS_DIR ${PROJECT_SOURCE_DIR}/src/os/darwin)
SET(TD_DARWIN TRUE)
ADD_DEFINITIONS(-DDARWIN)
# Set c++ compiler options
# SET(COMMON_CXX_FLAGS "${COMMON_FLAGS} -std=c++11")
# SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${COMMON_CXX_FLAGS} ${DEBUG_FLAGS}")
# SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${COMMON_CXX_FLAGS} ${RELEASE_FLAGS}")
SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -malign-double -g -Wno-char-subscripts -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE -Wno-unused-variable -Wno-bitfield-constant-conversion")
SET(DEBUG_FLAGS "-O0 -DDEBUG")
SET(RELEASE_FLAGS "-O0")
ADD_DEFINITIONS(-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)
IF (${CMAKE_BUILD_TYPE} MATCHES "Debug")
MESSAGE(STATUS "Build Debug Version")
ELSEIF (${CMAKE_BUILD_TYPE} MATCHES "Release")
MESSAGE(STATUS "Build Release Version")
ELSE ()
MESSAGE(FATAL_ERROR "The current platform is Darwin 32-bit, not supported yet")
EXIT ()
IF (TD_WINDOWS_64)
SET(CMAKE_BUILD_TYPE "Release")
MESSAGE(STATUS "Build Release Version in Windows as default")
ELSE ()
SET(CMAKE_BUILD_TYPE "Debug")
MESSAGE(STATUS "Build Debug Version as default")
ENDIF()
ENDIF ()
ELSE ()
MESSAGE(FATAL_ERROR "The current platform is not Linux/MAC/Windows, stop compile")
EXIT ()
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(COMMON_CXX_FLAGS "${COMMON_FLAGS} -std=c++11")
# SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${COMMON_CXX_FLAGS} ${DEBUG_FLAGS}")
# SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${COMMON_CXX_FLAGS} ${RELEASE_FLAGS}")
IF (${CMAKE_BUILD_TYPE} MATCHES "Debug")
MESSAGE(STATUS "Build Debug Version")
ELSEIF (${CMAKE_BUILD_TYPE} MATCHES "Release")
MESSAGE(STATUS "Build Release Version")
ELSE ()
IF (TD_WINDOWS)
SET(CMAKE_BUILD_TYPE "Release")
MESSAGE(STATUS "Build Release Version")
ELSE ()
SET(CMAKE_BUILD_TYPE "Debug")
MESSAGE(STATUS "Build Debug Version")
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")
#set output directory
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/build/lib)
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/build/bin)
SET(TD_TESTS_OUTPUT_DIR ${PROJECT_BINARY_DIR}/test)
MESSAGE(STATUS "Operating system dependency directory: " ${TD_OS_DIR})
MESSAGE(STATUS "Project source directory: " ${PROJECT_SOURCE_DIR})
MESSAGE(STATUS "Project binary files output path: " ${PROJECT_BINARY_DIR})
MESSAGE(STATUS "Project executable files output path: " ${EXECUTABLE_OUTPUT_PATH})
MESSAGE(STATUS "Project library files output path: " ${LIBRARY_OUTPUT_PATH})
IF (TD_LINUX_64)
SET(TD_MAKE_INSTALL_SH "${TD_COMMUNITY_DIR}/packaging/tools/make_install.sh")
INSTALL(CODE "MESSAGE(\"make install script: ${TD_MAKE_INSTALL_SH}\")")
INSTALL(CODE "execute_process(COMMAND chmod 777 ${TD_MAKE_INSTALL_SH})")
INSTALL(CODE "execute_process(COMMAND ${TD_MAKE_INSTALL_SH} ${TD_COMMUNITY_DIR} ${PROJECT_BINARY_DIR})")
ELSEIF (TD_WINDOWS_64)
SET(CMAKE_INSTALL_PREFIX C:/TDengine)
INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/src/connector/go DESTINATION connector)
INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/src/connector/grafana DESTINATION connector)
INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/src/connector/python DESTINATION connector)
INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/tests/examples DESTINATION .)
INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/packaging/cfg DESTINATION .)
INSTALL(FILES ${TD_COMMUNITY_DIR}/src/inc/taos.h DESTINATION include)
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.lib DESTINATION driver)
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.exp DESTINATION driver)
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.dll DESTINATION driver)
INSTALL(FILES ${EXECUTABLE_OUTPUT_PATH}/taos.exe DESTINATION .)
#INSTALL(TARGETS taos RUNTIME DESTINATION driver)
#INSTALL(TARGETS shell RUNTIME DESTINATION .)
IF (TD_MVN_INSTALLED)
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-1.0.2-dist.jar DESTINATION connector/jdbc)
ENDIF ()
ENDIF ()
ENDIF ()
#set output directory
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/build/lib)
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/build/bin)
SET(TD_TESTS_OUTPUT_DIR ${PROJECT_BINARY_DIR}/test)
MESSAGE(STATUS "Operating system dependency directory: " ${TD_OS_DIR})
MESSAGE(STATUS "Project source directory: " ${PROJECT_SOURCE_DIR})
MESSAGE(STATUS "Project binary files output path: " ${PROJECT_BINARY_DIR})
MESSAGE(STATUS "Project executable files output path: " ${EXECUTABLE_OUTPUT_PATH})
MESSAGE(STATUS "Project library files output path: " ${LIBRARY_OUTPUT_PATH})
ADD_SUBDIRECTORY(deps)
ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(tests)
IF (TD_LINUX)
SET(TD_MAKE_INSTALL_SH "${TD_ROOT_DIR}/packaging/tools/make_install.sh")
INSTALL(CODE "MESSAGE(\"make install script: ${TD_MAKE_INSTALL_SH}\")")
INSTALL(CODE "execute_process(COMMAND chmod 777 ${TD_MAKE_INSTALL_SH})")
INSTALL(CODE "execute_process(COMMAND ${TD_MAKE_INSTALL_SH} ${TD_ROOT_DIR} ${PROJECT_BINARY_DIR})")
ELSEIF (TD_WINDOWS)
SET(CMAKE_INSTALL_PREFIX C:/TDengine)
INSTALL(DIRECTORY ${TD_ROOT_DIR}/src/connector/go DESTINATION connector)
INSTALL(DIRECTORY ${TD_ROOT_DIR}/src/connector/grafana DESTINATION connector)
INSTALL(DIRECTORY ${TD_ROOT_DIR}/src/connector/python DESTINATION connector)
INSTALL(DIRECTORY ${TD_ROOT_DIR}/tests/examples DESTINATION .)
INSTALL(DIRECTORY ${TD_ROOT_DIR}/packaging/cfg DESTINATION .)
INSTALL(FILES ${TD_ROOT_DIR}/src/inc/taos.h DESTINATION include)
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.lib DESTINATION driver)
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.exp DESTINATION driver)
INSTALL(TARGETS taos RUNTIME DESTINATION driver)
INSTALL(TARGETS shell RUNTIME DESTINATION .)
IF (TD_MVN_INSTALLED)
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-1.0.2-dist.jar DESTINATION connector/jdbc)
ENDIF ()
ENDIF ()
INCLUDE(CPack)
\ No newline at end of file
INCLUDE(CPack)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(TDengine)
ADD_SUBDIRECTORY(zlib-1.2.11)
......
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(TDengine)
IF (TD_WINDOWS)
IF (TD_WINDOWS_64)
LIST(APPEND SRC iconv.c)
LIST(APPEND SRC localcharset.c)
INCLUDE_DIRECTORIES(.)
......
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(TDengine)
IF (TD_WINDOWS)
LIST(APPEND SRC pthread.c)
IF (TD_WINDOWS_64)
INCLUDE_DIRECTORIES(.)
LIST(APPEND SRC pthread.c)
ADD_LIBRARY(pthread ${SRC})
ENDIF ()
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(TDengine)
IF (TD_WINDOWS)
LIST(APPEND SRC regex.c)
IF (TD_WINDOWS_64)
INCLUDE_DIRECTORIES(inc .)
LIST(APPEND SRC regex.c)
ADD_LIBRARY(regex ${SRC})
ENDIF ()
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(TDengine)
IF (TD_LINUX)
AUX_SOURCE_DIRECTORY(src SRC)
IF (TD_LINUX_64)
INCLUDE_DIRECTORIES(inc)
AUX_SOURCE_DIRECTORY(src SRC)
ADD_LIBRARY(z ${SRC})
ENDIF ()
......@@ -4,7 +4,7 @@
*/
/* @(#) $Id$ */
//#include <stdint.h>
#ifndef ZCONF_H
#define ZCONF_H
......@@ -238,16 +238,16 @@
#endif
#ifdef Z_SOLO
typedef unsigned long z_size_t;
typedef uint64_t z_size_t;
#else
# define z_longlong long long
# define z_longlong int64_t
# if defined(NO_SIZE_T)
typedef unsigned NO_SIZE_T z_size_t;
# elif defined(STDC)
# include <stddef.h>
typedef size_t z_size_t;
# else
typedef unsigned long z_size_t;
typedef uint64_t z_size_t;
# endif
# undef z_longlong
#endif
......@@ -391,7 +391,7 @@
typedef unsigned char Byte; /* 8 bits */
#endif
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
/* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
......@@ -419,7 +419,7 @@ typedef uLong FAR uLongf;
# if (UINT_MAX == 0xffffffffUL)
# define Z_U4 unsigned
# elif (ULONG_MAX == 0xffffffffUL)
# define Z_U4 unsigned long
# define Z_U4 uint64_t
# elif (USHRT_MAX == 0xffffffffUL)
# define Z_U4 unsigned short
# endif
......@@ -428,7 +428,7 @@ typedef uLong FAR uLongf;
#ifdef Z_U4
typedef Z_U4 z_crc_t;
#else
typedef unsigned long z_crc_t;
typedef uint64_t z_crc_t;
#endif
#if 1 /* was set to #if 1 by ./configure */
......@@ -501,7 +501,7 @@ typedef uLong FAR uLongf;
#endif
#ifndef z_off_t
# define z_off_t long
# define z_off_t int64_t
#endif
#if !defined(_WIN32) && defined(Z_LARGE64)
......
......@@ -999,7 +999,7 @@ ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm,
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
value, and the other in the remaining upper bits, obtained by shifting the
......@@ -1890,7 +1890,7 @@ ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp));
ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void));
ZEXTERN int ZEXPORT inflateUndermine 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 deflateResetKeep OF((z_streamp));
#if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(Z_SOLO)
......
......@@ -4,7 +4,7 @@
*/
/* @(#) $Id$ */
#include <stdint.h>
#include "zutil.h"
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) */
# define CHOP(a) \
do { \
unsigned long tmp = a >> 16; \
uint64_t tmp = a >> 16; \
a &= 0xffffUL; \
a += (tmp << 4) - tmp; \
} while (0)
......@@ -65,7 +65,7 @@ uLong ZEXPORT adler32_z(adler, buf, len)
const Bytef *buf;
z_size_t len;
{
unsigned long sum2;
uint64_t sum2;
unsigned n;
/* split Adler-32 into component sums */
......@@ -145,8 +145,8 @@ local uLong adler32_combine_(adler1, adler2, len2)
uLong adler2;
z_off64_t len2;
{
unsigned long sum1;
unsigned long sum2;
uint64_t sum1;
uint64_t sum2;
unsigned rem;
/* for negative len, return invalid adler32 as a clue for debugging */
......@@ -163,7 +163,7 @@ local uLong adler32_combine_(adler1, adler2, len2)
sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
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;
return sum1 | (sum2 << 16);
}
......
......@@ -4,7 +4,7 @@
*/
/* @(#) $Id$ */
#include <stdint.h>
#define ZLIB_INTERNAL
#include "zlib.h"
......
......@@ -20,7 +20,7 @@
DYNAMIC_CRC_TABLE and MAKECRCH can be #defined to write out crc32.h.
*/
#include <stdint.h>
#ifdef MAKECRCH
# include <stdio.h>
# ifndef DYNAMIC_CRC_TABLE
......@@ -35,9 +35,9 @@
# define BYFOUR
#endif
#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));
local unsigned long crc32_big OF((unsigned long,
local uint64_t crc32_big OF((uint64_t,
const unsigned char FAR *, z_size_t));
# define TBLS 8
#else
......@@ -45,9 +45,9 @@
#endif /* BYFOUR */
/* Local functions for crc concatenation */
local unsigned long gf2_matrix_times OF((unsigned long *mat,
unsigned long vec));
local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat));
local uint64_t gf2_matrix_times OF((uint64_t *mat,
uint64_t vec));
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));
......@@ -170,7 +170,7 @@ local void write_table(out, table)
for (n = 0; n < 256; n++)
fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ",
(unsigned long)(table[n]),
(uint64_t)(table[n]),
n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", "));
}
#endif /* MAKECRCH */
......@@ -199,8 +199,8 @@ const z_crc_t FAR * ZEXPORT get_crc_table()
#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
/* ========================================================================= */
unsigned long ZEXPORT crc32_z(crc, buf, len)
unsigned long crc;
uint64_t ZEXPORT crc32_z(crc, buf, len)
uint64_t crc;
const unsigned char FAR *buf;
z_size_t len;
{
......@@ -234,8 +234,8 @@ unsigned long ZEXPORT crc32_z(crc, buf, len)
}
/* ========================================================================= */
unsigned long ZEXPORT crc32(crc, buf, len)
unsigned long crc;
uint64_t ZEXPORT crc32(crc, buf, len)
uint64_t crc;
const unsigned char FAR *buf;
uInt len;
{
......@@ -263,8 +263,8 @@ unsigned long ZEXPORT crc32(crc, buf, len)
#define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4
/* ========================================================================= */
local unsigned long crc32_little(crc, buf, len)
unsigned long crc;
local uint64_t crc32_little(crc, buf, len)
uint64_t crc;
const unsigned char FAR *buf;
z_size_t len;
{
......@@ -293,7 +293,7 @@ local unsigned long crc32_little(crc, buf, len)
c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
} while (--len);
c = ~c;
return (unsigned long)c;
return (uint64_t)c;
}
/* ========================================================================= */
......@@ -303,8 +303,8 @@ local unsigned long crc32_little(crc, buf, len)
#define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4
/* ========================================================================= */
local unsigned long crc32_big(crc, buf, len)
unsigned long crc;
local uint64_t crc32_big(crc, buf, len)
uint64_t crc;
const unsigned char FAR *buf;
z_size_t len;
{
......@@ -333,7 +333,7 @@ local unsigned long crc32_big(crc, buf, len)
c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
} while (--len);
c = ~c;
return (unsigned long)(ZSWAP32(c));
return (uint64_t)(ZSWAP32(c));
}
#endif /* BYFOUR */
......@@ -341,11 +341,11 @@ local unsigned long crc32_big(crc, buf, len)
#define GF2_DIM 32 /* dimension of GF(2) vectors (length of CRC) */
/* ========================================================================= */
local unsigned long gf2_matrix_times(mat, vec)
unsigned long *mat;
unsigned long vec;
local uint64_t gf2_matrix_times(mat, vec)
uint64_t *mat;
uint64_t vec;
{
unsigned long sum;
uint64_t sum;
sum = 0;
while (vec) {
......@@ -359,8 +359,8 @@ local unsigned long gf2_matrix_times(mat, vec)
/* ========================================================================= */
local void gf2_matrix_square(square, mat)
unsigned long *square;
unsigned long *mat;
uint64_t *square;
uint64_t *mat;
{
int n;
......@@ -375,9 +375,9 @@ local uLong crc32_combine_(crc1, crc2, len2)
z_off64_t len2;
{
int n;
unsigned long row;
unsigned long even[GF2_DIM]; /* even-power-of-two zeros operator */
unsigned long odd[GF2_DIM]; /* odd-power-of-two zeros operator */
uint64_t row;
uint64_t even[GF2_DIM]; /* even-power-of-two zeros operator */
uint64_t odd[GF2_DIM]; /* odd-power-of-two zeros operator */
/* degenerate case (also disallow negative lengths) */
if (len2 <= 0)
......
......@@ -48,7 +48,7 @@
*/
/* @(#) $Id$ */
#include <stdint.h>
#include "deflate.h"
const char deflate_copyright[] =
......@@ -430,7 +430,7 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
fill_window(s);
}
s->strstart += s->lookahead;
s->block_start = (long)s->strstart;
s->block_start = (int64_t)s->strstart;
s->insert = s->lookahead;
s->lookahead = 0;
s->match_length = s->prev_length = MIN_MATCH-1;
......@@ -1512,7 +1512,7 @@ local void fill_window(s)
zmemcpy(s->window, s->window+wsize, (unsigned)wsize - more);
s->match_start -= wsize;
s->strstart -= wsize; /* we now have strstart >= MAX_DIST */
s->block_start -= (long) wsize;
s->block_start -= (int64_t) wsize;
slide_hash(s);
more += wsize;
}
......@@ -1606,7 +1606,7 @@ local void fill_window(s)
_tr_flush_block(s, (s->block_start >= 0L ? \
(charf *)&s->window[(unsigned)s->block_start] : \
(charf *)Z_NULL), \
(ulg)((long)s->strstart - s->block_start), \
(ulg)((int64_t)s->strstart - s->block_start), \
(last)); \
s->block_start = s->strstart; \
flush_pending(s->strm); \
......@@ -1766,12 +1766,12 @@ local block_state deflate_stored(s, flush)
/* If flushing and all input has been consumed, then done. */
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;
/* Fill the window with any remaining input. */
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. */
s->block_start -= s->w_size;
s->strstart -= s->w_size;
......
......@@ -151,7 +151,7 @@ typedef struct internal_state {
* hash_shift * MIN_MATCH >= hash_bits
*/
long block_start;
int64_t block_start;
/* Window position at the beginning of the current output block. Gets
* negative when the window is moved backwards.
*/
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2004, 2010 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
#include <stdint.h>
#include "gzguts.h"
/* gzclose() is in a separate file so that it is linked in only if it is used.
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2004-2017 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
#include <stdint.h>
#include "gzguts.h"
#if defined(_WIN32) && !defined(__BORLANDC__) && !defined(__MINGW32__)
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013, 2016 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
#include <stdint.h>
#include "gzguts.h"
/* Local functions */
......
......@@ -2,7 +2,7 @@
* Copyright (C) 2004-2017 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
#include <stdint.h>
#include "gzguts.h"
/* Local functions */
......
......@@ -9,7 +9,7 @@
with inffast.c is retained so that optimized assembler-coded versions of
inflate_fast() can be used with either inflate.c or infback.c.
*/
#include <stdint.h>
#include "zutil.h"
#include "inftrees.h"
#include "inflate.h"
......@@ -173,7 +173,7 @@ struct inflate_state FAR *state;
do { \
PULL(); \
have--; \
hold += (unsigned long)(*next++) << bits; \
hold += (uint64_t)(*next++) << bits; \
bits += 8; \
} while (0)
......@@ -258,7 +258,7 @@ void FAR *out_desc;
z_const unsigned char FAR *next; /* next input */
unsigned char FAR *put; /* next 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 copy; /* number of stored or match bytes to copy */
unsigned char FAR *from; /* where to copy match bytes from */
......
......@@ -2,7 +2,7 @@
* Copyright (C) 1995-2017 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
#include <stdint.h>
#include "zutil.h"
#include "inftrees.h"
#include "inflate.h"
......@@ -64,7 +64,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
unsigned whave; /* valid bytes in the window */
unsigned wnext; /* window write index */
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 */
code const FAR *lcode; /* local strm->lencode */
code const FAR *dcode; /* local strm->distcode */
......@@ -102,9 +102,9 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
input data or output space */
do {
if (bits < 15) {
hold += (unsigned long)(*in++) << bits;
hold += (uint64_t)(*in++) << bits;
bits += 8;
hold += (unsigned long)(*in++) << bits;
hold += (uint64_t)(*in++) << bits;
bits += 8;
}
here = lcode[hold & lmask];
......@@ -124,7 +124,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
op &= 15; /* number of extra bits */
if (op) {
if (bits < op) {
hold += (unsigned long)(*in++) << bits;
hold += (uint64_t)(*in++) << bits;
bits += 8;
}
len += (unsigned)hold & ((1U << op) - 1);
......@@ -133,9 +133,9 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
}
Tracevv((stderr, "inflate: length %u\n", len));
if (bits < 15) {
hold += (unsigned long)(*in++) << bits;
hold += (uint64_t)(*in++) << bits;
bits += 8;
hold += (unsigned long)(*in++) << bits;
hold += (uint64_t)(*in++) << bits;
bits += 8;
}
here = dcode[hold & dmask];
......@@ -148,10 +148,10 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
dist = (unsigned)(here.val);
op &= 15; /* number of extra bits */
if (bits < op) {
hold += (unsigned long)(*in++) << bits;
hold += (uint64_t)(*in++) << bits;
bits += 8;
if (bits < op) {
hold += (unsigned long)(*in++) << bits;
hold += (uint64_t)(*in++) << bits;
bits += 8;
}
}
......
......@@ -79,7 +79,7 @@
*
* The history for versions after 1.2.0 are in ChangeLog in zlib distribution.
*/
#include <stdint.h>
#include "zutil.h"
#include "inftrees.h"
#include "inflate.h"
......@@ -507,7 +507,7 @@ unsigned copy;
do { \
if (have == 0) goto inf_leave; \
have--; \
hold += (unsigned long)(*next++) << bits; \
hold += (uint64_t)(*next++) << bits; \
bits += 8; \
} while (0)
......@@ -627,7 +627,7 @@ int flush;
z_const unsigned char FAR *next; /* next input */
unsigned char FAR *put; /* next 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 in, out; /* save starting available input and output */
unsigned copy; /* number of stored or match bytes to copy */
......@@ -1317,7 +1317,7 @@ const Bytef *dictionary;
uInt dictLength;
{
struct inflate_state FAR *state;
unsigned long dictid;
uint64_t dictid;
int ret;
/* check state */
......@@ -1401,7 +1401,7 @@ int ZEXPORT inflateSync(strm)
z_streamp strm;
{
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 */
struct inflate_state FAR *state;
......@@ -1538,7 +1538,7 @@ int check;
return Z_OK;
}
long ZEXPORT inflateMark(strm)
int64_t ZEXPORT inflateMark(strm)
z_streamp strm;
{
struct inflate_state FAR *state;
......@@ -1546,16 +1546,16 @@ z_streamp strm;
if (inflateStateCheck(strm))
return -(1L << 16);
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 == MATCH ? state->was - state->length : 0));
}
unsigned long ZEXPORT inflateCodesUsed(strm)
uint64_t ZEXPORT inflateCodesUsed(strm)
z_streamp strm;
{
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;
return (unsigned long)(state->next - state->codes);
return (uint64_t)(state->next - state->codes);
}
......@@ -88,8 +88,8 @@ struct inflate_state {
int havedict; /* true if dictionary provided */
int flags; /* gzip header method and flags (0 if zlib) */
unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */
unsigned long check; /* protected copy of check value */
unsigned long total; /* protected copy of output count */
uint64_t check; /* protected copy of check value */
uint64_t total; /* protected copy of output count */
gz_headerp head; /* where to save gzip header information */
/* sliding window */
unsigned wbits; /* log base 2 of requested window size */
......@@ -98,7 +98,7 @@ struct inflate_state {
unsigned wnext; /* window write index */
unsigned char FAR *window; /* allocated sliding window, if needed */
/* bit accumulator */
unsigned long hold; /* input bit accumulator */
uint64_t hold; /* input bit accumulator */
unsigned bits; /* number of bits in "in" */
/* for string and stored block copying */
unsigned length; /* literal or length of data to copy */
......
......@@ -2,7 +2,7 @@
* Copyright (C) 1995-2017 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
#include <stdint.h>
#include "zutil.h"
#include "inftrees.h"
......
......@@ -33,7 +33,7 @@
/* @(#) $Id$ */
/* #define GEN_TREES_H */
#include <stdint.h>
#include "deflate.h"
#ifdef ZLIB_DEBUG
......@@ -1038,7 +1038,7 @@ int ZLIB_INTERNAL _tr_tally (s, dist, lc)
if ((s->last_lit & 0x1fff) == 0 && s->level > 2) {
/* Compute an upper bound for the compressed length */
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;
for (dcode = 0; dcode < D_CODES; dcode++) {
out_length += (ulg)s->dyn_dtree[dcode].Freq *
......@@ -1128,7 +1128,7 @@ local int detect_data_type(s)
* set bits 0..6, 14..25, and 28..31
* 0xf3ffc07f = binary 11110011111111111100000001111111
*/
unsigned long black_mask = 0xf3ffc07fUL;
uint64_t black_mask = 0xf3ffc07fUL;
int n;
/* Check for non-textual ("black-listed") bytes. */
......
......@@ -4,7 +4,7 @@
*/
/* @(#) $Id$ */
#include <stdint.h>
#define ZLIB_INTERNAL
#include "zlib.h"
......
......@@ -238,16 +238,16 @@
#endif
#ifdef Z_SOLO
typedef unsigned long z_size_t;
typedef uint64_t z_size_t;
#else
# define z_longlong long long
# define z_longlong int64_t
# if defined(NO_SIZE_T)
typedef unsigned NO_SIZE_T z_size_t;
# elif defined(STDC)
# include <stddef.h>
typedef size_t z_size_t;
# else
typedef unsigned long z_size_t;
typedef uint64_t z_size_t;
# endif
# undef z_longlong
#endif
......@@ -391,7 +391,7 @@
typedef unsigned char Byte; /* 8 bits */
#endif
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
/* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
......@@ -419,7 +419,7 @@ typedef uLong FAR uLongf;
# if (UINT_MAX == 0xffffffffUL)
# define Z_U4 unsigned
# elif (ULONG_MAX == 0xffffffffUL)
# define Z_U4 unsigned long
# define Z_U4 uint64_t
# elif (USHRT_MAX == 0xffffffffUL)
# define Z_U4 unsigned short
# endif
......@@ -428,7 +428,7 @@ typedef uLong FAR uLongf;
#ifdef Z_U4
typedef Z_U4 z_crc_t;
#else
typedef unsigned long z_crc_t;
typedef uint64_t z_crc_t;
#endif
#if 1 /* was set to #if 1 by ./configure */
......@@ -501,7 +501,7 @@ typedef uLong FAR uLongf;
#endif
#ifndef z_off_t
# define z_off_t long
# define z_off_t int64_t
#endif
#if !defined(_WIN32) && defined(Z_LARGE64)
......
......@@ -999,7 +999,7 @@ ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm,
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
value, and the other in the remaining upper bits, obtained by shifting the
......@@ -1890,7 +1890,7 @@ ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp));
ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void));
ZEXTERN int ZEXPORT inflateUndermine 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 deflateResetKeep OF((z_streamp));
#if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(Z_SOLO)
......
......@@ -4,7 +4,7 @@
*/
/* @(#) $Id$ */
#include <stdint.h>
#include "zutil.h"
#ifndef Z_SOLO
# include "gzguts.h"
......@@ -280,7 +280,7 @@ void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, uInt items, uInt size)
{
(void)opaque;
return _halloc((long)items, size);
return _halloc((int64_t)items, size);
}
void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
......
......@@ -30,7 +30,7 @@
#endif
#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
#ifndef local
......@@ -44,7 +44,7 @@ typedef unsigned char uch;
typedef uch FAR uchf;
typedef unsigned short ush;
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 */
/* (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 */
# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
/* Allow compilation with ANSI keywords only enabled */
void _Cdecl farfree( void *block );
void *_Cdecl farmalloc( unsigned long nbytes );
void *_Cdecl farmalloc( uint64_t nbytes );
# else
# include <alloc.h>
# endif
......
......@@ -131,10 +131,10 @@
# maxVnodeConnections 10000
# start http service in the cluster
# enableHttp 1
# http 1
# start system monitor module in the cluster
# enableMonitor 1
# monitor 1
# number of threads used to process http requests
# httpMaxThreads 2
......
#!/bin/bash
#
# Generate deb package for ubuntu
#set -x
# set -x
#curr_dir=$(pwd)
compile_dir=$1
......@@ -24,7 +24,7 @@ fi
mkdir -p ${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}"
# create install dir
......
文件模式从 100755 更改为 100644
......@@ -8,7 +8,7 @@ set -e
curr_dir=$(pwd)
script_dir="$(dirname $(readlink -f $0))"
top_dir="$(readlink -m ${script_dir}/..)"
versioninfo="${top_dir}/src/util/src/version.c"
versioninfo="${top_dir}/src/util/lite/src/version.c"
csudo=""
if command -v sudo > /dev/null; then
......
文件模式从 100755 更改为 100644
......@@ -39,7 +39,7 @@ echo topdir: %{_topdir}
echo version: %{_version}
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}"
# create install path, and cp file
......
......@@ -7,8 +7,7 @@ set -e
# set -x
# -----------------------Variables definition---------------------
script_dir=$(dirname $(readlink -m "$0"))
verinfo=$(cat ${script_dir}/../../src/util/src/version.c | grep " version" | cut -d '"' -f2)
verinfo=$(cat $1 | grep " version" | cut -d '"' -f2)
verinfo=$(echo $verinfo | tr "\n" " ")
len=$(echo ${#verinfo})
len=$((len-1))
......
......@@ -101,7 +101,7 @@ function install_lib() {
# Remove links
${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} 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
......
......@@ -20,7 +20,7 @@ install_dir="${release_dir}/taos-${version}-${package_name}-$(echo ${build_time}
# 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"
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}"
header_files="${code_dir}/inc/taos.h"
cfg_files="${top_dir}/packaging/cfg/*.cfg"
......
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(TDengine)
SET(PRJ_HEADER_PATH ${CMAKE_CURRENT_SOURCE_DIR}/inc)
ADD_SUBDIRECTORY(os)
ADD_SUBDIRECTORY(util)
ADD_SUBDIRECTORY(rpc)
......
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
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)
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
ADD_LIBRARY(taos_static STATIC ${SRC})
......@@ -23,30 +24,38 @@ IF (TD_LINUX)
#set version of .so
#VERSION so version
#SOVERSION api version
execute_process(COMMAND chmod 777 ${PROJECT_SOURCE_DIR}/../../packaging/tools/get_version.sh)
execute_process(COMMAND ${PROJECT_SOURCE_DIR}/../../packaging/tools/get_version.sh
OUTPUT_VARIABLE
VERSION_INFO)
IF (TD_LITE)
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
VERSION_INFO)
MESSAGE(STATUS "build cluster version ${VERSION_INFO}")
ENDIF ()
MESSAGE(STATUS "build version ${VERSION_INFO}")
SET_TARGET_PROPERTIES(taos PROPERTIES VERSION ${VERSION_INFO} SOVERSION 1)
ELSEIF (TD_WINDOWS)
INCLUDE_DIRECTORIES(${TD_ROOT_DIR}/deps/jni/windows)
INCLUDE_DIRECTORIES(${TD_ROOT_DIR}/deps/jni/windows/win32)
INCLUDE_DIRECTORIES(${TD_ROOT_DIR}/deps/pthread)
ELSEIF (TD_WINDOWS_64)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/jni/windows)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/jni/windows/win32)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/pthread)
ADD_LIBRARY(taos_static STATIC ${SRC})
TARGET_LINK_LIBRARIES(taos_static trpc tutil)
# generate dynamic library (*.dll)
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)
ELSEIF (TD_DARWIN)
INCLUDE_DIRECTORIES(${TD_ROOT_DIR}/deps/jni/linux)
ELSEIF (TD_DARWIN_64)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/jni/linux)
ADD_LIBRARY(taos_static STATIC ${SRC})
TARGET_LINK_LIBRARIES(taos_static trpc tutil pthread m)
......@@ -55,6 +64,6 @@ ELSEIF (TD_DARWIN)
# generate dynamic library (*.dylib)
ADD_LIBRARY(taos SHARED ${SRC})
TARGET_LINK_LIBRARIES(taos trpc tutil pthread m)
ENDIF ()
/*
* 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,74 +52,53 @@ enum {
};
typedef struct SLocalReducer {
SLocalDataSource **pLocalDataSrc;
int32_t numOfBuffer;
int32_t numOfCompleted;
int32_t numOfVnode;
SLoserTreeInfo *pLoserTree;
char * prevRowOfInput;
tFilePage *pResultBuf;
int32_t nResultBufSize;
char *pBufForInterpo; // intermediate buffer for interpolation
tFilePage *pTempBuffer;
SLocalDataSource ** pLocalDataSrc;
int32_t numOfBuffer;
int32_t numOfCompleted;
int32_t numOfVnode;
SLoserTreeInfo * pLoserTree;
char * prevRowOfInput;
tFilePage * pResultBuf;
int32_t nResultBufSize;
char * pBufForInterpo; // intermediate buffer for interpolation
tFilePage * pTempBuffer;
struct SQLFunctionCtx *pCtx;
int32_t rowSize; // size of each intermediate result.
int32_t status; // denote it is in reduce process, in reduce process, it
// cannot be released
bool hasPrevRow;
bool hasUnprocessedRow;
tOrderDescriptor *pDesc;
tColModel * resColModel;
tExtMemBuffer ** pExtMemBuffer; // disk-based buffer
SInterpolationInfo interpolationInfo; // interpolation support structure
char *pFinalRes; // result data after interpo
tFilePage *discardData;
bool discard;
int32_t offset;
int32_t rowSize; // size of each intermediate result.
int32_t status; // denote it is in reduce process, in reduce process, it
bool hasPrevRow; // cannot be released
bool hasUnprocessedRow;
tOrderDescriptor * pDesc;
tColModel * resColModel;
tExtMemBuffer ** pExtMemBuffer; // disk-based buffer
SInterpolationInfo interpolationInfo; // interpolation support structure
char * pFinalRes; // result data after interpo
tFilePage * discardData;
SResultInfo * pResInfo;
bool discard;
int32_t offset; // limit offset value
} SLocalReducer;
typedef struct SRetrieveSupport {
tExtMemBuffer ** pExtMemBuffer; // for build loser tree
tOrderDescriptor *pOrderDescriptor;
tColModel * pFinalColModel; // colModel for final result
/*
* shared by all subqueries
* It is the number of completed retrieval subquery.
* once this value equals to numOfVnodes, all retrieval are completed.
* Local merge is launched.
*/
int32_t *numOfFinished;
int32_t numOfVnodes; // total number of vnode
int32_t vnodeIdx; // index of current vnode in vnode list
typedef struct SSubqueryState {
/*
* shared by all subqueries
* denote the status of query on vnode, if code!=0, all following
* retrieval on vnode are aborted.
* the number of completed retrieval subquery, once this value equals to numOfVnodes,
* all retrieval are completed.Local merge is launched.
*/
int32_t *code;
SSqlObj * pParentSqlObj;
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
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;
uint32_t numOfRetry; // record the number of retry times
pthread_mutex_t queryMutex;
typedef struct SRetrieveSupport {
tExtMemBuffer ** pExtMemBuffer; // for build loser tree
tOrderDescriptor *pOrderDescriptor;
tColModel * pFinalColModel; // colModel for final result
SSubqueryState * pState;
int32_t vnodeIdx; // index of current vnode in vnode list
SSqlObj * pParentSqlObj;
tFilePage * localBuffer; // temp buffer, there is a buffer for each vnode to
uint32_t numOfRetry; // record the number of retry times
pthread_mutex_t queryMutex;
} SRetrieveSupport;
int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOrderDescriptor **pDesc,
......
......@@ -23,18 +23,20 @@ extern "C" {
/*
* @date 2018/09/30
*/
#include <limits.h>
#include <stdio.h>
#include "tsdb.h"
#include "tsclient.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_NOMRAL_METER(cmd) (!(UTIL_METER_IS_METRIC(cmd)))
#define UTIL_METER_IS_CREATE_FROM_METRIC(cmd) \
(((cmd)->pMeterMeta != NULL) && ((cmd)->pMeterMeta->meterType == TSDB_METER_MTABLE))
#define TSDB_COL_IS_TAG(f) (((f)&TSDB_COL_TAG) != 0)
typedef struct SParsedColElem {
int16_t colIndex;
int16_t offset;
......@@ -47,15 +49,36 @@ typedef struct SParsedDataColInfo {
bool hasVal[TSDB_MAX_COLUMNS];
} 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);
STableDataBlocks* tscCreateDataBlock(int32_t size);
void tscAppendDataBlock(SDataBlockList* pList, STableDataBlocks* pBlocks);
SParamInfo* tscAddParamToDataBlock(STableDataBlocks* pDataBlock, char type, uint8_t timePrec, short bytes, uint32_t offset);
SDataBlockList* tscCreateBlockArrayList();
void* tscDestroyBlockArrayList(SDataBlockList* pList);
int32_t tscCopyDataBlockToPayload(SSqlObj* pSql, STableDataBlocks* pDataBlock);
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,
int32_t startOffset, int32_t rowSize, char* tableId);
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
SVnodeSidList* tscGetVnodeSidList(SMetricMeta* pMetricmeta, int32_t vnodeIdx);
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,
......@@ -73,52 +93,71 @@ bool tscIsTwoStageMergeMetricQuery(SSqlObj* pSql);
*
* @param pSql sql object
* @return
*
*/
bool tscIsFirstProjQueryOnMetric(SSqlObj* pSql);
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);
/* use for keep current db info temporarily, for handle table with db prefix */
void tscGetDBInfoFromMeterId(char* meterId, char* db);
void tscGetMetricMetaCacheKey(SSqlCmd* pCmd, char* keyStr);
bool tscQueryOnMetric(SSqlCmd* pCmd);
int tscAllocPayloadWithSize(SSqlCmd* pCmd, int size);
int tscAllocPayload(SSqlCmd* pCmd, int size);
void tscFieldInfoSetValFromSchema(SFieldInfo* pFieldInfo, int32_t index, SSchema* pSchema);
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 tscFieldInfoUpdateVisible(SFieldInfo* pFieldInfo, int32_t index, bool visible);
void tscFieldInfoCalOffset(SSqlCmd* pCmd);
void tscFieldInfoRenewOffsetForInterResult(SSqlCmd* pCmd);
void tscFieldInfoClone(SFieldInfo* src, SFieldInfo* dst);
void tscFieldInfoUpdateOffset(SSqlCmd* pCmd);
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);
int16_t tscFieldInfoGetOffset(SSqlCmd* pCmd, int32_t index);
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,
int16_t size);
SSqlExpr* tscSqlExprInsert(SSqlCmd* pCmd, int32_t index, int16_t functionId, SColumnIndex* pColIndex, int16_t type,
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,
int16_t size);
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);
SColumnBase* tscColumnInfoGet(SSqlCmd* pCmd, int32_t index);
void tscColumnInfoReserve(SSqlCmd* pCmd, int32_t size);
void tscColumnBaseInfoReserve(SColumnBaseInfo* pColumnBaseInfo, int32_t size);
void tscColumnBaseInfoDestroy(SColumnBaseInfo* pColumnBaseInfo);
int32_t tscValidateName(SSQLToken* pToken);
......@@ -127,8 +166,10 @@ void tscIncStreamExecutionCount(void* pStream);
bool tscValidateColumnId(SSqlCmd* pCmd, int32_t colId);
// get starter position of metric query condition (query on tags) in SSqlCmd.payload
char* tsGetMetricQueryCondPos(STagCond* pCond);
void tscTagCondAssign(STagCond* pDst, STagCond* pSrc);
SCond* tsGetMetricQueryCondPos(STagCond* pCond, uint64_t tableIndex);
void tsSetMetricQueryCond(STagCond* pTagCond, uint64_t uid, const char* str);
void tscTagCondCopy(STagCond* dest, const STagCond* src);
void tscTagCondRelease(STagCond* pCond);
void tscTagCondSetQueryCondType(STagCond* pCond, int16_t type);
......@@ -138,8 +179,54 @@ void tscSetFreeHeatBeat(STscObj* pObj);
bool tscShouldFreeHeatBeat(SSqlObj* pHb);
void tscCleanSqlCmd(SSqlCmd* pCmd);
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);
/**
* 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);
#ifdef __cplusplus
}
......
......@@ -63,9 +63,9 @@ enum _sql_cmd {
TSDB_SQL_ALTER_DB,
TSDB_SQL_CREATE_MNODE,
TSDB_SQL_DROP_MNODE,
TSDB_SQL_CREATE_PNODE,
TSDB_SQL_DROP_PNODE,
TSDB_SQL_CFG_PNODE, // 20
TSDB_SQL_CREATE_DNODE,
TSDB_SQL_DROP_DNODE,
TSDB_SQL_CFG_DNODE, // 20
TSDB_SQL_CFG_MNODE,
TSDB_SQL_SHOW,
TSDB_SQL_RETRIEVE,
......@@ -78,15 +78,21 @@ enum _sql_cmd {
TSDB_SQL_USE_DB,
TSDB_SQL_META, // 30
TSDB_SQL_METRIC,
TSDB_SQL_MULTI_META,
TSDB_SQL_HB,
TSDB_SQL_LOCAL, // SQL below for client local
TSDB_SQL_DESCRIBE_TABLE,
TSDB_SQL_RETRIEVE_METRIC,
TSDB_SQL_METRIC_JOIN_RETRIEVE,
TSDB_SQL_RETRIEVE_TAGS,
TSDB_SQL_RETRIEVE_EMPTY_RESULT, // build empty result instead of accessing
// dnode to fetch result
TSDB_SQL_RESET_CACHE, // reset the client cache
/*
* build empty result instead of accessing dnode to fetch result
* reset the client cache
*/
TSDB_SQL_RETRIEVE_EMPTY_RESULT,
TSDB_SQL_RESET_CACHE,
TSDB_SQL_CFG_LOCAL,
TSDB_SQL_MAX
......@@ -96,24 +102,35 @@ enum _sql_cmd {
struct SSqlInfo;
typedef struct SSqlGroupbyExpr {
int16_t numOfGroupbyCols;
int16_t tagIndex[TSDB_MAX_TAGS]; /* group by columns information */
int16_t orderIdx; /* order by column index */
int16_t orderType; /* order by type: asc/desc */
} SSqlGroupbyExpr;
int16_t tableIndex;
/* the structure for sql function in select clause */
typedef struct SSqlExpr {
char aliasName[TSDB_COL_NAME_LEN + 1]; // as aliasName
int16_t numOfGroupCols;
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;
SColIndex colInfo;
int16_t sqlFuncId; // function id in aAgg array
typedef struct SMeterMetaInfo {
SMeterMeta * pMeterMeta; // metermeta
SMetricMeta *pMetricMeta; // metricmeta
int16_t resType; // return value type
int16_t resBytes; // length of return value
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;
int16_t numOfParams; // argument value of each function
tVariant param[3]; // parameters are not more than 3
/* the structure for sql function in select clause */
typedef struct SSqlExpr {
char aliasName[TSDB_COL_NAME_LEN + 1]; // as aliasName
SColIndexEx colInfo;
int64_t uid; // refactor use the pointer
int16_t functionId; // function id in aAgg array
int16_t resType; // return value type
int16_t resBytes; // length of return value
int16_t interResBytes; // inter result buffer size
int16_t numOfParams; // argument value of each function
tVariant param[3]; // parameters are not more than 3
} SSqlExpr;
typedef struct SFieldInfo {
......@@ -121,6 +138,15 @@ typedef struct SFieldInfo {
int16_t numOfAlloc; // allocated size
TAOS_FIELD *pFields;
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;
typedef struct SSqlExprInfo {
......@@ -129,87 +155,122 @@ typedef struct SSqlExprInfo {
SSqlExpr *pExprs;
} SSqlExprInfo;
typedef struct SColumnBase {
int16_t colIndex;
/* todo refactor: the following data is belong to one struct */
int16_t filterOn; /* denote if the filter is active */
int16_t lowerRelOptr;
int16_t upperRelOptr;
int16_t filterOnBinary; /* denote if current column is binary */
typedef struct SColumnIndex {
int16_t tableIndex;
int16_t columnIndex;
} SColumnIndex;
union {
struct {
int64_t lowerBndi;
int64_t upperBndi;
};
struct {
double lowerBndd;
double upperBndd;
};
struct {
int64_t pz;
int64_t len;
};
};
typedef struct SColumnBase {
SColumnIndex colIndex;
int32_t numOfFilters;
SColumnFilterInfo *filterInfo;
} SColumnBase;
typedef struct SColumnsInfo {
typedef struct SColumnBaseInfo {
int16_t numOfAlloc;
int16_t numOfCols;
SColumnBase *pColList;
} SColumnsInfo;
} SColumnBaseInfo;
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 {
int32_t len;
int32_t allocSize;
int16_t type;
char * pData;
// relation between tbname list and query condition, including : TK_AND or TK_OR
int16_t relType;
// 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;
typedef struct SParamInfo {
int32_t idx;
char type;
uint8_t timePrec;
short bytes;
uint32_t offset;
} SParamInfo;
typedef struct STableDataBlocks {
char meterId[TSDB_METER_ID_LEN];
int8_t tsSource;
char meterId[TSDB_METER_ID_LEN];
int8_t tsSource;
bool ordered;
int64_t vgid;
int64_t size;
int64_t vgid;
int64_t prevTS;
int64_t prevTS;
bool ordered;
int32_t numOfMeters;
int32_t numOfMeters;
int32_t rowSize;
uint32_t nAllocSize;
int32_t rowSize;
uint32_t nAllocSize;
uint32_t size;
union {
char *filename;
char *pData;
};
// for parameter ('?') binding
uint32_t numOfAllocedParams;
uint32_t numOfParams;
SParamInfo* params;
} STableDataBlocks;
typedef struct SDataBlockList {
int32_t idx;
int32_t nSize;
int32_t nAlloc;
char * userParam; /* user assigned parameters for async query */
void * udfp; /* user defined function pointer, used in async model */
int32_t idx;
int32_t nSize;
int32_t nAlloc;
char * userParam; /* user assigned parameters for async query */
void * udfp; /* user defined function pointer, used in async model */
STableDataBlocks **pData;
} SDataBlockList;
typedef struct {
char name[TSDB_METER_ID_LEN];
SOrderVal order;
int command;
int count;
int16_t isInsertFromFile; // load data from file or not
int16_t metricQuery; // metric query or not
bool existsCheck;
SOrderVal order;
int command;
// TODO refactor
int count;
int16_t isInsertFromFile; // load data from file or not
union {
bool existsCheck;
int8_t showType;
};
char msgType;
char type;
uint16_t type;
char intervalTimeUnit;
int64_t etime;
int64_t stime;
int64_t etime, stime;
int64_t nAggTimeInterval; // aggregation time interval
int64_t nSlidingTime; // sliding window in mseconds
SSqlGroupbyExpr groupbyExpr; // group by tags info
......@@ -224,24 +285,27 @@ typedef struct {
char * payload;
int payloadLen;
short numOfCols;
SColumnsInfo colList;
SColumnBaseInfo colList;
SFieldInfo fieldsInfo;
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 slimit;
int64_t globalLimit;
SLimitVal glimit;
STagCond tagCond;
int16_t vnodeIdx; // vnode index in pMetricMeta for metric query
int16_t interpoType; // interpolate type
int16_t numOfTables;
SDataBlockList *pDataBlocks; // submit data blocks branched according to vnode
SMeterMeta * pMeterMeta; // metermeta
SMetricMeta * pMetricMeta; // metricmeta
// submit data blocks branched according to vnode
SDataBlockList * pDataBlocks;
SMeterMetaInfo **pMeterInfo;
struct STSBuf * tsBuf;
// todo use dynamic allocated memory for defaultVal
int64_t defaultVal[TSDB_MAX_COLUMNS]; // default value for interpolation
// for parameter ('?') binding and batch processing
int32_t batchSize;
int32_t numOfParams;
} SSqlCmd;
typedef struct SResRec {
......@@ -249,28 +313,29 @@ typedef struct SResRec {
int numOfTotal;
} SResRec;
struct STSBuf;
typedef struct {
uint8_t code;
int numOfRows; // num of results in current retrieved
int numOfTotal; // num of total results
char * pRsp;
int rspType;
int rspLen;
uint64_t qhandle;
int64_t useconds;
int64_t offset; // offset value from vnode during projection query of stable
int row;
int16_t numOfnchar;
int16_t precision;
int32_t numOfGroups;
SResRec *pGroupRec;
char * data;
short * bytes;
void ** tsrow;
// Buffer used to put multibytes encoded using unicode (wchar_t)
char ** buffer;
uint8_t code;
int numOfRows; // num of results in current retrieved
int numOfTotal; // num of total results
char * pRsp;
int rspType;
int rspLen;
uint64_t qhandle;
int64_t useconds;
int64_t offset; // offset value from vnode during projection query of stable
int row;
int16_t numOfnchar;
int16_t precision;
int32_t numOfGroups;
SResRec * pGroupRec;
char * data;
short * bytes;
void ** tsrow;
char ** buffer; // Buffer used to put multibytes encoded using unicode (wchar_t)
struct SLocalReducer *pLocalReducer;
SColumnIndex * pColumnIndex;
} SSqlRes;
typedef struct _tsc_obj {
......@@ -328,7 +393,7 @@ typedef struct _sstream {
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
*/
int64_t numOfRes;
......@@ -336,8 +401,7 @@ typedef struct _sstream {
int64_t useconds; // total elapsed time
int64_t ctime; // stream created time
int64_t stime; // stream next executed time
int64_t etime; // stream end query time, when time is larger then etime, the
// stream will be closed
int64_t etime; // stream end query time, when time is larger then etime, the stream will be closed
int64_t interval;
int64_t slidingTime;
int16_t precision;
......@@ -346,8 +410,7 @@ typedef struct _sstream {
void (*fp)();
void *param;
// Call backfunction when stream is stopped from client level
void (*callback)(void *);
void (*callback)(void *); // Callback function when stream is stopped from client level
struct _sstream *prev, *next;
} SSqlStream;
......@@ -363,14 +426,12 @@ int tsParseSql(SSqlObj *pSql, char *acct, char *db, bool multiVnodeInsertion);
void tscInitMsgs();
void *tscProcessMsgFromServer(char *msg, void *ahandle, void *thandle);
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);
int tscRenewMeterMeta(SSqlObj *pSql, char *meterId);
void tscQueueAsyncRes(SSqlObj *pSql);
int tscGetMetricMeta(SSqlObj *pSql, char *meterId);
void tscQueueAsyncError(void(*fp), void *param);
int tscProcessLocalCmd(SSqlObj *pSql);
......@@ -381,7 +442,7 @@ int taos_retrieve(TAOS_RES *res);
* transfer function for metric query in stream computing, the function need to be change
* before send query message to vnode
*/
void tscTansformSQLFunctionForMetricQuery(SSqlCmd *pCmd);
int32_t tscTansformSQLFunctionForMetricQuery(SSqlCmd *pCmd);
void tscRestoreSQLFunctionForMetricQuery(SSqlCmd *pCmd);
/**
......@@ -395,7 +456,7 @@ void tscClearSqlMetaInfoForce(SSqlCmd *pCmd);
int32_t tscCreateResPointerInfo(SSqlCmd *pCmd, SSqlRes *pRes);
void tscDestroyResPointerInfo(SSqlRes *pRes);
void tscfreeSqlCmdData(SSqlCmd *pCmd);
void tscFreeSqlCmdData(SSqlCmd *pCmd);
/**
* only free part of resources allocated during query.
......@@ -413,17 +474,6 @@ void tscFreeSqlObj(SSqlObj *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 tscProcessMultiVnodesInsertForFile(SSqlObj *pSql);
void tscKillMetricQuery(SSqlObj *pSql);
......@@ -435,18 +485,18 @@ int32_t tscToSQLCmd(SSqlObj *pSql, struct SSqlInfo *pInfo);
void tscQueueAsyncFreeResult(SSqlObj *pSql);
extern void * pVnodeConn;
extern void * pTscMgmtConn;
extern void * tscCacheHandle;
extern uint8_t globalCode;
extern int slaveIndex;
extern void * tscTmr;
extern void * tscConnCache;
extern void * tscQhandle;
extern int tscKeepConn[];
extern int tsInsertHeadSize;
extern int tscNumOfThreads;
extern uint32_t tsServerIp;
extern void * pVnodeConn;
extern void * pTscMgmtConn;
extern void * tscCacheHandle;
extern uint8_t globalCode;
extern int slaveIndex;
extern void * tscTmr;
extern void * tscConnCache;
extern void * tscQhandle;
extern int tscKeepConn[];
extern int tsInsertHeadSize;
extern int tscNumOfThreads;
extern SIpStrList tscMgmtIpList;
#ifdef __cplusplus
}
......
文件模式从 100755 更改为 100644
......@@ -19,6 +19,7 @@
#include "com_taosdata_jdbc_TSDBJNIConnector.h"
#include "taos.h"
#include "tlog.h"
#include "tscJoinProcess.h"
#include "tsclient.h"
#include "tscUtil.h"
......@@ -660,4 +661,4 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_validateCreateTab
JNIEXPORT jstring JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_getTsCharset(JNIEnv *env, jobject jobj) {
return (*env)->NewStringUTF(env, (const char *)tsCharset);
}
}
\ No newline at end of file
此差异已折叠。
......@@ -40,7 +40,7 @@ static void tscProcessAsyncRetrieveImpl(void *param, TAOS_RES *tres, int numOfRo
*/
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;
if (pObj == NULL || pObj->signature != pObj) {
tscError("bug!!! pObj:%p", pObj);
......@@ -72,13 +72,14 @@ void taos_query_a(TAOS *taos, char *sqlstr, void (*fp)(void *, TAOS_RES *, int),
pSql->fp = fp;
pSql->param = param;
if (tscAllocPayloadWithSize(pCmd, TSDB_DEFAULT_PAYLOAD_SIZE) != TSDB_CODE_SUCCESS) {
tscError("%p failed to alloc payload", pSql);
if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, TSDB_DEFAULT_PAYLOAD_SIZE)) {
tscError("failed to malloc payload");
tfree(pSql);
tscQueueAsyncError(fp, param);
free(pSql);
return;
}
pSql->sqlstr = malloc(sqlLen + 1);
if (pSql->sqlstr == NULL) {
tscError("%p failed to malloc sql string buffer", pSql);
......@@ -116,9 +117,9 @@ static void tscProcessAsyncFetchRowsProxy(void *param, TAOS_RES *tres, int numOf
SSqlCmd *pCmd = &pSql->cmd;
// 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
assert(pCmd->vnodeIdx >= 1);
assert(pCmd->vnodeIdx >= 0);
/* reach the maximum number of output rows, abort */
if (pCmd->globalLimit > 0 && pRes->numOfTotal >= pCmd->globalLimit) {
......@@ -128,14 +129,14 @@ static void tscProcessAsyncFetchRowsProxy(void *param, TAOS_RES *tres, int numOf
/* update the limit value according to current retrieval results */
pCmd->limit.limit = pCmd->globalLimit - pRes->numOfTotal;
pCmd->limit.offset = pRes->offset;
if ((++(pSql->cmd.vnodeIdx)) <= pCmd->pMetricMeta->numOfVnodes) {
pCmd->command = TSDB_SQL_SELECT; // reset flag to launch query first.
if ((++(pCmd->vnodeIdx)) < tscGetMeterMetaInfo(pCmd, 0)->pMetricMeta->numOfVnodes) {
tscTrace("%p retrieve data from next vnode:%d", pSql, pCmd->vnodeIdx);
pRes->row = 0;
pRes->numOfRows = 0;
pCmd->type = 0;
pSql->cmd.command = TSDB_SQL_SELECT; // reset flag to launch query first.
tscResetForNextRetrieve(pRes);
pSql->fp = tscProcessAsyncRetrieveNextVnode;
tscProcessSql(pSql);
return;
......@@ -213,14 +214,12 @@ void taos_fetch_rows_a(TAOS_RES *taosa, void (*fp)(void *, TAOS_RES *, int), voi
pSql->fp = tscProcessAsyncFetchRowsProxy;
pSql->param = param;
pRes->row = 0;
pRes->numOfRows = 0;
pCmd->type = 0;
tscResetForNextRetrieve(pRes);
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;
}
tscProcessSql(pSql);
}
......@@ -246,9 +245,7 @@ void taos_fetch_row_a(TAOS_RES *taosa, void (*fp)(void *, TAOS_RES *, TAOS_ROW),
pSql->param = param;
if (pRes->row >= pRes->numOfRows) {
pRes->row = 0;
pRes->numOfRows = 0;
pCmd->type = 0;
tscResetForNextRetrieve(pRes);
pSql->fp = tscProcessAsyncRetrieve;
pCmd->command = (pCmd->command > TSDB_SQL_MGMT) ? TSDB_SQL_RETRIEVE : TSDB_SQL_FETCH;
tscProcessSql(pSql);
......@@ -269,7 +266,7 @@ void tscProcessAsyncRetrieve(void *param, TAOS_RES *tres, int numOfRows) {
if (numOfRows == 0) {
// 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
*/
......@@ -284,13 +281,10 @@ void tscProcessAsyncRetrieve(void *param, TAOS_RES *tres, int numOfRows) {
/* update the limit value according to current retrieval results */
pCmd->limit.limit = pCmd->globalLimit - pRes->numOfTotal;
if ((++pCmd->vnodeIdx) <= pCmd->pMetricMeta->numOfVnodes) {
pCmd->command = TSDB_SQL_SELECT; // reset flag to launch query first.
pRes->row = 0;
pRes->numOfRows = 0;
pCmd->type = 0;
if ((++pCmd->vnodeIdx) <= tscGetMeterMetaInfo(pCmd, 0)->pMetricMeta->numOfVnodes) {
pSql->cmd.command = TSDB_SQL_SELECT; // reset flag to launch query first.
tscResetForNextRetrieve(pRes);
pSql->fp = tscProcessAsyncContinueRetrieve;
tscProcessSql(pSql);
return;
......@@ -463,10 +457,10 @@ void tscMeterMetaCallBack(void *param, TAOS_RES *res, int code) {
tsem_post(&pSql->rspSem);
} else {
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);
tscGetMeterMeta(pSql, pSql->cmd.name);
assert(tscGetMeterMetaInfo(&pSql->cmd, 0)->pMeterMeta == NULL);
tscGetMeterMeta(pSql, tscGetMeterMetaInfo(&pSql->cmd, 0)->name, 0);
code = tscSendMsgToServer(pSql);
if (code != 0) {
......@@ -486,21 +480,23 @@ void tscMeterMetaCallBack(void *param, TAOS_RES *res, int code) {
if (pSql->pStream == NULL) {
// check if it is a sub-query of metric query first, if true, enter another routine
// todo refactor
if (pSql->fp == tscRetrieveDataRes || pSql->fp == tscRetrieveFromVnodeCallBack) {
assert(pCmd->pMeterMeta->numOfTags != 0 && pCmd->vnodeIdx > 0 && pSql->param != NULL);
if ((pSql->cmd.type & TSDB_QUERY_TYPE_STABLE_SUBQUERY) == TSDB_QUERY_TYPE_STABLE_SUBQUERY) {
SMeterMetaInfo* pMeterMetaInfo = tscGetMeterMetaInfo(pCmd, 0);
assert(pMeterMetaInfo->pMeterMeta->numOfTags != 0 && pCmd->vnodeIdx >= 0 && pSql->param != NULL);
SRetrieveSupport *trs = (SRetrieveSupport *)pSql->param;
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);
code = tscGetMeterMeta(pSql, pSql->cmd.name);
code = tscGetMeterMeta(pSql, tscGetMeterMetaInfo(&pSql->cmd, 0)->name, 0);
pRes->code = code;
if (code == TSDB_CODE_ACTION_IN_PROGRESS) return;
code = tscGetMetricMeta(pSql, pSql->cmd.name);
code = tscGetMetricMeta(pSql);
pRes->code = code;
if (code == TSDB_CODE_ACTION_IN_PROGRESS) return;
......@@ -508,14 +504,17 @@ void tscMeterMetaCallBack(void *param, TAOS_RES *res, int code) {
code = tsParseSql(pSql, pObj->acctId, pObj->db, false);
if (code == TSDB_CODE_ACTION_IN_PROGRESS) return;
}
} else { // stream computing
code = tscGetMeterMeta(pSql, pSql->cmd.name);
SMeterMetaInfo *pMeterMetaInfo = tscGetMeterMetaInfo(pCmd, 0);
code = tscGetMeterMeta(pSql, pMeterMetaInfo->name, 0);
pRes->code = code;
if (code == TSDB_CODE_ACTION_IN_PROGRESS) return;
if (code == TSDB_CODE_SUCCESS && UTIL_METER_IS_METRIC(pCmd)) {
code = tscGetMetricMeta(pSql, pSql->cmd.name);
pMeterMetaInfo = tscGetMeterMetaInfo(pCmd, 0);
if (code == TSDB_CODE_SUCCESS && UTIL_METER_IS_METRIC(pMeterMetaInfo)) {
code = tscGetMetricMeta(pSql);
pRes->code = code;
if (code == TSDB_CODE_ACTION_IN_PROGRESS) return;
......
......@@ -102,7 +102,12 @@ void *taosAddConnIntoCache(void *handle, void *data, uint32_t ip, short port, ch
pObj = (SConnCache *)handle;
if (pObj == NULL || pObj->maxSessions == 0) return NULL;
#ifdef CLUSTER
if (data == NULL || ip == 0) {
#else
if (data == NULL) {
#endif
tscTrace("data:%p ip:%p:%d not valid, not added in cache", data, ip, port);
return NULL;
}
......
此差异已折叠。
此差异已折叠。
......@@ -16,8 +16,6 @@
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <taos.h>
#include <tsclient.h>
#include "taosmsg.h"
#include "tcache.h"
......@@ -40,11 +38,31 @@ static int32_t getToStringLength(char *pData, int32_t length, int32_t type) {
return length;
case TSDB_DATA_TYPE_NCHAR:
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);
#endif
if (strncasecmp("nan", buf, 3) == 0) {
len = 4;
}
}
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);
#endif
if (strncasecmp("nan", buf, 3) == 0) {
len = 4;
}
}
break;
case TSDB_DATA_TYPE_TIMESTAMP:
case TSDB_DATA_TYPE_BIGINT:
......@@ -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)
*/
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;
}
......@@ -97,8 +116,9 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
SSqlRes *pRes = &pSql->res;
// one column for each row
SSqlCmd * pCmd = &pSql->cmd;
SMeterMeta *pMeta = pCmd->pMeterMeta;
SSqlCmd * pCmd = &pSql->cmd;
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.
......@@ -109,7 +129,7 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
int32_t numOfRows = pMeta->numOfColumns;
int32_t totalNumOfRows = numOfRows + pMeta->numOfTags;
if (UTIL_METER_IS_METRIC(pCmd)) {
if (UTIL_METER_IS_METRIC(pMeterMetaInfo)) {
numOfRows = pMeta->numOfColumns + pMeta->numOfTags;
}
......@@ -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;
}
......@@ -182,11 +202,25 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
case TSDB_DATA_TYPE_NCHAR:
taosUcs4ToMbs(pTagValue, pSchema[i].bytes, target);
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);
#endif
}
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);
#endif
}
break;
case TSDB_DATA_TYPE_TINYINT:
sprintf(target, "%d", *(int8_t *)pTagValue);
......@@ -240,7 +274,7 @@ static int32_t tscBuildMeterSchemaResultFields(SSqlObj *pSql, int32_t numOfCols,
}
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 TYPE_COLUMN_LENGTH = 16;
......@@ -261,15 +295,17 @@ static int32_t tscProcessDescribeTable(SSqlObj *pSql) {
static int tscBuildMetricTagProjectionResult(SSqlObj *pSql) {
// the result structure has been completed in sql parse, so we
// only need to reorganize the results in the column format
SSqlCmd *pCmd = &pSql->cmd;
SSqlRes *pRes = &pSql->res;
SSqlCmd * pCmd = &pSql->cmd;
SSqlRes * pRes = &pSql->res;
SMeterMetaInfo *pMeterMetaInfo = tscGetMeterMetaInfo(pCmd, 0);
SMetricMeta *pMetricMeta = pCmd->pMetricMeta;
SSchema * pSchema = tsGetTagSchema(pCmd->pMeterMeta);
SMetricMeta *pMetricMeta = pMeterMetaInfo->pMetricMeta;
SSchema * pSchema = tsGetTagSchema(pMeterMetaInfo->pMeterMeta);
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) {
vOffset[f] = vOffset[f - 1] + TSDB_METER_NAME_LEN;
} else {
......@@ -290,10 +326,10 @@ static int tscBuildMetricTagProjectionResult(SSqlObj *pSql) {
SMeterSidExtInfo *pSidExt = tscGetMeterSidInfo(pSidList, j);
for (int32_t k = 0; k < pCmd->fieldsInfo.numOfOutputCols; ++k) {
SColIndex *pColIndex = &tscSqlExprGet(pCmd, k)->colInfo;
int32_t offsetId = pColIndex->colIdx;
SColIndexEx *pColIndex = &tscSqlExprGet(pCmd, k)->colInfo;
int16_t offsetId = pColIndex->colIdx;
assert(pColIndex->isTag);
assert((pColIndex->flag & TSDB_COL_TAG) != 0);
char * val = pSidExt->tags + vOffset[offsetId];
TAOS_FIELD *pField = tscFieldInfoGetField(pCmd, k);
......@@ -312,7 +348,7 @@ static int tscBuildMetricTagSqlFunctionResult(SSqlObj *pSql) {
SSqlCmd *pCmd = &pSql->cmd;
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 rowLen = tscGetResRowLength(pCmd);
......@@ -323,7 +359,7 @@ static int tscBuildMetricTagSqlFunctionResult(SSqlObj *pSql) {
for (int32_t k = 0; k < pCmd->fieldsInfo.numOfOutputCols; ++k) {
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);
memcpy(pRes->data + tscFieldInfoGetOffset(pCmd, i) * totalNumOfResults + pField->bytes * rowIdx,
......@@ -342,7 +378,7 @@ static int tscBuildMetricTagSqlFunctionResult(SSqlObj *pSql) {
static int tscProcessQueryTags(SSqlObj *pSql) {
SSqlCmd *pCmd = &pSql->cmd;
SMeterMeta *pMeterMeta = pCmd->pMeterMeta;
SMeterMeta *pMeterMeta = tscGetMeterMetaInfo(pCmd, 0)->pMeterMeta;
if (pMeterMeta == NULL || pMeterMeta->numOfTags == 0 || pMeterMeta->numOfColumns == 0) {
strcpy(pCmd->payload, "invalid table");
pSql->res.code = TSDB_CODE_INVALID_TABLE;
......@@ -350,7 +386,7 @@ static int tscProcessQueryTags(SSqlObj *pSql) {
}
SSqlExpr *pExpr = tscSqlExprGet(pCmd, 0);
if (pExpr->sqlFuncId == TSDB_FUNC_COUNT) {
if (pExpr->functionId == TSDB_FUNC_COUNT) {
return tscBuildMetricTagSqlFunctionResult(pSql);
} else {
return tscBuildMetricTagProjectionResult(pSql);
......@@ -367,7 +403,11 @@ int tscProcessLocalCmd(SSqlObj *pSql) {
} else if (pCmd->command == TSDB_SQL_RETRIEVE_TAGS) {
pSql->res.code = (uint8_t)tscProcessQueryTags(pSql);
} else if (pCmd->command == TSDB_SQL_RETRIEVE_EMPTY_RESULT) {
pSql->res.qhandle = 0x1; // pass the qhandle check
/*
* 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.numOfRows = 0;
} else if (pCmd->command == TSDB_SQL_RESET_CACHE) {
taosClearDataCache(tscCacheHandle);
......@@ -376,7 +416,7 @@ int tscProcessLocalCmd(SSqlObj *pSql) {
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;
if (pSql->fp != NULL) { // callback function
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -15,13 +15,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include <assert.h>
#include <errno.h>
#include <stdarg.h>
#include "os.h"
......@@ -119,31 +115,29 @@ void tSQLExprListDestroy(tSQLExprList *pList) {
free(pList);
}
tSQLExpr *tSQLExprIdValueCreate(SSQLToken *pToken, int32_t optrType) {
tSQLExpr *tSQLExprIdValueCreate(SSQLToken *pAliasToken, int32_t optrType) {
tSQLExpr *nodePtr = calloc(1, sizeof(tSQLExpr));
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;
} else if (optrType == TK_NOW) {
// default use microsecond
nodePtr->val.i64Key = taosGetTimestamp(TSDB_TIME_PRECISION_MICRO);
nodePtr->val.nType = TSDB_DATA_TYPE_BIGINT;
nodePtr->nSQLOptr = TK_TIMESTAMP;
// TK_TIMESTAMP used to denote the time value is in microsecond
nodePtr->nSQLOptr = TK_TIMESTAMP; // TK_TIMESTAMP used to denote the time value is in microsecond
} 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);
nodePtr->val.nType = TSDB_DATA_TYPE_BIGINT;
nodePtr->nSQLOptr = TK_TIMESTAMP;
} else { // must be field id if not numbers
assert(optrType == TK_ALL || optrType == TK_ID);
if (pToken != NULL) { // it must be the column name (tk_id)
nodePtr->colInfo = *pToken;
} else { // it must be the column name (tk_id) if it is not the number
assert(optrType == TK_ID || optrType == TK_ALL);
if (pAliasToken != NULL) {
nodePtr->colInfo = *pAliasToken;
}
nodePtr->nSQLOptr = optrType;
......@@ -273,11 +267,10 @@ tSQLExpr *tSQLExprCreate(tSQLExpr *pLeft, tSQLExpr *pRight, int32_t optrType) {
return pExpr;
}
void tSQLExprDestroy(tSQLExpr *pExpr) {
if (pExpr == NULL) return;
tSQLExprDestroy(pExpr->pLeft);
tSQLExprDestroy(pExpr->pRight);
void tSQLExprNodeDestroy(tSQLExpr *pExpr) {
if (pExpr == NULL) {
return;
}
if (pExpr->nSQLOptr == TK_STRING) {
tVariantDestroy(&pExpr->val);
......@@ -288,6 +281,17 @@ void tSQLExprDestroy(tSQLExpr *pExpr) {
free(pExpr);
}
void tSQLExprDestroy(tSQLExpr *pExpr) {
if (pExpr == NULL) {
return;
}
tSQLExprDestroy(pExpr->pLeft);
tSQLExprDestroy(pExpr->pRight);
tSQLExprNodeDestroy(pExpr);
}
static void *tVariantListExpand(tVariantList *pList) {
if (pList->nAlloc <= pList->nExpr) { //
int32_t newSize = (pList->nAlloc << 1) + 4;
......@@ -420,6 +424,44 @@ void setDBName(SSQLToken *pCpxName, SSQLToken *pDB) {
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) {
int32_t maxLen = sizeof(pField->name) / sizeof(pField->name[0]);
/* truncate the column name */
......@@ -462,7 +504,7 @@ void tSQLSetColumnType(TAOS_FIELD *pField, SSQLToken *type) {
/*
* 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,
SSQLToken *pSliding, tVariantList *pFill, SLimitVal *pLimit, SLimitVal *pGLimit) {
assert(pSelection != NULL && pFrom != NULL && pInterval != NULL && pLimit != NULL && pGLimit != NULL);
......@@ -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->pSelection = pSelection;
pQuery->from = *pFrom;
pQuery->from = pFrom;
pQuery->pGroupby = pGroupby;
pQuery->pSortOrder = pSortOrder;
pQuery->pWhere = pWhere;
pQuery->limit = *pLimit;
pQuery->glimit = *pGLimit;
pQuery->slimit = *pGLimit;
pQuery->interval = *pInterval;
pQuery->sliding = *pSliding;
......@@ -532,6 +574,9 @@ void destroyQuerySql(SQuerySQL *pSql) {
tVariantListDestroy(pSql->pGroupby);
pSql->pGroupby = NULL;
tVariantListDestroy(pSql->from);
pSql->from = NULL;
tVariantListDestroy(pSql->fillType);
free(pSql);
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -36,7 +36,7 @@ typedef struct {
TAOS_RES * result;
} 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;
pSub = (SSub *)malloc(sizeof(SSub));
......
此差异已折叠。
此差异已折叠。
......@@ -69,7 +69,7 @@ public enum TSDBError {
TSDB_CODE_INVALID_OPTION(45, "invalid option"),
TSDB_CODE_NODE_OFFLINE(46, "node offline"),
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_TOO_SLOW(50, "too slow"),
TSDB_CODE_OTHERS(51, "others"),
......
import com.taosdata.jdbc.TSDBDriver;
import com.taosdata.jdbc.TSDBPreparedStatement;
import java.sql.*;
import java.util.Properties;
public class TestPreparedStatement {
public static void main(String[] args) {
try {
Class.forName("com.taosdata.jdbc.TSDBDriver");
Properties properties = new Properties();
properties.setProperty(TSDBDriver.PROPERTY_KEY_HOST, "192.168.1.117");
Connection connection = DriverManager.getConnection("jdbc:TAOS://192.168.1.117:0/?user=root&password=taosdata", properties);
String rawSql = "SELECT ts, c1 FROM (select c1, ts from db.tb1) SUB_QRY";
// String[] params = new String[]{"ts", "c1"};
PreparedStatement pstmt = (TSDBPreparedStatement) connection.prepareStatement(rawSql);
ResultSet resSet = pstmt.executeQuery();
while(resSet.next()) {
for (int i = 1; i <= resSet.getMetaData().getColumnCount(); i++) {
System.out.printf("%d: %s\n", i, resSet.getString(i));
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
文件模式从 100755 更改为 100644
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -22,6 +22,10 @@ extern "C" {
void *taosInitIdPool(int maxId);
int taosUpdateIdPool(void *handle, int maxId);
int taosIdPoolMaxSize(void *handle);
int taosAllocateId(void *handle);
void taosFreeId(void *handle, int id);
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(TDengine)
ADD_SUBDIRECTORY(shell)
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册