Merge remote-tracking branch 'origin/develop' into feature/crash_gen
This commit is contained in:
commit
1d35b45961
|
@ -1,4 +1,4 @@
|
|||
CMAKE_MINIMUM_REQUIRED(VERSION 3.5)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
IF (CMAKE_VERSION VERSION_LESS 3.0)
|
||||
PROJECT(TDengine CXX)
|
||||
SET(PROJECT_VERSION_MAJOR "${LIB_MAJOR_VERSION}")
|
||||
|
@ -15,6 +15,7 @@ SET(TD_ADMIN FALSE)
|
|||
SET(TD_GRANT FALSE)
|
||||
SET(TD_MQTT FALSE)
|
||||
SET(TD_TSDB_PLUGINS FALSE)
|
||||
SET(TD_STORAGE FALSE)
|
||||
|
||||
SET(TD_COVER FALSE)
|
||||
SET(TD_MEM_CHECK FALSE)
|
||||
|
|
|
@ -5,7 +5,7 @@ node {
|
|||
git url: 'https://github.com/taosdata/TDengine.git'
|
||||
}
|
||||
|
||||
|
||||
def kipstage=0
|
||||
def abortPreviousBuilds() {
|
||||
def currentJobName = env.JOB_NAME
|
||||
def currentBuildNumber = env.BUILD_NUMBER.toInteger()
|
||||
|
@ -45,6 +45,7 @@ def pre_test(){
|
|||
git pull
|
||||
git fetch origin +refs/pull/${CHANGE_ID}/merge
|
||||
git checkout -qf FETCH_HEAD
|
||||
git --no-pager diff --name-only FETCH_HEAD $(git merge-base FETCH_HEAD develop)|grep -v -E '.*md|//src//connector|Jenkinsfile' || exit 0
|
||||
cd ${WK}
|
||||
git reset --hard HEAD~10
|
||||
git checkout develop
|
||||
|
@ -62,6 +63,7 @@ def pre_test(){
|
|||
'''
|
||||
return 1
|
||||
}
|
||||
|
||||
pipeline {
|
||||
agent none
|
||||
|
||||
|
@ -71,21 +73,46 @@ pipeline {
|
|||
}
|
||||
|
||||
stages {
|
||||
|
||||
stage('pre_build'){
|
||||
agent{label 'master'}
|
||||
when {
|
||||
changeRequest()
|
||||
}
|
||||
steps {
|
||||
sh'''
|
||||
cp -r ${WORKSPACE} ${WORKSPACE}.tes
|
||||
cd ${WORKSPACE}.tes
|
||||
git checkout develop
|
||||
git pull
|
||||
git fetch origin +refs/pull/${CHANGE_ID}/merge
|
||||
git checkout -qf FETCH_HEAD
|
||||
'''
|
||||
script{
|
||||
skipstage=sh(script:"git --no-pager diff --name-only FETCH_HEAD develop|grep -v -E '.*md|//src//connector|Jenkinsfile|test-all.sh' || echo 0 ",returnStdout:true)
|
||||
}
|
||||
sh'''
|
||||
rm -rf ${WORKSPACE}.tes
|
||||
'''
|
||||
}
|
||||
}
|
||||
|
||||
stage('Parallel test stage') {
|
||||
//only build pr
|
||||
when {
|
||||
changeRequest()
|
||||
expression {
|
||||
skipstage != 0
|
||||
}
|
||||
}
|
||||
parallel {
|
||||
stage('python_1') {
|
||||
stage('python_1_s1') {
|
||||
agent{label 'p1'}
|
||||
steps {
|
||||
|
||||
pre_test()
|
||||
timeout(time: 90, unit: 'MINUTES'){
|
||||
timeout(time: 45, unit: 'MINUTES'){
|
||||
sh '''
|
||||
date
|
||||
cd ${WKC}/tests
|
||||
find pytest -name '*'sql|xargs rm -rf
|
||||
./test-all.sh p1
|
||||
|
@ -94,26 +121,38 @@ pipeline {
|
|||
|
||||
}
|
||||
}
|
||||
stage('python_2') {
|
||||
stage('python_2_s5') {
|
||||
agent{label 'p2'}
|
||||
steps {
|
||||
|
||||
pre_test()
|
||||
sh '''
|
||||
cd ${WKC}/tests
|
||||
find pytest -name '*'sql|xargs rm -rf
|
||||
./test-all.sh p2
|
||||
date'''
|
||||
sh '''
|
||||
cd ${WKC}/tests
|
||||
./test-all.sh b4fq
|
||||
'''
|
||||
timeout(time: 45, unit: 'MINUTES'){
|
||||
sh '''
|
||||
date
|
||||
cd ${WKC}/tests
|
||||
find pytest -name '*'sql|xargs rm -rf
|
||||
./test-all.sh p2
|
||||
date'''
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('test_b1') {
|
||||
stage('python_3_s6') {
|
||||
agent{label 'p3'}
|
||||
steps {
|
||||
timeout(time: 45, unit: 'MINUTES'){
|
||||
pre_test()
|
||||
sh '''
|
||||
date
|
||||
cd ${WKC}/tests
|
||||
./test-all.sh p3
|
||||
date'''
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('test_b1_s2') {
|
||||
agent{label 'b1'}
|
||||
steps {
|
||||
timeout(time: 90, unit: 'MINUTES'){
|
||||
timeout(time: 45, unit: 'MINUTES'){
|
||||
pre_test()
|
||||
sh '''
|
||||
cd ${WKC}/tests
|
||||
|
@ -123,8 +162,9 @@ pipeline {
|
|||
}
|
||||
}
|
||||
|
||||
stage('test_crash_gen') {
|
||||
stage('test_crash_gen_s3') {
|
||||
agent{label "b2"}
|
||||
|
||||
steps {
|
||||
pre_test()
|
||||
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
|
||||
|
@ -136,21 +176,24 @@ pipeline {
|
|||
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
|
||||
sh '''
|
||||
cd ${WKC}/tests/pytest
|
||||
rm -rf /var/lib/taos/*
|
||||
rm -rf /var/log/taos/*
|
||||
./handle_crash_gen_val_log.sh
|
||||
'''
|
||||
}
|
||||
timeout(time: 90, unit: 'MINUTES'){
|
||||
sh '''
|
||||
date
|
||||
cd ${WKC}/tests
|
||||
./test-all.sh b2fq
|
||||
date
|
||||
'''
|
||||
}
|
||||
}
|
||||
timeout(time: 45, unit: 'MINUTES'){
|
||||
sh '''
|
||||
date
|
||||
cd ${WKC}/tests
|
||||
./test-all.sh b2fq
|
||||
date
|
||||
'''
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
stage('test_valgrind') {
|
||||
stage('test_valgrind_s4') {
|
||||
agent{label "b3"}
|
||||
|
||||
steps {
|
||||
|
@ -162,7 +205,7 @@ pipeline {
|
|||
./handle_val_log.sh
|
||||
'''
|
||||
}
|
||||
timeout(time: 90, unit: 'MINUTES'){
|
||||
timeout(time: 45, unit: 'MINUTES'){
|
||||
sh '''
|
||||
date
|
||||
cd ${WKC}/tests
|
||||
|
@ -171,17 +214,68 @@ pipeline {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
stage('test_b4_s7') {
|
||||
agent{label 'b4'}
|
||||
steps {
|
||||
timeout(time: 45, unit: 'MINUTES'){
|
||||
pre_test()
|
||||
sh '''
|
||||
date
|
||||
cd ${WKC}/tests
|
||||
./test-all.sh b4fq
|
||||
cd ${WKC}/tests
|
||||
./test-all.sh p4
|
||||
date'''
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('test_b5_s8') {
|
||||
agent{label 'b5'}
|
||||
steps {
|
||||
timeout(time: 45, unit: 'MINUTES'){
|
||||
pre_test()
|
||||
sh '''
|
||||
date
|
||||
cd ${WKC}/tests
|
||||
./test-all.sh b5fq
|
||||
date'''
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('test_b6_s9') {
|
||||
agent{label 'b6'}
|
||||
steps {
|
||||
timeout(time: 45, unit: 'MINUTES'){
|
||||
pre_test()
|
||||
sh '''
|
||||
date
|
||||
cd ${WKC}/tests
|
||||
./test-all.sh b6fq
|
||||
date'''
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('test_b7_s10') {
|
||||
agent{label 'b7'}
|
||||
steps {
|
||||
timeout(time: 45, unit: 'MINUTES'){
|
||||
pre_test()
|
||||
sh '''
|
||||
date
|
||||
cd ${WKC}/tests
|
||||
./test-all.sh b7fq
|
||||
date'''
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
|
||||
post {
|
||||
success {
|
||||
emailext (
|
||||
subject: "PR-result: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
|
||||
body: '''<!DOCTYPE html>
|
||||
subject: "PR-result: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' SUCCESS",
|
||||
body: """<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
|
@ -197,29 +291,29 @@ pipeline {
|
|||
<td>
|
||||
<ul>
|
||||
<div style="font-size:18px">
|
||||
<li>构建名称>>分支:${PROJECT_NAME}</li>
|
||||
<li>构建名称>>分支:${env.BRANCH_NAME}</li>
|
||||
<li>构建结果:<span style="color:green"> Successful </span></li>
|
||||
<li>构建编号:${BUILD_NUMBER}</li>
|
||||
<li>触发用户:${CAUSE}</li>
|
||||
<li>提交信息:${CHANGE_TITLE}</li>
|
||||
<li>触发用户:${env.CHANGE_AUTHOR}</li>
|
||||
<li>提交信息:${env.CHANGE_TITLE}</li>
|
||||
<li>构建地址:<a href=${BUILD_URL}>${BUILD_URL}</a></li>
|
||||
<li>构建日志:<a href=${BUILD_URL}console>${BUILD_URL}console</a></li>
|
||||
<li>变更集:${JELLY_SCRIPT}</li>
|
||||
|
||||
</div>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</table></font>
|
||||
</body>
|
||||
</html>''',
|
||||
</html>""",
|
||||
to: "${env.CHANGE_AUTHOR_EMAIL}",
|
||||
from: "support@taosdata.com"
|
||||
)
|
||||
}
|
||||
failure {
|
||||
emailext (
|
||||
subject: "PR-result: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
|
||||
body: '''<!DOCTYPE html>
|
||||
subject: "PR-result: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' FAIL",
|
||||
body: """<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
|
@ -235,21 +329,21 @@ pipeline {
|
|||
<td>
|
||||
<ul>
|
||||
<div style="font-size:18px">
|
||||
<li>构建名称>>分支:${PROJECT_NAME}</li>
|
||||
<li>构建结果:<span style="color:green"> Successful </span></li>
|
||||
<li>构建名称>>分支:${env.BRANCH_NAME}</li>
|
||||
<li>构建结果:<span style="color:red"> Failure </span></li>
|
||||
<li>构建编号:${BUILD_NUMBER}</li>
|
||||
<li>触发用户:${CAUSE}</li>
|
||||
<li>提交信息:${CHANGE_TITLE}</li>
|
||||
<li>触发用户:${env.CHANGE_AUTHOR}</li>
|
||||
<li>提交信息:${env.CHANGE_TITLE}</li>
|
||||
<li>构建地址:<a href=${BUILD_URL}>${BUILD_URL}</a></li>
|
||||
<li>构建日志:<a href=${BUILD_URL}console>${BUILD_URL}console</a></li>
|
||||
<li>变更集:${JELLY_SCRIPT}</li>
|
||||
|
||||
</div>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</table></font>
|
||||
</body>
|
||||
</html>''',
|
||||
</html>""",
|
||||
to: "${env.CHANGE_AUTHOR_EMAIL}",
|
||||
from: "support@taosdata.com"
|
||||
)
|
||||
|
|
|
@ -21,6 +21,10 @@ IF (TD_TSDB_PLUGINS)
|
|||
ADD_DEFINITIONS(-D_TSDB_PLUGINS)
|
||||
ENDIF ()
|
||||
|
||||
IF (TD_STORAGE)
|
||||
ADD_DEFINITIONS(-D_STORAGE)
|
||||
ENDIF ()
|
||||
|
||||
IF (TD_GODLL)
|
||||
ADD_DEFINITIONS(-D_TD_GO_DLL_)
|
||||
ENDIF ()
|
||||
|
|
|
@ -32,7 +32,7 @@ ELSEIF (TD_WINDOWS)
|
|||
#INSTALL(TARGETS taos RUNTIME DESTINATION driver)
|
||||
#INSTALL(TARGETS shell RUNTIME DESTINATION .)
|
||||
IF (TD_MVN_INSTALLED)
|
||||
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-2.0.18-dist.jar DESTINATION connector/jdbc)
|
||||
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-2.0.19-dist.jar DESTINATION connector/jdbc)
|
||||
ENDIF ()
|
||||
ELSEIF (TD_DARWIN)
|
||||
SET(TD_MAKE_INSTALL_SH "${TD_COMMUNITY_DIR}/packaging/tools/make_install.sh")
|
||||
|
|
|
@ -13,28 +13,40 @@ ELSE ()
|
|||
SET(TD_VER_COMPATIBLE "2.0.0.0")
|
||||
ENDIF ()
|
||||
|
||||
find_program(HAVE_GIT NAMES git)
|
||||
|
||||
IF (DEFINED GITINFO)
|
||||
SET(TD_VER_GIT ${GITINFO})
|
||||
ELSEIF (HAVE_GIT)
|
||||
execute_process(COMMAND git log -1 --format=%H WORKING_DIRECTORY ${TD_COMMUNITY_DIR} OUTPUT_VARIABLE GIT_COMMITID)
|
||||
message(STATUS "git log result:${GIT_COMMITID}")
|
||||
IF (GIT_COMMITID)
|
||||
string (REGEX REPLACE "[\n\t\r]" "" GIT_COMMITID ${GIT_COMMITID})
|
||||
SET(TD_VER_GIT ${GIT_COMMITID})
|
||||
ELSE ()
|
||||
message(STATUS "not a git repository")
|
||||
SET(TD_VER_GIT "no git commit id")
|
||||
ENDIF ()
|
||||
ELSE ()
|
||||
execute_process(
|
||||
COMMAND git log -1 --format=%H
|
||||
WORKING_DIRECTORY ${TD_COMMUNITY_DIR}
|
||||
OUTPUT_VARIABLE GIT_COMMITID
|
||||
)
|
||||
string (REGEX REPLACE "[\n\t\r]" "" GIT_COMMITID ${GIT_COMMITID})
|
||||
SET(TD_VER_GIT ${GIT_COMMITID})
|
||||
message(STATUS "no git cmd")
|
||||
SET(TD_VER_GIT "no git commit id")
|
||||
ENDIF ()
|
||||
|
||||
IF (DEFINED GITINFOI)
|
||||
SET(TD_VER_GIT_INTERNAL ${GITINFOI})
|
||||
ELSEIF (HAVE_GIT)
|
||||
execute_process(COMMAND git log -1 --format=%H WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE GIT_COMMITID)
|
||||
message(STATUS "git log result:${GIT_COMMITID}")
|
||||
IF (GIT_COMMITID)
|
||||
string (REGEX REPLACE "[\n\t\r]" "" GIT_COMMITID ${GIT_COMMITID})
|
||||
SET(TD_VER_GIT_INTERNAL ${GIT_COMMITID})
|
||||
ELSE ()
|
||||
message(STATUS "not a git repository")
|
||||
SET(TD_VER_GIT "no git commit id")
|
||||
ENDIF ()
|
||||
ELSE ()
|
||||
execute_process(
|
||||
COMMAND git log -1 --format=%H
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_COMMITID
|
||||
)
|
||||
string (REGEX REPLACE "[\n\t\r]" "" GIT_COMMITID ${GIT_COMMITID})
|
||||
SET(TD_VER_GIT_INTERNAL ${GIT_COMMITID})
|
||||
message(STATUS "no git cmd")
|
||||
SET(TD_VER_GIT_INTERNAL "no git commit id")
|
||||
ENDIF ()
|
||||
|
||||
IF (DEFINED VERDATE)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CMAKE_MINIMUM_REQUIRED(VERSION 3.5)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
PROJECT(TDengine)
|
||||
|
||||
ADD_SUBDIRECTORY(zlib-1.2.11)
|
||||
|
@ -9,6 +9,7 @@ ADD_SUBDIRECTORY(lz4)
|
|||
ADD_SUBDIRECTORY(cJson)
|
||||
ADD_SUBDIRECTORY(wepoll)
|
||||
ADD_SUBDIRECTORY(MsvcLibX)
|
||||
ADD_SUBDIRECTORY(rmonotonic)
|
||||
|
||||
IF (TD_LINUX AND TD_MQTT)
|
||||
ADD_SUBDIRECTORY(MQTT-C)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CMAKE_MINIMUM_REQUIRED(VERSION 3.5)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
|
||||
# MQTT-C build options
|
||||
option(MQTT_C_OpenSSL_SUPPORT "Build MQTT-C with OpenSSL support?" OFF)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CMAKE_MINIMUM_REQUIRED(VERSION 3.5)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
PROJECT(TDengine)
|
||||
|
||||
IF (TD_WINDOWS)
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
typedef int clockid_t;
|
||||
/* Supported values for clockid_t */
|
||||
#define CLOCK_REALTIME 0
|
||||
#define CLOCK_MONOTONIC 1
|
||||
|
||||
int clock_gettime(clockid_t clock_id, struct timespec *tp);
|
||||
|
||||
|
|
|
@ -89,11 +89,12 @@ pid_t getppid(void); /* Get parent PID */
|
|||
|
||||
/* Path management */
|
||||
#if defined(_WIN32)
|
||||
#if defined(_UTF8_SOURCE) || defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
|
||||
#define realpath realpathU
|
||||
#if defined(_UTF8_SOURCE) || defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
|
||||
// #define realpath realpathU
|
||||
#define CompactPath CompactPathU
|
||||
#else /* _ANSI_SOURCE */
|
||||
#define realpath realpathA
|
||||
// #define realpath realpathA
|
||||
#define CompactPath CompactPathA
|
||||
#endif
|
||||
#endif /* defined(_WIN32) */
|
||||
|
|
|
@ -34,15 +34,56 @@
|
|||
#include "msvcTime.h"
|
||||
#include "sys/msvcStat.h" /* For MsvcLibX's Filetime2Timespec */
|
||||
|
||||
int clock_gettime(clockid_t clock_id, struct timespec *pTS) {
|
||||
FILETIME ft;
|
||||
if (clock_id != CLOCK_REALTIME) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
#define MS_PER_SEC 1000ULL // MS = milliseconds
|
||||
#define US_PER_MS 1000ULL // US = microseconds
|
||||
#define HNS_PER_US 10ULL // HNS = hundred-nanoseconds (e.g., 1 hns = 100 ns)
|
||||
#define NS_PER_US 1000ULL
|
||||
|
||||
#define HNS_PER_SEC (MS_PER_SEC * US_PER_MS * HNS_PER_US)
|
||||
#define NS_PER_HNS (100ULL) // NS = nanoseconds
|
||||
#define NS_PER_SEC (MS_PER_SEC * US_PER_MS * NS_PER_US)
|
||||
|
||||
int clock_gettime_monotonic(struct timespec *tv) {
|
||||
static LARGE_INTEGER ticksPerSec;
|
||||
LARGE_INTEGER ticks;
|
||||
double seconds;
|
||||
|
||||
if (!ticksPerSec.QuadPart) {
|
||||
QueryPerformanceFrequency(&ticksPerSec);
|
||||
if (!ticksPerSec.QuadPart) {
|
||||
errno = ENOTSUP;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
GetSystemTimeAsFileTime(&ft);
|
||||
Filetime2Timespec(&ft, pTS);
|
||||
|
||||
QueryPerformanceCounter(&ticks);
|
||||
|
||||
seconds = (double) ticks.QuadPart / (double) ticksPerSec.QuadPart;
|
||||
tv->tv_sec = (time_t)seconds;
|
||||
tv->tv_nsec = (long)((ULONGLONG)(seconds * NS_PER_SEC) % NS_PER_SEC);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int clock_gettime_realtime(struct timespec *pTS) {
|
||||
FILETIME ft;
|
||||
|
||||
GetSystemTimeAsFileTime(&ft);
|
||||
Filetime2Timespec(&ft, pTS);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int clock_gettime(clockid_t clock_id, struct timespec *pTS) {
|
||||
if (clock_id == CLOCK_MONOTONIC) {
|
||||
return clock_gettime_monotonic(pTS);
|
||||
} else if (clock_id == CLOCK_REALTIME) {
|
||||
return clock_gettime_realtime(pTS);
|
||||
}
|
||||
|
||||
errno = ENOTSUP;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif /* defined(_WIN32) */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CMAKE_MINIMUM_REQUIRED(VERSION 3.5)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
PROJECT(TDengine)
|
||||
|
||||
IF (TD_WINDOWS)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CMAKE_MINIMUM_REQUIRED(VERSION 3.5)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
PROJECT(TDengine)
|
||||
|
||||
IF (TD_WINDOWS)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CMAKE_MINIMUM_REQUIRED(VERSION 3.5)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
PROJECT(TDengine)
|
||||
|
||||
IF (TD_WINDOWS)
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src SOURCE_LIST)
|
||||
|
||||
add_definitions(-DUSE_PROCESSOR_CLOCK)
|
||||
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../MsvcLibX/include)
|
||||
|
||||
ADD_LIBRARY(rmonotonic ${SOURCE_LIST})
|
||||
TARGET_INCLUDE_DIRECTORIES(rmonotonic PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/inc)
|
||||
IF (TD_WINDOWS)
|
||||
TARGET_LINK_LIBRARIES(rmonotonic MsvcLibXw)
|
||||
ENDIF ()
|
|
@ -0,0 +1,56 @@
|
|||
#ifndef __MONOTONIC_H
|
||||
#define __MONOTONIC_H
|
||||
/* The monotonic clock is an always increasing clock source. It is unrelated to
|
||||
* the actual time of day and should only be used for relative timings. The
|
||||
* monotonic clock is also not guaranteed to be chronologically precise; there
|
||||
* may be slight skew/shift from a precise clock.
|
||||
*
|
||||
* Depending on system architecture, the monotonic time may be able to be
|
||||
* retrieved much faster than a normal clock source by using an instruction
|
||||
* counter on the CPU. On x86 architectures (for example), the RDTSC
|
||||
* instruction is a very fast clock source for this purpose.
|
||||
*/
|
||||
|
||||
//#include "fmacros.h"
|
||||
#include <stdint.h>
|
||||
//#include <unistd.h>
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#define inline
|
||||
#endif
|
||||
|
||||
/* A counter in micro-seconds. The 'monotime' type is provided for variables
|
||||
* holding a monotonic time. This will help distinguish & document that the
|
||||
* variable is associated with the monotonic clock and should not be confused
|
||||
* with other types of time.*/
|
||||
typedef uint64_t monotime;
|
||||
|
||||
/* Retrieve counter of micro-seconds relative to an arbitrary point in time. */
|
||||
extern monotime (*getMonotonicUs)(void);
|
||||
|
||||
|
||||
/* Call once at startup to initialize the monotonic clock. Though this only
|
||||
* needs to be called once, it may be called additional times without impact.
|
||||
* Returns a printable string indicating the type of clock initialized.
|
||||
* (The returned string is static and doesn't need to be freed.) */
|
||||
const char * monotonicInit();
|
||||
|
||||
|
||||
/* Functions to measure elapsed time. Example:
|
||||
* monotime myTimer;
|
||||
* elapsedStart(&myTimer);
|
||||
* while (elapsedMs(myTimer) < 10) {} // loops for 10ms
|
||||
*/
|
||||
static inline void elapsedStart(monotime *start_time) {
|
||||
*start_time = getMonotonicUs();
|
||||
}
|
||||
|
||||
static inline uint64_t elapsedUs(monotime start_time) {
|
||||
return getMonotonicUs() - start_time;
|
||||
}
|
||||
|
||||
static inline uint64_t elapsedMs(monotime start_time) {
|
||||
return elapsedUs(start_time) / 1000;
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,173 @@
|
|||
#include "monotonic.h"
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
#undef NDEBUG
|
||||
#include <assert.h>
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#include "msvcTime.h"
|
||||
#include "msvcStdio.h"
|
||||
#endif
|
||||
|
||||
/* The function pointer for clock retrieval. */
|
||||
monotime (*getMonotonicUs)(void) = NULL;
|
||||
|
||||
static char monotonic_info_string[32];
|
||||
|
||||
|
||||
/* Using the processor clock (aka TSC on x86) can provide improved performance
|
||||
* throughout Redis wherever the monotonic clock is used. The processor clock
|
||||
* is significantly faster than calling 'clock_getting' (POSIX). While this is
|
||||
* generally safe on modern systems, this link provides additional information
|
||||
* about use of the x86 TSC: http://oliveryang.net/2015/09/pitfalls-of-TSC-usage
|
||||
*
|
||||
* To use the processor clock, either uncomment this line, or build with
|
||||
* CFLAGS="-DUSE_PROCESSOR_CLOCK"
|
||||
#define USE_PROCESSOR_CLOCK
|
||||
*/
|
||||
|
||||
|
||||
#if defined(USE_PROCESSOR_CLOCK) && defined(__x86_64__) && defined(__linux__)
|
||||
#include <regex.h>
|
||||
#include <x86intrin.h>
|
||||
|
||||
static long mono_ticksPerMicrosecond = 0;
|
||||
|
||||
static monotime getMonotonicUs_x86() {
|
||||
return __rdtsc() / mono_ticksPerMicrosecond;
|
||||
}
|
||||
|
||||
static void monotonicInit_x86linux() {
|
||||
const int bufflen = 256;
|
||||
char buf[bufflen];
|
||||
regex_t cpuGhzRegex, constTscRegex;
|
||||
const size_t nmatch = 2;
|
||||
regmatch_t pmatch[nmatch];
|
||||
int constantTsc = 0;
|
||||
int rc;
|
||||
|
||||
/* Determine the number of TSC ticks in a micro-second. This is
|
||||
* a constant value matching the standard speed of the processor.
|
||||
* On modern processors, this speed remains constant even though
|
||||
* the actual clock speed varies dynamically for each core. */
|
||||
rc = regcomp(&cpuGhzRegex, "^model name\\s+:.*@ ([0-9.]+)GHz", REG_EXTENDED);
|
||||
assert(rc == 0);
|
||||
|
||||
/* Also check that the constant_tsc flag is present. (It should be
|
||||
* unless this is a really old CPU. */
|
||||
rc = regcomp(&constTscRegex, "^flags\\s+:.* constant_tsc", REG_EXTENDED);
|
||||
assert(rc == 0);
|
||||
|
||||
FILE *cpuinfo = fopen("/proc/cpuinfo", "r");
|
||||
if (cpuinfo != NULL) {
|
||||
while (fgets(buf, bufflen, cpuinfo) != NULL) {
|
||||
if (regexec(&cpuGhzRegex, buf, nmatch, pmatch, 0) == 0) {
|
||||
buf[pmatch[1].rm_eo] = '\0';
|
||||
double ghz = atof(&buf[pmatch[1].rm_so]);
|
||||
mono_ticksPerMicrosecond = (long)(ghz * 1000);
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (fgets(buf, bufflen, cpuinfo) != NULL) {
|
||||
if (regexec(&constTscRegex, buf, nmatch, pmatch, 0) == 0) {
|
||||
constantTsc = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fclose(cpuinfo);
|
||||
}
|
||||
regfree(&cpuGhzRegex);
|
||||
regfree(&constTscRegex);
|
||||
|
||||
if (mono_ticksPerMicrosecond == 0) {
|
||||
//fprintf(stderr, "monotonic: x86 linux, unable to determine clock rate");
|
||||
return;
|
||||
}
|
||||
if (!constantTsc) {
|
||||
//fprintf(stderr, "monotonic: x86 linux, 'constant_tsc' flag not present");
|
||||
return;
|
||||
}
|
||||
|
||||
snprintf(monotonic_info_string, sizeof(monotonic_info_string),
|
||||
"X86 TSC @ %ld ticks/us", mono_ticksPerMicrosecond);
|
||||
getMonotonicUs = getMonotonicUs_x86;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(USE_PROCESSOR_CLOCK) && defined(__aarch64__)
|
||||
static long mono_ticksPerMicrosecond = 0;
|
||||
|
||||
/* Read the clock value. */
|
||||
static inline uint64_t __cntvct() {
|
||||
uint64_t virtual_timer_value;
|
||||
__asm__ volatile("mrs %0, cntvct_el0" : "=r"(virtual_timer_value));
|
||||
return virtual_timer_value;
|
||||
}
|
||||
|
||||
/* Read the Count-timer Frequency. */
|
||||
static inline uint32_t cntfrq_hz() {
|
||||
uint64_t virtual_freq_value;
|
||||
__asm__ volatile("mrs %0, cntfrq_el0" : "=r"(virtual_freq_value));
|
||||
return (uint32_t)virtual_freq_value; /* top 32 bits are reserved */
|
||||
}
|
||||
|
||||
static monotime getMonotonicUs_aarch64() {
|
||||
return __cntvct() / mono_ticksPerMicrosecond;
|
||||
}
|
||||
|
||||
static void monotonicInit_aarch64() {
|
||||
mono_ticksPerMicrosecond = (long)cntfrq_hz() / 1000L / 1000L;
|
||||
if (mono_ticksPerMicrosecond == 0) {
|
||||
fprintf(stderr, "monotonic: aarch64, unable to determine clock rate");
|
||||
return;
|
||||
}
|
||||
|
||||
snprintf(monotonic_info_string, sizeof(monotonic_info_string),
|
||||
"ARM CNTVCT @ %ld ticks/us", mono_ticksPerMicrosecond);
|
||||
getMonotonicUs = getMonotonicUs_aarch64;
|
||||
}
|
||||
#endif
|
||||
|
||||
static monotime getMonotonicUs_posix(void) {
|
||||
/* clock_gettime() is specified in POSIX.1b (1993). Even so, some systems
|
||||
* did not support this until much later. CLOCK_MONOTONIC is technically
|
||||
* optional and may not be supported - but it appears to be universal.
|
||||
* If this is not supported, provide a system-specific alternate version. */
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
return ((uint64_t)ts.tv_sec) * 1000000 + ts.tv_nsec / 1000;
|
||||
}
|
||||
|
||||
static void monotonicInit_posix() {
|
||||
/* Ensure that CLOCK_MONOTONIC is supported. This should be supported
|
||||
* on any reasonably current OS. If the assertion below fails, provide
|
||||
* an appropriate alternate implementation. */
|
||||
struct timespec ts;
|
||||
int rc = clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
assert(rc == 0);
|
||||
|
||||
snprintf(monotonic_info_string, sizeof(monotonic_info_string),
|
||||
"POSIX clock_gettime");
|
||||
getMonotonicUs = getMonotonicUs_posix;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char * monotonicInit() {
|
||||
#if defined(USE_PROCESSOR_CLOCK) && defined(__x86_64__) && defined(__linux__)
|
||||
if (getMonotonicUs == NULL) monotonicInit_x86linux();
|
||||
#endif
|
||||
|
||||
#if defined(USE_PROCESSOR_CLOCK) && defined(__aarch64__)
|
||||
if (getMonotonicUs == NULL) monotonicInit_aarch64();
|
||||
#endif
|
||||
|
||||
if (getMonotonicUs == NULL) monotonicInit_posix();
|
||||
|
||||
return monotonic_info_string;
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
CMAKE_MINIMUM_REQUIRED(VERSION 3.5)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
PROJECT(TDengine)
|
||||
|
||||
IF (TD_WINDOWS)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CMAKE_MINIMUM_REQUIRED(VERSION 3.5)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
PROJECT(TDengine)
|
||||
|
||||
IF (TD_WINDOWS)
|
||||
|
|
|
@ -290,7 +290,7 @@ TDengine缺省的时间戳是毫秒精度,但通过修改配置参数enableMic
|
|||
- **修改子表标签值**
|
||||
|
||||
```mysql
|
||||
ALTER STABLE tb_name SET TAG tag_name=new_tag_value;
|
||||
ALTER TABLE tb_name SET TAG tag_name=new_tag_value;
|
||||
```
|
||||
说明:除了更新标签的值的操作是针对子表进行,其他所有的标签操作(添加标签、删除标签等)均只能作用于 STable,不能对单个子表操作。对 STable 添加标签以后,依托于该 STable 建立的所有表将自动增加了一个标签,所有新增标签的默认值都是 NULL。
|
||||
|
||||
|
@ -757,7 +757,7 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数
|
|||
|
||||
应用字段:不能应用在timestamp、binary、nchar、bool类型字段。
|
||||
|
||||
适用于:表。(从 2.0.15 版本开始,本函数也支持超级表)
|
||||
适用于:表。(从 2.0.15.1 版本开始,本函数也支持超级表)
|
||||
|
||||
示例:
|
||||
```mysql
|
||||
|
|
|
@ -852,7 +852,7 @@ npm install td2.0-connector
|
|||
### Linux
|
||||
|
||||
- `python` (建议`v2.7` , `v3.x.x` 目前还不支持)
|
||||
- `node` 必须采用v10.x版本,其他版本存在包兼容性的问题。
|
||||
- `node` 2.0.6支持v12.x和v10.x,2.0.5及更早版本支持v10.x版本,其他版本可能存在包兼容性的问题。
|
||||
- `make`
|
||||
- c语言编译器比如<a href="https://gcc.gnu.org">GCC</a>
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
# 1.0: all CPU cores are available for query processing [default].
|
||||
# 0.5: only half of the CPU cores are available for query.
|
||||
# 0.0: only one core available.
|
||||
# tsRatioOfQueryCores 1.0
|
||||
# ratioOfQueryCores 1.0
|
||||
|
||||
# the last_row/first/last aggregator will not change the original column name in the result fields
|
||||
# keepColumnName 0
|
||||
|
|
|
@ -147,8 +147,8 @@ done
|
|||
|
||||
#echo "verType=${verType} interactiveFqdn=${interactiveFqdn}"
|
||||
|
||||
function kill_taosd() {
|
||||
pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}')
|
||||
function kill_process() {
|
||||
pid=$(ps -ef | grep "$1" | grep -v "grep" | awk '{print $2}')
|
||||
if [ -n "$pid" ]; then
|
||||
${csudo} kill -9 $pid || :
|
||||
fi
|
||||
|
@ -168,7 +168,10 @@ function install_main_path() {
|
|||
if [ "$verMode" == "cluster" ]; then
|
||||
${csudo} mkdir -p ${nginx_dir}
|
||||
fi
|
||||
${csudo} cp ${script_dir}/email ${install_main_dir}/ ||:
|
||||
|
||||
if [[ -e ${script_dir}/email ]]; then
|
||||
${csudo} cp ${script_dir}/email ${install_main_dir}/ ||:
|
||||
fi
|
||||
}
|
||||
|
||||
function install_bin() {
|
||||
|
@ -680,7 +683,7 @@ function install_service() {
|
|||
install_service_on_sysvinit
|
||||
else
|
||||
# must manual stop taosd
|
||||
kill_taosd
|
||||
kill_process taosd
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -749,11 +752,24 @@ function update_TDengine() {
|
|||
elif ((${service_mod}==1)); then
|
||||
${csudo} service taosd stop || :
|
||||
else
|
||||
kill_taosd
|
||||
kill_process taosd
|
||||
fi
|
||||
sleep 1
|
||||
fi
|
||||
|
||||
if [ "$verMode" == "cluster" ]; then
|
||||
if pidof nginx &> /dev/null; then
|
||||
if ((${service_mod}==0)); then
|
||||
${csudo} systemctl stop nginxd || :
|
||||
elif ((${service_mod}==1)); then
|
||||
${csudo} service nginxd stop || :
|
||||
else
|
||||
kill_process nginx
|
||||
fi
|
||||
sleep 1
|
||||
fi
|
||||
fi
|
||||
|
||||
install_main_path
|
||||
|
||||
install_log
|
||||
|
|
|
@ -146,8 +146,8 @@ done
|
|||
|
||||
#echo "verType=${verType} interactiveFqdn=${interactiveFqdn}"
|
||||
|
||||
function kill_powerd() {
|
||||
pid=$(ps -ef | grep "powerd" | grep -v "grep" | awk '{print $2}')
|
||||
function kill_process() {
|
||||
pid=$(ps -ef | grep "$1" | grep -v "grep" | awk '{print $2}')
|
||||
if [ -n "$pid" ]; then
|
||||
${csudo} kill -9 $pid || :
|
||||
fi
|
||||
|
@ -652,7 +652,7 @@ function install_service() {
|
|||
install_service_on_sysvinit
|
||||
else
|
||||
# must manual stop powerd
|
||||
kill_powerd
|
||||
kill_process powerd
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -721,9 +721,21 @@ function update_PowerDB() {
|
|||
elif ((${service_mod}==1)); then
|
||||
${csudo} service powerd stop || :
|
||||
else
|
||||
kill_powerd
|
||||
kill_process powerd
|
||||
fi
|
||||
sleep 1
|
||||
fi
|
||||
if [ "$verMode" == "cluster" ]; then
|
||||
if pidof nginx &> /dev/null; then
|
||||
if ((${service_mod}==0)); then
|
||||
${csudo} systemctl stop nginxd || :
|
||||
elif ((${service_mod}==1)); then
|
||||
${csudo} service nginxd stop || :
|
||||
else
|
||||
kill_process nginx
|
||||
fi
|
||||
sleep 1
|
||||
fi
|
||||
fi
|
||||
|
||||
install_main_path
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
CMAKE_MINIMUM_REQUIRED(VERSION 3.5)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
PROJECT(TDengine)
|
||||
|
||||
# Base compile
|
||||
ADD_SUBDIRECTORY(os)
|
||||
ADD_SUBDIRECTORY(common)
|
||||
ADD_SUBDIRECTORY(util)
|
||||
ADD_SUBDIRECTORY(tfs)
|
||||
ADD_SUBDIRECTORY(rpc)
|
||||
ADD_SUBDIRECTORY(client)
|
||||
ADD_SUBDIRECTORY(query)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CMAKE_MINIMUM_REQUIRED(VERSION 3.5)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
PROJECT(TDengine)
|
||||
|
||||
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/mnode/inc)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CMAKE_MINIMUM_REQUIRED(VERSION 3.5)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
PROJECT(TDengine)
|
||||
|
||||
INCLUDE_DIRECTORIES(inc)
|
||||
|
|
|
@ -33,6 +33,7 @@ SJoinSupporter* tscCreateJoinSupporter(SSqlObj* pSql, int32_t index);
|
|||
void tscHandleMasterJoinQuery(SSqlObj* pSql);
|
||||
|
||||
int32_t tscHandleMasterSTableQuery(SSqlObj *pSql);
|
||||
int32_t tscHandleFirstRoundStableQuery(SSqlObj *pSql);
|
||||
|
||||
int32_t tscHandleMultivnodeInsert(SSqlObj *pSql);
|
||||
|
||||
|
|
|
@ -132,8 +132,9 @@ bool tscIsProjectionQuery(SQueryInfo* pQueryInfo);
|
|||
|
||||
bool tscIsTwoStageSTableQuery(SQueryInfo* pQueryInfo, int32_t tableIndex);
|
||||
bool tscQueryTags(SQueryInfo* pQueryInfo);
|
||||
bool tscMultiRoundQuery(SQueryInfo* pQueryInfo, int32_t tableIndex);
|
||||
|
||||
SSqlExpr* tscAddSpecialColumnForSelect(SQueryInfo* pQueryInfo, int32_t outputColIndex, int16_t functionId,
|
||||
SSqlExpr* tscAddFuncInSelectClause(SQueryInfo* pQueryInfo, int32_t outputColIndex, int16_t functionId,
|
||||
SColumnIndex* pIndex, SSchema* pColSchema, int16_t colType);
|
||||
|
||||
int32_t tscSetTableFullName(STableMetaInfo* pTableMetaInfo, SStrToken* pzTableName, SSqlObj* pSql);
|
||||
|
@ -174,6 +175,7 @@ SSqlExpr* tscSqlExprAppend(SQueryInfo* pQueryInfo, int16_t functionId, SColumnIn
|
|||
SSqlExpr* tscSqlExprUpdate(SQueryInfo* pQueryInfo, int32_t index, int16_t functionId, int16_t srcColumnIndex, int16_t type,
|
||||
int16_t size);
|
||||
size_t tscSqlExprNumOfExprs(SQueryInfo* pQueryInfo);
|
||||
void tscInsertPrimaryTsSourceColumn(SQueryInfo* pQueryInfo, SColumnIndex* pIndex);
|
||||
|
||||
SSqlExpr* tscSqlExprGet(SQueryInfo* pQueryInfo, int32_t index);
|
||||
int32_t tscSqlExprCopy(SArray* dst, const SArray* src, uint64_t uid, bool deepcopy);
|
||||
|
|
|
@ -224,7 +224,9 @@ typedef struct SQueryInfo {
|
|||
int32_t udColumnId; // current user-defined constant output field column id, monotonically decreases from TSDB_UD_COLUMN_INDEX
|
||||
int16_t resColumnId; // result column id
|
||||
bool distinctTag; // distinct tag or not
|
||||
|
||||
int32_t round; // 0/1/....
|
||||
int32_t bufLen;
|
||||
char* buf;
|
||||
} SQueryInfo;
|
||||
|
||||
typedef struct {
|
||||
|
@ -412,10 +414,9 @@ void tscQueueAsyncError(void(*fp), void *param, int32_t code);
|
|||
|
||||
int tscProcessLocalCmd(SSqlObj *pSql);
|
||||
int tscCfgDynamicOptions(char *msg);
|
||||
int taos_retrieve(TAOS_RES *res);
|
||||
|
||||
int32_t tscTansformSQLFuncForSTableQuery(SQueryInfo *pQueryInfo);
|
||||
void tscRestoreSQLFuncForSTableQuery(SQueryInfo *pQueryInfo);
|
||||
int32_t tscTansformFuncForSTableQuery(SQueryInfo *pQueryInfo);
|
||||
void tscRestoreFuncForSTableQuery(SQueryInfo *pQueryInfo);
|
||||
|
||||
int32_t tscCreateResPointerInfo(SSqlRes *pRes, SQueryInfo *pQueryInfo);
|
||||
void tscSetResRawPtr(SSqlRes* pRes, SQueryInfo* pQueryInfo);
|
||||
|
|
|
@ -273,14 +273,15 @@ void tscQueueAsyncError(void(*fp), void *param, int32_t code) {
|
|||
taosScheduleTask(tscQhandle, &schedMsg);
|
||||
}
|
||||
|
||||
void tscAsyncResultOnError(SSqlObj *pSql) {
|
||||
static void tscAsyncResultCallback(SSchedMsg *pMsg) {
|
||||
SSqlObj* pSql = pMsg->ahandle;
|
||||
if (pSql == NULL || pSql->signature != pSql) {
|
||||
tscDebug("%p SqlObj is freed, not add into queue async res", pSql);
|
||||
return;
|
||||
}
|
||||
|
||||
assert(pSql->res.code != TSDB_CODE_SUCCESS);
|
||||
tscError("%p invoke user specified function due to error occured, code:%s", pSql, tstrerror(pSql->res.code));
|
||||
tscError("%p invoke user specified function due to error occurred, code:%s", pSql, tstrerror(pSql->res.code));
|
||||
|
||||
SSqlRes *pRes = &pSql->res;
|
||||
if (pSql->fp == NULL || pSql->fetchFp == NULL){
|
||||
|
@ -291,6 +292,16 @@ void tscAsyncResultOnError(SSqlObj *pSql) {
|
|||
(*pSql->fp)(pSql->param, pSql, pRes->code);
|
||||
}
|
||||
|
||||
void tscAsyncResultOnError(SSqlObj* pSql) {
|
||||
SSchedMsg schedMsg = {0};
|
||||
schedMsg.fp = tscAsyncResultCallback;
|
||||
schedMsg.ahandle = pSql;
|
||||
schedMsg.thandle = (void *)1;
|
||||
schedMsg.msg = 0;
|
||||
taosScheduleTask(tscQhandle, &schedMsg);
|
||||
}
|
||||
|
||||
|
||||
int tscSendMsgToServer(SSqlObj *pSql);
|
||||
|
||||
void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
|
||||
|
@ -322,7 +333,7 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
|
|||
code = tscGetTableMeta(pSql, pTableMetaInfo);
|
||||
assert(code == TSDB_CODE_TSC_ACTION_IN_PROGRESS || code == TSDB_CODE_SUCCESS);
|
||||
|
||||
if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) {
|
||||
if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) {
|
||||
taosReleaseRef(tscObjRef, pSql->self);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -892,7 +892,12 @@ int tscProcessLocalCmd(SSqlObj *pSql) {
|
|||
SSqlRes *pRes = &pSql->res;
|
||||
|
||||
if (pCmd->command == TSDB_SQL_CFG_LOCAL) {
|
||||
pRes->code = (uint8_t)taosCfgDynamicOptions(pCmd->payload);
|
||||
if (taosCfgDynamicOptions(pCmd->payload)) {
|
||||
pRes->code = TSDB_CODE_SUCCESS;
|
||||
} else {
|
||||
pRes->code = TSDB_CODE_COM_INVALID_CFG_MSG;
|
||||
}
|
||||
pRes->numOfRows = 0;
|
||||
} else if (pCmd->command == TSDB_SQL_DESCRIBE_TABLE) {
|
||||
pRes->code = (uint8_t)tscProcessDescribeTable(pSql);
|
||||
} else if (pCmd->command == TSDB_SQL_RETRIEVE_EMPTY_RESULT) {
|
||||
|
|
|
@ -68,7 +68,7 @@ static void tscInitSqlContext(SSqlCmd *pCmd, SLocalMerger *pReducer, tOrderDescr
|
|||
SQLFunctionCtx *pCtx = &pReducer->pCtx[i];
|
||||
SSqlExpr * pExpr = tscSqlExprGet(pQueryInfo, i);
|
||||
|
||||
pCtx->aOutputBuf = pReducer->pResultBuf->data + pExpr->offset * pReducer->resColModel->capacity;
|
||||
pCtx->pOutput = pReducer->pResultBuf->data + pExpr->offset * pReducer->resColModel->capacity;
|
||||
pCtx->order = pQueryInfo->order.order;
|
||||
pCtx->functionId = pExpr->functionId;
|
||||
|
||||
|
@ -76,7 +76,7 @@ static void tscInitSqlContext(SSqlCmd *pCmd, SLocalMerger *pReducer, tOrderDescr
|
|||
int16_t offset = getColumnModelOffset(pDesc->pColumnModel, i);
|
||||
SSchema *pSchema = getColumnModelSchema(pDesc->pColumnModel, i);
|
||||
|
||||
pCtx->aInputElemBuf = pReducer->pTempBuffer->data + offset;
|
||||
pCtx->pInput = pReducer->pTempBuffer->data + offset;
|
||||
|
||||
// input data format comes from pModel
|
||||
pCtx->inputType = pSchema->type;
|
||||
|
@ -86,7 +86,6 @@ static void tscInitSqlContext(SSqlCmd *pCmd, SLocalMerger *pReducer, tOrderDescr
|
|||
pCtx->outputBytes = pExpr->resBytes;
|
||||
pCtx->outputType = pExpr->resType;
|
||||
|
||||
pCtx->startOffset = 0;
|
||||
pCtx->size = 1;
|
||||
pCtx->hasNull = true;
|
||||
pCtx->currentStage = MERGE_STAGE;
|
||||
|
@ -94,7 +93,7 @@ static void tscInitSqlContext(SSqlCmd *pCmd, SLocalMerger *pReducer, tOrderDescr
|
|||
// for top/bottom function, the output of timestamp is the first column
|
||||
int32_t functionId = pExpr->functionId;
|
||||
if (functionId == TSDB_FUNC_TOP || functionId == TSDB_FUNC_BOTTOM || functionId == TSDB_FUNC_DIFF) {
|
||||
pCtx->ptsOutputBuf = pReducer->pCtx[0].aOutputBuf;
|
||||
pCtx->ptsOutputBuf = pReducer->pCtx[0].pOutput;
|
||||
pCtx->param[2].i64 = pQueryInfo->order.order;
|
||||
pCtx->param[2].nType = TSDB_DATA_TYPE_BIGINT;
|
||||
pCtx->param[1].i64 = pQueryInfo->order.orderColId;
|
||||
|
@ -118,7 +117,7 @@ static void tscInitSqlContext(SSqlCmd *pCmd, SLocalMerger *pReducer, tOrderDescr
|
|||
if (pExpr->functionId == TSDB_FUNC_TAG_DUMMY || pExpr->functionId == TSDB_FUNC_TS_DUMMY) {
|
||||
tagLen += pExpr->resBytes;
|
||||
pTagCtx[n++] = &pReducer->pCtx[i];
|
||||
} else if ((aAggs[pExpr->functionId].nStatus & TSDB_FUNCSTATE_SELECTIVITY) != 0) {
|
||||
} else if ((aAggs[pExpr->functionId].status & TSDB_FUNCSTATE_SELECTIVITY) != 0) {
|
||||
pCtx = &pReducer->pCtx[i];
|
||||
}
|
||||
}
|
||||
|
@ -311,7 +310,7 @@ void tscCreateLocalMerger(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrde
|
|||
pReducer->pCtx = (SQLFunctionCtx *)calloc(tscSqlExprNumOfExprs(pQueryInfo), sizeof(SQLFunctionCtx));
|
||||
pReducer->rowSize = pMemBuffer[0]->nElemSize;
|
||||
|
||||
tscRestoreSQLFuncForSTableQuery(pQueryInfo);
|
||||
tscRestoreFuncForSTableQuery(pQueryInfo);
|
||||
tscFieldInfoUpdateOffset(pQueryInfo);
|
||||
|
||||
if (pReducer->rowSize > pMemBuffer[0]->pageSize) {
|
||||
|
@ -383,7 +382,7 @@ void tscCreateLocalMerger(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrde
|
|||
|
||||
if (pQueryInfo->fillType != TSDB_FILL_NONE) {
|
||||
SFillColInfo* pFillCol = createFillColInfo(pQueryInfo);
|
||||
pReducer->pFillInfo = taosInitFillInfo(pQueryInfo->order.order, revisedSTime, pQueryInfo->groupbyExpr.numOfGroupCols,
|
||||
pReducer->pFillInfo = taosCreateFillInfo(pQueryInfo->order.order, revisedSTime, pQueryInfo->groupbyExpr.numOfGroupCols,
|
||||
4096, (int32_t)pQueryInfo->fieldsInfo.numOfOutput, pQueryInfo->interval.sliding, pQueryInfo->interval.slidingUnit,
|
||||
tinfo.precision, pQueryInfo->fillType, pFillCol, pSql);
|
||||
}
|
||||
|
@ -720,7 +719,7 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
|
|||
|
||||
SSchema p1 = {0};
|
||||
if (pExpr->colInfo.colIndex == TSDB_TBNAME_COLUMN_INDEX) {
|
||||
p1 = tGetTableNameColumnSchema();
|
||||
p1 = *tGetTbnameColumnSchema();
|
||||
} else if (TSDB_COL_IS_UD_COL(pExpr->colInfo.flag)) {
|
||||
p1.bytes = pExpr->resBytes;
|
||||
p1.type = (uint8_t) pExpr->resType;
|
||||
|
@ -744,6 +743,8 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
|
|||
functionId = TSDB_FUNC_FIRST;
|
||||
} else if (functionId == TSDB_FUNC_LAST_DST) {
|
||||
functionId = TSDB_FUNC_LAST;
|
||||
} else if (functionId == TSDB_FUNC_STDDEV_DST) {
|
||||
functionId = TSDB_FUNC_STDDEV;
|
||||
}
|
||||
|
||||
int32_t ret = getResultDataInfo(p1.type, p1.bytes, functionId, 0, &type, &bytes, &inter, 0, false);
|
||||
|
@ -1041,7 +1042,7 @@ static void savePreviousRow(SLocalMerger *pLocalMerge, tFilePage *tmpBuffer) {
|
|||
pLocalMerge->hasPrevRow = true;
|
||||
}
|
||||
|
||||
static void doExecuteSecondaryMerge(SSqlCmd *pCmd, SLocalMerger *pLocalMerge, bool needInit) {
|
||||
static void doExecuteFinalMerge(SSqlCmd *pCmd, SLocalMerger *pLocalMerge, bool needInit) {
|
||||
// the tag columns need to be set before all functions execution
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
||||
|
||||
|
@ -1053,7 +1054,7 @@ static void doExecuteSecondaryMerge(SSqlCmd *pCmd, SLocalMerger *pLocalMerge, bo
|
|||
int32_t functionId = pCtx->functionId;
|
||||
if (functionId == TSDB_FUNC_TAG_DUMMY || functionId == TSDB_FUNC_TAG || functionId == TSDB_FUNC_TS_DUMMY) {
|
||||
tVariantDestroy(&pCtx->tag);
|
||||
char* input = pCtx->aInputElemBuf;
|
||||
char* input = pCtx->pInput;
|
||||
|
||||
if (pCtx->inputType == TSDB_DATA_TYPE_BINARY || pCtx->inputType == TSDB_DATA_TYPE_NCHAR) {
|
||||
assert(varDataLen(input) <= pCtx->inputBytes);
|
||||
|
@ -1061,6 +1062,7 @@ static void doExecuteSecondaryMerge(SSqlCmd *pCmd, SLocalMerger *pLocalMerge, bo
|
|||
} else {
|
||||
tVariantCreateFromBinary(&pCtx->tag, input, pCtx->inputBytes, pCtx->inputType);
|
||||
}
|
||||
|
||||
} else if (functionId == TSDB_FUNC_TOP || functionId == TSDB_FUNC_BOTTOM) {
|
||||
SSqlExpr *pExpr = tscSqlExprGet(pQueryInfo, j);
|
||||
pCtx->param[0].i64 = pExpr->param[0].i64;
|
||||
|
@ -1086,7 +1088,7 @@ static void doExecuteSecondaryMerge(SSqlCmd *pCmd, SLocalMerger *pLocalMerge, bo
|
|||
static void handleUnprocessedRow(SSqlCmd *pCmd, SLocalMerger *pLocalMerge, tFilePage *tmpBuffer) {
|
||||
if (pLocalMerge->hasUnprocessedRow) {
|
||||
pLocalMerge->hasUnprocessedRow = false;
|
||||
doExecuteSecondaryMerge(pCmd, pLocalMerge, true);
|
||||
doExecuteFinalMerge(pCmd, pLocalMerge, true);
|
||||
savePreviousRow(pLocalMerge, tmpBuffer);
|
||||
}
|
||||
}
|
||||
|
@ -1142,11 +1144,11 @@ static void fillMultiRowsOfTagsVal(SQueryInfo *pQueryInfo, int32_t numOfRes, SLo
|
|||
|
||||
int32_t inc = numOfRes - 1; // tsdb_func_tag function only produce one row of result
|
||||
memset(buf, 0, (size_t)maxBufSize);
|
||||
memcpy(buf, pCtx->aOutputBuf, (size_t)pCtx->outputBytes);
|
||||
memcpy(buf, pCtx->pOutput, (size_t)pCtx->outputBytes);
|
||||
|
||||
for (int32_t i = 0; i < inc; ++i) {
|
||||
pCtx->aOutputBuf += pCtx->outputBytes;
|
||||
memcpy(pCtx->aOutputBuf, buf, (size_t)pCtx->outputBytes);
|
||||
pCtx->pOutput += pCtx->outputBytes;
|
||||
memcpy(pCtx->pOutput, buf, (size_t)pCtx->outputBytes);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1289,10 +1291,10 @@ void resetOutputBuf(SQueryInfo *pQueryInfo, SLocalMerger *pLocalMerge) {// reset
|
|||
size_t t = tscSqlExprNumOfExprs(pQueryInfo);
|
||||
for (int32_t i = 0; i < t; ++i) {
|
||||
SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, i);
|
||||
pLocalMerge->pCtx[i].aOutputBuf = pLocalMerge->pResultBuf->data + pExpr->offset * pLocalMerge->resColModel->capacity;
|
||||
pLocalMerge->pCtx[i].pOutput = pLocalMerge->pResultBuf->data + pExpr->offset * pLocalMerge->resColModel->capacity;
|
||||
|
||||
if (pExpr->functionId == TSDB_FUNC_TOP || pExpr->functionId == TSDB_FUNC_BOTTOM || pExpr->functionId == TSDB_FUNC_DIFF) {
|
||||
pLocalMerge->pCtx[i].ptsOutputBuf = pLocalMerge->pCtx[0].aOutputBuf;
|
||||
pLocalMerge->pCtx[i].ptsOutputBuf = pLocalMerge->pCtx[0].pOutput;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1404,7 +1406,7 @@ static void doProcessResultInNextWindow(SSqlObj *pSql, int32_t numOfRes) {
|
|||
|
||||
for (int32_t k = 0; k < size; ++k) {
|
||||
SQLFunctionCtx *pCtx = &pLocalMerge->pCtx[k];
|
||||
pCtx->aOutputBuf += pCtx->outputBytes * numOfRes;
|
||||
pCtx->pOutput += pCtx->outputBytes * numOfRes;
|
||||
|
||||
// set the correct output timestamp column position
|
||||
if (pCtx->functionId == TSDB_FUNC_TOP || pCtx->functionId == TSDB_FUNC_BOTTOM) {
|
||||
|
@ -1412,7 +1414,7 @@ static void doProcessResultInNextWindow(SSqlObj *pSql, int32_t numOfRes) {
|
|||
}
|
||||
}
|
||||
|
||||
doExecuteSecondaryMerge(pCmd, pLocalMerge, true);
|
||||
doExecuteFinalMerge(pCmd, pLocalMerge, true);
|
||||
}
|
||||
|
||||
int32_t tscDoLocalMerge(SSqlObj *pSql) {
|
||||
|
@ -1504,7 +1506,7 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) {
|
|||
if (pLocalMerge->hasPrevRow) {
|
||||
if (needToMerge(pQueryInfo, pLocalMerge, tmpBuffer)) {
|
||||
// belong to the group of the previous row, continue process it
|
||||
doExecuteSecondaryMerge(pCmd, pLocalMerge, false);
|
||||
doExecuteFinalMerge(pCmd, pLocalMerge, false);
|
||||
|
||||
// copy to buffer
|
||||
savePreviousRow(pLocalMerge, tmpBuffer);
|
||||
|
@ -1576,7 +1578,7 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
doExecuteSecondaryMerge(pCmd, pLocalMerge, true);
|
||||
doExecuteFinalMerge(pCmd, pLocalMerge, true);
|
||||
savePreviousRow(pLocalMerge, tmpBuffer); // copy the processed row to buffer
|
||||
}
|
||||
|
||||
|
|
|
@ -233,6 +233,7 @@ int tscBuildQueryStreamDesc(void *pMsg, STscObj *pObj) {
|
|||
|
||||
// We extract the lock to tscBuildHeartBeatMsg function.
|
||||
|
||||
int64_t now = taosGetTimestampMs();
|
||||
SSqlObj *pSql = pObj->sqlList;
|
||||
while (pSql) {
|
||||
/*
|
||||
|
@ -247,7 +248,8 @@ int tscBuildQueryStreamDesc(void *pMsg, STscObj *pObj) {
|
|||
tstrncpy(pQdesc->sql, pSql->sqlstr, sizeof(pQdesc->sql));
|
||||
pQdesc->stime = htobe64(pSql->stime);
|
||||
pQdesc->queryId = htonl(pSql->queryId);
|
||||
pQdesc->useconds = htobe64(pSql->res.useconds);
|
||||
//pQdesc->useconds = htobe64(pSql->res.useconds);
|
||||
pQdesc->useconds = htobe64(now - pSql->stime);
|
||||
pQdesc->qHandle = htobe64(pSql->res.qhandle);
|
||||
|
||||
pHeartbeat->numOfQueries++;
|
||||
|
|
|
@ -129,6 +129,7 @@ static int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo);
|
|||
static int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo);
|
||||
static int32_t doCheckForQuery(SSqlObj* pSql, SQuerySQL* pQuerySql, int32_t index);
|
||||
static int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSQLExpr* pSqlExpr, SQueryInfo* pQueryInfo, SArray* pCols, int64_t *uid);
|
||||
static bool validateDebugFlag(int32_t flag);
|
||||
|
||||
int16_t getNewResColId(SQueryInfo* pQueryInfo) {
|
||||
return pQueryInfo->resColumnId--;
|
||||
|
@ -173,6 +174,16 @@ static uint8_t convertOptr(SStrToken *pToken) {
|
|||
}
|
||||
}
|
||||
|
||||
static bool validateDebugFlag(int32_t v) {
|
||||
const static int validFlag[] = {131, 135, 143};
|
||||
|
||||
for (int i = 0; i < tListLen(validFlag); i++) {
|
||||
if (v == validFlag[i]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
* Used during parsing query sql. Since the query sql usually small in length, error position
|
||||
* is not needed in the final error message.
|
||||
|
@ -565,16 +576,16 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
|||
}
|
||||
|
||||
int32_t numOfToken = (int32_t) taosArrayGetSize(pMiscInfo->a);
|
||||
SStrToken* t = taosArrayGet(pMiscInfo->a, 0);
|
||||
SStrToken* t1 = taosArrayGet(pMiscInfo->a, 1);
|
||||
assert(numOfToken >= 1 && numOfToken <= 2);
|
||||
|
||||
SStrToken* t = taosArrayGet(pMiscInfo->a, 0);
|
||||
strncpy(pCmd->payload, t->z, t->n);
|
||||
if (numOfToken == 2) {
|
||||
SStrToken* t1 = taosArrayGet(pMiscInfo->a, 1);
|
||||
pCmd->payload[t->n] = ' '; // add sep
|
||||
strncpy(&pCmd->payload[t->n + 1], t1->z, t1->n);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
case TSDB_SQL_CREATE_TABLE: {
|
||||
|
@ -787,10 +798,10 @@ int32_t parseIntervalClause(SSqlObj* pSql, SQueryInfo* pQueryInfo, SQuerySQL* pQ
|
|||
}
|
||||
|
||||
SSchema s = {.bytes = TSDB_KEYSIZE, .type = TSDB_DATA_TYPE_TIMESTAMP, .colId = PRIMARYKEY_TIMESTAMP_COL_INDEX};
|
||||
tstrncpy(s.name, aAggs[TSDB_FUNC_TS].aName, sizeof(s.name));
|
||||
tstrncpy(s.name, aAggs[TSDB_FUNC_TS].name, sizeof(s.name));
|
||||
|
||||
SColumnIndex index = {tableIndex, PRIMARYKEY_TIMESTAMP_COL_INDEX};
|
||||
tscAddSpecialColumnForSelect(pQueryInfo, 0, TSDB_FUNC_TS, &index, &s, TSDB_COL_NORMAL);
|
||||
tscAddFuncInSelectClause(pQueryInfo, 0, TSDB_FUNC_TS, &index, &s, TSDB_COL_NORMAL);
|
||||
|
||||
if (parseOffsetClause(pCmd, pQueryInfo, pQuerySql) != TSDB_CODE_SUCCESS) {
|
||||
return TSDB_CODE_TSC_INVALID_SQL;
|
||||
|
@ -1319,7 +1330,7 @@ int32_t setObjFullName(char* fullName, const char* account, SStrToken* pDB, SStr
|
|||
return (totalLen < TSDB_TABLE_FNAME_LEN) ? TSDB_CODE_SUCCESS : TSDB_CODE_TSC_INVALID_SQL;
|
||||
}
|
||||
|
||||
static void tscInsertPrimaryTSSourceColumn(SQueryInfo* pQueryInfo, SColumnIndex* pIndex) {
|
||||
void tscInsertPrimaryTsSourceColumn(SQueryInfo* pQueryInfo, SColumnIndex* pIndex) {
|
||||
SColumnIndex tsCol = {.tableIndex = pIndex->tableIndex, .columnIndex = PRIMARYKEY_TIMESTAMP_COL_INDEX};
|
||||
tscColumnListInsert(pQueryInfo->colList, &tsCol);
|
||||
}
|
||||
|
@ -1401,7 +1412,7 @@ static int32_t handleArithmeticExpr(SSqlCmd* pCmd, int32_t clauseIndex, int32_t
|
|||
insertResultField(pQueryInfo, exprIndex, &columnList, sizeof(double), TSDB_DATA_TYPE_DOUBLE, pExpr->aliasName, pExpr);
|
||||
|
||||
// add ts column
|
||||
tscInsertPrimaryTSSourceColumn(pQueryInfo, &index);
|
||||
tscInsertPrimaryTsSourceColumn(pQueryInfo, &index);
|
||||
|
||||
tbufCloseWriter(&bw);
|
||||
taosArrayDestroy(colList);
|
||||
|
@ -1506,7 +1517,7 @@ static void addPrimaryTsColIntoResult(SQueryInfo* pQueryInfo) {
|
|||
// add the timestamp column into the output columns
|
||||
SColumnIndex index = {0}; // primary timestamp column info
|
||||
int32_t numOfCols = (int32_t)tscSqlExprNumOfExprs(pQueryInfo);
|
||||
tscAddSpecialColumnForSelect(pQueryInfo, numOfCols, TSDB_FUNC_PRJ, &index, pSchema, TSDB_COL_NORMAL);
|
||||
tscAddFuncInSelectClause(pQueryInfo, numOfCols, TSDB_FUNC_PRJ, &index, pSchema, TSDB_COL_NORMAL);
|
||||
|
||||
SInternalField* pSupInfo = tscFieldInfoGetInternalField(&pQueryInfo->fieldsInfo, numOfCols);
|
||||
pSupInfo->visible = false;
|
||||
|
@ -1602,7 +1613,7 @@ int32_t parseSelectClause(SSqlCmd* pCmd, int32_t clauseIndex, tSQLExprList* pSel
|
|||
* in dealing with super table queries such as: count/first/last
|
||||
*/
|
||||
if (isSTable) {
|
||||
tscTansformSQLFuncForSTableQuery(pQueryInfo);
|
||||
tscTansformFuncForSTableQuery(pQueryInfo);
|
||||
|
||||
if (hasUnsupportFunctionsForSTableQuery(pCmd, pQueryInfo)) {
|
||||
return TSDB_CODE_TSC_INVALID_SQL;
|
||||
|
@ -1656,7 +1667,7 @@ SSqlExpr* doAddProjectCol(SQueryInfo* pQueryInfo, int32_t colIndex, int32_t tabl
|
|||
(functionId == TSDB_FUNC_TAGPRJ));
|
||||
}
|
||||
|
||||
SSqlExpr* tscAddSpecialColumnForSelect(SQueryInfo* pQueryInfo, int32_t outputColIndex, int16_t functionId,
|
||||
SSqlExpr* tscAddFuncInSelectClause(SQueryInfo* pQueryInfo, int32_t outputColIndex, int16_t functionId,
|
||||
SColumnIndex* pIndex, SSchema* pColSchema, int16_t flag) {
|
||||
int16_t colId = getNewResColId(pQueryInfo);
|
||||
|
||||
|
@ -1738,7 +1749,7 @@ int32_t addProjectionExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, t
|
|||
}
|
||||
|
||||
// add the primary timestamp column even though it is not required by user
|
||||
tscInsertPrimaryTSSourceColumn(pQueryInfo, &index);
|
||||
tscInsertPrimaryTsSourceColumn(pQueryInfo, &index);
|
||||
} else if (optr == TK_STRING || optr == TK_INTEGER || optr == TK_FLOAT) { // simple column projection query
|
||||
SColumnIndex index = COLUMN_INDEX_INITIALIZER;
|
||||
|
||||
|
@ -1748,7 +1759,7 @@ int32_t addProjectionExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, t
|
|||
|
||||
SSchema colSchema = tGetUserSpecifiedColumnSchema(&pItem->pNode->val, &pItem->pNode->token, pItem->aliasName);
|
||||
SSqlExpr* pExpr =
|
||||
tscAddSpecialColumnForSelect(pQueryInfo, startPos, TSDB_FUNC_PRJ, &index, &colSchema, TSDB_COL_UDC);
|
||||
tscAddFuncInSelectClause(pQueryInfo, startPos, TSDB_FUNC_PRJ, &index, &colSchema, TSDB_COL_UDC);
|
||||
|
||||
// NOTE: the first parameter is reserved for the tag column id during join query process.
|
||||
pExpr->numOfParams = 2;
|
||||
|
@ -1761,11 +1772,11 @@ int32_t addProjectionExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, t
|
|||
}
|
||||
|
||||
if (index.columnIndex == TSDB_TBNAME_COLUMN_INDEX) {
|
||||
SSchema colSchema = tGetTableNameColumnSchema();
|
||||
tscAddSpecialColumnForSelect(pQueryInfo, startPos, TSDB_FUNC_TAGPRJ, &index, &colSchema, TSDB_COL_TAG);
|
||||
SSchema* colSchema = tGetTbnameColumnSchema();
|
||||
tscAddFuncInSelectClause(pQueryInfo, startPos, TSDB_FUNC_TAGPRJ, &index, colSchema, TSDB_COL_TAG);
|
||||
} else if (index.columnIndex == TSDB_BLOCK_DIST_COLUMN_INDEX) {
|
||||
SSchema colSchema = tGetBlockDistColumnSchema();
|
||||
tscAddSpecialColumnForSelect(pQueryInfo, startPos, TSDB_FUNC_PRJ, &index, &colSchema, TSDB_COL_TAG);
|
||||
tscAddFuncInSelectClause(pQueryInfo, startPos, TSDB_FUNC_PRJ, &index, &colSchema, TSDB_COL_TAG);
|
||||
} else {
|
||||
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, index.tableIndex);
|
||||
STableMeta* pTableMeta = pTableMetaInfo->pTableMeta;
|
||||
|
@ -1779,7 +1790,7 @@ int32_t addProjectionExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, t
|
|||
}
|
||||
|
||||
// add the primary timestamp column even though it is not required by user
|
||||
tscInsertPrimaryTSSourceColumn(pQueryInfo, &index);
|
||||
tscInsertPrimaryTsSourceColumn(pQueryInfo, &index);
|
||||
} else {
|
||||
return TSDB_CODE_TSC_INVALID_SQL;
|
||||
}
|
||||
|
@ -1849,9 +1860,9 @@ void setResultColName(char* name, tSqlExprItem* pItem, int32_t functionId, SStrT
|
|||
if (tsKeepOriginalColumnName) { // keep the original column name
|
||||
tstrncpy(name, uname, TSDB_COL_NAME_LEN);
|
||||
} else {
|
||||
int32_t size = TSDB_COL_NAME_LEN + tListLen(aAggs[functionId].aName) + 2 + 1;
|
||||
char tmp[TSDB_COL_NAME_LEN + tListLen(aAggs[functionId].aName) + 2 + 1] = {0};
|
||||
snprintf(tmp, size, "%s(%s)", aAggs[functionId].aName, uname);
|
||||
int32_t size = TSDB_COL_NAME_LEN + tListLen(aAggs[functionId].name) + 2 + 1;
|
||||
char tmp[TSDB_COL_NAME_LEN + tListLen(aAggs[functionId].name) + 2 + 1] = {0};
|
||||
snprintf(tmp, size, "%s(%s)", aAggs[functionId].name, uname);
|
||||
|
||||
tstrncpy(name, tmp, TSDB_COL_NAME_LEN);
|
||||
}
|
||||
|
@ -1966,7 +1977,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
|
|||
|
||||
// the time stamp may be always needed
|
||||
if (index.tableIndex < tscGetNumOfColumns(pTableMetaInfo->pTableMeta)) {
|
||||
tscInsertPrimaryTSSourceColumn(pQueryInfo, &index);
|
||||
tscInsertPrimaryTsSourceColumn(pQueryInfo, &index);
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -2036,7 +2047,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
|
|||
getNewResColId(pQueryInfo), TSDB_KEYSIZE, false);
|
||||
|
||||
SColumnList ids = getColumnList(1, 0, 0);
|
||||
insertResultField(pQueryInfo, 0, &ids, TSDB_KEYSIZE, TSDB_DATA_TYPE_TIMESTAMP, aAggs[TSDB_FUNC_TS_DUMMY].aName, pExpr);
|
||||
insertResultField(pQueryInfo, 0, &ids, TSDB_KEYSIZE, TSDB_DATA_TYPE_TIMESTAMP, aAggs[TSDB_FUNC_TS_DUMMY].name, pExpr);
|
||||
}
|
||||
|
||||
// functions can not be applied to tags
|
||||
|
@ -2079,7 +2090,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
|
|||
}
|
||||
}
|
||||
|
||||
tscInsertPrimaryTSSourceColumn(pQueryInfo, &index);
|
||||
tscInsertPrimaryTsSourceColumn(pQueryInfo, &index);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
case TK_FIRST:
|
||||
|
@ -2285,7 +2296,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
|
|||
if (convertFunctionId(optr, &functionId) != TSDB_CODE_SUCCESS) {
|
||||
return TSDB_CODE_TSC_INVALID_SQL;
|
||||
}
|
||||
tscInsertPrimaryTSSourceColumn(pQueryInfo, &index);
|
||||
tscInsertPrimaryTsSourceColumn(pQueryInfo, &index);
|
||||
colIndex += 1; // the first column is ts
|
||||
|
||||
pExpr = tscSqlExprAppend(pQueryInfo, functionId, &index, resultType, resultSize, getNewResColId(pQueryInfo), resultSize, false);
|
||||
|
@ -2308,12 +2319,12 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
|
|||
SColumnIndex index1 = {0, PRIMARYKEY_TIMESTAMP_COL_INDEX};
|
||||
pExpr = tscSqlExprAppend(pQueryInfo, TSDB_FUNC_TS, &index1, TSDB_DATA_TYPE_TIMESTAMP, TSDB_KEYSIZE, getNewResColId(pQueryInfo),
|
||||
TSDB_KEYSIZE, false);
|
||||
tstrncpy(pExpr->aliasName, aAggs[TSDB_FUNC_TS].aName, sizeof(pExpr->aliasName));
|
||||
tstrncpy(pExpr->aliasName, aAggs[TSDB_FUNC_TS].name, sizeof(pExpr->aliasName));
|
||||
|
||||
const int32_t TS_COLUMN_INDEX = PRIMARYKEY_TIMESTAMP_COL_INDEX;
|
||||
SColumnList ids = getColumnList(1, 0, TS_COLUMN_INDEX);
|
||||
insertResultField(pQueryInfo, TS_COLUMN_INDEX, &ids, TSDB_KEYSIZE, TSDB_DATA_TYPE_TIMESTAMP,
|
||||
aAggs[TSDB_FUNC_TS].aName, pExpr);
|
||||
aAggs[TSDB_FUNC_TS].name, pExpr);
|
||||
|
||||
colIndex += 1; // the first column is ts
|
||||
|
||||
|
@ -2384,7 +2395,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
|
|||
|
||||
SSchema s = {0};
|
||||
if (index.columnIndex == TSDB_TBNAME_COLUMN_INDEX) {
|
||||
s = tGetTableNameColumnSchema();
|
||||
s = *tGetTbnameColumnSchema();
|
||||
} else {
|
||||
s = pTagSchema[index.columnIndex];
|
||||
}
|
||||
|
@ -2400,7 +2411,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
|
|||
s.bytes = bytes;
|
||||
|
||||
TSDB_QUERY_SET_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_TAG_FILTER_QUERY);
|
||||
tscAddSpecialColumnForSelect(pQueryInfo, 0, TSDB_FUNC_TID_TAG, &index, &s, TSDB_COL_TAG);
|
||||
tscAddFuncInSelectClause(pQueryInfo, 0, TSDB_FUNC_TID_TAG, &index, &s, TSDB_COL_TAG);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -2778,7 +2789,7 @@ bool validateIpAddress(const char* ip, size_t size) {
|
|||
return epAddr != INADDR_NONE;
|
||||
}
|
||||
|
||||
int32_t tscTansformSQLFuncForSTableQuery(SQueryInfo* pQueryInfo) {
|
||||
int32_t tscTansformFuncForSTableQuery(SQueryInfo* pQueryInfo) {
|
||||
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||
|
||||
if (pTableMetaInfo->pTableMeta == NULL || !UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) {
|
||||
|
@ -2800,7 +2811,7 @@ int32_t tscTansformSQLFuncForSTableQuery(SQueryInfo* pQueryInfo) {
|
|||
SSchema* pSrcSchema = tscGetTableColumnSchema(pTableMetaInfo->pTableMeta, colIndex);
|
||||
|
||||
if ((functionId >= TSDB_FUNC_SUM && functionId <= TSDB_FUNC_TWA) ||
|
||||
(functionId >= TSDB_FUNC_FIRST_DST && functionId <= TSDB_FUNC_LAST_DST) ||
|
||||
(functionId >= TSDB_FUNC_FIRST_DST && functionId <= TSDB_FUNC_STDDEV_DST) ||
|
||||
(functionId >= TSDB_FUNC_RATE && functionId <= TSDB_FUNC_AVG_IRATE)) {
|
||||
if (getResultDataInfo(pSrcSchema->type, pSrcSchema->bytes, functionId, (int32_t)pExpr->param[0].i64, &type, &bytes,
|
||||
&interBytes, 0, true) != TSDB_CODE_SUCCESS) {
|
||||
|
@ -2818,7 +2829,7 @@ int32_t tscTansformSQLFuncForSTableQuery(SQueryInfo* pQueryInfo) {
|
|||
}
|
||||
|
||||
/* transfer the field-info back to original input format */
|
||||
void tscRestoreSQLFuncForSTableQuery(SQueryInfo* pQueryInfo) {
|
||||
void tscRestoreFuncForSTableQuery(SQueryInfo* pQueryInfo) {
|
||||
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||
if (!UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) {
|
||||
return;
|
||||
|
@ -2842,6 +2853,8 @@ void tscRestoreSQLFuncForSTableQuery(SQueryInfo* pQueryInfo) {
|
|||
functionId = TSDB_FUNC_FIRST;
|
||||
} else if (functionId == TSDB_FUNC_LAST_DST) {
|
||||
functionId = TSDB_FUNC_LAST;
|
||||
} else if (functionId == TSDB_FUNC_STDDEV_DST) {
|
||||
functionId = TSDB_FUNC_STDDEV;
|
||||
}
|
||||
|
||||
getResultDataInfo(pSchema->type, pSchema->bytes, functionId, 0, &pExpr->resType, &pExpr->resBytes,
|
||||
|
@ -2858,7 +2871,7 @@ bool hasUnsupportFunctionsForSTableQuery(SSqlCmd* pCmd, SQueryInfo* pQueryInfo)
|
|||
size_t size = tscSqlExprNumOfExprs(pQueryInfo);
|
||||
for (int32_t i = 0; i < size; ++i) {
|
||||
int32_t functionId = tscSqlExprGet(pQueryInfo, i)->functionId;
|
||||
if ((aAggs[functionId].nStatus & TSDB_FUNCSTATE_STABLE) == 0) {
|
||||
if ((aAggs[functionId].status & TSDB_FUNCSTATE_STABLE) == 0) {
|
||||
invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3);
|
||||
return true;
|
||||
}
|
||||
|
@ -2968,7 +2981,6 @@ int32_t parseGroupbyClause(SQueryInfo* pQueryInfo, SArray* pList, SSqlCmd* pCmd)
|
|||
|
||||
STableMeta* pTableMeta = NULL;
|
||||
SSchema* pSchema = NULL;
|
||||
SSchema s = tGetTbnameColumnSchema();
|
||||
|
||||
int32_t tableIndex = COLUMN_INDEX_INITIAL_VAL;
|
||||
|
||||
|
@ -2995,7 +3007,7 @@ int32_t parseGroupbyClause(SQueryInfo* pQueryInfo, SArray* pList, SSqlCmd* pCmd)
|
|||
|
||||
int32_t numOfCols = tscGetNumOfColumns(pTableMeta);
|
||||
if (index.columnIndex == TSDB_TBNAME_COLUMN_INDEX) {
|
||||
pSchema = &s;
|
||||
pSchema = tGetTbnameColumnSchema();
|
||||
} else {
|
||||
pSchema = tscGetTableColumnSchema(pTableMeta, index.columnIndex);
|
||||
}
|
||||
|
@ -3440,6 +3452,7 @@ static int32_t getTagCondString(tSQLExpr* pExpr, char** str) {
|
|||
|
||||
static int32_t getTablenameCond(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSQLExpr* pTableCond, SStringBuilder* sb) {
|
||||
const char* msg0 = "invalid table name list";
|
||||
const char* msg1 = "not string following like";
|
||||
|
||||
if (pTableCond == NULL) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -3457,6 +3470,10 @@ static int32_t getTablenameCond(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSQLExpr*
|
|||
if (pTableCond->nSQLOptr == TK_IN) {
|
||||
ret = tablenameListToString(pRight, sb);
|
||||
} else if (pTableCond->nSQLOptr == TK_LIKE) {
|
||||
if (pRight->nSQLOptr != TK_STRING) {
|
||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
|
||||
}
|
||||
|
||||
ret = tablenameCondToString(pRight, sb);
|
||||
}
|
||||
|
||||
|
@ -3547,38 +3564,6 @@ static int32_t getJoinCondInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSQLExpr*
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
// todo error handle / such as and /or mixed with +/-/*/
|
||||
int32_t doArithmeticExprToString(tSQLExpr* pExpr, char** exprString) {
|
||||
tSQLExpr* pLeft = pExpr->pLeft;
|
||||
tSQLExpr* pRight = pExpr->pRight;
|
||||
|
||||
*(*exprString)++ = '(';
|
||||
|
||||
if (pLeft->nSQLOptr >= TK_PLUS && pLeft->nSQLOptr <= TK_REM) {
|
||||
doArithmeticExprToString(pLeft, exprString);
|
||||
} else {
|
||||
int32_t ret = tSQLExprNodeToString(pLeft, exprString);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
return TSDB_CODE_TSC_INVALID_SQL;
|
||||
}
|
||||
}
|
||||
|
||||
optrToString(pExpr, exprString);
|
||||
|
||||
if (pRight->nSQLOptr >= TK_PLUS && pRight->nSQLOptr <= TK_REM) {
|
||||
doArithmeticExprToString(pRight, exprString);
|
||||
} else {
|
||||
int32_t ret = tSQLExprNodeToString(pRight, exprString);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
return TSDB_CODE_TSC_INVALID_SQL;
|
||||
}
|
||||
}
|
||||
|
||||
*(*exprString)++ = ')';
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t validateSQLExpr(SSqlCmd* pCmd, tSQLExpr* pExpr, SQueryInfo* pQueryInfo, SColumnList* pList,
|
||||
int32_t* type, uint64_t* uid) {
|
||||
if (pExpr->nSQLOptr == TK_ID) {
|
||||
|
@ -4762,7 +4747,7 @@ static void setDefaultOrderInfo(SQueryInfo* pQueryInfo) {
|
|||
int32_t parseOrderbyClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql, SSchema* pSchema) {
|
||||
const char* msg0 = "only support order by primary timestamp";
|
||||
const char* msg1 = "invalid column name";
|
||||
const char* msg2 = "only support order by primary timestamp or first tag in groupby clause allowed";
|
||||
const char* msg2 = "order by primary timestamp or first tag in groupby clause allowed";
|
||||
const char* msg3 = "invalid column in order by clause, only primary timestamp or first tag in groupby clause allowed";
|
||||
|
||||
setDefaultOrderInfo(pQueryInfo);
|
||||
|
@ -5228,7 +5213,7 @@ int32_t validateSqlFunctionInStreamSql(SSqlCmd* pCmd, SQueryInfo* pQueryInfo) {
|
|||
size_t size = taosArrayGetSize(pQueryInfo->exprList);
|
||||
for (int32_t i = 0; i < size; ++i) {
|
||||
int32_t functId = tscSqlExprGet(pQueryInfo, i)->functionId;
|
||||
if (!IS_STREAM_QUERY_VALID(aAggs[functId].nStatus)) {
|
||||
if (!IS_STREAM_QUERY_VALID(aAggs[functId].status)) {
|
||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
|
||||
}
|
||||
}
|
||||
|
@ -5251,7 +5236,7 @@ int32_t validateFunctionsInIntervalOrGroupbyQuery(SSqlCmd* pCmd, SQueryInfo* pQu
|
|||
bool hasSelectivity = false;
|
||||
for (int32_t j = 0; j < size; ++j) {
|
||||
SSqlExpr* pEx = tscSqlExprGet(pQueryInfo, j);
|
||||
if ((aAggs[pEx->functionId].nStatus & TSDB_FUNCSTATE_SELECTIVITY) == TSDB_FUNCSTATE_SELECTIVITY) {
|
||||
if ((aAggs[pEx->functionId].status & TSDB_FUNCSTATE_SELECTIVITY) == TSDB_FUNCSTATE_SELECTIVITY) {
|
||||
hasSelectivity = true;
|
||||
break;
|
||||
}
|
||||
|
@ -5382,13 +5367,15 @@ int32_t validateLocalConfig(SMiscInfo* pOptions) {
|
|||
SDNodeDynConfOption LOCAL_DYNAMIC_CFG_OPTIONS[6] = {{"resetLog", 8}, {"rpcDebugFlag", 12}, {"tmrDebugFlag", 12},
|
||||
{"cDebugFlag", 10}, {"uDebugFlag", 10}, {"debugFlag", 9}};
|
||||
|
||||
|
||||
SStrToken* pOptionToken = taosArrayGet(pOptions->a, 0);
|
||||
|
||||
if (numOfToken == 1) {
|
||||
// reset log does not need value
|
||||
for (int32_t i = 0; i < 1; ++i) {
|
||||
SDNodeDynConfOption* pOption = &LOCAL_DYNAMIC_CFG_OPTIONS[i];
|
||||
if ((strncasecmp(pOption->name, pOptionToken->z, pOptionToken->n) == 0) && (pOption->len == pOptionToken->n)) {
|
||||
if ((pOption->len == pOptionToken->n) &&
|
||||
(strncasecmp(pOption->name, pOptionToken->z, pOptionToken->n) == 0)) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
@ -5396,15 +5383,14 @@ int32_t validateLocalConfig(SMiscInfo* pOptions) {
|
|||
SStrToken* pValToken = taosArrayGet(pOptions->a, 1);
|
||||
|
||||
int32_t val = strtol(pValToken->z, NULL, 10);
|
||||
if (val < 131 || val > 199) {
|
||||
// options value is out of valid range
|
||||
if (!validateDebugFlag(val)) {
|
||||
return TSDB_CODE_TSC_INVALID_SQL;
|
||||
}
|
||||
|
||||
for (int32_t i = 1; i < tListLen(LOCAL_DYNAMIC_CFG_OPTIONS); ++i) {
|
||||
SDNodeDynConfOption* pOption = &LOCAL_DYNAMIC_CFG_OPTIONS[i];
|
||||
if ((strncasecmp(pOption->name, pOptionToken->z, pOptionToken->n) == 0) && (pOption->len == pOptionToken->n)) {
|
||||
// options is valid
|
||||
if ((pOption->len == pOptionToken->n)
|
||||
&& (strncasecmp(pOption->name, pOptionToken->z, pOptionToken->n) == 0)) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
@ -5705,7 +5691,7 @@ void doAddGroupColumnForSubquery(SQueryInfo* pQueryInfo, int32_t tagIndex) {
|
|||
SSchema* pSchema = tscGetTableColumnSchema(pTableMetaInfo->pTableMeta, pColIndex->colIndex);
|
||||
SColumnIndex colIndex = {.tableIndex = 0, .columnIndex = pColIndex->colIndex};
|
||||
|
||||
tscAddSpecialColumnForSelect(pQueryInfo, (int32_t)size, TSDB_FUNC_PRJ, &colIndex, pSchema, TSDB_COL_NORMAL);
|
||||
tscAddFuncInSelectClause(pQueryInfo, (int32_t)size, TSDB_FUNC_PRJ, &colIndex, pSchema, TSDB_COL_NORMAL);
|
||||
|
||||
int32_t numOfFields = tscNumOfFields(pQueryInfo);
|
||||
SInternalField* pInfo = tscFieldInfoGetInternalField(&pQueryInfo->fieldsInfo, numOfFields - 1);
|
||||
|
@ -5869,7 +5855,7 @@ static int32_t checkUpdateTagPrjFunctions(SQueryInfo* pQueryInfo, SSqlCmd* pCmd)
|
|||
continue;
|
||||
}
|
||||
|
||||
if ((aAggs[functionId].nStatus & TSDB_FUNCSTATE_SELECTIVITY) != 0) {
|
||||
if ((aAggs[functionId].status & TSDB_FUNCSTATE_SELECTIVITY) != 0) {
|
||||
numOfSelectivity++;
|
||||
} else {
|
||||
numOfAggregation++;
|
||||
|
@ -5901,7 +5887,7 @@ static int32_t checkUpdateTagPrjFunctions(SQueryInfo* pQueryInfo, SSqlCmd* pCmd)
|
|||
for (int32_t i = 0; i < numOfExprs; ++i) {
|
||||
SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, i);
|
||||
int16_t functionId = pExpr->functionId;
|
||||
if (functionId == TSDB_FUNC_TAGPRJ || (aAggs[functionId].nStatus & TSDB_FUNCSTATE_SELECTIVITY) == 0) {
|
||||
if (functionId == TSDB_FUNC_TAGPRJ || (aAggs[functionId].status & TSDB_FUNCSTATE_SELECTIVITY) == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -5944,7 +5930,7 @@ static int32_t doAddGroupbyColumnsOnDemand(SSqlCmd* pCmd, SQueryInfo* pQueryInfo
|
|||
|
||||
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||
|
||||
SSchema s = tGetTableNameColumnSchema();
|
||||
SSchema s = *tGetTbnameColumnSchema();
|
||||
SSchema* pSchema = tscGetTableSchema(pTableMetaInfo->pTableMeta);
|
||||
int16_t bytes = 0;
|
||||
int16_t type = 0;
|
||||
|
@ -6088,7 +6074,7 @@ int32_t doFunctionsCompatibleCheck(SSqlCmd* pCmd, SQueryInfo* pQueryInfo) {
|
|||
}
|
||||
}
|
||||
|
||||
if (IS_MULTIOUTPUT(aAggs[functId].nStatus) && functId != TSDB_FUNC_TOP && functId != TSDB_FUNC_BOTTOM &&
|
||||
if (IS_MULTIOUTPUT(aAggs[functId].status) && functId != TSDB_FUNC_TOP && functId != TSDB_FUNC_BOTTOM &&
|
||||
functId != TSDB_FUNC_TAGPRJ && functId != TSDB_FUNC_PRJ) {
|
||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
|
||||
}
|
||||
|
@ -6278,7 +6264,7 @@ void tscPrintSelectClause(SSqlObj* pSql, int32_t subClauseIndex) {
|
|||
char tmpBuf[1024] = {0};
|
||||
int32_t tmpLen = 0;
|
||||
tmpLen =
|
||||
sprintf(tmpBuf, "%s(uid:%" PRId64 ", %d)", aAggs[pExpr->functionId].aName, pExpr->uid, pExpr->colInfo.colId);
|
||||
sprintf(tmpBuf, "%s(uid:%" PRId64 ", %d)", aAggs[pExpr->functionId].name, pExpr->uid, pExpr->colInfo.colId);
|
||||
|
||||
if (tmpLen + offset >= totalBufSize - 1) break;
|
||||
|
||||
|
@ -6979,3 +6965,4 @@ bool hasNormalColumnFilter(SQueryInfo* pQueryInfo) {
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -451,7 +451,7 @@ int doProcessSql(SSqlObj *pSql) {
|
|||
|
||||
if (pRes->code != TSDB_CODE_SUCCESS) {
|
||||
tscAsyncResultOnError(pSql);
|
||||
return pRes->code;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t code = tscSendMsgToServer(pSql);
|
||||
|
@ -460,7 +460,7 @@ int doProcessSql(SSqlObj *pSql) {
|
|||
if (code != TSDB_CODE_SUCCESS) {
|
||||
pRes->code = code;
|
||||
tscAsyncResultOnError(pSql);
|
||||
return code;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -609,7 +609,7 @@ static int32_t tscEstimateQueryMsgSize(SSqlObj *pSql, int32_t clauseIndex) {
|
|||
}
|
||||
|
||||
return MIN_QUERY_MSG_PKT_SIZE + minMsgSize() + sizeof(SQueryTableMsg) + srcColListSize + exprSize + tsBufSize +
|
||||
tableSerialize + sqlLen + 4096;
|
||||
tableSerialize + sqlLen + 4096 + pQueryInfo->bufLen;
|
||||
}
|
||||
|
||||
static char *doSerializeTableInfo(SQueryTableMsg* pQueryMsg, SSqlObj *pSql, char *pMsg) {
|
||||
|
@ -752,6 +752,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
|||
pQueryMsg->queryType = htonl(pQueryInfo->type);
|
||||
pQueryMsg->vgroupLimit = htobe64(pQueryInfo->vgroupLimit);
|
||||
pQueryMsg->sqlstrLen = htonl(sqlLen);
|
||||
pQueryMsg->prevResultLen = htonl(pQueryInfo->bufLen);
|
||||
|
||||
size_t numOfOutput = tscSqlExprNumOfExprs(pQueryInfo);
|
||||
pQueryMsg->numOfOutput = htons((int16_t)numOfOutput); // this is the stage one output column number
|
||||
|
@ -769,6 +770,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
|||
char n[TSDB_TABLE_FNAME_LEN] = {0};
|
||||
tNameExtractFullName(&pTableMetaInfo->name, n);
|
||||
|
||||
|
||||
tscError("%p tid:%d uid:%" PRIu64" id:%s, column index out of range, numOfColumns:%d, index:%d, column name:%s",
|
||||
pSql, pTableMeta->id.tid, pTableMeta->id.uid, n, tscGetNumOfColumns(pTableMeta), pCol->colIndex.columnIndex,
|
||||
pColSchema->name);
|
||||
|
@ -812,6 +814,13 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
|||
for (int32_t i = 0; i < tscSqlExprNumOfExprs(pQueryInfo); ++i) {
|
||||
SSqlExpr *pExpr = tscSqlExprGet(pQueryInfo, i);
|
||||
|
||||
// the queried table has been removed and a new table with the same name has already been created already
|
||||
// return error msg
|
||||
if (pExpr->uid != pTableMeta->id.uid) {
|
||||
tscError("%p table has already been destroyed", pSql);
|
||||
return TSDB_CODE_TSC_INVALID_TABLE_NAME;
|
||||
}
|
||||
|
||||
if (!tscValidateColumnId(pTableMetaInfo, pExpr->colInfo.colId, pExpr->numOfParams)) {
|
||||
tscError("%p table schema is not matched with parsed sql", pSql);
|
||||
return TSDB_CODE_TSC_INVALID_SQL;
|
||||
|
@ -855,6 +864,13 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
|||
SInternalField* pField = tscFieldInfoGetInternalField(&pQueryInfo->fieldsInfo, i);
|
||||
SSqlExpr *pExpr = pField->pSqlExpr;
|
||||
if (pExpr != NULL) {
|
||||
// the queried table has been removed and a new table with the same name has already been created already
|
||||
// return error msg
|
||||
if (pExpr->uid != pTableMeta->id.uid) {
|
||||
tscError("%p table has already been destroyed", pSql);
|
||||
return TSDB_CODE_TSC_INVALID_TABLE_NAME;
|
||||
}
|
||||
|
||||
if (!tscValidateColumnId(pTableMetaInfo, pExpr->colInfo.colId, pExpr->numOfParams)) {
|
||||
tscError("%p table schema is not matched with parsed sql", pSql);
|
||||
return TSDB_CODE_TSC_INVALID_SQL;
|
||||
|
@ -989,6 +1005,11 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
|||
}
|
||||
}
|
||||
|
||||
if (pQueryInfo->bufLen > 0) {
|
||||
memcpy(pMsg, pQueryInfo->buf, pQueryInfo->bufLen);
|
||||
pMsg += pQueryInfo->bufLen;
|
||||
}
|
||||
|
||||
SCond* pCond = &pQueryInfo->tagCond.tbnameCond;
|
||||
if (pCond->len > 0) {
|
||||
strncpy(pMsg, pCond->cond, pCond->len);
|
||||
|
|
|
@ -443,24 +443,6 @@ TAOS_FIELD *taos_fetch_fields(TAOS_RES *res) {
|
|||
return pFieldInfo->final;
|
||||
}
|
||||
|
||||
int taos_retrieve(TAOS_RES *res) {
|
||||
if (res == NULL) return 0;
|
||||
SSqlObj *pSql = (SSqlObj *)res;
|
||||
SSqlCmd *pCmd = &pSql->cmd;
|
||||
SSqlRes *pRes = &pSql->res;
|
||||
if (pSql == NULL || pSql->signature != pSql) return 0;
|
||||
if (pRes->qhandle == 0) return 0;
|
||||
|
||||
tscResetForNextRetrieve(pRes);
|
||||
|
||||
if (pCmd->command < TSDB_SQL_LOCAL) {
|
||||
pCmd->command = (pCmd->command > TSDB_SQL_MGMT) ? TSDB_SQL_RETRIEVE : TSDB_SQL_FETCH;
|
||||
}
|
||||
|
||||
tscProcessSql(pSql);
|
||||
return pRes->numOfRows;
|
||||
}
|
||||
|
||||
static bool needToFetchNewBlock(SSqlObj* pSql) {
|
||||
SSqlRes *pRes = &pSql->res;
|
||||
SSqlCmd *pCmd = &pSql->cmd;
|
||||
|
@ -714,7 +696,7 @@ static void tscKillSTableQuery(SSqlObj *pSql) {
|
|||
}
|
||||
|
||||
tscAsyncResultOnError(pSubObj);
|
||||
taosReleaseRef(tscObjRef, pSubObj->self);
|
||||
// taosRelekaseRef(tscObjRef, pSubObj->self);
|
||||
}
|
||||
|
||||
if (pSql->subState.numOfSub <= 0) {
|
||||
|
|
|
@ -103,7 +103,7 @@ static void doLaunchQuery(void* param, TAOS_RES* tres, int32_t code) {
|
|||
|
||||
// failed to get table Meta or vgroup list, retry in 10sec.
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
tscTansformSQLFuncForSTableQuery(pQueryInfo);
|
||||
tscTansformFuncForSTableQuery(pQueryInfo);
|
||||
tscDebug("%p stream:%p, start stream query on:%s", pSql, pStream, tNameGetTableName(&pTableMetaInfo->name));
|
||||
|
||||
pSql->fp = tscProcessStreamQueryCallback;
|
||||
|
|
|
@ -61,7 +61,7 @@ TSKEY tscGetSubscriptionProgress(void* sub, int64_t uid, TSKEY dflt) {
|
|||
SSub* pSub = (SSub*)sub;
|
||||
|
||||
SSubscriptionProgress target = {.uid = uid, .key = 0};
|
||||
SSubscriptionProgress* p = taosArraySearch(pSub->progress, &target, tscCompareSubscriptionProgress);
|
||||
SSubscriptionProgress* p = taosArraySearch(pSub->progress, &target, tscCompareSubscriptionProgress, TD_EQ);
|
||||
if (p == NULL) {
|
||||
return dflt;
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ void tscUpdateSubscriptionProgress(void* sub, int64_t uid, TSKEY ts) {
|
|||
SSub* pSub = (SSub*)sub;
|
||||
|
||||
SSubscriptionProgress target = {.uid = uid, .key = ts};
|
||||
SSubscriptionProgress* p = taosArraySearch(pSub->progress, &target, tscCompareSubscriptionProgress);
|
||||
SSubscriptionProgress* p = taosArraySearch(pSub->progress, &target, tscCompareSubscriptionProgress, TD_EQ);
|
||||
if (p != NULL) {
|
||||
p->key = ts;
|
||||
tscDebug("subscribe:%s, uid:%"PRIu64" update sub start ts:%"PRId64, pSub->topic, p->uid, p->key);
|
||||
|
@ -270,7 +270,7 @@ static int tscUpdateSubscription(STscObj* pObj, SSub* pSub) {
|
|||
if (UTIL_TABLE_IS_NORMAL_TABLE(pTableMetaInfo)) {
|
||||
STableMeta * pTableMeta = pTableMetaInfo->pTableMeta;
|
||||
SSubscriptionProgress target = {.uid = pTableMeta->id.uid, .key = 0};
|
||||
SSubscriptionProgress* p = taosArraySearch(pSub->progress, &target, tscCompareSubscriptionProgress);
|
||||
SSubscriptionProgress* p = taosArraySearch(pSub->progress, &target, tscCompareSubscriptionProgress, TD_EQ);
|
||||
if (p == NULL) {
|
||||
taosArrayClear(pSub->progress);
|
||||
taosArrayPush(pSub->progress, &target);
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#define _GNU_SOURCE
|
||||
|
||||
|
||||
#include "os.h"
|
||||
|
||||
#include "texpr.h"
|
||||
|
@ -23,6 +23,7 @@
|
|||
#include "tscSubquery.h"
|
||||
#include "tschemautil.h"
|
||||
#include "tsclient.h"
|
||||
#include "qUtil.h"
|
||||
|
||||
typedef struct SInsertSupporter {
|
||||
SSqlObj* pSql;
|
||||
|
@ -94,11 +95,21 @@ static bool subAndCheckDone(SSqlObj *pSql, SSqlObj *pParentSql, int idx) {
|
|||
|
||||
pthread_mutex_lock(&subState->mutex);
|
||||
|
||||
bool done = allSubqueryDone(pParentSql);
|
||||
|
||||
if (done) {
|
||||
tscDebug("%p subquery:%p,%d all subs already done", pParentSql, pSql, idx);
|
||||
|
||||
pthread_mutex_unlock(&subState->mutex);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
tscDebug("%p subquery:%p,%d state set to 1", pParentSql, pSql, idx);
|
||||
|
||||
subState->states[idx] = 1;
|
||||
|
||||
bool done = allSubqueryDone(pParentSql);
|
||||
done = allSubqueryDone(pParentSql);
|
||||
|
||||
pthread_mutex_unlock(&subState->mutex);
|
||||
|
||||
|
@ -501,7 +512,7 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) {
|
|||
|
||||
int16_t functionId = tscIsProjectionQuery(pQueryInfo)? TSDB_FUNC_PRJ : TSDB_FUNC_TS;
|
||||
|
||||
tscAddSpecialColumnForSelect(pQueryInfo, 0, functionId, &index, s, TSDB_COL_NORMAL);
|
||||
tscAddFuncInSelectClause(pQueryInfo, 0, functionId, &index, s, TSDB_COL_NORMAL);
|
||||
tscPrintSelectClause(pNew, 0);
|
||||
tscFieldInfoUpdateOffset(pQueryInfo);
|
||||
|
||||
|
@ -681,7 +692,7 @@ void tscBuildVgroupTableInfo(SSqlObj* pSql, STableMetaInfo* pTableMetaInfo, SArr
|
|||
}
|
||||
}
|
||||
|
||||
static void issueTSCompQuery(SSqlObj* pSql, SJoinSupporter* pSupporter, SSqlObj* pParent) {
|
||||
static void issueTsCompQuery(SSqlObj* pSql, SJoinSupporter* pSupporter, SSqlObj* pParent) {
|
||||
SSqlCmd* pCmd = &pSql->cmd;
|
||||
tscClearSubqueryInfo(pCmd);
|
||||
tscFreeSqlResult(pSql);
|
||||
|
@ -701,7 +712,7 @@ static void issueTSCompQuery(SSqlObj* pSql, SJoinSupporter* pSupporter, SSqlObj*
|
|||
SSchema colSchema = {.type = TSDB_DATA_TYPE_BINARY, .bytes = 1};
|
||||
|
||||
SColumnIndex index = {0, PRIMARYKEY_TIMESTAMP_COL_INDEX};
|
||||
tscAddSpecialColumnForSelect(pQueryInfo, 0, TSDB_FUNC_TS_COMP, &index, &colSchema, TSDB_COL_NORMAL);
|
||||
tscAddFuncInSelectClause(pQueryInfo, 0, TSDB_FUNC_TS_COMP, &index, &colSchema, TSDB_COL_NORMAL);
|
||||
|
||||
// set the tags value for ts_comp function
|
||||
if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) {
|
||||
|
@ -970,7 +981,7 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
|
|||
|
||||
for (int32_t m = 0; m < pParentSql->subState.numOfSub; ++m) {
|
||||
SSqlObj* sub = pParentSql->pSubs[m];
|
||||
issueTSCompQuery(sub, sub->param, pParentSql);
|
||||
issueTsCompQuery(sub, sub->param, pParentSql);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1470,7 +1481,7 @@ void tscSetupOutputColumnIndex(SSqlObj* pSql) {
|
|||
}
|
||||
|
||||
// restore the offset value for super table query in case of final result.
|
||||
tscRestoreSQLFuncForSTableQuery(pQueryInfo);
|
||||
tscRestoreFuncForSTableQuery(pQueryInfo);
|
||||
tscFieldInfoUpdateOffset(pQueryInfo);
|
||||
}
|
||||
|
||||
|
@ -1651,7 +1662,7 @@ int32_t tscCreateJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter
|
|||
|
||||
// set get tags query type
|
||||
TSDB_QUERY_SET_TYPE(pNewQueryInfo->type, TSDB_QUERY_TYPE_TAG_FILTER_QUERY);
|
||||
tscAddSpecialColumnForSelect(pNewQueryInfo, 0, TSDB_FUNC_TID_TAG, &colIndex, &s1, TSDB_COL_TAG);
|
||||
tscAddFuncInSelectClause(pNewQueryInfo, 0, TSDB_FUNC_TID_TAG, &colIndex, &s1, TSDB_COL_TAG);
|
||||
size_t numOfCols = taosArrayGetSize(pNewQueryInfo->colList);
|
||||
|
||||
tscDebug(
|
||||
|
@ -1662,7 +1673,7 @@ int32_t tscCreateJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter
|
|||
} else {
|
||||
SSchema colSchema = {.type = TSDB_DATA_TYPE_BINARY, .bytes = 1};
|
||||
SColumnIndex colIndex = {0, PRIMARYKEY_TIMESTAMP_COL_INDEX};
|
||||
tscAddSpecialColumnForSelect(pNewQueryInfo, 0, TSDB_FUNC_TS_COMP, &colIndex, &colSchema, TSDB_COL_NORMAL);
|
||||
tscAddFuncInSelectClause(pNewQueryInfo, 0, TSDB_FUNC_TS_COMP, &colIndex, &colSchema, TSDB_COL_NORMAL);
|
||||
|
||||
// set the tags value for ts_comp function
|
||||
SSqlExpr *pExpr = tscSqlExprGet(pNewQueryInfo, 0);
|
||||
|
@ -1821,7 +1832,316 @@ void tscUnlockByThread(int64_t *lockedBy) {
|
|||
}
|
||||
}
|
||||
|
||||
typedef struct SFirstRoundQuerySup {
|
||||
SSqlObj *pParent;
|
||||
int32_t numOfRows;
|
||||
SArray *pColsInfo;
|
||||
int32_t tagLen;
|
||||
STColumn *pTagCols;
|
||||
SArray *pResult; // SArray<SInterResult>
|
||||
int64_t interval;
|
||||
char* buf;
|
||||
int32_t bufLen;
|
||||
} SFirstRoundQuerySup;
|
||||
|
||||
void doAppendData(SInterResult* pInterResult, TAOS_ROW row, int32_t numOfCols, SQueryInfo* pQueryInfo) {
|
||||
TSKEY key = INT64_MIN;
|
||||
for(int32_t i = 0; i < numOfCols; ++i) {
|
||||
SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, i);
|
||||
if (TSDB_COL_IS_TAG(pExpr->colInfo.flag)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (pExpr->colInfo.colId == PRIMARYKEY_TIMESTAMP_COL_INDEX) {
|
||||
key = *(TSKEY*) row[i];
|
||||
continue;
|
||||
}
|
||||
|
||||
double v = 0;
|
||||
if (row[i] != NULL) {
|
||||
v = *(double*) row[i];
|
||||
} else {
|
||||
SET_DOUBLE_NULL(&v);
|
||||
}
|
||||
|
||||
int32_t id = pExpr->colInfo.colId;
|
||||
int32_t numOfQueriedCols = (int32_t) taosArrayGetSize(pInterResult->pResult);
|
||||
|
||||
SArray* p = NULL;
|
||||
for(int32_t j = 0; j < numOfQueriedCols; ++j) {
|
||||
SStddevInterResult* pColRes = taosArrayGet(pInterResult->pResult, j);
|
||||
if (pColRes->colId == id) {
|
||||
p = pColRes->pResult;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//append a new column
|
||||
if (p == NULL) {
|
||||
SStddevInterResult t = {.colId = id, .pResult = taosArrayInit(10, sizeof(SResPair)),};
|
||||
taosArrayPush(pInterResult->pResult, &t);
|
||||
p = t.pResult;
|
||||
}
|
||||
|
||||
SResPair pair = {.avg = v, .key = key};
|
||||
taosArrayPush(p, &pair);
|
||||
}
|
||||
}
|
||||
|
||||
static void destroySup(SFirstRoundQuerySup* pSup) {
|
||||
taosArrayDestroyEx(pSup->pResult, freeInterResult);
|
||||
taosArrayDestroy(pSup->pColsInfo);
|
||||
tfree(pSup);
|
||||
}
|
||||
|
||||
void tscFirstRoundRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) {
|
||||
SSqlObj* pSql = (SSqlObj*)tres;
|
||||
SSqlRes* pRes = &pSql->res;
|
||||
|
||||
SFirstRoundQuerySup* pSup = param;
|
||||
|
||||
SSqlObj* pParent = pSup->pParent;
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0);
|
||||
|
||||
int32_t code = taos_errno(pSql);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
destroySup(pSup);
|
||||
taos_free_result(pSql);
|
||||
pParent->res.code = code;
|
||||
tscAsyncResultOnError(pParent);
|
||||
return;
|
||||
}
|
||||
|
||||
if (numOfRows > 0) { // the number is not correct for group by column in super table query
|
||||
TAOS_ROW row = NULL;
|
||||
int32_t numOfCols = taos_field_count(tres);
|
||||
|
||||
if (pSup->tagLen == 0) { // no tags, all rows belong to one group
|
||||
SInterResult interResult = {.tags = NULL, .pResult = taosArrayInit(4, sizeof(SStddevInterResult))};
|
||||
taosArrayPush(pSup->pResult, &interResult);
|
||||
|
||||
while ((row = taos_fetch_row(tres)) != NULL) {
|
||||
doAppendData(&interResult, row, numOfCols, pQueryInfo);
|
||||
pSup->numOfRows += 1;
|
||||
}
|
||||
} else { // tagLen > 0
|
||||
char* p = calloc(1, pSup->tagLen);
|
||||
|
||||
while ((row = taos_fetch_row(tres)) != NULL) {
|
||||
int32_t* length = taos_fetch_lengths(tres);
|
||||
memset(p, 0, pSup->tagLen);
|
||||
|
||||
int32_t offset = 0;
|
||||
for (int32_t i = 0; i < numOfCols && offset < pSup->tagLen; ++i) {
|
||||
SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, i);
|
||||
|
||||
// tag or group by column
|
||||
if (TSDB_COL_IS_TAG(pExpr->colInfo.flag) || pExpr->functionId == TSDB_FUNC_PRJ) {
|
||||
memcpy(p + offset, row[i], length[i]);
|
||||
offset += pExpr->resBytes;
|
||||
}
|
||||
}
|
||||
|
||||
assert(offset == pSup->tagLen);
|
||||
size_t size = taosArrayGetSize(pSup->pResult);
|
||||
|
||||
if (size > 0) {
|
||||
SInterResult* pInterResult = taosArrayGetLast(pSup->pResult);
|
||||
if (memcmp(pInterResult->tags, p, pSup->tagLen) == 0) { // belongs to the same group
|
||||
doAppendData(pInterResult, row, numOfCols, pQueryInfo);
|
||||
} else {
|
||||
char* tags = malloc( pSup->tagLen);
|
||||
memcpy(tags, p, pSup->tagLen);
|
||||
|
||||
SInterResult interResult = {.tags = tags, .pResult = taosArrayInit(4, sizeof(SStddevInterResult))};
|
||||
taosArrayPush(pSup->pResult, &interResult);
|
||||
doAppendData(&interResult, row, numOfCols, pQueryInfo);
|
||||
}
|
||||
} else {
|
||||
char* tags = malloc(pSup->tagLen);
|
||||
memcpy(tags, p, pSup->tagLen);
|
||||
|
||||
SInterResult interResult = {.tags = tags, .pResult = taosArrayInit(4, sizeof(SStddevInterResult))};
|
||||
taosArrayPush(pSup->pResult, &interResult);
|
||||
doAppendData(&interResult, row, numOfCols, pQueryInfo);
|
||||
}
|
||||
|
||||
pSup->numOfRows += 1;
|
||||
}
|
||||
|
||||
tfree(p);
|
||||
}
|
||||
}
|
||||
|
||||
if (!pRes->completed) {
|
||||
taos_fetch_rows_a(tres, tscFirstRoundRetrieveCallback, param);
|
||||
return;
|
||||
}
|
||||
|
||||
// set the parameters for the second round query process
|
||||
SSqlCmd *pPCmd = &pParent->cmd;
|
||||
SQueryInfo *pQueryInfo1 = tscGetQueryInfoDetail(pPCmd, 0);
|
||||
|
||||
if (pSup->numOfRows > 0) {
|
||||
SBufferWriter bw = tbufInitWriter(NULL, false);
|
||||
interResToBinary(&bw, pSup->pResult, pSup->tagLen);
|
||||
|
||||
pQueryInfo1->bufLen = (int32_t) tbufTell(&bw);
|
||||
pQueryInfo1->buf = tbufGetData(&bw, true);
|
||||
|
||||
// set the serialized binary string as the parameter of arithmetic expression
|
||||
tbufCloseWriter(&bw);
|
||||
}
|
||||
|
||||
taosArrayDestroyEx(pSup->pResult, freeInterResult);
|
||||
taosArrayDestroy(pSup->pColsInfo);
|
||||
tfree(pSup);
|
||||
|
||||
taos_free_result(pSql);
|
||||
|
||||
pQueryInfo1->round = 1;
|
||||
tscDoQuery(pParent);
|
||||
}
|
||||
|
||||
void tscFirstRoundCallback(void* param, TAOS_RES* tres, int code) {
|
||||
SFirstRoundQuerySup* pSup = (SFirstRoundQuerySup*) param;
|
||||
|
||||
SSqlObj* pSql = (SSqlObj*) tres;
|
||||
int32_t c = taos_errno(pSql);
|
||||
|
||||
if (c != TSDB_CODE_SUCCESS) {
|
||||
SSqlObj* parent = pSup->pParent;
|
||||
|
||||
destroySup(pSup);
|
||||
taos_free_result(pSql);
|
||||
parent->res.code = code;
|
||||
tscAsyncResultOnError(parent);
|
||||
return;
|
||||
}
|
||||
|
||||
taos_fetch_rows_a(tres, tscFirstRoundRetrieveCallback, param);
|
||||
}
|
||||
|
||||
int32_t tscHandleFirstRoundStableQuery(SSqlObj *pSql) {
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0);
|
||||
STableMetaInfo* pTableMetaInfo1 = tscGetTableMetaInfoFromCmd(&pSql->cmd, 0, 0);
|
||||
|
||||
SFirstRoundQuerySup *pSup = calloc(1, sizeof(SFirstRoundQuerySup));
|
||||
|
||||
pSup->pParent = pSql;
|
||||
pSup->interval = pQueryInfo->interval.interval;
|
||||
pSup->pResult = taosArrayInit(6, sizeof(SStddevInterResult));
|
||||
pSup->pColsInfo = taosArrayInit(6, sizeof(int16_t)); // result column id
|
||||
|
||||
SSqlObj *pNew = createSubqueryObj(pSql, 0, tscFirstRoundCallback, pSup, TSDB_SQL_SELECT, NULL);
|
||||
SSqlCmd *pCmd = &pNew->cmd;
|
||||
|
||||
tscClearSubqueryInfo(pCmd);
|
||||
tscFreeSqlResult(pSql);
|
||||
|
||||
SQueryInfo* pNewQueryInfo = tscGetQueryInfoDetail(pCmd, 0);
|
||||
assert(pQueryInfo->numOfTables == 1);
|
||||
|
||||
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pNewQueryInfo, 0);
|
||||
|
||||
tscInitQueryInfo(pNewQueryInfo);
|
||||
pNewQueryInfo->groupbyExpr = pQueryInfo->groupbyExpr;
|
||||
if (pQueryInfo->groupbyExpr.columnInfo != NULL) {
|
||||
pNewQueryInfo->groupbyExpr.columnInfo = taosArrayDup(pQueryInfo->groupbyExpr.columnInfo);
|
||||
if (pNewQueryInfo->groupbyExpr.columnInfo == NULL) {
|
||||
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
goto _error;
|
||||
}
|
||||
}
|
||||
|
||||
if (tscTagCondCopy(&pNewQueryInfo->tagCond, &pQueryInfo->tagCond) != 0) {
|
||||
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
goto _error;
|
||||
}
|
||||
|
||||
pNewQueryInfo->interval = pQueryInfo->interval;
|
||||
|
||||
pCmd->command = TSDB_SQL_SELECT;
|
||||
pNew->fp = tscFirstRoundCallback;
|
||||
|
||||
int32_t numOfExprs = (int32_t) tscSqlExprNumOfExprs(pQueryInfo);
|
||||
|
||||
int32_t index = 0;
|
||||
for(int32_t i = 0; i < numOfExprs; ++i) {
|
||||
SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, i);
|
||||
if (pExpr->functionId == TSDB_FUNC_TS && pQueryInfo->interval.interval > 0) {
|
||||
taosArrayPush(pSup->pColsInfo, &pExpr->resColId);
|
||||
|
||||
SColumnIndex colIndex = {.tableIndex = 0, .columnIndex = PRIMARYKEY_TIMESTAMP_COL_INDEX};
|
||||
SSchema* schema = tscGetColumnSchemaById(pTableMetaInfo1->pTableMeta, pExpr->colInfo.colId);
|
||||
|
||||
SSqlExpr* p = tscAddFuncInSelectClause(pNewQueryInfo, index++, TSDB_FUNC_TS, &colIndex, schema, TSDB_COL_NORMAL);
|
||||
p->resColId = pExpr->resColId; // update the result column id
|
||||
} else if (pExpr->functionId == TSDB_FUNC_STDDEV_DST) {
|
||||
taosArrayPush(pSup->pColsInfo, &pExpr->resColId);
|
||||
|
||||
SColumnIndex colIndex = {.tableIndex = 0, .columnIndex = pExpr->colInfo.colIndex};
|
||||
SSchema schema = {.type = TSDB_DATA_TYPE_DOUBLE, .bytes = sizeof(double)};
|
||||
tstrncpy(schema.name, pExpr->aliasName, tListLen(schema.name));
|
||||
|
||||
SSqlExpr* p = tscAddFuncInSelectClause(pNewQueryInfo, index++, TSDB_FUNC_AVG, &colIndex, &schema, TSDB_COL_NORMAL);
|
||||
p->resColId = pExpr->resColId; // update the result column id
|
||||
} else if (pExpr->functionId == TSDB_FUNC_TAG) {
|
||||
pSup->tagLen += pExpr->resBytes;
|
||||
SColumnIndex colIndex = {.tableIndex = 0, .columnIndex = pExpr->colInfo.colIndex};
|
||||
|
||||
SSchema* schema = NULL;
|
||||
if (pExpr->colInfo.colId != TSDB_TBNAME_COLUMN_INDEX) {
|
||||
schema = tscGetColumnSchemaById(pTableMetaInfo1->pTableMeta, pExpr->colInfo.colId);
|
||||
} else {
|
||||
schema = tGetTbnameColumnSchema();
|
||||
}
|
||||
|
||||
SSqlExpr* p = tscAddFuncInSelectClause(pNewQueryInfo, index++, TSDB_FUNC_TAG, &colIndex, schema, TSDB_COL_TAG);
|
||||
p->resColId = pExpr->resColId;
|
||||
} else if (pExpr->functionId == TSDB_FUNC_PRJ) {
|
||||
int32_t num = (int32_t) taosArrayGetSize(pNewQueryInfo->groupbyExpr.columnInfo);
|
||||
for(int32_t k = 0; k < num; ++k) {
|
||||
SColIndex* pIndex = taosArrayGet(pNewQueryInfo->groupbyExpr.columnInfo, k);
|
||||
if (pExpr->colInfo.colId == pIndex->colId) {
|
||||
pSup->tagLen += pExpr->resBytes;
|
||||
taosArrayPush(pSup->pColsInfo, &pExpr->resColId);
|
||||
|
||||
SColumnIndex colIndex = {.tableIndex = 0, .columnIndex = pIndex->colIndex};
|
||||
SSchema* schema = tscGetColumnSchemaById(pTableMetaInfo1->pTableMeta, pExpr->colInfo.colId);
|
||||
|
||||
//doLimitOutputNormalColOfGroupby
|
||||
SSqlExpr* p = tscAddFuncInSelectClause(pNewQueryInfo, index++, TSDB_FUNC_PRJ, &colIndex, schema, TSDB_COL_NORMAL);
|
||||
p->numOfParams = 1;
|
||||
p->param[0].i64 = 1;
|
||||
p->param[0].nType = TSDB_DATA_TYPE_INT;
|
||||
p->resColId = pExpr->resColId; // update the result column id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SColumnIndex columnIndex = {.tableIndex = 0, .columnIndex = PRIMARYKEY_TIMESTAMP_COL_INDEX};
|
||||
tscInsertPrimaryTsSourceColumn(pNewQueryInfo, &columnIndex);
|
||||
|
||||
tscTansformFuncForSTableQuery(pNewQueryInfo);
|
||||
|
||||
tscDebug(
|
||||
"%p first round subquery:%p tableIndex:%d, vgroupIndex:%d, numOfVgroups:%d, type:%d, query to retrieve timestamps, "
|
||||
"numOfExpr:%" PRIzu ", colList:%d, numOfOutputFields:%d, name:%s",
|
||||
pSql, pNew, 0, pTableMetaInfo->vgroupIndex, pTableMetaInfo->vgroupList->numOfVgroups, pNewQueryInfo->type,
|
||||
tscSqlExprNumOfExprs(pNewQueryInfo), index+1, pNewQueryInfo->fieldsInfo.numOfOutput, tNameGetTableName(&pTableMetaInfo->name));
|
||||
|
||||
tscHandleMasterSTableQuery(pNew);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
||||
_error:
|
||||
destroySup(pSup);
|
||||
taos_free_result(pNew);
|
||||
pSql->res.code = terrno;
|
||||
tscAsyncResultOnError(pSql);
|
||||
return terrno;
|
||||
}
|
||||
|
||||
int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
|
||||
SSqlRes *pRes = &pSql->res;
|
||||
|
@ -1833,7 +2153,7 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
|
|||
return pRes->code;
|
||||
}
|
||||
|
||||
tExtMemBuffer ** pMemoryBuf = NULL;
|
||||
tExtMemBuffer **pMemoryBuf = NULL;
|
||||
tOrderDescriptor *pDesc = NULL;
|
||||
SColumnModel *pModel = NULL;
|
||||
SColumnModel *pFinalModel = NULL;
|
||||
|
@ -1862,11 +2182,9 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
|
|||
tfree(pMemoryBuf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
pSql->pSubs = calloc(pState->numOfSub, POINTER_BYTES);
|
||||
|
||||
tscDebug("%p retrieved query data from %d vnode(s)", pSql, pState->numOfSub);
|
||||
|
||||
pSql->pSubs = calloc(pState->numOfSub, POINTER_BYTES);
|
||||
if (pSql->pSubs == NULL) {
|
||||
tfree(pSql->pSubs);
|
||||
pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
|
@ -1991,7 +2309,9 @@ static void tscAbortFurtherRetryRetrieval(SRetrieveSupport *trsupport, TAOS_RES
|
|||
* current query failed, and the retry count is less than the available
|
||||
* count, retry query clear previous retrieved data, then launch a new sub query
|
||||
*/
|
||||
static int32_t tscReissueSubquery(SRetrieveSupport *oriTrs, SSqlObj *pSql, int32_t code) {
|
||||
static int32_t tscReissueSubquery(SRetrieveSupport *oriTrs, SSqlObj *pSql, int32_t code, int32_t *sent) {
|
||||
*sent = 0;
|
||||
|
||||
SRetrieveSupport *trsupport = malloc(sizeof(SRetrieveSupport));
|
||||
if (trsupport == NULL) {
|
||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
|
@ -2023,21 +2343,28 @@ static int32_t tscReissueSubquery(SRetrieveSupport *oriTrs, SSqlObj *pSql, int32
|
|||
SSqlObj *pNew = tscCreateSTableSubquery(trsupport->pParentSql, trsupport, pSql);
|
||||
if (pNew == NULL) {
|
||||
tscError("%p sub:%p failed to create new subquery due to error:%s, abort retry, vgId:%d, orderOfSub:%d",
|
||||
trsupport->pParentSql, pSql, tstrerror(terrno), pVgroup->vgId, trsupport->subqueryIndex);
|
||||
oriTrs->pParentSql, pSql, tstrerror(terrno), pVgroup->vgId, oriTrs->subqueryIndex);
|
||||
|
||||
pParentSql->res.code = terrno;
|
||||
trsupport->numOfRetry = MAX_NUM_OF_SUBQUERY_RETRY;
|
||||
oriTrs->numOfRetry = MAX_NUM_OF_SUBQUERY_RETRY;
|
||||
|
||||
tfree(trsupport);
|
||||
return pParentSql->res.code;
|
||||
}
|
||||
|
||||
int32_t ret = tscProcessSql(pNew);
|
||||
|
||||
*sent = 1;
|
||||
|
||||
// if failed to process sql, let following code handle the pSql
|
||||
if (ret == TSDB_CODE_SUCCESS) {
|
||||
tscFreeRetrieveSup(pSql);
|
||||
taos_free_result(pSql);
|
||||
return ret;
|
||||
} else {
|
||||
} else {
|
||||
pParentSql->pSubs[trsupport->subqueryIndex] = pSql;
|
||||
tscFreeRetrieveSup(pNew);
|
||||
taos_free_result(pNew);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
@ -2074,7 +2401,10 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO
|
|||
subqueryIndex, tstrerror(pParentSql->res.code));
|
||||
} else {
|
||||
if (trsupport->numOfRetry++ < MAX_NUM_OF_SUBQUERY_RETRY && pParentSql->res.code == TSDB_CODE_SUCCESS) {
|
||||
if (tscReissueSubquery(trsupport, pSql, numOfRows) == TSDB_CODE_SUCCESS) {
|
||||
int32_t sent = 0;
|
||||
|
||||
tscReissueSubquery(trsupport, pSql, numOfRows, &sent);
|
||||
if (sent) {
|
||||
return;
|
||||
}
|
||||
} else { // reach the maximum retry count, abort
|
||||
|
@ -2196,7 +2526,6 @@ static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfR
|
|||
SRetrieveSupport *trsupport = (SRetrieveSupport *)param;
|
||||
if (pSql->param == NULL || param == NULL) {
|
||||
tscDebug("%p already freed in dnodecallback", pSql);
|
||||
assert(pSql->res.code == TSDB_CODE_TSC_QUERY_CANCELLED);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2228,7 +2557,10 @@ static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfR
|
|||
if (trsupport->numOfRetry++ < MAX_NUM_OF_SUBQUERY_RETRY) {
|
||||
tscError("%p sub:%p failed code:%s, retry:%d", pParentSql, pSql, tstrerror(numOfRows), trsupport->numOfRetry);
|
||||
|
||||
if (tscReissueSubquery(trsupport, pSql, numOfRows) == TSDB_CODE_SUCCESS) {
|
||||
int32_t sent = 0;
|
||||
|
||||
tscReissueSubquery(trsupport, pSql, numOfRows, &sent);
|
||||
if (sent) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
@ -2350,7 +2682,11 @@ void tscRetrieveDataRes(void *param, TAOS_RES *tres, int code) {
|
|||
|
||||
if (trsupport->numOfRetry++ < MAX_NUM_OF_SUBQUERY_RETRY) {
|
||||
tscError("%p sub:%p failed code:%s, retry:%d", pParentSql, pSql, tstrerror(code), trsupport->numOfRetry);
|
||||
if (tscReissueSubquery(trsupport, pSql, code) == TSDB_CODE_SUCCESS) {
|
||||
|
||||
int32_t sent = 0;
|
||||
|
||||
tscReissueSubquery(trsupport, pSql, code, &sent);
|
||||
if (sent) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
@ -2410,7 +2746,7 @@ static void multiVnodeInsertFinalize(void* param, TAOS_RES* tres, int numOfRows)
|
|||
|
||||
// record the total inserted rows
|
||||
if (numOfRows > 0) {
|
||||
pParentObj->res.numOfRows += numOfRows;
|
||||
atomic_add_fetch_32(&pParentObj->res.numOfRows, numOfRows);
|
||||
}
|
||||
|
||||
if (taos_errno(tres) != TSDB_CODE_SUCCESS) {
|
||||
|
@ -2739,7 +3075,7 @@ void tscBuildResFromSubqueries(SSqlObj *pSql) {
|
|||
return;
|
||||
}
|
||||
|
||||
tscRestoreSQLFuncForSTableQuery(pQueryInfo);
|
||||
tscRestoreFuncForSTableQuery(pQueryInfo);
|
||||
}
|
||||
|
||||
assert (pRes->row >= pRes->numOfRows);
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#include "tref.h"
|
||||
#include "trpc.h"
|
||||
#include "tnote.h"
|
||||
#include "tsystem.h"
|
||||
#include "ttimer.h"
|
||||
#include "tutil.h"
|
||||
#include "tsched.h"
|
||||
|
@ -49,7 +48,7 @@ int32_t tscNumOfThreads = 1; // num of rpc threads
|
|||
static pthread_mutex_t rpcObjMutex; // mutex to protect open the rpc obj concurrently
|
||||
static pthread_once_t tscinit = PTHREAD_ONCE_INIT;
|
||||
|
||||
void tscCheckDiskUsage(void *UNUSED_PARAM(para), void* UNUSED_PARAM(param)) {
|
||||
void tscCheckDiskUsage(void *UNUSED_PARAM(para), void *UNUSED_PARAM(param)) {
|
||||
taosGetDisk();
|
||||
taosTmrReset(tscCheckDiskUsage, 1000, NULL, tscTmr, &tscCheckDiskUsageTmr);
|
||||
}
|
||||
|
@ -88,7 +87,7 @@ int32_t tscAcquireRpc(const char *key, const char *user, const char *secretEncry
|
|||
rpcInit.sessions = tsMaxConnections;
|
||||
rpcInit.connType = TAOS_CONN_CLIENT;
|
||||
rpcInit.user = (char *)user;
|
||||
rpcInit.idleTime = 2000;
|
||||
rpcInit.idleTime = tsShellActivityTimer * 1000;
|
||||
rpcInit.ckey = "key";
|
||||
rpcInit.spi = 1;
|
||||
rpcInit.secret = (char *)secretEncrypt;
|
||||
|
@ -102,7 +101,7 @@ int32_t tscAcquireRpc(const char *key, const char *user, const char *secretEncry
|
|||
tscError("failed to init connection to TDengine");
|
||||
return -1;
|
||||
}
|
||||
pRpcObj = taosCachePut(tscRpcCache, rpcObj.key, strlen(rpcObj.key), &rpcObj, sizeof(rpcObj), 1000*10);
|
||||
pRpcObj = taosCachePut(tscRpcCache, rpcObj.key, strlen(rpcObj.key), &rpcObj, sizeof(rpcObj), 1000*5);
|
||||
if (pRpcObj == NULL) {
|
||||
rpcClose(rpcObj.pDnodeConn);
|
||||
pthread_mutex_unlock(&rpcObjMutex);
|
||||
|
@ -155,6 +154,7 @@ void taos_init_imp(void) {
|
|||
if (tscNumOfThreads < 2) {
|
||||
tscNumOfThreads = 2;
|
||||
}
|
||||
taosTmrThreads = tscNumOfThreads;
|
||||
|
||||
tscQhandle = taosInitScheduler(queueSize, tscNumOfThreads, "tsc");
|
||||
if (NULL == tscQhandle) {
|
||||
|
@ -216,7 +216,6 @@ void taos_cleanup(void) {
|
|||
taosCloseRef(id);
|
||||
|
||||
taosCleanupKeywordsTable();
|
||||
taosCloseLog();
|
||||
|
||||
p = tscRpcCache;
|
||||
tscRpcCache = NULL;
|
||||
|
@ -226,7 +225,10 @@ void taos_cleanup(void) {
|
|||
pthread_mutex_destroy(&rpcObjMutex);
|
||||
}
|
||||
|
||||
if (tscEmbedded == 0) rpcCleanup();
|
||||
if (tscEmbedded == 0) {
|
||||
rpcCleanup();
|
||||
taosCloseLog();
|
||||
};
|
||||
|
||||
p = tscTmr;
|
||||
tscTmr = NULL;
|
||||
|
|
|
@ -107,11 +107,6 @@ bool tscIsTwoStageSTableQuery(SQueryInfo* pQueryInfo, int32_t tableIndex) {
|
|||
return false;
|
||||
}
|
||||
|
||||
// for select query super table, the super table vgroup list can not be null in any cases.
|
||||
// if (pQueryInfo->command == TSDB_SQL_SELECT && UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) {
|
||||
// assert(pTableMetaInfo->vgroupList != NULL);
|
||||
// }
|
||||
|
||||
if ((pQueryInfo->type & TSDB_QUERY_TYPE_FREE_RESOURCE) == TSDB_QUERY_TYPE_FREE_RESOURCE) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1074,7 +1069,7 @@ void tscFieldInfoClear(SFieldInfo* pFieldInfo) {
|
|||
memset(pFieldInfo, 0, sizeof(SFieldInfo));
|
||||
}
|
||||
|
||||
static SSqlExpr* doBuildSqlExpr(SQueryInfo* pQueryInfo, int16_t functionId, SColumnIndex* pColIndex, int16_t type,
|
||||
static SSqlExpr* doCreateSqlExpr(SQueryInfo* pQueryInfo, int16_t functionId, SColumnIndex* pColIndex, int16_t type,
|
||||
int16_t size, int16_t resColId, int16_t interSize, int32_t colType) {
|
||||
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, pColIndex->tableIndex);
|
||||
|
||||
|
@ -1127,14 +1122,14 @@ SSqlExpr* tscSqlExprInsert(SQueryInfo* pQueryInfo, int32_t index, int16_t functi
|
|||
return tscSqlExprAppend(pQueryInfo, functionId, pColIndex, type, size, resColId, interSize, isTagCol);
|
||||
}
|
||||
|
||||
SSqlExpr* pExpr = doBuildSqlExpr(pQueryInfo, functionId, pColIndex, type, size, resColId, interSize, isTagCol);
|
||||
SSqlExpr* pExpr = doCreateSqlExpr(pQueryInfo, functionId, pColIndex, type, size, resColId, interSize, isTagCol);
|
||||
taosArrayInsert(pQueryInfo->exprList, index, &pExpr);
|
||||
return pExpr;
|
||||
}
|
||||
|
||||
SSqlExpr* tscSqlExprAppend(SQueryInfo* pQueryInfo, int16_t functionId, SColumnIndex* pColIndex, int16_t type,
|
||||
int16_t size, int16_t resColId, int16_t interSize, bool isTagCol) {
|
||||
SSqlExpr* pExpr = doBuildSqlExpr(pQueryInfo, functionId, pColIndex, type, size, resColId, interSize, isTagCol);
|
||||
SSqlExpr* pExpr = doCreateSqlExpr(pQueryInfo, functionId, pColIndex, type, size, resColId, interSize, isTagCol);
|
||||
taosArrayPush(pQueryInfo->exprList, &pExpr);
|
||||
return pExpr;
|
||||
}
|
||||
|
@ -1158,6 +1153,22 @@ SSqlExpr* tscSqlExprUpdate(SQueryInfo* pQueryInfo, int32_t index, int16_t functi
|
|||
return pExpr;
|
||||
}
|
||||
|
||||
bool tscMultiRoundQuery(SQueryInfo* pQueryInfo, int32_t index) {
|
||||
if (!UTIL_TABLE_IS_SUPER_TABLE(pQueryInfo->pTableMetaInfo[index])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t numOfExprs = (int32_t) tscSqlExprNumOfExprs(pQueryInfo);
|
||||
for(int32_t i = 0; i < numOfExprs; ++i) {
|
||||
SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, i);
|
||||
if (pExpr->functionId == TSDB_FUNC_STDDEV_DST) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t tscSqlExprNumOfExprs(SQueryInfo* pQueryInfo) {
|
||||
return taosArrayGetSize(pQueryInfo->exprList);
|
||||
}
|
||||
|
@ -1422,9 +1433,9 @@ int32_t tscValidateName(SStrToken* pToken) {
|
|||
if (sep == NULL) { // single part
|
||||
if (pToken->type == TK_STRING) {
|
||||
|
||||
strdequote(pToken->z);
|
||||
tscDequoteAndTrimToken(pToken);
|
||||
tscStrToLower(pToken->z, pToken->n);
|
||||
pToken->n = (uint32_t)strtrim(pToken->z);
|
||||
//pToken->n = (uint32_t)strtrim(pToken->z);
|
||||
|
||||
int len = tSQLGetToken(pToken->z, &pToken->type);
|
||||
|
||||
|
@ -1762,6 +1773,7 @@ static void freeQueryInfoImpl(SQueryInfo* pQueryInfo) {
|
|||
pQueryInfo->tsBuf = tsBufDestroy(pQueryInfo->tsBuf);
|
||||
|
||||
tfree(pQueryInfo->fillVal);
|
||||
tfree(pQueryInfo->buf);
|
||||
}
|
||||
|
||||
void tscClearSubqueryInfo(SSqlCmd* pCmd) {
|
||||
|
@ -2029,7 +2041,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, __async_cb_func_t
|
|||
pNew->signature = pNew;
|
||||
pNew->sqlstr = strdup(pSql->sqlstr);
|
||||
|
||||
SSqlCmd* pnCmd = &pNew->cmd;
|
||||
SSqlCmd* pnCmd = &pNew->cmd;
|
||||
memcpy(pnCmd, pCmd, sizeof(SSqlCmd));
|
||||
|
||||
pnCmd->command = cmd;
|
||||
|
@ -2068,7 +2080,18 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, __async_cb_func_t
|
|||
pNewQueryInfo->clauseLimit = pQueryInfo->clauseLimit;
|
||||
pNewQueryInfo->numOfTables = 0;
|
||||
pNewQueryInfo->pTableMetaInfo = NULL;
|
||||
|
||||
pNewQueryInfo->bufLen = pQueryInfo->bufLen;
|
||||
|
||||
pNewQueryInfo->buf = malloc(pQueryInfo->bufLen);
|
||||
if (pNewQueryInfo->buf == NULL) {
|
||||
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
goto _error;
|
||||
}
|
||||
|
||||
if (pQueryInfo->bufLen > 0) {
|
||||
memcpy(pNewQueryInfo->buf, pQueryInfo->buf, pQueryInfo->bufLen);
|
||||
}
|
||||
|
||||
pNewQueryInfo->groupbyExpr = pQueryInfo->groupbyExpr;
|
||||
if (pQueryInfo->groupbyExpr.columnInfo != NULL) {
|
||||
pNewQueryInfo->groupbyExpr.columnInfo = taosArrayDup(pQueryInfo->groupbyExpr.columnInfo);
|
||||
|
@ -2234,6 +2257,9 @@ void tscDoQuery(SSqlObj* pSql) {
|
|||
}
|
||||
}
|
||||
|
||||
return;
|
||||
} else if (tscMultiRoundQuery(pQueryInfo, 0) && pQueryInfo->round == 0) {
|
||||
tscHandleFirstRoundStableQuery(pSql); // todo lock?
|
||||
return;
|
||||
} else if (tscIsTwoStageSTableQuery(pQueryInfo, 0)) { // super table query
|
||||
tscLockByThread(&pSql->squeryLock);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CMAKE_MINIMUM_REQUIRED(VERSION 3.5)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
PROJECT(TDengine)
|
||||
|
||||
FIND_PATH(HEADER_GTEST_INCLUDE_DIR gtest.h /usr/include/gtest /usr/local/include/gtest)
|
||||
|
|
|
@ -57,7 +57,7 @@ void stmtInsertTest() {
|
|||
v.ts = start_ts + 20;
|
||||
v.k = 123;
|
||||
|
||||
char* str = "abc";
|
||||
char str[] = "abc";
|
||||
uintptr_t len = strlen(str);
|
||||
|
||||
v.a = str;
|
||||
|
@ -65,7 +65,7 @@ void stmtInsertTest() {
|
|||
params[2].buffer_length = len;
|
||||
params[2].buffer = str;
|
||||
|
||||
char* nstr = "999";
|
||||
char nstr[] = "999";
|
||||
uintptr_t len1 = strlen(nstr);
|
||||
|
||||
v.b = nstr;
|
||||
|
@ -84,18 +84,18 @@ void stmtInsertTest() {
|
|||
v.ts = start_ts + 30;
|
||||
v.k = 911;
|
||||
|
||||
str = "92";
|
||||
len = strlen(str);
|
||||
char str1[] = "92";
|
||||
len = strlen(str1);
|
||||
|
||||
params[2].length = &len;
|
||||
params[2].buffer_length = len;
|
||||
params[2].buffer = str;
|
||||
params[2].buffer = str1;
|
||||
|
||||
nstr = "1920";
|
||||
len1 = strlen(nstr);
|
||||
char nstr1[] = "1920";
|
||||
len1 = strlen(nstr1);
|
||||
|
||||
params[3].buffer_length = len1;
|
||||
params[3].buffer = nstr;
|
||||
params[3].buffer = nstr1;
|
||||
params[3].length = &len1;
|
||||
|
||||
taos_stmt_bind_param(stmt, params);
|
||||
|
@ -103,7 +103,7 @@ void stmtInsertTest() {
|
|||
|
||||
ret = taos_stmt_execute(stmt);
|
||||
if (ret != 0) {
|
||||
printf("%p\n", ret);
|
||||
printf("%d\n", ret);
|
||||
printf("\033[31mfailed to execute insert statement.\033[0m\n");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CMAKE_MINIMUM_REQUIRED(VERSION 3.5)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
PROJECT(TDengine)
|
||||
|
||||
INCLUDE_DIRECTORIES(inc)
|
||||
|
|
|
@ -68,9 +68,9 @@ typedef struct {
|
|||
typedef struct {
|
||||
int version; // version
|
||||
int numOfCols; // Number of columns appended
|
||||
int tlen; // maximum length of a SDataRow without the header part
|
||||
int tlen; // maximum length of a SDataRow without the header part (sizeof(VarDataOffsetT) + sizeof(VarDataLenT) + (bytes))
|
||||
uint16_t flen; // First part length in a SDataRow after the header part
|
||||
uint16_t vlen; // pure value part length, excluded the overhead
|
||||
uint16_t vlen; // pure value part length, excluded the overhead (bytes only)
|
||||
STColumn columns[];
|
||||
} STSchema;
|
||||
|
||||
|
@ -134,6 +134,22 @@ typedef uint64_t TKEY;
|
|||
#define tdGetTKEY(key) (((TKEY)ABS(key)) | (TKEY_NEGATIVE_FLAG & (TKEY)(key)))
|
||||
#define tdGetKey(tkey) (((TSKEY)((tkey)&TKEY_VALUE_FILTER)) * (TKEY_IS_NEGATIVE(tkey) ? -1 : 1))
|
||||
|
||||
#define MIN_TS_KEY ((TSKEY)0x8000000000000001)
|
||||
#define MAX_TS_KEY ((TSKEY)0x3fffffffffffffff)
|
||||
|
||||
#define TD_TO_TKEY(key) tdGetTKEY(((key) < MIN_TS_KEY) ? MIN_TS_KEY : (((key) > MAX_TS_KEY) ? MAX_TS_KEY : key))
|
||||
|
||||
static FORCE_INLINE TKEY keyToTkey(TSKEY key) {
|
||||
TSKEY lkey = key;
|
||||
if (key > MAX_TS_KEY) {
|
||||
lkey = MAX_TS_KEY;
|
||||
} else if (key < MIN_TS_KEY) {
|
||||
lkey = MIN_TS_KEY;
|
||||
}
|
||||
|
||||
return tdGetTKEY(lkey);
|
||||
}
|
||||
|
||||
static FORCE_INLINE int tkeyComparFn(const void *tkey1, const void *tkey2) {
|
||||
TSKEY key1 = tdGetKey(*(TKEY *)tkey1);
|
||||
TSKEY key2 = tdGetKey(*(TKEY *)tkey2);
|
||||
|
@ -278,7 +294,7 @@ SDataCols *tdNewDataCols(int maxRowSize, int maxCols, int maxRows);
|
|||
void tdResetDataCols(SDataCols *pCols);
|
||||
int tdInitDataCols(SDataCols *pCols, STSchema *pSchema);
|
||||
SDataCols *tdDupDataCols(SDataCols *pCols, bool keepData);
|
||||
void tdFreeDataCols(SDataCols *pCols);
|
||||
SDataCols *tdFreeDataCols(SDataCols *pCols);
|
||||
void tdAppendDataRowToDataCol(SDataRow row, STSchema *pSchema, SDataCols *pCols);
|
||||
int tdMergeDataCols(SDataCols *target, SDataCols *src, int rowsToMerge);
|
||||
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
#ifndef TDENGINE_COMMON_GLOBAL_H
|
||||
#define TDENGINE_COMMON_GLOBAL_H
|
||||
|
||||
#include "taosdef.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -147,7 +149,6 @@ extern char tsDataDir[];
|
|||
extern char tsLogDir[];
|
||||
extern char tsScriptDir[];
|
||||
extern int64_t tsMsPerDay[3];
|
||||
extern char tsVnodeBakDir[];
|
||||
|
||||
// system info
|
||||
extern char tsOsName[];
|
||||
|
@ -196,6 +197,14 @@ extern int32_t wDebugFlag;
|
|||
extern int32_t cqDebugFlag;
|
||||
extern int32_t debugFlag;
|
||||
|
||||
typedef struct {
|
||||
char dir[TSDB_FILENAME_LEN];
|
||||
int level;
|
||||
int primary;
|
||||
} SDiskCfg;
|
||||
extern int32_t tsDiskCfgNum;
|
||||
extern SDiskCfg tsDiskCfg[];
|
||||
|
||||
#define NEEDTO_COMPRESSS_MSG(size) (tsCompressMsgSize != -1 && (size) > tsCompressMsgSize)
|
||||
|
||||
void taosInitGlobalCfg();
|
||||
|
@ -204,6 +213,9 @@ void taosSetAllDebugFlag();
|
|||
bool taosCfgDynamicOptions(char *msg);
|
||||
int taosGetFqdnPortFromEp(const char *ep, char *fqdn, uint16_t *port);
|
||||
bool taosCheckBalanceCfgOptions(const char *option, int32_t *vnodeId, int32_t *dnodeId);
|
||||
void taosAddDataDir(int index, char *v1, int level, int primary);
|
||||
void taosReadDataDirCfg(char *v1, char *v2, char *v3);
|
||||
void taosPrintDataDirCfg();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -36,6 +36,11 @@ typedef struct SColumnInfoData {
|
|||
void* pData; // the corresponding block data in memory
|
||||
} SColumnInfoData;
|
||||
|
||||
typedef struct SResPair {
|
||||
TSKEY key;
|
||||
double avg;
|
||||
} SResPair;
|
||||
|
||||
#define TSDB_DB_NAME_T 1
|
||||
#define TSDB_TABLE_NAME_T 2
|
||||
|
||||
|
@ -58,7 +63,7 @@ size_t tableIdPrefix(const char* name, char* prefix, int32_t len);
|
|||
|
||||
void extractTableNameFromToken(SStrToken *pToken, SStrToken* pTable);
|
||||
|
||||
SSchema tGetTableNameColumnSchema();
|
||||
//SSchema tGetTbnameColumnSchema();
|
||||
|
||||
SSchema tGetBlockDistColumnSchema();
|
||||
|
||||
|
@ -68,7 +73,7 @@ bool tscValidateTableNameLength(size_t len);
|
|||
|
||||
SColumnFilterInfo* tFilterInfoDup(const SColumnFilterInfo* src, int32_t numOfFilters);
|
||||
|
||||
SSchema tGetTbnameColumnSchema();
|
||||
SSchema* tGetTbnameColumnSchema();
|
||||
|
||||
/**
|
||||
* check if the schema is valid or not, including following aspects:
|
||||
|
|
|
@ -289,23 +289,31 @@ SDataCols *tdNewDataCols(int maxRowSize, int maxCols, int maxRows) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
pCols->cols = (SDataCol *)calloc(maxCols, sizeof(SDataCol));
|
||||
if (pCols->cols == NULL) {
|
||||
uDebug("malloc failure, size:%" PRId64 " failed, reason:%s", (int64_t)sizeof(SDataCol) * maxCols, strerror(errno));
|
||||
tdFreeDataCols(pCols);
|
||||
return NULL;
|
||||
pCols->maxPoints = maxRows;
|
||||
|
||||
if (maxCols > 0) {
|
||||
pCols->cols = (SDataCol *)calloc(maxCols, sizeof(SDataCol));
|
||||
if (pCols->cols == NULL) {
|
||||
uDebug("malloc failure, size:%" PRId64 " failed, reason:%s", (int64_t)sizeof(SDataCol) * maxCols,
|
||||
strerror(errno));
|
||||
tdFreeDataCols(pCols);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pCols->maxCols = maxCols;
|
||||
}
|
||||
|
||||
pCols->maxRowSize = maxRowSize;
|
||||
pCols->maxCols = maxCols;
|
||||
pCols->maxPoints = maxRows;
|
||||
pCols->bufSize = maxRowSize * maxRows;
|
||||
|
||||
pCols->buf = malloc(pCols->bufSize);
|
||||
if (pCols->buf == NULL) {
|
||||
uDebug("malloc failure, size:%" PRId64 " failed, reason:%s", (int64_t)sizeof(SDataCol) * maxCols, strerror(errno));
|
||||
tdFreeDataCols(pCols);
|
||||
return NULL;
|
||||
if (pCols->bufSize > 0) {
|
||||
pCols->buf = malloc(pCols->bufSize);
|
||||
if (pCols->buf == NULL) {
|
||||
uDebug("malloc failure, size:%" PRId64 " failed, reason:%s", (int64_t)sizeof(SDataCol) * maxCols,
|
||||
strerror(errno));
|
||||
tdFreeDataCols(pCols);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return pCols;
|
||||
|
@ -337,12 +345,13 @@ int tdInitDataCols(SDataCols *pCols, STSchema *pSchema) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void tdFreeDataCols(SDataCols *pCols) {
|
||||
SDataCols *tdFreeDataCols(SDataCols *pCols) {
|
||||
if (pCols) {
|
||||
tfree(pCols->buf);
|
||||
tfree(pCols->cols);
|
||||
free(pCols);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SDataCols *tdDupDataCols(SDataCols *pDataCols, bool keepData) {
|
||||
|
|
|
@ -407,7 +407,7 @@ tExprNode* exprTreeFromTableName(const char* tbnameCond) {
|
|||
SSchema* pSchema = exception_calloc(1, sizeof(SSchema));
|
||||
left->pSchema = pSchema;
|
||||
|
||||
*pSchema = tGetTbnameColumnSchema();
|
||||
*pSchema = *tGetTbnameColumnSchema();
|
||||
|
||||
tExprNode* right = exception_calloc(1, sizeof(tExprNode));
|
||||
expr->_node.pRight = right;
|
||||
|
|
|
@ -59,7 +59,6 @@ char tsLocale[TSDB_LOCALE_LEN] = {0};
|
|||
char tsCharset[TSDB_LOCALE_LEN] = {0}; // default encode string
|
||||
int8_t tsEnableCoreFile = 0;
|
||||
int32_t tsMaxBinaryDisplayWidth = 30;
|
||||
char tsTempDir[TSDB_FILENAME_LEN] = "/tmp/";
|
||||
|
||||
/*
|
||||
* denote if the server needs to compress response message at the application layer to client, including query rsp,
|
||||
|
@ -182,7 +181,15 @@ char tsDnodeDir[TSDB_FILENAME_LEN] = {0};
|
|||
char tsMnodeDir[TSDB_FILENAME_LEN] = {0};
|
||||
char tsDataDir[TSDB_FILENAME_LEN] = {0};
|
||||
char tsScriptDir[TSDB_FILENAME_LEN] = {0};
|
||||
char tsVnodeBakDir[TSDB_FILENAME_LEN] = {0};
|
||||
char tsTempDir[TSDB_FILENAME_LEN] = "/tmp/";
|
||||
|
||||
int32_t tsDiskCfgNum = 0;
|
||||
|
||||
#ifndef _STORAGE
|
||||
SDiskCfg tsDiskCfg[1];
|
||||
#else
|
||||
SDiskCfg tsDiskCfg[TSDB_MAX_DISKS];
|
||||
#endif
|
||||
|
||||
/*
|
||||
* minimum scale for whole system, millisecond by default
|
||||
|
@ -227,6 +234,7 @@ int32_t sDebugFlag = 135;
|
|||
int32_t wDebugFlag = 135;
|
||||
int32_t tsdbDebugFlag = 131;
|
||||
int32_t cqDebugFlag = 131;
|
||||
int32_t fsDebugFlag = 135;
|
||||
|
||||
int32_t (*monStartSystemFp)() = NULL;
|
||||
void (*monStopSystemFp)() = NULL;
|
||||
|
@ -265,7 +273,7 @@ bool taosCfgDynamicOptions(char *msg) {
|
|||
int32_t vint = 0;
|
||||
|
||||
paGetToken(msg, &option, &olen);
|
||||
if (olen == 0) return TSDB_CODE_COM_INVALID_CFG_MSG;
|
||||
if (olen == 0) return false;;
|
||||
|
||||
paGetToken(option + olen + 1, &value, &vlen);
|
||||
if (vlen == 0)
|
||||
|
@ -308,11 +316,9 @@ bool taosCfgDynamicOptions(char *msg) {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (strncasecmp(cfg->option, "debugFlag", olen) == 0) {
|
||||
taosSetAllDebugFlag();
|
||||
taosSetAllDebugFlag();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -334,6 +340,39 @@ bool taosCfgDynamicOptions(char *msg) {
|
|||
return false;
|
||||
}
|
||||
|
||||
void taosAddDataDir(int index, char *v1, int level, int primary) {
|
||||
tstrncpy(tsDiskCfg[index].dir, v1, TSDB_FILENAME_LEN);
|
||||
tsDiskCfg[index].level = level;
|
||||
tsDiskCfg[index].primary = primary;
|
||||
uTrace("dataDir:%s, level:%d primary:%d is configured", v1, level, primary);
|
||||
}
|
||||
|
||||
#ifndef _STORAGE
|
||||
void taosReadDataDirCfg(char *v1, char *v2, char *v3) {
|
||||
if (tsDiskCfgNum == 1) {
|
||||
SDiskCfg *cfg = &tsDiskCfg[0];
|
||||
uInfo("dataDir:%s, level:%d primary:%d is replaced by %s", cfg->dir, cfg->level, cfg->primary, v1);
|
||||
}
|
||||
taosAddDataDir(0, v1, 0, 1);
|
||||
tsDiskCfgNum = 1;
|
||||
}
|
||||
|
||||
void taosPrintDataDirCfg() {
|
||||
for (int i = 0; i < tsDiskCfgNum; ++i) {
|
||||
SDiskCfg *cfg = &tsDiskCfg[i];
|
||||
uInfo(" dataDir: %s", cfg->dir);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void taosCheckDataDirCfg() {
|
||||
if (tsDiskCfgNum <= 0) {
|
||||
taosAddDataDir(0, tsDataDir, 0, 1);
|
||||
tsDiskCfgNum = 1;
|
||||
uTrace("dataDir:%s, level:0 primary:1 is configured by default", tsDataDir);
|
||||
}
|
||||
}
|
||||
|
||||
static void doInitGlobalConfig(void) {
|
||||
osInit();
|
||||
srand(taosSafeRand());
|
||||
|
@ -415,7 +454,7 @@ static void doInitGlobalConfig(void) {
|
|||
|
||||
cfg.option = "dataDir";
|
||||
cfg.ptr = tsDataDir;
|
||||
cfg.valType = TAOS_CFG_VTYPE_DIRECTORY;
|
||||
cfg.valType = TAOS_CFG_VTYPE_DATA_DIRCTORY;
|
||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG;
|
||||
cfg.minValue = 0;
|
||||
cfg.maxValue = 0;
|
||||
|
@ -1448,6 +1487,7 @@ int32_t taosCheckGlobalCfg() {
|
|||
snprintf(tsSecond, sizeof(tsSecond), "%s:%u", fqdn, port);
|
||||
}
|
||||
|
||||
taosCheckDataDirCfg();
|
||||
taosGetSystemInfo();
|
||||
|
||||
tsSetLocale();
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#define VALID_NAME_TYPE(x) ((x) == TSDB_DB_NAME_T || (x) == TSDB_TABLE_NAME_T)
|
||||
|
||||
//TODO remove it
|
||||
void extractTableName(const char* tableId, char* name) {
|
||||
size_t s1 = strcspn(tableId, &TS_PATH_DELIMITER[0]);
|
||||
size_t s2 = strcspn(&tableId[s1 + 1], &TS_PATH_DELIMITER[0]);
|
||||
|
@ -24,6 +25,7 @@ char* extractDBName(const char* tableId, char* name) {
|
|||
return strncpy(name, &tableId[offset1 + 1], len);
|
||||
}
|
||||
|
||||
// todo remove it
|
||||
size_t tableIdPrefix(const char* name, char* prefix, int32_t len) {
|
||||
tstrncpy(prefix, name, len);
|
||||
strcat(prefix, TS_PATH_DELIMITER);
|
||||
|
@ -31,14 +33,6 @@ size_t tableIdPrefix(const char* name, char* prefix, int32_t len) {
|
|||
return strlen(prefix);
|
||||
}
|
||||
|
||||
SSchema tGetTableNameColumnSchema() {
|
||||
SSchema s = {0};
|
||||
s.bytes = TSDB_TABLE_NAME_LEN - 1 + VARSTR_HEADER_SIZE;
|
||||
s.type = TSDB_DATA_TYPE_BINARY;
|
||||
s.colId = TSDB_TBNAME_COLUMN_INDEX;
|
||||
tstrncpy(s.name, TSQL_TBNAME_L, TSDB_COL_NAME_LEN);
|
||||
return s;
|
||||
}
|
||||
SSchema tGetBlockDistColumnSchema() {
|
||||
SSchema s = {0};
|
||||
s.bytes = TSDB_MAX_BINARY_LEN;;
|
||||
|
@ -189,15 +183,15 @@ void extractTableNameFromToken(SStrToken* pToken, SStrToken* pTable) {
|
|||
}
|
||||
}
|
||||
|
||||
SSchema tGetTbnameColumnSchema() {
|
||||
struct SSchema s = {
|
||||
.colId = TSDB_TBNAME_COLUMN_INDEX,
|
||||
.type = TSDB_DATA_TYPE_BINARY,
|
||||
.bytes = TSDB_TABLE_NAME_LEN
|
||||
};
|
||||
static struct SSchema _s = {
|
||||
.colId = TSDB_TBNAME_COLUMN_INDEX,
|
||||
.type = TSDB_DATA_TYPE_BINARY,
|
||||
.bytes = TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE,
|
||||
.name = TSQL_TBNAME_L,
|
||||
};
|
||||
|
||||
strcpy(s.name, TSQL_TBNAME_L);
|
||||
return s;
|
||||
SSchema* tGetTbnameColumnSchema() {
|
||||
return &_s;
|
||||
}
|
||||
|
||||
static bool doValidateSchema(SSchema* pSchema, int32_t numOfCols, int32_t maxLen) {
|
||||
|
|
|
@ -86,43 +86,53 @@ void tVariantCreateFromBinary(tVariant *pVar, const char *pz, size_t len, uint32
|
|||
switch (type) {
|
||||
case TSDB_DATA_TYPE_BOOL:
|
||||
case TSDB_DATA_TYPE_TINYINT: {
|
||||
pVar->nLen = tDataTypes[type].bytes;
|
||||
pVar->i64 = GET_INT8_VAL(pz);
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_UTINYINT: {
|
||||
pVar->nLen = tDataTypes[type].bytes;
|
||||
pVar->u64 = GET_UINT8_VAL(pz);
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_SMALLINT: {
|
||||
pVar->nLen = tDataTypes[type].bytes;
|
||||
pVar->i64 = GET_INT16_VAL(pz);
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_USMALLINT: {
|
||||
pVar->nLen = tDataTypes[type].bytes;
|
||||
pVar->u64 = GET_UINT16_VAL(pz);
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_INT: {
|
||||
pVar->nLen = tDataTypes[type].bytes;
|
||||
pVar->i64 = GET_INT32_VAL(pz);
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_UINT: {
|
||||
pVar->nLen = tDataTypes[type].bytes;
|
||||
pVar->u64 = GET_UINT32_VAL(pz);
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_BIGINT:
|
||||
case TSDB_DATA_TYPE_TIMESTAMP: {
|
||||
pVar->nLen = tDataTypes[type].bytes;
|
||||
pVar->i64 = GET_INT64_VAL(pz);
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_UBIGINT: {
|
||||
pVar->nLen = tDataTypes[type].bytes;
|
||||
pVar->u64 = GET_UINT64_VAL(pz);
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_DOUBLE: {
|
||||
pVar->nLen = tDataTypes[type].bytes;
|
||||
pVar->dKey = GET_DOUBLE_VAL(pz);
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_FLOAT: {
|
||||
pVar->nLen = tDataTypes[type].bytes;
|
||||
pVar->dKey = GET_FLOAT_VAL(pz);
|
||||
break;
|
||||
}
|
||||
|
@ -144,6 +154,7 @@ void tVariantCreateFromBinary(tVariant *pVar, const char *pz, size_t len, uint32
|
|||
|
||||
default:
|
||||
pVar->i64 = GET_INT32_VAL(pz);
|
||||
pVar->nLen = tDataTypes[TSDB_DATA_TYPE_INT].bytes;
|
||||
}
|
||||
|
||||
pVar->nType = type;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CMAKE_MINIMUM_REQUIRED(VERSION 3.5)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
|
||||
PROJECT(TDengine)
|
||||
|
||||
|
@ -8,7 +8,7 @@ IF (TD_MVN_INSTALLED)
|
|||
ADD_CUSTOM_COMMAND(OUTPUT ${JDBC_CMD_NAME}
|
||||
POST_BUILD
|
||||
COMMAND mvn -Dmaven.test.skip=true install -f ${CMAKE_CURRENT_SOURCE_DIR}/pom.xml
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/target/taos-jdbcdriver-2.0.18-dist.jar ${LIBRARY_OUTPUT_PATH}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/target/taos-jdbcdriver-2.0.19-dist.jar ${LIBRARY_OUTPUT_PATH}
|
||||
COMMAND mvn -Dmaven.test.skip=true clean -f ${CMAKE_CURRENT_SOURCE_DIR}/pom.xml
|
||||
COMMENT "build jdbc driver")
|
||||
ADD_CUSTOM_TARGET(${JDBC_TARGET_NAME} ALL WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} DEPENDS ${JDBC_CMD_NAME})
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
<groupId>com.taosdata.jdbc</groupId>
|
||||
<artifactId>taos-jdbcdriver</artifactId>
|
||||
<version>2.0.18</version>
|
||||
<version>2.0.19</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>JDBCDriver</name>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.taosdata.jdbc</groupId>
|
||||
<artifactId>taos-jdbcdriver</artifactId>
|
||||
<version>2.0.18</version>
|
||||
<version>2.0.19</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>JDBCDriver</name>
|
||||
<url>https://github.com/taosdata/TDengine/tree/master/src/connector/jdbc</url>
|
||||
|
@ -36,6 +36,7 @@
|
|||
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
|
||||
<commons-logging.version>1.1.2</commons-logging.version>
|
||||
<commons-lang3.version>3.5</commons-lang3.version>
|
||||
<maven.test.jvmargs></maven.test.jvmargs>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
@ -80,8 +81,6 @@
|
|||
<artifactId>commons-dbcp2</artifactId>
|
||||
<version>2.7.0</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -122,12 +121,16 @@
|
|||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.12.4</version>
|
||||
<configuration>
|
||||
<forkMode>pertest</forkMode>
|
||||
<argLine>${maven.test.jvmargs}</argLine>
|
||||
<includes>
|
||||
<include>**/*Test.java</include>
|
||||
</includes>
|
||||
<excludes>
|
||||
<exclude>**/AppMemoryLeakTest.java</exclude>
|
||||
<exclude>**/TaosInfoMonitorTest.java</exclude>
|
||||
<exclude>**/FailOverTest.java</exclude>
|
||||
<exclude>**/InvalidResultSetPointerTest.java</exclude>
|
||||
</excludes>
|
||||
<testFailureIgnore>true</testFailureIgnore>
|
||||
</configuration>
|
||||
|
|
|
@ -8,7 +8,7 @@ import java.util.List;
|
|||
import java.util.Properties;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
public abstract class AbstractTaosDriver implements Driver {
|
||||
public abstract class AbstractDriver implements Driver {
|
||||
|
||||
private static final String TAOS_CFG_FILENAME = "taos.cfg";
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,249 @@
|
|||
package com.taosdata.jdbc;
|
||||
|
||||
import java.sql.*;
|
||||
|
||||
public abstract class AbstractStatement extends WrapperImpl implements Statement {
|
||||
|
||||
private volatile boolean closeOnCompletion;
|
||||
private int fetchSize;
|
||||
|
||||
@Override
|
||||
public abstract ResultSet executeQuery(String sql) throws SQLException;
|
||||
|
||||
@Override
|
||||
public abstract int executeUpdate(String sql) throws SQLException;
|
||||
|
||||
@Override
|
||||
public abstract void close() throws SQLException;
|
||||
|
||||
@Override
|
||||
public int getMaxFieldSize() throws SQLException {
|
||||
if (isClosed())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
|
||||
return TSDBConstants.maxFieldSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxFieldSize(int max) throws SQLException {
|
||||
if (isClosed())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
|
||||
if (max < 0)
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_VARIABLE);
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxRows() throws SQLException {
|
||||
if (isClosed())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxRows(int max) throws SQLException {
|
||||
if (isClosed())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
|
||||
if (max < 0)
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_VARIABLE);
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEscapeProcessing(boolean enable) throws SQLException {
|
||||
if (isClosed())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getQueryTimeout() throws SQLException {
|
||||
if (isClosed())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setQueryTimeout(int seconds) throws SQLException {
|
||||
if (isClosed())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
|
||||
if (seconds < 0)
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_VARIABLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() throws SQLException {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SQLWarning getWarnings() throws SQLException {
|
||||
if (isClosed())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearWarnings() throws SQLException {
|
||||
// nothing to do
|
||||
if (isClosed())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCursorName(String name) throws SQLException {
|
||||
if (isClosed())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract boolean execute(String sql) throws SQLException;
|
||||
|
||||
@Override
|
||||
public abstract ResultSet getResultSet() throws SQLException;
|
||||
|
||||
@Override
|
||||
public abstract int getUpdateCount() throws SQLException;
|
||||
|
||||
@Override
|
||||
public boolean getMoreResults() throws SQLException {
|
||||
return getMoreResults(CLOSE_CURRENT_RESULT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFetchDirection(int direction) throws SQLException {
|
||||
if (isClosed())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
|
||||
//nothing to do
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFetchDirection() throws SQLException {
|
||||
if (isClosed())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
|
||||
return ResultSet.FETCH_FORWARD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFetchSize(int rows) throws SQLException {
|
||||
if (isClosed())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
|
||||
if (rows < 0)
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_VARIABLE);
|
||||
//nothing to do
|
||||
this.fetchSize = rows;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFetchSize() throws SQLException {
|
||||
if (isClosed())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
|
||||
return this.fetchSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getResultSetConcurrency() throws SQLException {
|
||||
if (isClosed())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
|
||||
return ResultSet.CONCUR_READ_ONLY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getResultSetType() throws SQLException {
|
||||
if (isClosed())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
|
||||
return ResultSet.TYPE_FORWARD_ONLY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract void addBatch(String sql) throws SQLException;
|
||||
|
||||
@Override
|
||||
public abstract void clearBatch() throws SQLException;
|
||||
|
||||
@Override
|
||||
public abstract int[] executeBatch() throws SQLException;
|
||||
|
||||
@Override
|
||||
public abstract Connection getConnection() throws SQLException;
|
||||
|
||||
@Override
|
||||
public boolean getMoreResults(int current) throws SQLException {
|
||||
if (isClosed())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultSet getGeneratedKeys() throws SQLException {
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException {
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int executeUpdate(String sql, int[] columnIndexes) throws SQLException {
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int executeUpdate(String sql, String[] columnNames) throws SQLException {
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(String sql, int autoGeneratedKeys) throws SQLException {
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(String sql, int[] columnIndexes) throws SQLException {
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(String sql, String[] columnNames) throws SQLException {
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getResultSetHoldability() throws SQLException {
|
||||
if (isClosed())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
|
||||
return ResultSet.HOLD_CURSORS_OVER_COMMIT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract boolean isClosed() throws SQLException;
|
||||
|
||||
@Override
|
||||
public void setPoolable(boolean poolable) throws SQLException {
|
||||
if (isClosed())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
|
||||
//nothing to do
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPoolable() throws SQLException {
|
||||
if (isClosed())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeOnCompletion() throws SQLException {
|
||||
if (isClosed())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
|
||||
this.closeOnCompletion = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCloseOnCompletion() throws SQLException {
|
||||
if (isClosed())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
|
||||
return this.closeOnCompletion;
|
||||
}
|
||||
|
||||
}
|
|
@ -160,12 +160,12 @@ public class DatabaseMetaDataResultSet implements ResultSet {
|
|||
|
||||
@Override
|
||||
public Date getDate(int columnIndex) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Time getTime(int columnIndex) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -176,17 +176,17 @@ public class DatabaseMetaDataResultSet implements ResultSet {
|
|||
|
||||
@Override
|
||||
public InputStream getAsciiStream(int columnIndex) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getUnicodeStream(int columnIndex) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getBinaryStream(int columnIndex) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -256,22 +256,22 @@ public class DatabaseMetaDataResultSet implements ResultSet {
|
|||
|
||||
@Override
|
||||
public InputStream getAsciiStream(String columnLabel) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getUnicodeStream(String columnLabel) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getBinaryStream(String columnLabel) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SQLWarning getWarnings() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -281,7 +281,7 @@ public class DatabaseMetaDataResultSet implements ResultSet {
|
|||
|
||||
@Override
|
||||
public String getCursorName() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -313,12 +313,12 @@ public class DatabaseMetaDataResultSet implements ResultSet {
|
|||
|
||||
@Override
|
||||
public Reader getCharacterStream(int columnIndex) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Reader getCharacterStream(String columnLabel) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -353,22 +353,22 @@ public class DatabaseMetaDataResultSet implements ResultSet {
|
|||
|
||||
@Override
|
||||
public void beforeFirst() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterLast() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean first() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean last() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -383,17 +383,17 @@ public class DatabaseMetaDataResultSet implements ResultSet {
|
|||
|
||||
@Override
|
||||
public boolean absolute(int row) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean relative(int rows) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean previous() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -443,227 +443,227 @@ public class DatabaseMetaDataResultSet implements ResultSet {
|
|||
|
||||
@Override
|
||||
public void updateNull(int columnIndex) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateBoolean(int columnIndex, boolean x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByte(int columnIndex, byte x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateShort(int columnIndex, short x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateInt(int columnIndex, int x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateLong(int columnIndex, long x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFloat(int columnIndex, float x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDouble(int columnIndex, double x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateString(int columnIndex, String x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateBytes(int columnIndex, byte[] x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDate(int columnIndex, Date x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTime(int columnIndex, Time x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTimestamp(int columnIndex, Timestamp x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateBinaryStream(int columnIndex, InputStream x, int length) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCharacterStream(int columnIndex, Reader x, int length) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateObject(int columnIndex, Object x, int scaleOrLength) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateObject(int columnIndex, Object x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateNull(String columnLabel) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateBoolean(String columnLabel, boolean x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByte(String columnLabel, byte x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateShort(String columnLabel, short x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateInt(String columnLabel, int x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateLong(String columnLabel, long x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFloat(String columnLabel, float x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDouble(String columnLabel, double x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateBigDecimal(String columnLabel, BigDecimal x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateString(String columnLabel, String x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateBytes(String columnLabel, byte[] x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDate(String columnLabel, Date x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTime(String columnLabel, Time x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTimestamp(String columnLabel, Timestamp x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAsciiStream(String columnLabel, InputStream x, int length) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateBinaryStream(String columnLabel, InputStream x, int length) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCharacterStream(String columnLabel, Reader reader, int length) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateObject(String columnLabel, Object x, int scaleOrLength) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateObject(String columnLabel, Object x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertRow() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateRow() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteRow() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshRow() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelRowUpdates() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moveToInsertRow() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moveToCurrentRow() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -673,12 +673,12 @@ public class DatabaseMetaDataResultSet implements ResultSet {
|
|||
|
||||
@Override
|
||||
public Object getObject(int columnIndex, Map<String, Class<?>> map) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Ref getRef(int columnIndex) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1043,12 +1043,12 @@ public class DatabaseMetaDataResultSet implements ResultSet {
|
|||
|
||||
@Override
|
||||
public <T> T getObject(int columnIndex, Class<T> type) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getObject(String columnLabel, Class<T> type) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -34,44 +34,37 @@ import java.util.*;
|
|||
import java.util.concurrent.Executor;
|
||||
|
||||
public class TSDBConnection implements Connection {
|
||||
protected Properties props = null;
|
||||
|
||||
private TSDBJNIConnector connector = null;
|
||||
|
||||
private String catalog = null;
|
||||
|
||||
private TSDBDatabaseMetaData dbMetaData = null;
|
||||
private TSDBDatabaseMetaData dbMetaData;
|
||||
|
||||
private Properties clientInfoProps = new Properties();
|
||||
|
||||
private int timeoutMilliseconds = 0;
|
||||
|
||||
|
||||
private boolean batchFetch = false;
|
||||
|
||||
public TSDBConnection(Properties info, TSDBDatabaseMetaData meta) throws SQLException {
|
||||
this.dbMetaData = meta;
|
||||
connect(info.getProperty(TSDBDriver.PROPERTY_KEY_HOST),
|
||||
Integer.parseInt(info.getProperty(TSDBDriver.PROPERTY_KEY_PORT, "0")),
|
||||
info.getProperty(TSDBDriver.PROPERTY_KEY_DBNAME),
|
||||
info.getProperty(TSDBDriver.PROPERTY_KEY_DBNAME),
|
||||
info.getProperty(TSDBDriver.PROPERTY_KEY_USER),
|
||||
info.getProperty(TSDBDriver.PROPERTY_KEY_PASSWORD));
|
||||
|
||||
|
||||
String batchLoad = info.getProperty(TSDBDriver.PROPERTY_KEY_BATCH_LOAD);
|
||||
if (batchLoad != null) {
|
||||
this.batchFetch = Boolean.parseBoolean(batchLoad);
|
||||
this.batchFetch = Boolean.parseBoolean(batchLoad);
|
||||
}
|
||||
}
|
||||
|
||||
private void connect(String host, int port, String dbName, String user, String password) throws SQLException {
|
||||
this.connector = new TSDBJNIConnector();
|
||||
this.connector.connect(host, port, dbName, user, password);
|
||||
|
||||
try {
|
||||
this.setCatalog(dbName);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
this.setCatalog(dbName);
|
||||
this.dbMetaData.setConnection(this);
|
||||
}
|
||||
|
||||
|
@ -80,68 +73,86 @@ public class TSDBConnection implements Connection {
|
|||
}
|
||||
|
||||
public Statement createStatement() throws SQLException {
|
||||
if (!this.connector.isClosed()) {
|
||||
TSDBStatement statement = new TSDBStatement(this, this.connector);
|
||||
statement.setConnection(this);
|
||||
return statement;
|
||||
} else {
|
||||
throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL));
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
|
||||
TSDBStatement statement = new TSDBStatement(this, this.connector);
|
||||
statement.setConnection(this);
|
||||
return statement;
|
||||
}
|
||||
|
||||
public TSDBSubscribe subscribe(String topic, String sql, boolean restart) throws SQLException {
|
||||
if (this.connector.isClosed()) {
|
||||
throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL));
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
|
||||
long id = this.connector.subscribe(topic, sql, restart, 0);
|
||||
if (id == 0) {
|
||||
throw new SQLException(TSDBConstants.WrapErrMsg("failed to create subscription"));
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_SUBSCRIBE_FAILED);
|
||||
}
|
||||
|
||||
return new TSDBSubscribe(this.connector, id);
|
||||
}
|
||||
|
||||
public PreparedStatement prepareStatement(String sql) throws SQLException {
|
||||
if (!this.connector.isClosed()) {
|
||||
return new TSDBPreparedStatement(this, this.connector, sql);
|
||||
} else {
|
||||
throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL));
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
|
||||
return new TSDBPreparedStatement(this, this.connector, sql);
|
||||
}
|
||||
|
||||
public CallableStatement prepareCall(String sql) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||
}
|
||||
|
||||
public String nativeSQL(String sql) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||
}
|
||||
|
||||
public void setAutoCommit(boolean autoCommit) throws SQLException {
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean getAutoCommit() throws SQLException {
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void commit() throws SQLException {
|
||||
}
|
||||
|
||||
public void rollback() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void close() throws SQLException {
|
||||
if (this.connector != null && !this.connector.isClosed()) {
|
||||
this.connector.closeConnection();
|
||||
} else {
|
||||
throw new SQLException(TSDBConstants.WrapErrMsg("connection is already closed!"));
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
}
|
||||
|
||||
public void rollback() throws SQLException {
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||
}
|
||||
|
||||
public void close() throws SQLException {
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
this.connector.closeConnection();
|
||||
}
|
||||
|
||||
public boolean isClosed() throws SQLException {
|
||||
return this.connector.isClosed();
|
||||
return this.connector != null && this.connector.isClosed();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -154,6 +165,9 @@ public class TSDBConnection implements Connection {
|
|||
* @throws SQLException if a database access error occurs
|
||||
*/
|
||||
public DatabaseMetaData getMetaData() throws SQLException {
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
return this.dbMetaData;
|
||||
}
|
||||
|
||||
|
@ -165,17 +179,29 @@ public class TSDBConnection implements Connection {
|
|||
* @throws SQLException
|
||||
*/
|
||||
public void setReadOnly(boolean readOnly) throws SQLException {
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isReadOnly() throws SQLException {
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setCatalog(String catalog) throws SQLException {
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
this.catalog = catalog;
|
||||
}
|
||||
|
||||
public String getCatalog() throws SQLException {
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
return this.catalog;
|
||||
}
|
||||
|
||||
|
@ -187,6 +213,19 @@ public class TSDBConnection implements Connection {
|
|||
* @throws SQLException
|
||||
*/
|
||||
public void setTransactionIsolation(int level) throws SQLException {
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
switch (level) {
|
||||
case Connection.TRANSACTION_NONE:
|
||||
case Connection.TRANSACTION_READ_COMMITTED:
|
||||
case Connection.TRANSACTION_READ_UNCOMMITTED:
|
||||
case Connection.TRANSACTION_REPEATABLE_READ:
|
||||
case Connection.TRANSACTION_SERIALIZABLE:
|
||||
break;
|
||||
default:
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_VARIABLE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -196,60 +235,81 @@ public class TSDBConnection implements Connection {
|
|||
* @throws SQLException
|
||||
*/
|
||||
public int getTransactionIsolation() throws SQLException {
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
return Connection.TRANSACTION_NONE;
|
||||
}
|
||||
|
||||
public SQLWarning getWarnings() throws SQLException {
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
//todo: implement getWarnings according to the warning messages returned from TDengine
|
||||
return null;
|
||||
// throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void clearWarnings() throws SQLException {
|
||||
// left blank to support HikariCP connection
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
//todo: implement clearWarnings according to the warning messages returned from TDengine
|
||||
}
|
||||
|
||||
public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||
}
|
||||
|
||||
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency)
|
||||
throws SQLException {
|
||||
// This method is implemented in the current way to support Spark
|
||||
if (resultSetType != ResultSet.TYPE_FORWARD_ONLY) {
|
||||
throw new SQLException(TSDBConstants.INVALID_VARIABLES);
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_VARIABLE);
|
||||
}
|
||||
|
||||
if (resultSetConcurrency != ResultSet.CONCUR_READ_ONLY) {
|
||||
throw new SQLException(TSDBConstants.INVALID_VARIABLES);
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_VARIABLE);
|
||||
}
|
||||
|
||||
return this.prepareStatement(sql);
|
||||
}
|
||||
|
||||
|
||||
public Boolean getBatchFetch() {
|
||||
return this.batchFetch;
|
||||
return this.batchFetch;
|
||||
}
|
||||
|
||||
|
||||
public void setBatchFetch(Boolean batchFetch) {
|
||||
this.batchFetch = batchFetch;
|
||||
this.batchFetch = batchFetch;
|
||||
}
|
||||
|
||||
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||
}
|
||||
|
||||
public Map<String, Class<?>> getTypeMap() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||
}
|
||||
|
||||
public void setTypeMap(Map<String, Class<?>> map) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||
}
|
||||
|
||||
public void setHoldability(int holdability) throws SQLException {
|
||||
// intentionally left empty to support druid connection pool.
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -259,67 +319,111 @@ public class TSDBConnection implements Connection {
|
|||
* @throws SQLException
|
||||
*/
|
||||
public int getHoldability() throws SQLException {
|
||||
//intentionally left empty to support HikariCP connection.
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
return ResultSet.HOLD_CURSORS_OVER_COMMIT;
|
||||
}
|
||||
|
||||
public Savepoint setSavepoint() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||
}
|
||||
|
||||
public Savepoint setSavepoint(String name) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||
}
|
||||
|
||||
public void rollback(Savepoint savepoint) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||
}
|
||||
|
||||
public void releaseSavepoint(Savepoint savepoint) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||
}
|
||||
|
||||
public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
|
||||
throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||
}
|
||||
|
||||
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency,
|
||||
int resultSetHoldability) throws SQLException {
|
||||
return this.prepareStatement(sql, resultSetType, resultSetConcurrency);
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||
}
|
||||
|
||||
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency,
|
||||
int resultSetHoldability) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||
}
|
||||
|
||||
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||
}
|
||||
|
||||
public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||
}
|
||||
|
||||
public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||
}
|
||||
|
||||
public Clob createClob() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||
}
|
||||
|
||||
public Blob createBlob() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||
}
|
||||
|
||||
public NClob createNClob() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||
}
|
||||
|
||||
public SQLXML createSQLXML() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||
}
|
||||
|
||||
public boolean isValid(int timeout) throws SQLException {
|
||||
|
@ -338,31 +442,52 @@ public class TSDBConnection implements Connection {
|
|||
}
|
||||
|
||||
public String getClientInfo(String name) throws SQLException {
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
return clientInfoProps.getProperty(name);
|
||||
}
|
||||
|
||||
public Properties getClientInfo() throws SQLException {
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
return clientInfoProps;
|
||||
}
|
||||
|
||||
public Array createArrayOf(String typeName, Object[] elements) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||
}
|
||||
|
||||
public Struct createStruct(String typeName, Object[] attributes) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||
}
|
||||
|
||||
public void setSchema(String schema) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||
}
|
||||
|
||||
public String getSchema() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||
}
|
||||
|
||||
public void abort(Executor executor) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||
}
|
||||
|
||||
public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException {
|
||||
|
@ -370,14 +495,21 @@ public class TSDBConnection implements Connection {
|
|||
}
|
||||
|
||||
public int getNetworkTimeout() throws SQLException {
|
||||
if (isClosed()) {
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
|
||||
}
|
||||
return this.timeoutMilliseconds;
|
||||
}
|
||||
|
||||
public <T> T unwrap(Class<T> iface) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
try {
|
||||
return iface.cast(this);
|
||||
} catch (ClassCastException cce) {
|
||||
throw new SQLException("Unable to unwrap to " + iface.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isWrapperFor(Class<?> iface) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
return iface.isInstance(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,12 +19,12 @@ import java.util.Map;
|
|||
|
||||
public abstract class TSDBConstants {
|
||||
|
||||
public static final String STATEMENT_CLOSED = "Statement already closed.";
|
||||
public static final String DEFAULT_PORT = "6200";
|
||||
public static final String UNSUPPORT_METHOD_EXCEPTIONZ_MSG = "this operation is NOT supported currently!";
|
||||
public static final String STATEMENT_CLOSED = "statement is closed";
|
||||
public static final String UNSUPPORTED_METHOD_EXCEPTION_MSG = "this operation is NOT supported currently!";
|
||||
public static final String INVALID_VARIABLES = "invalid variables";
|
||||
public static final String RESULT_SET_IS_CLOSED = "resultSet is closed.";
|
||||
public static final String RESULT_SET_IS_CLOSED = "resultSet is closed";
|
||||
|
||||
public static final String DEFAULT_PORT = "6200";
|
||||
public static Map<Integer, String> DATATYPE_MAP = null;
|
||||
|
||||
public static final long JNI_NULL_POINTER = 0L;
|
||||
|
@ -36,6 +36,7 @@ public abstract class TSDBConstants {
|
|||
public static final int JNI_NUM_OF_FIELDS_0 = -4;
|
||||
public static final int JNI_SQL_NULL = -5;
|
||||
public static final int JNI_FETCH_END = -6;
|
||||
public static final int JNI_OUT_OF_MEMORY = -7;
|
||||
|
||||
public static final int TSDB_DATA_TYPE_NULL = 0;
|
||||
public static final int TSDB_DATA_TYPE_BOOL = 1;
|
||||
|
|
|
@ -37,7 +37,7 @@ import java.util.logging.Logger;
|
|||
* register it with the DriverManager. This means that a user can load and
|
||||
* register a driver by doing Class.forName("foo.bah.Driver")
|
||||
*/
|
||||
public class TSDBDriver extends AbstractTaosDriver {
|
||||
public class TSDBDriver extends AbstractDriver {
|
||||
|
||||
@Deprecated
|
||||
private static final String URL_PREFIX1 = "jdbc:TSDB://";
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
package com.taosdata.jdbc;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.sql.SQLFeatureNotSupportedException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class TSDBError {
|
||||
private static Map<Integer, String> TSDBErrorMap = new HashMap<>();
|
||||
|
||||
static {
|
||||
TSDBErrorMap.put(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED, "connection already closed");
|
||||
TSDBErrorMap.put(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD, "this operation is NOT supported currently!");
|
||||
TSDBErrorMap.put(TSDBErrorNumbers.ERROR_INVALID_VARIABLE, "invalid variables");
|
||||
TSDBErrorMap.put(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED, "statement is closed");
|
||||
TSDBErrorMap.put(TSDBErrorNumbers.ERROR_RESULTSET_CLOSED, "resultSet is closed");
|
||||
TSDBErrorMap.put(TSDBErrorNumbers.ERROR_BATCH_IS_EMPTY, "Batch is empty!");
|
||||
TSDBErrorMap.put(TSDBErrorNumbers.ERROR_INVALID_WITH_EXECUTEQUERY, "Can not issue data manipulation statements with executeQuery()");
|
||||
TSDBErrorMap.put(TSDBErrorNumbers.ERROR_INVALID_WITH_EXECUTEUPDATE, "Can not issue SELECT via executeUpdate()");
|
||||
|
||||
/**************************************************/
|
||||
TSDBErrorMap.put(TSDBErrorNumbers.ERROR_UNKNOWN, "unknown error");
|
||||
/**************************************************/
|
||||
TSDBErrorMap.put(TSDBErrorNumbers.ERROR_SUBSCRIBE_FAILED, "failed to create subscription");
|
||||
TSDBErrorMap.put(TSDBErrorNumbers.ERROR_UNSUPPORTED_ENCODING, "Unsupported encoding");
|
||||
|
||||
TSDBErrorMap.put(TSDBErrorNumbers.ERROR_JNI_TDENGINE_ERROR, "internal error of database!");
|
||||
TSDBErrorMap.put(TSDBErrorNumbers.ERROR_JNI_CONNECTION_NULL, "JNI connection already closed!");
|
||||
TSDBErrorMap.put(TSDBErrorNumbers.ERROR_JNI_RESULT_SET_NULL, "invalid JNI result set!");
|
||||
TSDBErrorMap.put(TSDBErrorNumbers.ERROR_JNI_NUM_OF_FIELDS_0, "invalid num of fields!");
|
||||
TSDBErrorMap.put(TSDBErrorNumbers.ERROR_JNI_SQL_NULL, "empty sql string!");
|
||||
TSDBErrorMap.put(TSDBErrorNumbers.ERROR_JNI_FETCH_END, "fetch to the end of resultset");
|
||||
TSDBErrorMap.put(TSDBErrorNumbers.ERROR_JNI_OUT_OF_MEMORY, "JNI alloc memory failed!");
|
||||
}
|
||||
|
||||
public static String wrapErrMsg(String msg) {
|
||||
return "TDengine Error: " + msg;
|
||||
}
|
||||
|
||||
public static SQLException createSQLException(int errorNumber) {
|
||||
return createSQLException(errorNumber, null);
|
||||
}
|
||||
|
||||
public static SQLException createSQLException(int errorNumber, String message) {
|
||||
if (message == null || message.isEmpty()) {
|
||||
if (TSDBErrorNumbers.contains(errorNumber))
|
||||
message = TSDBErrorMap.get(errorNumber);
|
||||
else
|
||||
message = TSDBErrorMap.get(TSDBErrorNumbers.ERROR_UNKNOWN);
|
||||
}
|
||||
|
||||
if (errorNumber == TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD)
|
||||
return new SQLFeatureNotSupportedException(message);
|
||||
|
||||
if (errorNumber < TSDBErrorNumbers.ERROR_UNKNOWN)
|
||||
// JDBC exception's error number is less than 0x2350
|
||||
return new SQLException("ERROR (" + Integer.toHexString(errorNumber) + "): " + message);
|
||||
// JNI exception's error number is large than 0x2350
|
||||
return new SQLException("TDengine ERROR (" + Integer.toHexString(errorNumber) + "): " + message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package com.taosdata.jdbc;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
public class TSDBErrorNumbers {
|
||||
|
||||
public static final int ERROR_CONNECTION_CLOSED = 0x2301; // connection already closed
|
||||
public static final int ERROR_UNSUPPORTED_METHOD = 0x2302; //this operation is NOT supported currently!
|
||||
public static final int ERROR_INVALID_VARIABLE = 0x2303; //invalid variables
|
||||
public static final int ERROR_STATEMENT_CLOSED = 0x2304; //statement already closed
|
||||
public static final int ERROR_RESULTSET_CLOSED = 0x2305; //resultSet is closed
|
||||
public static final int ERROR_BATCH_IS_EMPTY = 0x2306; //Batch is empty!
|
||||
public static final int ERROR_INVALID_WITH_EXECUTEQUERY = 0x2307; //Can not issue data manipulation statements with executeQuery()
|
||||
public static final int ERROR_INVALID_WITH_EXECUTEUPDATE = 0x2308; //Can not issue SELECT via executeUpdate()
|
||||
|
||||
public static final int ERROR_UNKNOWN = 0x2350; //unknown error
|
||||
|
||||
public static final int ERROR_SUBSCRIBE_FAILED = 0x2351; //failed to create subscription
|
||||
public static final int ERROR_UNSUPPORTED_ENCODING = 0x2352; //Unsupported encoding
|
||||
|
||||
public static final int ERROR_JNI_TDENGINE_ERROR = 0x2353;
|
||||
public static final int ERROR_JNI_CONNECTION_NULL = 0x2354; //invalid tdengine connection!
|
||||
public static final int ERROR_JNI_RESULT_SET_NULL = 0x2355;
|
||||
public static final int ERROR_JNI_NUM_OF_FIELDS_0 = 0x2356;
|
||||
public static final int ERROR_JNI_SQL_NULL = 0x2357;
|
||||
public static final int ERROR_JNI_FETCH_END = 0x2358;
|
||||
public static final int ERROR_JNI_OUT_OF_MEMORY = 0x2359;
|
||||
|
||||
private static final HashSet<Integer> errorNumbers;
|
||||
|
||||
static {
|
||||
errorNumbers = new HashSet();
|
||||
errorNumbers.add(ERROR_CONNECTION_CLOSED);
|
||||
errorNumbers.add(ERROR_UNSUPPORTED_METHOD);
|
||||
errorNumbers.add(ERROR_INVALID_VARIABLE);
|
||||
errorNumbers.add(ERROR_STATEMENT_CLOSED);
|
||||
errorNumbers.add(ERROR_RESULTSET_CLOSED);
|
||||
errorNumbers.add(ERROR_INVALID_WITH_EXECUTEQUERY);
|
||||
errorNumbers.add(ERROR_INVALID_WITH_EXECUTEUPDATE);
|
||||
/*****************************************************/
|
||||
errorNumbers.add(ERROR_SUBSCRIBE_FAILED);
|
||||
errorNumbers.add(ERROR_UNSUPPORTED_ENCODING);
|
||||
|
||||
errorNumbers.add(ERROR_JNI_TDENGINE_ERROR);
|
||||
errorNumbers.add(ERROR_JNI_CONNECTION_NULL);
|
||||
errorNumbers.add(ERROR_JNI_RESULT_SET_NULL);
|
||||
errorNumbers.add(ERROR_JNI_NUM_OF_FIELDS_0);
|
||||
errorNumbers.add(ERROR_JNI_SQL_NULL);
|
||||
errorNumbers.add(ERROR_JNI_FETCH_END);
|
||||
errorNumbers.add(ERROR_JNI_OUT_OF_MEMORY);
|
||||
|
||||
}
|
||||
|
||||
private TSDBErrorNumbers() {
|
||||
}
|
||||
|
||||
public static boolean contains(int errorNumber) {
|
||||
return errorNumbers.contains(errorNumber);
|
||||
}
|
||||
}
|
|
@ -14,6 +14,8 @@
|
|||
*****************************************************************************/
|
||||
package com.taosdata.jdbc;
|
||||
|
||||
import com.taosdata.jdbc.utils.TaosInfo;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.sql.SQLWarning;
|
||||
import java.util.List;
|
||||
|
@ -21,6 +23,8 @@ import java.util.List;
|
|||
public class TSDBJNIConnector {
|
||||
private static volatile Boolean isInitialized = false;
|
||||
|
||||
private TaosInfo taosInfo = TaosInfo.getInstance();
|
||||
|
||||
static {
|
||||
System.loadLibrary("taos");
|
||||
System.out.println("java.library.path:" + System.getProperty("java.library.path"));
|
||||
|
@ -34,7 +38,7 @@ public class TSDBJNIConnector {
|
|||
/**
|
||||
* Result set pointer for the current connection
|
||||
*/
|
||||
private long taosResultSetPointer = TSDBConstants.JNI_NULL_POINTER;
|
||||
// private long taosResultSetPointer = TSDBConstants.JNI_NULL_POINTER;
|
||||
|
||||
/**
|
||||
* result set status in current connection
|
||||
|
@ -91,7 +95,8 @@ public class TSDBJNIConnector {
|
|||
*/
|
||||
public boolean connect(String host, int port, String dbName, String user, String password) throws SQLException {
|
||||
if (this.taos != TSDBConstants.JNI_NULL_POINTER) {
|
||||
this.closeConnectionImp(this.taos);
|
||||
// this.closeConnectionImp(this.taos);
|
||||
closeConnection();
|
||||
this.taos = TSDBConstants.JNI_NULL_POINTER;
|
||||
}
|
||||
|
||||
|
@ -99,7 +104,8 @@ public class TSDBJNIConnector {
|
|||
if (this.taos == TSDBConstants.JNI_NULL_POINTER) {
|
||||
throw new SQLException(TSDBConstants.WrapErrMsg(this.getErrMsg(0L)), "", this.getErrCode(0l));
|
||||
}
|
||||
|
||||
// invoke connectImp only here
|
||||
taosInfo.conn_open_increment();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -113,31 +119,43 @@ public class TSDBJNIConnector {
|
|||
public long executeQuery(String sql) throws SQLException {
|
||||
// close previous result set if the user forgets to invoke the
|
||||
// free method to close previous result set.
|
||||
if (!this.isResultsetClosed) {
|
||||
freeResultSet(taosResultSetPointer);
|
||||
}
|
||||
// if (!this.isResultsetClosed) {
|
||||
// freeResultSet(taosResultSetPointer);
|
||||
// }
|
||||
|
||||
Long pSql = 0l;
|
||||
try {
|
||||
pSql = this.executeQueryImp(sql.getBytes(TaosGlobalConfig.getCharset()), this.taos);
|
||||
taosInfo.stmt_count_increment();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
this.freeResultSetImp(this.taos, pSql);
|
||||
throw new SQLException(TSDBConstants.WrapErrMsg("Unsupported encoding"));
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_ENCODING);
|
||||
}
|
||||
if (pSql == TSDBConstants.JNI_CONNECTION_NULL) {
|
||||
this.freeResultSetImp(this.taos, pSql);
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_CONNECTION_NULL);
|
||||
}
|
||||
if (pSql == TSDBConstants.JNI_SQL_NULL) {
|
||||
this.freeResultSetImp(this.taos, pSql);
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_SQL_NULL);
|
||||
}
|
||||
if (pSql == TSDBConstants.JNI_OUT_OF_MEMORY) {
|
||||
this.freeResultSetImp(this.taos, pSql);
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
int code = this.getErrCode(pSql);
|
||||
if (code != 0) {
|
||||
if (code != TSDBConstants.JNI_SUCCESS) {
|
||||
affectedRows = -1;
|
||||
String msg = this.getErrMsg(pSql);
|
||||
|
||||
this.freeResultSetImp(this.taos, pSql);
|
||||
throw new SQLException(TSDBConstants.WrapErrMsg(msg), "", code);
|
||||
throw TSDBError.createSQLException(code, msg);
|
||||
}
|
||||
|
||||
// Try retrieving result set for the executed SQL using the current connection pointer.
|
||||
taosResultSetPointer = this.getResultSetImp(this.taos, pSql);
|
||||
isResultsetClosed = (taosResultSetPointer == TSDBConstants.JNI_NULL_POINTER);
|
||||
pSql = this.getResultSetImp(this.taos, pSql);
|
||||
isResultsetClosed = (pSql == TSDBConstants.JNI_NULL_POINTER);
|
||||
|
||||
return pSql;
|
||||
}
|
||||
|
@ -166,9 +184,9 @@ public class TSDBJNIConnector {
|
|||
* Get resultset pointer
|
||||
* Each connection should have a single open result set at a time
|
||||
*/
|
||||
public long getResultSet() {
|
||||
return taosResultSetPointer;
|
||||
}
|
||||
// public long getResultSet() {
|
||||
// return taosResultSetPointer;
|
||||
// }
|
||||
|
||||
private native long getResultSetImp(long connection, long pSql);
|
||||
|
||||
|
@ -181,16 +199,16 @@ public class TSDBJNIConnector {
|
|||
/**
|
||||
* Free resultset operation from C to release resultset pointer by JNI
|
||||
*/
|
||||
public int freeResultSet(long result) {
|
||||
public int freeResultSet(long pSql) {
|
||||
int res = TSDBConstants.JNI_SUCCESS;
|
||||
if (result != taosResultSetPointer && taosResultSetPointer != TSDBConstants.JNI_NULL_POINTER) {
|
||||
throw new RuntimeException("Invalid result set pointer");
|
||||
}
|
||||
// if (result != taosResultSetPointer && taosResultSetPointer != TSDBConstants.JNI_NULL_POINTER) {
|
||||
// throw new RuntimeException("Invalid result set pointer");
|
||||
// }
|
||||
|
||||
if (taosResultSetPointer != TSDBConstants.JNI_NULL_POINTER) {
|
||||
res = this.freeResultSetImp(this.taos, result);
|
||||
taosResultSetPointer = TSDBConstants.JNI_NULL_POINTER;
|
||||
}
|
||||
// if (taosResultSetPointer != TSDBConstants.JNI_NULL_POINTER) {
|
||||
res = this.freeResultSetImp(this.taos, pSql);
|
||||
// taosResultSetPointer = TSDBConstants.JNI_NULL_POINTER;
|
||||
// }
|
||||
|
||||
isResultsetClosed = true;
|
||||
return res;
|
||||
|
@ -200,15 +218,15 @@ public class TSDBJNIConnector {
|
|||
* Close the open result set which is associated to the current connection. If the result set is already
|
||||
* closed, return 0 for success.
|
||||
*/
|
||||
public int freeResultSet() {
|
||||
int resCode = TSDBConstants.JNI_SUCCESS;
|
||||
if (!isResultsetClosed) {
|
||||
resCode = this.freeResultSetImp(this.taos, this.taosResultSetPointer);
|
||||
taosResultSetPointer = TSDBConstants.JNI_NULL_POINTER;
|
||||
isResultsetClosed = true;
|
||||
}
|
||||
return resCode;
|
||||
}
|
||||
// public int freeResultSet() {
|
||||
// int resCode = TSDBConstants.JNI_SUCCESS;
|
||||
// if (!isResultsetClosed) {
|
||||
// resCode = this.freeResultSetImp(this.taos, this.taosResultSetPointer);
|
||||
// taosResultSetPointer = TSDBConstants.JNI_NULL_POINTER;
|
||||
// isResultsetClosed = true;
|
||||
// }
|
||||
// return resCode;
|
||||
// }
|
||||
|
||||
private native int freeResultSetImp(long connection, long result);
|
||||
|
||||
|
@ -244,10 +262,11 @@ public class TSDBJNIConnector {
|
|||
private native int fetchRowImp(long connection, long resultSet, TSDBResultSetRowData rowData);
|
||||
|
||||
public int fetchBlock(long resultSet, TSDBResultSetBlockData blockData) {
|
||||
return this.fetchBlockImp(this.taos, resultSet, blockData);
|
||||
return this.fetchBlockImp(this.taos, resultSet, blockData);
|
||||
}
|
||||
|
||||
|
||||
private native int fetchBlockImp(long connection, long resultSet, TSDBResultSetBlockData blockData);
|
||||
|
||||
/**
|
||||
* Execute close operation from C to release connection pointer by JNI
|
||||
*
|
||||
|
@ -262,6 +281,8 @@ public class TSDBJNIConnector {
|
|||
} else {
|
||||
throw new SQLException("Undefined error code returned by TDengine when closing a connection");
|
||||
}
|
||||
// invoke closeConnectionImpl only here
|
||||
taosInfo.connect_close_increment();
|
||||
}
|
||||
|
||||
private native int closeConnectionImp(long connection);
|
||||
|
|
|
@ -264,17 +264,17 @@ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStat
|
|||
|
||||
@Override
|
||||
public void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUnicodeStream(int parameterIndex, InputStream x, int length) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -284,7 +284,7 @@ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStat
|
|||
|
||||
@Override
|
||||
public void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -321,156 +321,156 @@ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStat
|
|||
|
||||
@Override
|
||||
public void setCharacterStream(int parameterIndex, Reader reader, int length) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRef(int parameterIndex, Ref x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlob(int parameterIndex, Blob x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClob(int parameterIndex, Clob x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setArray(int parameterIndex, Array x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultSetMetaData getMetaData() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDate(int parameterIndex, Date x, Calendar cal) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNull(int parameterIndex, int sqlType, String typeName) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setURL(int parameterIndex, URL x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParameterMetaData getParameterMetaData() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRowId(int parameterIndex, RowId x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNString(int parameterIndex, String value) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNCharacterStream(int parameterIndex, Reader value, long length) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNClob(int parameterIndex, NClob value) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClob(int parameterIndex, Reader reader, long length) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlob(int parameterIndex, InputStream inputStream, long length) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNClob(int parameterIndex, Reader reader, long length) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setObject(int parameterIndex, Object x, int targetSqlType, int scaleOrLength) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAsciiStream(int parameterIndex, InputStream x, long length) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBinaryStream(int parameterIndex, InputStream x, long length) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCharacterStream(int parameterIndex, Reader reader, long length) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAsciiStream(int parameterIndex, InputStream x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBinaryStream(int parameterIndex, InputStream x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCharacterStream(int parameterIndex, Reader reader) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNCharacterStream(int parameterIndex, Reader value) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClob(int parameterIndex, Reader reader) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlob(int parameterIndex, InputStream inputStream) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNClob(int parameterIndex, Reader reader) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,36 +14,17 @@
|
|||
*****************************************************************************/
|
||||
package com.taosdata.jdbc;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.Reader;
|
||||
import java.math.BigDecimal;
|
||||
import java.net.URL;
|
||||
import java.sql.Array;
|
||||
import java.sql.Blob;
|
||||
import java.sql.Clob;
|
||||
import java.sql.Date;
|
||||
import java.sql.NClob;
|
||||
import java.sql.Ref;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.ResultSetMetaData;
|
||||
import java.sql.RowId;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.SQLWarning;
|
||||
import java.sql.SQLXML;
|
||||
import java.sql.Statement;
|
||||
import java.sql.Time;
|
||||
import java.sql.Timestamp;
|
||||
import java.sql.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class TSDBResultSet implements ResultSet {
|
||||
private TSDBJNIConnector jniConnector = null;
|
||||
public class TSDBResultSet extends AbstractResultSet implements ResultSet {
|
||||
private TSDBJNIConnector jniConnector;
|
||||
|
||||
private final TSDBStatement statement;
|
||||
private long resultSetPointer = 0L;
|
||||
private List<ColumnMetaData> columnMetaDataList = new ArrayList<ColumnMetaData>();
|
||||
private List<ColumnMetaData> columnMetaDataList = new ArrayList<>();
|
||||
|
||||
private TSDBResultSetRowData rowData;
|
||||
private TSDBResultSetBlockData blockData;
|
||||
|
@ -52,24 +33,6 @@ public class TSDBResultSet implements ResultSet {
|
|||
private boolean lastWasNull = false;
|
||||
private final int COLUMN_INDEX_START_VALUE = 1;
|
||||
|
||||
private int rowIndex = 0;
|
||||
|
||||
public TSDBJNIConnector getJniConnector() {
|
||||
return jniConnector;
|
||||
}
|
||||
|
||||
public void setJniConnector(TSDBJNIConnector jniConnector) {
|
||||
this.jniConnector = jniConnector;
|
||||
}
|
||||
|
||||
public long getResultSetPointer() {
|
||||
return resultSetPointer;
|
||||
}
|
||||
|
||||
public void setResultSetPointer(long resultSetPointer) {
|
||||
this.resultSetPointer = resultSetPointer;
|
||||
}
|
||||
|
||||
public void setBatchFetch(boolean batchFetch) {
|
||||
this.batchFetch = batchFetch;
|
||||
}
|
||||
|
@ -78,10 +41,6 @@ public class TSDBResultSet implements ResultSet {
|
|||
return this.batchFetch;
|
||||
}
|
||||
|
||||
public List<ColumnMetaData> getColumnMetaDataList() {
|
||||
return columnMetaDataList;
|
||||
}
|
||||
|
||||
public void setColumnMetaDataList(List<ColumnMetaData> columnMetaDataList) {
|
||||
this.columnMetaDataList = columnMetaDataList;
|
||||
}
|
||||
|
@ -90,56 +49,25 @@ public class TSDBResultSet implements ResultSet {
|
|||
return rowData;
|
||||
}
|
||||
|
||||
public void setRowData(TSDBResultSetRowData rowData) {
|
||||
this.rowData = rowData;
|
||||
}
|
||||
|
||||
public boolean isLastWasNull() {
|
||||
return lastWasNull;
|
||||
}
|
||||
|
||||
public void setLastWasNull(boolean lastWasNull) {
|
||||
this.lastWasNull = lastWasNull;
|
||||
}
|
||||
|
||||
public TSDBResultSet() {
|
||||
|
||||
}
|
||||
|
||||
public TSDBResultSet(TSDBJNIConnector connector, long resultSetPointer) throws SQLException {
|
||||
public TSDBResultSet(TSDBStatement statement, TSDBJNIConnector connector, long resultSetPointer) throws SQLException {
|
||||
this.statement = statement;
|
||||
this.jniConnector = connector;
|
||||
this.resultSetPointer = resultSetPointer;
|
||||
|
||||
int code = this.jniConnector.getSchemaMetaData(this.resultSetPointer, this.columnMetaDataList);
|
||||
if (code == TSDBConstants.JNI_CONNECTION_NULL) {
|
||||
throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL));
|
||||
} else if (code == TSDBConstants.JNI_RESULT_SET_NULL) {
|
||||
}
|
||||
if (code == TSDBConstants.JNI_RESULT_SET_NULL) {
|
||||
throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_RESULT_SET_NULL));
|
||||
} else if (code == TSDBConstants.JNI_NUM_OF_FIELDS_0) {
|
||||
}
|
||||
if (code == TSDBConstants.JNI_NUM_OF_FIELDS_0) {
|
||||
throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_NUM_OF_FIELDS_0));
|
||||
}
|
||||
|
||||
this.rowData = new TSDBResultSetRowData(this.columnMetaDataList.size());
|
||||
this.blockData = new TSDBResultSetBlockData(this.columnMetaDataList, this.columnMetaDataList.size());
|
||||
}
|
||||
|
||||
public <T> T unwrap(Class<T> iface) throws SQLException {
|
||||
if (isClosed())
|
||||
throw new SQLException(TSDBConstants.WrapErrMsg(TSDBConstants.RESULT_SET_IS_CLOSED));
|
||||
|
||||
try {
|
||||
return iface.cast(this);
|
||||
} catch (ClassCastException cce) {
|
||||
throw new SQLException("Unable to unwrap to " + iface.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isWrapperFor(Class<?> iface) throws SQLException {
|
||||
if (isClosed())
|
||||
throw new SQLException(TSDBConstants.WrapErrMsg(TSDBConstants.RESULT_SET_IS_CLOSED));
|
||||
|
||||
return iface.isInstance(this);
|
||||
}
|
||||
|
||||
public boolean next() throws SQLException {
|
||||
if (this.getBatchFetch()) {
|
||||
if (this.blockData.forward()) {
|
||||
|
@ -273,7 +201,7 @@ public class TSDBResultSet implements ResultSet {
|
|||
}
|
||||
|
||||
public long getLong(int columnIndex) throws SQLException {
|
||||
long res = 0l;
|
||||
long res = 0L;
|
||||
int colIndex = getTrueColumnIndex(columnIndex);
|
||||
|
||||
if (!this.getBatchFetch()) {
|
||||
|
@ -317,14 +245,6 @@ public class TSDBResultSet implements ResultSet {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.sql.ResultSet#getBigDecimal(int, int)
|
||||
*
|
||||
* @deprecated Use {@code getBigDecimal(int columnIndex)} or {@code
|
||||
* getBigDecimal(String columnLabel)}
|
||||
*/
|
||||
@Deprecated
|
||||
public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException {
|
||||
return new BigDecimal(getLong(columnIndex));
|
||||
|
@ -334,16 +254,6 @@ public class TSDBResultSet implements ResultSet {
|
|||
return getString(columnIndex).getBytes();
|
||||
}
|
||||
|
||||
public Date getDate(int columnIndex) throws SQLException {
|
||||
int colIndex = getTrueColumnIndex(columnIndex);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public Time getTime(int columnIndex) throws SQLException {
|
||||
int colIndex = getTrueColumnIndex(columnIndex);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public Timestamp getTimestamp(int columnIndex) throws SQLException {
|
||||
Timestamp res = null;
|
||||
int colIndex = getTrueColumnIndex(columnIndex);
|
||||
|
@ -359,112 +269,11 @@ public class TSDBResultSet implements ResultSet {
|
|||
}
|
||||
}
|
||||
|
||||
public InputStream getAsciiStream(int columnIndex) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.sql.ResultSet#getUnicodeStream(int)
|
||||
*
|
||||
* * @deprecated use <code>getCharacterStream</code> in place of
|
||||
* <code>getUnicodeStream</code>
|
||||
*/
|
||||
@Deprecated
|
||||
public InputStream getUnicodeStream(int columnIndex) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public InputStream getBinaryStream(int columnIndex) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public String getString(String columnLabel) throws SQLException {
|
||||
return this.getString(this.findColumn(columnLabel));
|
||||
}
|
||||
|
||||
public boolean getBoolean(String columnLabel) throws SQLException {
|
||||
return this.getBoolean(this.findColumn(columnLabel));
|
||||
}
|
||||
|
||||
public byte getByte(String columnLabel) throws SQLException {
|
||||
return this.getByte(this.findColumn(columnLabel));
|
||||
}
|
||||
|
||||
public short getShort(String columnLabel) throws SQLException {
|
||||
return this.getShort(this.findColumn(columnLabel));
|
||||
}
|
||||
|
||||
public int getInt(String columnLabel) throws SQLException {
|
||||
return this.getInt(this.findColumn(columnLabel));
|
||||
}
|
||||
|
||||
public long getLong(String columnLabel) throws SQLException {
|
||||
return this.getLong(this.findColumn(columnLabel));
|
||||
}
|
||||
|
||||
public float getFloat(String columnLabel) throws SQLException {
|
||||
return this.getFloat(this.findColumn(columnLabel));
|
||||
}
|
||||
|
||||
public double getDouble(String columnLabel) throws SQLException {
|
||||
return this.getDouble(this.findColumn(columnLabel));
|
||||
}
|
||||
|
||||
/*
|
||||
* used by spark
|
||||
*/
|
||||
@Deprecated
|
||||
public BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLException {
|
||||
return this.getBigDecimal(this.findColumn(columnLabel), scale);
|
||||
}
|
||||
|
||||
public byte[] getBytes(String columnLabel) throws SQLException {
|
||||
return this.getBytes(this.findColumn(columnLabel));
|
||||
}
|
||||
|
||||
public Date getDate(String columnLabel) throws SQLException {
|
||||
return this.getDate(this.findColumn(columnLabel));
|
||||
}
|
||||
|
||||
public Time getTime(String columnLabel) throws SQLException {
|
||||
return this.getTime(this.findColumn(columnLabel));
|
||||
}
|
||||
|
||||
public Timestamp getTimestamp(String columnLabel) throws SQLException {
|
||||
return this.getTimestamp(this.findColumn(columnLabel));
|
||||
}
|
||||
|
||||
public InputStream getAsciiStream(String columnLabel) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public InputStream getUnicodeStream(String columnLabel) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public InputStream getBinaryStream(String columnLabel) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public SQLWarning getWarnings() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void clearWarnings() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public String getCursorName() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public ResultSetMetaData getMetaData() throws SQLException {
|
||||
return new TSDBResultSetMetaData(this.columnMetaDataList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getObject(int columnIndex) throws SQLException {
|
||||
int colIndex = getTrueColumnIndex(columnIndex);
|
||||
|
||||
|
@ -476,32 +285,21 @@ public class TSDBResultSet implements ResultSet {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getObject(String columnLabel) throws SQLException {
|
||||
return this.getObject(this.findColumn(columnLabel));
|
||||
}
|
||||
|
||||
public int findColumn(String columnLabel) throws SQLException {
|
||||
Iterator<ColumnMetaData> colMetaDataIt = this.columnMetaDataList.iterator();
|
||||
while (colMetaDataIt.hasNext()) {
|
||||
ColumnMetaData colMetaData = colMetaDataIt.next();
|
||||
for (ColumnMetaData colMetaData : this.columnMetaDataList) {
|
||||
if (colMetaData.getColName() != null && colMetaData.getColName().equalsIgnoreCase(columnLabel)) {
|
||||
return colMetaData.getColIndex() + 1;
|
||||
}
|
||||
}
|
||||
throw new SQLException(TSDBConstants.INVALID_VARIABLES);
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_VARIABLE);
|
||||
}
|
||||
|
||||
public Reader getCharacterStream(int columnIndex) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public Reader getCharacterStream(String columnLabel) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
/*
|
||||
* used by spark
|
||||
*/
|
||||
@Override
|
||||
public BigDecimal getBigDecimal(int columnIndex) throws SQLException {
|
||||
int colIndex = getTrueColumnIndex(columnIndex);
|
||||
|
||||
|
@ -513,403 +311,111 @@ public class TSDBResultSet implements ResultSet {
|
|||
}
|
||||
}
|
||||
|
||||
public BigDecimal getBigDecimal(String columnLabel) throws SQLException {
|
||||
return this.getBigDecimal(this.findColumn(columnLabel));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBeforeFirst() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
if (isClosed())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_RESULTSET_CLOSED);
|
||||
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAfterLast() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
if (isClosed())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_RESULTSET_CLOSED);
|
||||
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFirst() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
if (isClosed())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_RESULTSET_CLOSED);
|
||||
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLast() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
if (isClosed())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_RESULTSET_CLOSED);
|
||||
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeFirst() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
if (isClosed())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_RESULTSET_CLOSED);
|
||||
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterLast() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
if (isClosed())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_RESULTSET_CLOSED);
|
||||
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean first() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
if (isClosed())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_RESULTSET_CLOSED);
|
||||
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean last() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
if (isClosed())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_RESULTSET_CLOSED);
|
||||
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRow() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
if (isClosed())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_RESULTSET_CLOSED);
|
||||
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean absolute(int row) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
if (isClosed())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_RESULTSET_CLOSED);
|
||||
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean relative(int rows) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
if (isClosed())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_RESULTSET_CLOSED);
|
||||
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean previous() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
if (isClosed())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_RESULTSET_CLOSED);
|
||||
|
||||
public void setFetchDirection(int direction) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public int getFetchDirection() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void setFetchSize(int rows) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public int getFetchSize() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public int getType() throws SQLException {
|
||||
return ResultSet.TYPE_FORWARD_ONLY;
|
||||
}
|
||||
|
||||
public int getConcurrency() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public boolean rowUpdated() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public boolean rowInserted() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public boolean rowDeleted() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateNull(int columnIndex) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateBoolean(int columnIndex, boolean x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateByte(int columnIndex, byte x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateShort(int columnIndex, short x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateInt(int columnIndex, int x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateLong(int columnIndex, long x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateFloat(int columnIndex, float x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateDouble(int columnIndex, double x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateString(int columnIndex, String x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateBytes(int columnIndex, byte[] x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateDate(int columnIndex, Date x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateTime(int columnIndex, Time x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateTimestamp(int columnIndex, Timestamp x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateBinaryStream(int columnIndex, InputStream x, int length) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateCharacterStream(int columnIndex, Reader x, int length) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateObject(int columnIndex, Object x, int scaleOrLength) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateObject(int columnIndex, Object x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateNull(String columnLabel) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateBoolean(String columnLabel, boolean x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateByte(String columnLabel, byte x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateShort(String columnLabel, short x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateInt(String columnLabel, int x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateLong(String columnLabel, long x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateFloat(String columnLabel, float x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateDouble(String columnLabel, double x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateBigDecimal(String columnLabel, BigDecimal x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateString(String columnLabel, String x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateBytes(String columnLabel, byte[] x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateDate(String columnLabel, Date x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateTime(String columnLabel, Time x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateTimestamp(String columnLabel, Timestamp x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateAsciiStream(String columnLabel, InputStream x, int length) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateBinaryStream(String columnLabel, InputStream x, int length) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateCharacterStream(String columnLabel, Reader reader, int length) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateObject(String columnLabel, Object x, int scaleOrLength) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateObject(String columnLabel, Object x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void insertRow() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateRow() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void deleteRow() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void refreshRow() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void cancelRowUpdates() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void moveToInsertRow() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void moveToCurrentRow() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD);
|
||||
}
|
||||
|
||||
public Statement getStatement() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
if (isClosed())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_RESULTSET_CLOSED);
|
||||
|
||||
public Object getObject(int columnIndex, Map<String, Class<?>> map) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public Ref getRef(int columnIndex) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public Blob getBlob(int columnIndex) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public Clob getClob(int columnIndex) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public Array getArray(int columnIndex) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public Object getObject(String columnLabel, Map<String, Class<?>> map) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public Ref getRef(String columnLabel) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public Blob getBlob(String columnLabel) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public Clob getClob(String columnLabel) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public Array getArray(String columnLabel) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public Date getDate(int columnIndex, Calendar cal) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public Date getDate(String columnLabel, Calendar cal) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public Time getTime(int columnIndex, Calendar cal) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public Time getTime(String columnLabel, Calendar cal) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public Timestamp getTimestamp(String columnLabel, Calendar cal) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public URL getURL(int columnIndex) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public URL getURL(String columnLabel) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateRef(int columnIndex, Ref x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateRef(String columnLabel, Ref x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateBlob(int columnIndex, Blob x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateBlob(String columnLabel, Blob x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateClob(int columnIndex, Clob x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateClob(String columnLabel, Clob x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateArray(int columnIndex, Array x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateArray(String columnLabel, Array x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public RowId getRowId(int columnIndex) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public RowId getRowId(String columnLabel) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateRowId(int columnIndex, RowId x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateRowId(String columnLabel, RowId x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public int getHoldability() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
return this.statement;
|
||||
}
|
||||
|
||||
public boolean isClosed() throws SQLException {
|
||||
//TODO: check if need release resources
|
||||
boolean isClosed = true;
|
||||
if (jniConnector != null) {
|
||||
isClosed = jniConnector.isResultsetClosed();
|
||||
|
@ -917,183 +423,11 @@ public class TSDBResultSet implements ResultSet {
|
|||
return isClosed;
|
||||
}
|
||||
|
||||
public void updateNString(int columnIndex, String nString) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateNString(String columnLabel, String nString) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateNClob(int columnIndex, NClob nClob) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateNClob(String columnLabel, NClob nClob) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public NClob getNClob(int columnIndex) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public NClob getNClob(String columnLabel) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public SQLXML getSQLXML(int columnIndex) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public SQLXML getSQLXML(String columnLabel) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateSQLXML(String columnLabel, SQLXML xmlObject) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public String getNString(int columnIndex) throws SQLException {
|
||||
int colIndex = getTrueColumnIndex(columnIndex);
|
||||
return (String) rowData.get(colIndex);
|
||||
}
|
||||
|
||||
public String getNString(String columnLabel) throws SQLException {
|
||||
return (String) this.getString(columnLabel);
|
||||
}
|
||||
|
||||
public Reader getNCharacterStream(int columnIndex) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public Reader getNCharacterStream(String columnLabel) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateNCharacterStream(String columnLabel, Reader reader, long length) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateAsciiStream(int columnIndex, InputStream x, long length) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateBinaryStream(int columnIndex, InputStream x, long length) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateCharacterStream(int columnIndex, Reader x, long length) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateAsciiStream(String columnLabel, InputStream x, long length) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateBinaryStream(String columnLabel, InputStream x, long length) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateCharacterStream(String columnLabel, Reader reader, long length) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateBlob(int columnIndex, InputStream inputStream, long length) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateBlob(String columnLabel, InputStream inputStream, long length) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateClob(int columnIndex, Reader reader, long length) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateClob(String columnLabel, Reader reader, long length) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateNClob(int columnIndex, Reader reader, long length) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateNClob(String columnLabel, Reader reader, long length) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateNCharacterStream(int columnIndex, Reader x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateNCharacterStream(String columnLabel, Reader reader) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateAsciiStream(int columnIndex, InputStream x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateBinaryStream(int columnIndex, InputStream x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateCharacterStream(int columnIndex, Reader x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateAsciiStream(String columnLabel, InputStream x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateBinaryStream(String columnLabel, InputStream x) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateCharacterStream(String columnLabel, Reader reader) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateBlob(int columnIndex, InputStream inputStream) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateBlob(String columnLabel, InputStream inputStream) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateClob(int columnIndex, Reader reader) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateClob(String columnLabel, Reader reader) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateNClob(int columnIndex, Reader reader) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void updateNClob(String columnLabel, Reader reader) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public <T> T getObject(int columnIndex, Class<T> type) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public <T> T getObject(String columnLabel, Class<T> type) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
private int getTrueColumnIndex(int columnIndex) throws SQLException {
|
||||
if (columnIndex < this.COLUMN_INDEX_START_VALUE) {
|
||||
throw new SQLException("Column Index out of range, " + columnIndex + " < " + this.COLUMN_INDEX_START_VALUE);
|
||||
|
@ -1103,7 +437,6 @@ public class TSDBResultSet implements ResultSet {
|
|||
if (columnIndex > numOfCols) {
|
||||
throw new SQLException("Column Index out of range, " + columnIndex + " > " + numOfCols);
|
||||
}
|
||||
|
||||
return columnIndex - 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,11 +29,11 @@ public class TSDBResultSetMetaData implements ResultSetMetaData {
|
|||
}
|
||||
|
||||
public <T> T unwrap(Class<T> iface) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
public boolean isWrapperFor(Class<?> iface) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
public int getColumnCount() throws SQLException {
|
||||
|
@ -94,7 +94,7 @@ public class TSDBResultSetMetaData implements ResultSetMetaData {
|
|||
}
|
||||
|
||||
public String getSchemaName(int column) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
public int getPrecision(int column) throws SQLException {
|
||||
|
@ -125,11 +125,11 @@ public class TSDBResultSetMetaData implements ResultSetMetaData {
|
|||
}
|
||||
|
||||
public String getTableName(int column) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
public String getCatalogName(int column) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
public int getColumnType(int column) throws SQLException {
|
||||
|
@ -173,7 +173,7 @@ public class TSDBResultSetMetaData implements ResultSetMetaData {
|
|||
}
|
||||
|
||||
public boolean isDefinitelyWritable(int column) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
public String getColumnClassName(int column) throws SQLException {
|
||||
|
|
|
@ -1153,11 +1153,11 @@ public class TSDBResultSetWrapper implements ResultSet {
|
|||
}
|
||||
|
||||
public <T> T getObject(int columnIndex, Class<T> type) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
public <T> T getObject(String columnLabel, Class<T> type) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,30 +17,21 @@ package com.taosdata.jdbc;
|
|||
import java.sql.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class TSDBStatement implements Statement {
|
||||
private TSDBJNIConnector connector = null;
|
||||
public class TSDBStatement extends AbstractStatement {
|
||||
|
||||
private TSDBJNIConnector connector;
|
||||
/**
|
||||
* To store batched commands
|
||||
*/
|
||||
protected List<String> batchedArgs;
|
||||
|
||||
/**
|
||||
* Timeout for a query
|
||||
*/
|
||||
protected int queryTimeout = 0;
|
||||
|
||||
private Long pSql = 0l;
|
||||
|
||||
/**
|
||||
* Status of current statement
|
||||
*/
|
||||
private boolean isClosed = true;
|
||||
private int affectedRows = 0;
|
||||
|
||||
private boolean isClosed;
|
||||
private int affectedRows = -1;
|
||||
private TSDBConnection connection;
|
||||
private TSDBResultSet resultSet;
|
||||
|
||||
public void setConnection(TSDBConnection connection) {
|
||||
this.connection = connection;
|
||||
|
@ -49,213 +40,89 @@ public class TSDBStatement implements Statement {
|
|||
TSDBStatement(TSDBConnection connection, TSDBJNIConnector connector) {
|
||||
this.connection = connection;
|
||||
this.connector = connector;
|
||||
this.isClosed = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T unwrap(Class<T> iface) throws SQLException {
|
||||
try {
|
||||
return iface.cast(this);
|
||||
} catch (ClassCastException cce) {
|
||||
throw new SQLException("Unable to unwrap to " + iface.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWrapperFor(Class<?> iface) throws SQLException {
|
||||
return iface.isInstance(this);
|
||||
}
|
||||
|
||||
public ResultSet executeQuery(String sql) throws SQLException {
|
||||
if (isClosed) {
|
||||
throw new SQLException("Invalid method call on a closed statement.");
|
||||
}
|
||||
// check if closed
|
||||
if (isClosed())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
|
||||
//TODO: 如果在executeQuery方法中执行insert语句,那么先执行了SQL,再通过pSql来检查是否为一个insert语句,但这个insert SQL已经执行成功了
|
||||
|
||||
// TODO make sure it is not a update query
|
||||
pSql = this.connector.executeQuery(sql);
|
||||
|
||||
long resultSetPointer = this.connector.getResultSet();
|
||||
if (resultSetPointer == TSDBConstants.JNI_CONNECTION_NULL) {
|
||||
// execute query
|
||||
long pSql = this.connector.executeQuery(sql);
|
||||
// if pSql is create/insert/update/delete/alter SQL
|
||||
if (this.connector.isUpdateQuery(pSql)) {
|
||||
this.connector.freeResultSet(pSql);
|
||||
throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL));
|
||||
}
|
||||
|
||||
// create/insert/update/delete/alter
|
||||
if (resultSetPointer == TSDBConstants.JNI_NULL_POINTER) {
|
||||
this.connector.freeResultSet(pSql);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!this.connector.isUpdateQuery(pSql)) {
|
||||
TSDBResultSet res = new TSDBResultSet(this.connector, resultSetPointer);
|
||||
res.setBatchFetch(this.connection.getBatchFetch());
|
||||
return res;
|
||||
} else {
|
||||
this.connector.freeResultSet(pSql);
|
||||
return null;
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_WITH_EXECUTEQUERY);
|
||||
}
|
||||
|
||||
TSDBResultSet res = new TSDBResultSet(this, this.connector, pSql);
|
||||
res.setBatchFetch(this.connection.getBatchFetch());
|
||||
return res;
|
||||
}
|
||||
|
||||
public int executeUpdate(String sql) throws SQLException {
|
||||
if (isClosed) {
|
||||
throw new SQLException("Invalid method call on a closed statement.");
|
||||
}
|
||||
if (isClosed())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
|
||||
|
||||
// TODO check if current query is update query
|
||||
pSql = this.connector.executeQuery(sql);
|
||||
long resultSetPointer = this.connector.getResultSet();
|
||||
|
||||
if (resultSetPointer == TSDBConstants.JNI_CONNECTION_NULL) {
|
||||
long pSql = this.connector.executeQuery(sql);
|
||||
// if pSql is create/insert/update/delete/alter SQL
|
||||
if (!this.connector.isUpdateQuery(pSql)) {
|
||||
this.connector.freeResultSet(pSql);
|
||||
throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL));
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_WITH_EXECUTEUPDATE);
|
||||
}
|
||||
|
||||
this.affectedRows = this.connector.getAffectedRows(pSql);
|
||||
int affectedRows = this.connector.getAffectedRows(pSql);
|
||||
this.connector.freeResultSet(pSql);
|
||||
|
||||
return this.affectedRows;
|
||||
}
|
||||
|
||||
public String getErrorMsg(long pSql) {
|
||||
return this.connector.getErrMsg(pSql);
|
||||
return affectedRows;
|
||||
}
|
||||
|
||||
public void close() throws SQLException {
|
||||
if (!isClosed) {
|
||||
if (!this.connector.isResultsetClosed()) {
|
||||
this.connector.freeResultSet();
|
||||
}
|
||||
if (this.resultSet != null)
|
||||
this.resultSet.close();
|
||||
isClosed = true;
|
||||
}
|
||||
}
|
||||
|
||||
public int getMaxFieldSize() throws SQLException {
|
||||
return 0;
|
||||
// throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void setMaxFieldSize(int max) throws SQLException {
|
||||
if (isClosed())
|
||||
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public int getMaxRows() throws SQLException {
|
||||
if (isClosed())
|
||||
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||
// always set maxRows to zero, meaning unlimitted rows in a resultSet
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setMaxRows(int max) throws SQLException {
|
||||
// always set maxRows to zero, meaning unlimited rows in a resultSet
|
||||
}
|
||||
|
||||
public void setEscapeProcessing(boolean enable) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public int getQueryTimeout() throws SQLException {
|
||||
return queryTimeout;
|
||||
}
|
||||
|
||||
public void setQueryTimeout(int seconds) throws SQLException {
|
||||
this.queryTimeout = seconds;
|
||||
}
|
||||
|
||||
public void cancel() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public SQLWarning getWarnings() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void clearWarnings() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void setCursorName(String name) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public boolean execute(String sql) throws SQLException {
|
||||
if (isClosed) {
|
||||
throw new SQLException("Invalid method call on a closed statement.");
|
||||
}
|
||||
boolean res = true;
|
||||
pSql = this.connector.executeQuery(sql);
|
||||
long resultSetPointer = this.connector.getResultSet();
|
||||
|
||||
if (resultSetPointer == TSDBConstants.JNI_CONNECTION_NULL) {
|
||||
// check if closed
|
||||
if (isClosed())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
|
||||
// execute query
|
||||
long pSql = this.connector.executeQuery(sql);
|
||||
// if pSql is create/insert/update/delete/alter SQL
|
||||
if (this.connector.isUpdateQuery(pSql)) {
|
||||
this.affectedRows = this.connector.getAffectedRows(pSql);
|
||||
this.connector.freeResultSet(pSql);
|
||||
throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL));
|
||||
} else if (resultSetPointer == TSDBConstants.JNI_NULL_POINTER) {
|
||||
// no result set is retrieved
|
||||
this.connector.freeResultSet(pSql);
|
||||
res = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
return res;
|
||||
this.resultSet = new TSDBResultSet(this, this.connector, pSql);
|
||||
this.resultSet.setBatchFetch(this.connection.getBatchFetch());
|
||||
return true;
|
||||
}
|
||||
|
||||
public ResultSet getResultSet() throws SQLException {
|
||||
if (isClosed) {
|
||||
throw new SQLException("Invalid method call on a closed statement.");
|
||||
}
|
||||
long resultSetPointer = connector.getResultSet();
|
||||
TSDBResultSet resSet = null;
|
||||
if (resultSetPointer != TSDBConstants.JNI_NULL_POINTER) {
|
||||
resSet = new TSDBResultSet(connector, resultSetPointer);
|
||||
}
|
||||
return resSet;
|
||||
if (isClosed())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
|
||||
// long resultSetPointer = connector.getResultSet();
|
||||
// TSDBResultSet resSet = null;
|
||||
// if (resultSetPointer != TSDBConstants.JNI_NULL_POINTER) {
|
||||
// resSet = new TSDBResultSet(connector, resultSetPointer);
|
||||
// }
|
||||
return this.resultSet;
|
||||
}
|
||||
|
||||
public int getUpdateCount() throws SQLException {
|
||||
if (isClosed) {
|
||||
throw new SQLException("Invalid method call on a closed statement.");
|
||||
}
|
||||
|
||||
if (isClosed())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
|
||||
return this.affectedRows;
|
||||
}
|
||||
|
||||
public boolean getMoreResults() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void setFetchDirection(int direction) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public int getFetchDirection() throws SQLException {
|
||||
return ResultSet.FETCH_FORWARD;
|
||||
// throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
/*
|
||||
* used by spark
|
||||
*/
|
||||
public void setFetchSize(int rows) throws SQLException {
|
||||
}
|
||||
|
||||
/*
|
||||
* used by spark
|
||||
*/
|
||||
public int getFetchSize() throws SQLException {
|
||||
return 4096;
|
||||
}
|
||||
|
||||
public int getResultSetConcurrency() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public int getResultSetType() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void addBatch(String sql) throws SQLException {
|
||||
if (isClosed())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
|
||||
|
||||
if (batchedArgs == null) {
|
||||
batchedArgs = new ArrayList<>();
|
||||
}
|
||||
|
@ -263,83 +130,41 @@ public class TSDBStatement implements Statement {
|
|||
}
|
||||
|
||||
public void clearBatch() throws SQLException {
|
||||
batchedArgs.clear();
|
||||
if (isClosed())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
|
||||
if (batchedArgs != null)
|
||||
batchedArgs.clear();
|
||||
}
|
||||
|
||||
public int[] executeBatch() throws SQLException {
|
||||
if (isClosed) {
|
||||
throw new SQLException("Invalid method call on a closed statement.");
|
||||
}
|
||||
if (batchedArgs == null) {
|
||||
throw new SQLException(TSDBConstants.WrapErrMsg("Batch is empty!"));
|
||||
} else {
|
||||
int[] res = new int[batchedArgs.size()];
|
||||
for (int i = 0; i < batchedArgs.size(); i++) {
|
||||
res[i] = executeUpdate(batchedArgs.get(i));
|
||||
if (isClosed())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
|
||||
if (batchedArgs == null || batchedArgs.isEmpty())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_BATCH_IS_EMPTY);
|
||||
|
||||
int[] res = new int[batchedArgs.size()];
|
||||
for (int i = 0; i < batchedArgs.size(); i++) {
|
||||
boolean isSelect = execute(batchedArgs.get(i));
|
||||
if (isSelect) {
|
||||
res[i] = SUCCESS_NO_INFO;
|
||||
} else {
|
||||
res[i] = getUpdateCount();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public Connection getConnection() throws SQLException {
|
||||
if (this.connector != null)
|
||||
return this.connection;
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public boolean getMoreResults(int current) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public ResultSet getGeneratedKeys() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public int executeUpdate(String sql, int[] columnIndexes) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public int executeUpdate(String sql, String[] columnNames) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public boolean execute(String sql, int autoGeneratedKeys) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public boolean execute(String sql, int[] columnIndexes) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public boolean execute(String sql, String[] columnNames) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public int getResultSetHoldability() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
if (isClosed())
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
|
||||
if (this.connector == null)
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_CONNECTION_NULL);
|
||||
return this.connection;
|
||||
}
|
||||
|
||||
public boolean isClosed() throws SQLException {
|
||||
return isClosed;
|
||||
}
|
||||
|
||||
public void setPoolable(boolean poolable) throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public boolean isPoolable() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public void closeOnCompletion() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
public boolean isCloseOnCompletion() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ public class TSDBSubscribe {
|
|||
} else if (resultSetPointer == TSDBConstants.JNI_NULL_POINTER) {
|
||||
return null;
|
||||
} else {
|
||||
return new TSDBResultSet(this.connecter, resultSetPointer);
|
||||
return new TSDBResultSet(null, this.connecter, resultSetPointer);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package com.taosdata.jdbc;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Wrapper;
|
||||
|
||||
public class WrapperImpl implements Wrapper {
|
||||
|
||||
@Override
|
||||
public <T> T unwrap(Class<T> iface) throws SQLException {
|
||||
try {
|
||||
return iface.cast(this);
|
||||
} catch (ClassCastException cce) {
|
||||
throw new SQLException("Unable to unwrap to " + iface.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWrapperFor(Class<?> iface) throws SQLException {
|
||||
return iface.isInstance(this);
|
||||
}
|
||||
}
|
|
@ -47,7 +47,7 @@ public class RestfulConnection implements Connection {
|
|||
if (isClosed())
|
||||
throw new SQLException(CONNECTION_IS_CLOSED);
|
||||
//TODO: prepareStatement
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -55,7 +55,7 @@ public class RestfulConnection implements Connection {
|
|||
if (isClosed())
|
||||
throw new SQLException(CONNECTION_IS_CLOSED);
|
||||
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -72,7 +72,7 @@ public class RestfulConnection implements Connection {
|
|||
if (isClosed())
|
||||
throw new SQLException(CONNECTION_IS_CLOSED);
|
||||
if (!autoCommit)
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -162,7 +162,7 @@ public class RestfulConnection implements Connection {
|
|||
case Connection.TRANSACTION_READ_COMMITTED:
|
||||
case Connection.TRANSACTION_REPEATABLE_READ:
|
||||
case Connection.TRANSACTION_SERIALIZABLE:
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
default:
|
||||
throw new SQLException(TSDBConstants.INVALID_VARIABLES);
|
||||
}
|
||||
|
@ -197,10 +197,10 @@ public class RestfulConnection implements Connection {
|
|||
throw new SQLException(CONNECTION_IS_CLOSED);
|
||||
|
||||
if (resultSetType != ResultSet.TYPE_FORWARD_ONLY) {
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
if (resultSetConcurrency != ResultSet.CONCUR_READ_ONLY)
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
return createStatement();
|
||||
}
|
||||
|
||||
|
@ -221,7 +221,7 @@ public class RestfulConnection implements Connection {
|
|||
if (resultSetType != ResultSet.TYPE_FORWARD_ONLY || resultSetConcurrency != ResultSet.CONCUR_READ_ONLY)
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.INVALID_VARIABLES);
|
||||
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -252,7 +252,7 @@ public class RestfulConnection implements Connection {
|
|||
if (isClosed())
|
||||
throw new SQLException(CONNECTION_IS_CLOSED);
|
||||
if (holdability != ResultSet.HOLD_CURSORS_OVER_COMMIT)
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -269,7 +269,7 @@ public class RestfulConnection implements Connection {
|
|||
if (getAutoCommit())
|
||||
throw new SQLException(TSDBConstants.INVALID_VARIABLES);
|
||||
//nothing to do
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -279,7 +279,7 @@ public class RestfulConnection implements Connection {
|
|||
if (getAutoCommit())
|
||||
throw new SQLException(TSDBConstants.INVALID_VARIABLES);
|
||||
//nothing to do
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -289,68 +289,68 @@ public class RestfulConnection implements Connection {
|
|||
if (getAutoCommit())
|
||||
throw new SQLException(TSDBConstants.INVALID_VARIABLES);
|
||||
//nothing to do
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void releaseSavepoint(Savepoint savepoint) throws SQLException {
|
||||
if (isClosed())
|
||||
throw new SQLException(CONNECTION_IS_CLOSED);
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
|
||||
if (resultSetHoldability != ResultSet.HOLD_CURSORS_OVER_COMMIT)
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
return createStatement(resultSetType, resultSetConcurrency);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
|
||||
if (resultSetHoldability != ResultSet.HOLD_CURSORS_OVER_COMMIT)
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
return prepareStatement(sql, resultSetType, resultSetConcurrency);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException {
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException {
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException {
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Clob createClob() throws SQLException {
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Blob createBlob() throws SQLException {
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NClob createNClob() throws SQLException {
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SQLXML createSQLXML() throws SQLException {
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -399,12 +399,12 @@ public class RestfulConnection implements Connection {
|
|||
|
||||
@Override
|
||||
public Array createArrayOf(String typeName, Object[] elements) throws SQLException {
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Struct createStruct(String typeName, Object[] attributes) throws SQLException {
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -442,7 +442,7 @@ public class RestfulConnection implements Connection {
|
|||
public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException {
|
||||
if (isClosed())
|
||||
throw new SQLException(CONNECTION_IS_CLOSED);
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORTED_METHOD_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.taosdata.jdbc.rs;
|
|||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.taosdata.jdbc.AbstractTaosDriver;
|
||||
import com.taosdata.jdbc.AbstractDriver;
|
||||
import com.taosdata.jdbc.TSDBConstants;
|
||||
import com.taosdata.jdbc.TSDBDriver;
|
||||
import com.taosdata.jdbc.rs.util.HttpClientPoolUtil;
|
||||
|
@ -11,7 +11,7 @@ import java.sql.*;
|
|||
import java.util.Properties;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class RestfulDriver extends AbstractTaosDriver {
|
||||
public class RestfulDriver extends AbstractDriver {
|
||||
|
||||
private static final String URL_PREFIX = "jdbc:TAOS-RS://";
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -2,6 +2,7 @@ package com.taosdata.jdbc.rs;
|
|||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.taosdata.jdbc.AbstractStatement;
|
||||
import com.taosdata.jdbc.TSDBConstants;
|
||||
import com.taosdata.jdbc.rs.util.HttpClientPoolUtil;
|
||||
import com.taosdata.jdbc.utils.SqlSyntaxValidator;
|
||||
|
@ -12,7 +13,7 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class RestfulStatement implements Statement {
|
||||
public class RestfulStatement extends AbstractStatement {
|
||||
|
||||
private boolean closed;
|
||||
private String database;
|
||||
|
@ -20,7 +21,6 @@ public class RestfulStatement implements Statement {
|
|||
|
||||
private volatile RestfulResultSet resultSet;
|
||||
private volatile int affectedRows;
|
||||
private volatile boolean closeOnCompletion;
|
||||
|
||||
public RestfulStatement(RestfulConnection conn, String database) {
|
||||
this.conn = conn;
|
||||
|
@ -104,85 +104,6 @@ public class RestfulStatement implements Statement {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxFieldSize() throws SQLException {
|
||||
if (isClosed())
|
||||
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||
return TSDBConstants.maxFieldSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxFieldSize(int max) throws SQLException {
|
||||
if (isClosed())
|
||||
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||
if (max < 0)
|
||||
throw new SQLException(TSDBConstants.INVALID_VARIABLES);
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxRows() throws SQLException {
|
||||
if (isClosed())
|
||||
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxRows(int max) throws SQLException {
|
||||
if (isClosed())
|
||||
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||
if (max < 0)
|
||||
throw new SQLException(TSDBConstants.INVALID_VARIABLES);
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEscapeProcessing(boolean enable) throws SQLException {
|
||||
if (isClosed())
|
||||
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getQueryTimeout() throws SQLException {
|
||||
if (isClosed())
|
||||
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setQueryTimeout(int seconds) throws SQLException {
|
||||
if (isClosed())
|
||||
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||
if (seconds < 0)
|
||||
throw new SQLException(TSDBConstants.INVALID_VARIABLES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() throws SQLException {
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SQLWarning getWarnings() throws SQLException {
|
||||
if (isClosed())
|
||||
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearWarnings() throws SQLException {
|
||||
// nothing to do
|
||||
if (isClosed())
|
||||
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCursorName(String name) throws SQLException {
|
||||
if (isClosed())
|
||||
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(String sql) throws SQLException {
|
||||
if (isClosed())
|
||||
|
@ -271,53 +192,6 @@ public class RestfulStatement implements Statement {
|
|||
return this.affectedRows;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getMoreResults() throws SQLException {
|
||||
return getMoreResults(CLOSE_CURRENT_RESULT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFetchDirection(int direction) throws SQLException {
|
||||
if (direction != ResultSet.FETCH_FORWARD && direction != ResultSet.FETCH_REVERSE && direction != ResultSet.FETCH_UNKNOWN)
|
||||
throw new SQLException(TSDBConstants.INVALID_VARIABLES);
|
||||
this.resultSet.setFetchDirection(direction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFetchDirection() throws SQLException {
|
||||
return this.resultSet.getFetchDirection();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFetchSize(int rows) throws SQLException {
|
||||
if (isClosed())
|
||||
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||
if (rows < 0)
|
||||
throw new SQLException(TSDBConstants.INVALID_VARIABLES);
|
||||
//nothing to do
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFetchSize() throws SQLException {
|
||||
if (isClosed())
|
||||
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getResultSetConcurrency() throws SQLException {
|
||||
if (isClosed())
|
||||
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||
return this.resultSet.getConcurrency();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getResultSetType() throws SQLException {
|
||||
if (isClosed())
|
||||
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||
return this.resultSet.getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBatch(String sql) throws SQLException {
|
||||
if (isClosed())
|
||||
|
@ -343,115 +217,10 @@ public class RestfulStatement implements Statement {
|
|||
return this.conn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getMoreResults(int current) throws SQLException {
|
||||
if (isClosed())
|
||||
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||
if (resultSet == null)
|
||||
return false;
|
||||
|
||||
// switch (current) {
|
||||
// case CLOSE_CURRENT_RESULT:
|
||||
// resultSet.close();
|
||||
// break;
|
||||
// case KEEP_CURRENT_RESULT:
|
||||
// break;
|
||||
// case CLOSE_ALL_RESULTS:
|
||||
// resultSet.close();
|
||||
// break;
|
||||
// default:
|
||||
// throw new SQLException(TSDBConstants.INVALID_VARIABLES);
|
||||
// }
|
||||
// return next;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultSet getGeneratedKeys() throws SQLException {
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException {
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int executeUpdate(String sql, int[] columnIndexes) throws SQLException {
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int executeUpdate(String sql, String[] columnNames) throws SQLException {
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(String sql, int autoGeneratedKeys) throws SQLException {
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(String sql, int[] columnIndexes) throws SQLException {
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(String sql, String[] columnNames) throws SQLException {
|
||||
throw new SQLFeatureNotSupportedException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getResultSetHoldability() throws SQLException {
|
||||
if (isClosed())
|
||||
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||
return this.resultSet.getHoldability();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClosed() throws SQLException {
|
||||
return closed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPoolable(boolean poolable) throws SQLException {
|
||||
if (isClosed())
|
||||
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||
//nothing to do
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPoolable() throws SQLException {
|
||||
if (isClosed())
|
||||
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeOnCompletion() throws SQLException {
|
||||
if (isClosed())
|
||||
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||
this.closeOnCompletion = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCloseOnCompletion() throws SQLException {
|
||||
if (isClosed())
|
||||
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||
return this.closeOnCompletion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T unwrap(Class<T> iface) throws SQLException {
|
||||
try {
|
||||
return iface.cast(this);
|
||||
} catch (ClassCastException cce) {
|
||||
throw new SQLException("Unable to unwrap to " + iface.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWrapperFor(Class<?> iface) throws SQLException {
|
||||
return iface.isInstance(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,272 +0,0 @@
|
|||
package com.taosdata.jdbc.utils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class TDNode {
|
||||
|
||||
private int index;
|
||||
private int running;
|
||||
private int deployed;
|
||||
private boolean testCluster;
|
||||
private String path;
|
||||
private String cfgDir;
|
||||
private String dataDir;
|
||||
private String logDir;
|
||||
private String cfgPath;
|
||||
|
||||
public TDNode(int index) {
|
||||
this.index = index;
|
||||
running = 0;
|
||||
deployed = 0;
|
||||
testCluster = false;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public void setTestCluster(boolean testCluster) {
|
||||
this.testCluster = testCluster;
|
||||
}
|
||||
|
||||
public void setRunning(int running) {
|
||||
this.running = running;
|
||||
}
|
||||
|
||||
public void searchTaosd(File dir, ArrayList<String> taosdPath) {
|
||||
File[] fileList = dir.listFiles();
|
||||
|
||||
if(fileList == null || fileList.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
for(File file : fileList) {
|
||||
if(file.isFile()) {
|
||||
if(file.getName().equals("taosd")) {
|
||||
taosdPath.add(file.getAbsolutePath());
|
||||
}
|
||||
} else {
|
||||
searchTaosd(file, taosdPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void start() {
|
||||
String selfPath = System.getProperty("user.dir");
|
||||
String binPath = "";
|
||||
String projDir = selfPath + "/../../../";
|
||||
|
||||
try {
|
||||
ArrayList<String> taosdPath = new ArrayList<>();
|
||||
|
||||
File dir = new File(projDir);
|
||||
String realProjDir = dir.getCanonicalPath();
|
||||
dir = new File(realProjDir);
|
||||
System.out.println("project Dir: " + projDir);
|
||||
searchTaosd(dir, taosdPath);
|
||||
|
||||
if(taosdPath.size() == 0) {
|
||||
System.out.println("The project path doens't exist");
|
||||
return;
|
||||
} else {
|
||||
for(String p : taosdPath) {
|
||||
if(!p.contains("packaging")) {
|
||||
binPath = p;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if(binPath.isEmpty()) {
|
||||
System.out.println("taosd not found");
|
||||
return;
|
||||
} else {
|
||||
System.out.println("taosd found in " + binPath);
|
||||
}
|
||||
|
||||
if(this.deployed == 0) {
|
||||
System.out.println("dnode" + index + "is not deployed");
|
||||
return;
|
||||
}
|
||||
|
||||
String cmd = "nohup " + binPath + " -c " + cfgDir + " > /dev/null 2>&1 & ";
|
||||
System.out.println("start taosd cmd: " + cmd);
|
||||
|
||||
try{
|
||||
Runtime.getRuntime().exec(cmd);
|
||||
TimeUnit.SECONDS.sleep(5);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
this.running = 1;
|
||||
}
|
||||
|
||||
public Integer getTaosdPid() {
|
||||
String cmd = "ps -ef|grep -w taosd| grep -v grep | awk '{print $2}'";
|
||||
String[] cmds = {"sh", "-c", cmd};
|
||||
try {
|
||||
Process process = Runtime.getRuntime().exec(cmds);
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
String line = null;
|
||||
Integer res = null;
|
||||
while((line = reader.readLine()) != null) {
|
||||
if(!line.isEmpty()) {
|
||||
res = Integer.valueOf(line);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
|
||||
if (this.running != 0) {
|
||||
Integer pid = null;
|
||||
while((pid = getTaosdPid()) != null) {
|
||||
|
||||
String killCmd = "kill -term " + pid;
|
||||
String[] killCmds = {"sh", "-c", killCmd};
|
||||
try {
|
||||
Runtime.getRuntime().exec(killCmds).waitFor();
|
||||
|
||||
TimeUnit.SECONDS.sleep(2);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
for(int port = 6030; port < 6041; port ++) {
|
||||
String fuserCmd = "fuser -k -n tcp " + port;
|
||||
Runtime.getRuntime().exec(fuserCmd).waitFor();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
this.running = 0;
|
||||
System.out.println("dnode:" + this.index + " is stopped by kill -term");
|
||||
}
|
||||
}
|
||||
|
||||
public void startIP() {
|
||||
try{
|
||||
String cmd = "sudo ifconfig lo:" + index + "192.168.0." + index + " up";
|
||||
Runtime.getRuntime().exec(cmd).waitFor();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void stopIP() {
|
||||
try{
|
||||
String cmd = "sudo ifconfig lo:" + index + "192.168.0." + index + " down";
|
||||
Runtime.getRuntime().exec(cmd).waitFor();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void setCfgConfig(String option, String value) {
|
||||
try{
|
||||
String cmd = "echo " + option + " " + value + " >> " + this.cfgPath;
|
||||
String[] cmdLine = {"sh", "-c", cmd};
|
||||
Process ps = Runtime.getRuntime().exec(cmdLine);
|
||||
ps.waitFor();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public String getDnodeRootDir() {
|
||||
String dnodeRootDir = this.path + "/sim/psim/dnode" + this.index;
|
||||
return dnodeRootDir;
|
||||
}
|
||||
|
||||
public String getDnodesRootDir() {
|
||||
String dnodesRootDir = this.path + "/sim/psim" + this.index;
|
||||
return dnodesRootDir;
|
||||
}
|
||||
|
||||
public void deploy() {
|
||||
this.logDir = this.path + "/sim/dnode" + this.index + "/log";
|
||||
this.dataDir = this.path + "/sim/dnode" + this.index + "/data";
|
||||
this.cfgDir = this.path + "/sim/dnode" + this.index + "/cfg";
|
||||
this.cfgPath = this.path + "/sim/dnode" + this.index + "/cfg/taos.cfg";
|
||||
|
||||
try {
|
||||
String cmd = "rm -rf " + this.logDir;
|
||||
Runtime.getRuntime().exec(cmd).waitFor();
|
||||
|
||||
cmd = "rm -rf " + this.cfgDir;
|
||||
Runtime.getRuntime().exec(cmd).waitFor();
|
||||
|
||||
cmd = "rm -rf " + this.dataDir;
|
||||
Runtime.getRuntime().exec(cmd).waitFor();
|
||||
|
||||
cmd = "mkdir -p " + this.logDir;
|
||||
Runtime.getRuntime().exec(cmd).waitFor();
|
||||
|
||||
cmd = "mkdir -p " + this.cfgDir;
|
||||
Runtime.getRuntime().exec(cmd).waitFor();
|
||||
|
||||
cmd = "mkdir -p " + this.dataDir;
|
||||
Runtime.getRuntime().exec(cmd).waitFor();
|
||||
|
||||
cmd = "touch " + this.cfgPath;
|
||||
Runtime.getRuntime().exec(cmd).waitFor();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if(this.testCluster) {
|
||||
startIP();
|
||||
setCfgConfig("masterIp", "192.168.0.1");
|
||||
setCfgConfig("secondIp", "192.168.0.2");
|
||||
setCfgConfig("publicIp", "192.168.0." + this.index);
|
||||
setCfgConfig("internalIp", "192.168.0." + this.index);
|
||||
setCfgConfig("privateIp", "192.168.0." + this.index);
|
||||
}
|
||||
setCfgConfig("dataDir", this.dataDir);
|
||||
setCfgConfig("logDir", this.logDir);
|
||||
setCfgConfig("numOfLogLines", "1000000/00");
|
||||
setCfgConfig("mnodeEqualVnodeNum", "0");
|
||||
setCfgConfig("walLevel", "1");
|
||||
setCfgConfig("statusInterval", "1");
|
||||
setCfgConfig("numOfMnodes", "3");
|
||||
setCfgConfig("numOfThreadsPerCore", "2.0");
|
||||
setCfgConfig("monitor", "0");
|
||||
setCfgConfig("maxVnodeConnections", "30000");
|
||||
setCfgConfig("maxMgmtConnections", "30000");
|
||||
setCfgConfig("maxMeterConnections", "30000");
|
||||
setCfgConfig("maxShellConns", "30000");
|
||||
setCfgConfig("locale", "en_US.UTF-8");
|
||||
setCfgConfig("charset", "UTF-8");
|
||||
setCfgConfig("asyncLog", "0");
|
||||
setCfgConfig("anyIp", "0");
|
||||
setCfgConfig("dDebugFlag", "135");
|
||||
setCfgConfig("mDebugFlag", "135");
|
||||
setCfgConfig("sdbDebugFlag", "135");
|
||||
setCfgConfig("rpcDebugFlag", "135");
|
||||
setCfgConfig("tmrDebugFlag", "131");
|
||||
setCfgConfig("cDebugFlag", "135");
|
||||
setCfgConfig("httpDebugFlag", "135");
|
||||
setCfgConfig("monitorDebugFlag", "135");
|
||||
setCfgConfig("udebugFlag", "135");
|
||||
setCfgConfig("jnidebugFlag", "135");
|
||||
setCfgConfig("qdebugFlag", "135");
|
||||
this.deployed = 1;
|
||||
}
|
||||
}
|
|
@ -1,72 +0,0 @@
|
|||
package com.taosdata.jdbc.utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
public class TDNodes {
|
||||
private ArrayList<TDNode> tdNodes;
|
||||
private boolean testCluster;
|
||||
|
||||
public TDNodes () {
|
||||
tdNodes = new ArrayList<>();
|
||||
for(int i = 1; i < 11; i ++) {
|
||||
tdNodes.add(new TDNode(i));
|
||||
}
|
||||
}
|
||||
|
||||
public void setTestCluster(boolean testCluster) {
|
||||
this.testCluster = testCluster;
|
||||
}
|
||||
|
||||
public void check(int index) {
|
||||
if(index < 1 || index > 10) {
|
||||
System.out.println("index: " + index + " should on a scale of [1, 10]");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void deploy(int index) {
|
||||
try {
|
||||
File file = new File(System.getProperty("user.dir") + "/../../../");
|
||||
String projectRealPath = file.getCanonicalPath();
|
||||
check(index);
|
||||
tdNodes.get(index - 1).setTestCluster(this.testCluster);
|
||||
tdNodes.get(index - 1).setPath(projectRealPath);
|
||||
tdNodes.get(index - 1).deploy();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.out.println("deploy Test Exception");
|
||||
}
|
||||
}
|
||||
|
||||
public void cfg(int index, String option, String value) {
|
||||
check(index);
|
||||
tdNodes.get(index - 1).setCfgConfig(option, value);
|
||||
}
|
||||
|
||||
public TDNode getTDNode(int index) {
|
||||
check(index);
|
||||
return tdNodes.get(index - 1);
|
||||
}
|
||||
|
||||
public void start(int index) {
|
||||
check(index);
|
||||
tdNodes.get(index - 1).start();
|
||||
}
|
||||
|
||||
public void stop(int index) {
|
||||
check(index);
|
||||
tdNodes.get(index - 1).stop();
|
||||
}
|
||||
|
||||
public void startIP(int index) {
|
||||
check(index);
|
||||
tdNodes.get(index - 1).startIP();
|
||||
}
|
||||
|
||||
public void stopIP(int index) {
|
||||
check(index);
|
||||
tdNodes.get(index - 1).stopIP();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
package com.taosdata.jdbc.utils;
|
||||
|
||||
import javax.management.*;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
public class TaosInfo implements TaosInfoMBean {
|
||||
|
||||
private static volatile TaosInfo instance;
|
||||
private AtomicLong connect_open = new AtomicLong();
|
||||
private AtomicLong connect_close = new AtomicLong();
|
||||
private AtomicLong statement_count = new AtomicLong();
|
||||
|
||||
static {
|
||||
try {
|
||||
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
|
||||
ObjectName name = new ObjectName("TaosInfoMBean:name=TaosInfo");
|
||||
server.registerMBean(TaosInfo.getInstance(), name);
|
||||
|
||||
} catch (MalformedObjectNameException | InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getConnect_open() {
|
||||
return connect_open.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getConnect_close() {
|
||||
return connect_close.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getConnect_active() {
|
||||
return connect_open.get() - connect_close.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getStatement_count() {
|
||||
return statement_count.get();
|
||||
}
|
||||
|
||||
/*******************************************************/
|
||||
|
||||
public void conn_open_increment() {
|
||||
connect_open.incrementAndGet();
|
||||
}
|
||||
|
||||
public void connect_close_increment() {
|
||||
connect_close.incrementAndGet();
|
||||
}
|
||||
|
||||
public void stmt_count_increment() {
|
||||
statement_count.incrementAndGet();
|
||||
}
|
||||
|
||||
/********************************************************************************/
|
||||
private TaosInfo() {
|
||||
}
|
||||
|
||||
public static TaosInfo getInstance() {
|
||||
if (instance == null) {
|
||||
synchronized (TaosInfo.class) {
|
||||
if (instance == null) {
|
||||
instance = new TaosInfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.taosdata.jdbc.utils;
|
||||
|
||||
public interface TaosInfoMBean {
|
||||
|
||||
long getConnect_open();
|
||||
|
||||
long getConnect_close();
|
||||
|
||||
long getConnect_active();
|
||||
|
||||
long getStatement_count();
|
||||
|
||||
}
|
|
@ -7,6 +7,7 @@ import org.junit.Test;
|
|||
|
||||
import javax.sql.rowset.serial.SerialBlob;
|
||||
import javax.sql.rowset.serial.SerialClob;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.sql.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Properties;
|
||||
|
@ -39,7 +40,6 @@ public class ResultSetTest {
|
|||
} catch (ClassNotFoundException | SQLException e) {
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -54,51 +54,38 @@ public class ResultSetTest {
|
|||
short v6 = 12;
|
||||
boolean v7 = false;
|
||||
String v8 = "TDengine is powerful";
|
||||
|
||||
sql = "insert into " + dbName + "." + tName + " values (" + ts + "," + v1 + "," + v2 + "," + v3 + "," + v4
|
||||
+ ",\"" + v5 + "\"," + v6 + "," + v7 + ",\"" + v8 + "\")";
|
||||
|
||||
try {
|
||||
statement.executeUpdate(sql);
|
||||
assertEquals(1, statement.getUpdateCount());
|
||||
} catch (SQLException e) {
|
||||
assert false : "insert error " + e.getMessage();
|
||||
}
|
||||
|
||||
try {
|
||||
statement.executeQuery("select * from " + dbName + "." + tName + " where ts = " + ts);
|
||||
statement.execute("select * from " + dbName + "." + tName + " where ts = " + ts);
|
||||
resSet = statement.getResultSet();
|
||||
System.out.println(((TSDBResultSet) resSet).getRowData());
|
||||
while (resSet.next()) {
|
||||
assertEquals(ts, resSet.getLong(1));
|
||||
assertEquals(ts, resSet.getLong("ts"));
|
||||
|
||||
System.out.println(resSet.getTimestamp(1));
|
||||
|
||||
assertEquals(v1, resSet.getInt(2));
|
||||
assertEquals(v1, resSet.getInt("k1"));
|
||||
|
||||
assertEquals(v2, resSet.getLong(3));
|
||||
assertEquals(v2, resSet.getLong("k2"));
|
||||
|
||||
assertEquals(v3, resSet.getFloat(4), 7);
|
||||
assertEquals(v3, resSet.getFloat("k3"), 7);
|
||||
|
||||
assertEquals(v4, resSet.getDouble(5), 13);
|
||||
assertEquals(v4, resSet.getDouble("k4"), 13);
|
||||
|
||||
assertEquals(v5, resSet.getString(6));
|
||||
assertEquals(v5, resSet.getString("k5"));
|
||||
|
||||
assertEquals(v6, resSet.getShort(7));
|
||||
assertEquals(v6, resSet.getShort("k6"));
|
||||
|
||||
assertEquals(v7, resSet.getBoolean(8));
|
||||
assertEquals(v7, resSet.getBoolean("k7"));
|
||||
|
||||
assertEquals(v8, resSet.getString(9));
|
||||
assertEquals(v8, resSet.getString("k8"));
|
||||
|
||||
resSet.getBytes(9);
|
||||
resSet.getObject(6);
|
||||
resSet.getObject("k8");
|
||||
|
@ -111,684 +98,145 @@ public class ResultSetTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnsupport() throws SQLException {
|
||||
statement.executeQuery("show databases");
|
||||
@Test(expected = SQLException.class)
|
||||
public void testUnsupport() throws SQLException, UnsupportedEncodingException {
|
||||
statement.execute("show databases");
|
||||
resSet = statement.getResultSet();
|
||||
Assert.assertNotNull(resSet.unwrap(TSDBResultSet.class));
|
||||
Assert.assertTrue(resSet.isWrapperFor(TSDBResultSet.class));
|
||||
try {
|
||||
resSet.getAsciiStream(0);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.getUnicodeStream(null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.getBinaryStream(null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.getAsciiStream("");
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.getUnicodeStream(null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.getBinaryStream(null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.getWarnings();
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.clearWarnings();
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.getCursorName();
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.getCharacterStream(null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.getCharacterStream(null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.isBeforeFirst();
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.isAfterLast();
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.isFirst();
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.isLast();
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.beforeFirst();
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.afterLast();
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.first();
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.last();
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.getRow();
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.absolute(1);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.relative(1);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.previous();
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.setFetchDirection(0);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.getFetchDirection();
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.setFetchSize(0);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.getFetchSize();
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.getConcurrency();
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.rowUpdated();
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.rowInserted();
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.rowDeleted();
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateNull(null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateBoolean(0, true);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateByte(0, (byte) 2);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateShort(0, (short) 1);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateInt(0, 0);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateLong(0, 0l);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateFloat(0, 3.14f);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateDouble(0, 3.1415);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateBigDecimal(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateString(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateBytes(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateDate(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateTime(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateTimestamp(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateAsciiStream(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateBinaryStream(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateCharacterStream(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateObject(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateObject(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateNull(null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateBoolean("", false);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateByte("", (byte) 1);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateShort("", (short) 1);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateInt("", 0);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateLong("", 0l);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateFloat("", 3.14f);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateDouble("", 3.1415);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateBigDecimal(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateString(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateBytes(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateDate(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateTime(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateTimestamp(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateAsciiStream(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateBinaryStream(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateCharacterStream(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateObject(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateObject(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.insertRow();
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateRow();
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.deleteRow();
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.refreshRow();
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.cancelRowUpdates();
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.moveToInsertRow();
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.moveToCurrentRow();
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.getStatement();
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.getObject(0, new HashMap<>());
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.getRef(null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.getBlob(null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.getClob(null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.getArray(null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.getObject("", new HashMap<>());
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.getRef(null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.getBlob(null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.getClob(null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.getArray(null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.getDate(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.getDate(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.getTime(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.getTime(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.getTimestamp(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.getTimestamp(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.getURL(null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.getURL(null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateRef(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateRef(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateBlob(0, new SerialBlob("".getBytes("UTF8")));
|
||||
} catch (Exception e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateBlob("", new SerialBlob("".getBytes("UTF8")));
|
||||
} catch (Exception e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateClob("", new SerialClob("".toCharArray()));
|
||||
} catch (Exception e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateClob(0, new SerialClob("".toCharArray()));
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateArray(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateArray(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.getRowId(null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.getRowId(null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateRowId(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateRowId(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.getHoldability();
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateNString(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateNString(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
|
||||
try {
|
||||
resSet.getNClob(null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.getNClob(null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.getSQLXML(null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.getSQLXML(null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateSQLXML(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateSQLXML(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.getNCharacterStream(null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.getNCharacterStream(null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateNCharacterStream(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateNCharacterStream(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateAsciiStream(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateBinaryStream(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateCharacterStream(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateAsciiStream(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateBinaryStream(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateCharacterStream(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
|
||||
try {
|
||||
resSet.updateNCharacterStream(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateNCharacterStream(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateAsciiStream(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateBinaryStream(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateCharacterStream(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateAsciiStream(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateBinaryStream(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
try {
|
||||
resSet.updateCharacterStream(null, null);
|
||||
} catch (SQLException e) {
|
||||
assertTrue(e.getMessage().contains("this operation is NOT supported currently!"));
|
||||
}
|
||||
resSet.getUnicodeStream(null);
|
||||
resSet.getBinaryStream(null);
|
||||
resSet.getAsciiStream("");
|
||||
resSet.getUnicodeStream(null);
|
||||
resSet.getBinaryStream(null);
|
||||
resSet.getWarnings();
|
||||
resSet.clearWarnings();
|
||||
resSet.getCursorName();
|
||||
resSet.getCharacterStream(null);
|
||||
resSet.getCharacterStream(null);
|
||||
resSet.isBeforeFirst();
|
||||
resSet.isAfterLast();
|
||||
resSet.isFirst();
|
||||
resSet.isLast();
|
||||
resSet.beforeFirst();
|
||||
resSet.afterLast();
|
||||
resSet.first();
|
||||
resSet.last();
|
||||
resSet.getRow();
|
||||
resSet.absolute(1);
|
||||
resSet.relative(1);
|
||||
resSet.previous();
|
||||
resSet.setFetchDirection(0);
|
||||
resSet.getFetchDirection();
|
||||
resSet.setFetchSize(0);
|
||||
resSet.getFetchSize();
|
||||
resSet.getConcurrency();
|
||||
resSet.rowUpdated();
|
||||
resSet.rowInserted();
|
||||
resSet.rowDeleted();
|
||||
resSet.updateNull(null);
|
||||
resSet.updateBoolean(0, true);
|
||||
resSet.updateByte(0, (byte) 2);
|
||||
resSet.updateShort(0, (short) 1);
|
||||
resSet.updateInt(0, 0);
|
||||
resSet.updateLong(0, 0l);
|
||||
resSet.updateFloat(0, 3.14f);
|
||||
resSet.updateDouble(0, 3.1415);
|
||||
resSet.updateBigDecimal(null, null);
|
||||
resSet.updateString(null, null);
|
||||
resSet.updateBytes(null, null);
|
||||
resSet.updateDate(null, null);
|
||||
resSet.updateTime(null, null);
|
||||
resSet.updateTimestamp(null, null);
|
||||
resSet.updateAsciiStream(null, null);
|
||||
resSet.updateBinaryStream(null, null);
|
||||
resSet.updateCharacterStream(null, null);
|
||||
resSet.updateObject(null, null);
|
||||
resSet.updateObject(null, null);
|
||||
resSet.updateNull(null);
|
||||
resSet.updateBoolean("", false);
|
||||
resSet.updateByte("", (byte) 1);
|
||||
resSet.updateShort("", (short) 1);
|
||||
resSet.updateInt("", 0);
|
||||
resSet.updateLong("", 0l);
|
||||
resSet.updateFloat("", 3.14f);
|
||||
resSet.updateDouble("", 3.1415);
|
||||
resSet.updateBigDecimal(null, null);
|
||||
resSet.updateString(null, null);
|
||||
resSet.updateBytes(null, null);
|
||||
resSet.updateDate(null, null);
|
||||
resSet.updateTime(null, null);
|
||||
resSet.updateTimestamp(null, null);
|
||||
resSet.updateAsciiStream(null, null);
|
||||
resSet.updateBinaryStream(null, null);
|
||||
resSet.updateCharacterStream(null, null);
|
||||
resSet.updateObject(null, null);
|
||||
resSet.updateObject(null, null);
|
||||
resSet.insertRow();
|
||||
resSet.updateRow();
|
||||
resSet.deleteRow();
|
||||
resSet.refreshRow();
|
||||
resSet.cancelRowUpdates();
|
||||
resSet.moveToInsertRow();
|
||||
resSet.moveToCurrentRow();
|
||||
resSet.getStatement();
|
||||
resSet.getObject(0, new HashMap<>());
|
||||
resSet.getRef(null);
|
||||
resSet.getBlob(null);
|
||||
resSet.getClob(null);
|
||||
resSet.getArray(null);
|
||||
resSet.getObject("", new HashMap<>());
|
||||
resSet.getRef(null);
|
||||
resSet.getBlob(null);
|
||||
resSet.getClob(null);
|
||||
resSet.getArray(null);
|
||||
resSet.getDate(null, null);
|
||||
resSet.getDate(null, null);
|
||||
resSet.getTime(null, null);
|
||||
resSet.getTime(null, null);
|
||||
resSet.getTimestamp(null, null);
|
||||
resSet.getTimestamp(null, null);
|
||||
resSet.getURL(null);
|
||||
resSet.getURL(null);
|
||||
resSet.updateRef(null, null);
|
||||
resSet.updateRef(null, null);
|
||||
resSet.updateBlob(0, new SerialBlob("".getBytes("UTF8")));
|
||||
resSet.updateBlob("", new SerialBlob("".getBytes("UTF8")));
|
||||
resSet.updateClob("", new SerialClob("".toCharArray()));
|
||||
resSet.updateClob(0, new SerialClob("".toCharArray()));
|
||||
resSet.updateArray(null, null);
|
||||
resSet.updateArray(null, null);
|
||||
resSet.getRowId(null);
|
||||
resSet.getRowId(null);
|
||||
resSet.updateRowId(null, null);
|
||||
resSet.updateRowId(null, null);
|
||||
resSet.getHoldability();
|
||||
resSet.updateNString(null, null);
|
||||
resSet.updateNString(null, null);
|
||||
resSet.getNClob(null);
|
||||
resSet.getNClob(null);
|
||||
resSet.getSQLXML(null);
|
||||
resSet.getSQLXML(null);
|
||||
resSet.updateSQLXML(null, null);
|
||||
resSet.updateSQLXML(null, null);
|
||||
resSet.getNCharacterStream(null);
|
||||
resSet.getNCharacterStream(null);
|
||||
resSet.updateNCharacterStream(null, null);
|
||||
resSet.updateNCharacterStream(null, null);
|
||||
resSet.updateAsciiStream(null, null);
|
||||
resSet.updateBinaryStream(null, null);
|
||||
resSet.updateCharacterStream(null, null);
|
||||
resSet.updateAsciiStream(null, null);
|
||||
resSet.updateBinaryStream(null, null);
|
||||
resSet.updateCharacterStream(null, null);
|
||||
resSet.updateNCharacterStream(null, null);
|
||||
resSet.updateNCharacterStream(null, null);
|
||||
resSet.updateAsciiStream(null, null);
|
||||
resSet.updateBinaryStream(null, null);
|
||||
resSet.updateCharacterStream(null, null);
|
||||
resSet.updateAsciiStream(null, null);
|
||||
resSet.updateBinaryStream(null, null);
|
||||
resSet.updateCharacterStream(null, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -816,5 +264,4 @@ public class ResultSetTest {
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,9 +8,6 @@ import org.junit.Test;
|
|||
import java.sql.*;
|
||||
import java.util.Properties;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class StatementTest {
|
||||
static Connection connection = null;
|
||||
static Statement statement = null;
|
||||
|
@ -58,12 +55,12 @@ public class StatementTest {
|
|||
statement.executeUpdate("create database if not exists " + dbName);
|
||||
statement.executeUpdate("create table if not exists " + dbName + "." + tName + "(ts timestamp, k1 int)");
|
||||
statement.executeUpdate("insert into " + dbName + "." + tName + " values (" + ts + ", 1)");
|
||||
statement.executeQuery("select * from " + dbName + "." + tName);
|
||||
statement.execute("select * from " + dbName + "." + tName);
|
||||
ResultSet resultSet = statement.getResultSet();
|
||||
assertTrue(null != resultSet);
|
||||
Assert.assertNotNull(resultSet);
|
||||
|
||||
boolean isClosed = statement.isClosed();
|
||||
assertEquals(false, isClosed);
|
||||
Assert.assertEquals(false, isClosed);
|
||||
}
|
||||
|
||||
@Test(expected = SQLException.class)
|
||||
|
|
|
@ -9,13 +9,14 @@ import java.sql.DriverManager;
|
|||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class SubscribeTest {
|
||||
Connection connection;
|
||||
Statement statement;
|
||||
String dbName = "test";
|
||||
String tName = "t0";
|
||||
String host = "localhost";
|
||||
String host = "127.0.0.1";
|
||||
String topic = "test";
|
||||
|
||||
@Before
|
||||
|
@ -23,15 +24,15 @@ public class SubscribeTest {
|
|||
try {
|
||||
Class.forName("com.taosdata.jdbc.TSDBDriver");
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty(TSDBDriver.PROPERTY_KEY_HOST, host);
|
||||
properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8");
|
||||
properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8");
|
||||
properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8");
|
||||
connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/", properties);
|
||||
|
||||
statement = connection.createStatement();
|
||||
statement.executeUpdate("create database if not exists " + dbName);
|
||||
statement.executeUpdate("create table if not exists " + dbName + "." + tName + " (ts timestamp, k int, v int)");
|
||||
statement.execute("drop database if exists " + dbName);
|
||||
statement.execute("create database if not exists " + dbName);
|
||||
statement.execute("create table if not exists " + dbName + "." + tName + " (ts timestamp, k int, v int)");
|
||||
long ts = System.currentTimeMillis();
|
||||
for (int i = 0; i < 2; i++) {
|
||||
ts += i;
|
||||
|
@ -45,44 +46,40 @@ public class SubscribeTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void subscribe() throws Exception {
|
||||
TSDBSubscribe subscribe = null;
|
||||
public void subscribe() {
|
||||
try {
|
||||
|
||||
String rawSql = "select * from " + dbName + "." + tName + ";";
|
||||
System.out.println(rawSql);
|
||||
subscribe = ((TSDBConnection) connection).subscribe(topic, rawSql, false);
|
||||
TSDBSubscribe subscribe = ((TSDBConnection) connection).subscribe(topic, rawSql, false);
|
||||
|
||||
int a = 0;
|
||||
while (true) {
|
||||
Thread.sleep(900);
|
||||
TimeUnit.MILLISECONDS.sleep(1000);
|
||||
TSDBResultSet resSet = subscribe.consume();
|
||||
|
||||
while (resSet.next()) {
|
||||
for (int i = 1; i <= resSet.getMetaData().getColumnCount(); i++) {
|
||||
System.out.printf(i + ": " + resSet.getString(i) + "\t");
|
||||
}
|
||||
System.out.println("\n======" + a + "==========");
|
||||
}
|
||||
resSet.close();
|
||||
a++;
|
||||
if (a >= 2) {
|
||||
break;
|
||||
}
|
||||
// resSet.close();
|
||||
}
|
||||
|
||||
subscribe.close(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (null != subscribe) {
|
||||
subscribe.close(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@After
|
||||
public void close() {
|
||||
try {
|
||||
statement.executeQuery("drop database " + dbName);
|
||||
statement.execute("drop database " + dbName);
|
||||
if (statement != null)
|
||||
statement.close();
|
||||
if (connection != null)
|
||||
|
|
|
@ -0,0 +1,234 @@
|
|||
package com.taosdata.jdbc;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.Properties;
|
||||
import java.util.UUID;
|
||||
|
||||
public class TSDBStatementTest {
|
||||
private static final String host = "127.0.0.1";
|
||||
private static Connection conn;
|
||||
private static Statement stmt;
|
||||
|
||||
@Test
|
||||
public void executeQuery() {
|
||||
try {
|
||||
ResultSet rs = stmt.executeQuery("show databases");
|
||||
Assert.assertNotNull(rs);
|
||||
ResultSetMetaData meta = rs.getMetaData();
|
||||
while (rs.next()) {
|
||||
for (int i = 1; i <= meta.getColumnCount(); i++) {
|
||||
System.out.print(meta.getColumnLabel(i) + ": " + rs.getString(i) + "\t");
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
rs.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void executeUpdate() {
|
||||
final String dbName = ("test_" + UUID.randomUUID()).replace("-", "_").substring(0, 32);
|
||||
try {
|
||||
int affectRows = stmt.executeUpdate("create database " + dbName);
|
||||
Assert.assertEquals(0, affectRows);
|
||||
affectRows = stmt.executeUpdate("create table " + dbName + ".weather(ts timestamp, temperature float) tags(loc nchar(64))");
|
||||
Assert.assertEquals(0, affectRows);
|
||||
affectRows = stmt.executeUpdate("insert into " + dbName + ".t1 using " + dbName + ".weather tags('北京') values(now, 22.33)");
|
||||
Assert.assertEquals(1, affectRows);
|
||||
affectRows = stmt.executeUpdate("drop database " + dbName);
|
||||
Assert.assertEquals(0, affectRows);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void close() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void execute() {
|
||||
final String dbName = ("test_" + UUID.randomUUID()).replace("-", "_").substring(0, 32);
|
||||
try {
|
||||
boolean isSelect = stmt.execute("create database " + dbName);
|
||||
Assert.assertEquals(false, isSelect);
|
||||
int affectedRows = stmt.getUpdateCount();
|
||||
Assert.assertEquals(0, affectedRows);
|
||||
|
||||
isSelect = stmt.execute("create table " + dbName + ".weather(ts timestamp, temperature float) tags(loc nchar(64))");
|
||||
Assert.assertEquals(false, isSelect);
|
||||
affectedRows = stmt.getUpdateCount();
|
||||
Assert.assertEquals(0, affectedRows);
|
||||
|
||||
isSelect = stmt.execute("insert into " + dbName + ".t1 using " + dbName + ".weather tags('北京') values(now, 22.33)");
|
||||
Assert.assertEquals(false, isSelect);
|
||||
affectedRows = stmt.getUpdateCount();
|
||||
Assert.assertEquals(1, affectedRows);
|
||||
|
||||
isSelect = stmt.execute("select * from " + dbName + ".weather");
|
||||
Assert.assertEquals(true, isSelect);
|
||||
|
||||
isSelect = stmt.execute("drop database " + dbName);
|
||||
Assert.assertEquals(false, isSelect);
|
||||
affectedRows = stmt.getUpdateCount();
|
||||
Assert.assertEquals(0, affectedRows);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getResultSet() {
|
||||
final String dbName = ("test_" + UUID.randomUUID()).replace("-", "_").substring(0, 32);
|
||||
try {
|
||||
boolean isSelect = stmt.execute("create database " + dbName);
|
||||
Assert.assertEquals(false, isSelect);
|
||||
int affectedRows = stmt.getUpdateCount();
|
||||
Assert.assertEquals(0, affectedRows);
|
||||
|
||||
isSelect = stmt.execute("create table " + dbName + ".weather(ts timestamp, temperature float) tags(loc nchar(64))");
|
||||
Assert.assertEquals(false, isSelect);
|
||||
affectedRows = stmt.getUpdateCount();
|
||||
Assert.assertEquals(0, affectedRows);
|
||||
|
||||
isSelect = stmt.execute("insert into " + dbName + ".t1 using " + dbName + ".weather tags('北京') values(now, 22.33)");
|
||||
Assert.assertEquals(false, isSelect);
|
||||
affectedRows = stmt.getUpdateCount();
|
||||
Assert.assertEquals(1, affectedRows);
|
||||
|
||||
isSelect = stmt.execute("select * from " + dbName + ".weather");
|
||||
Assert.assertEquals(true, isSelect);
|
||||
ResultSet rs = stmt.getResultSet();
|
||||
Assert.assertNotNull(rs);
|
||||
ResultSetMetaData meta = rs.getMetaData();
|
||||
Assert.assertEquals(3, meta.getColumnCount());
|
||||
int count = 0;
|
||||
while (rs.next()) {
|
||||
for (int i = 1; i <= meta.getColumnCount(); i++) {
|
||||
System.out.print(meta.getColumnLabel(i) + ": " + rs.getString(i) + "\t");
|
||||
}
|
||||
System.out.println();
|
||||
count++;
|
||||
}
|
||||
Assert.assertEquals(1, count);
|
||||
|
||||
isSelect = stmt.execute("drop database " + dbName);
|
||||
Assert.assertEquals(false, isSelect);
|
||||
affectedRows = stmt.getUpdateCount();
|
||||
Assert.assertEquals(0, affectedRows);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getUpdateCount() {
|
||||
execute();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addBatch() {
|
||||
final String dbName = ("test_" + UUID.randomUUID()).replace("-", "_").substring(0, 32);
|
||||
try {
|
||||
stmt.addBatch("create database " + dbName);
|
||||
stmt.addBatch("create table " + dbName + ".weather(ts timestamp, temperature float) tags(loc nchar(64))");
|
||||
stmt.addBatch("insert into " + dbName + ".t1 using " + dbName + ".weather tags('北京') values(now, 22.33)");
|
||||
stmt.addBatch("select * from " + dbName + ".weather");
|
||||
stmt.addBatch("drop database " + dbName);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void clearBatch() {
|
||||
final String dbName = ("test_" + UUID.randomUUID()).replace("-", "_").substring(0, 32);
|
||||
try {
|
||||
stmt.clearBatch();
|
||||
stmt.addBatch("create database " + dbName);
|
||||
stmt.addBatch("create table " + dbName + ".weather(ts timestamp, temperature float) tags(loc nchar(64))");
|
||||
stmt.addBatch("insert into " + dbName + ".t1 using " + dbName + ".weather tags('北京') values(now, 22.33)");
|
||||
stmt.addBatch("select * from " + dbName + ".weather");
|
||||
stmt.addBatch("drop database " + dbName);
|
||||
stmt.clearBatch();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void executeBatch() {
|
||||
final String dbName = ("test_" + UUID.randomUUID()).replace("-", "_").substring(0, 32);
|
||||
try {
|
||||
stmt.addBatch("create database " + dbName);
|
||||
stmt.addBatch("create table " + dbName + ".weather(ts timestamp, temperature float) tags(loc nchar(64))");
|
||||
stmt.addBatch("insert into " + dbName + ".t1 using " + dbName + ".weather tags('北京') values(now, 22.33)");
|
||||
stmt.addBatch("select * from " + dbName + ".weather");
|
||||
stmt.addBatch("drop database " + dbName);
|
||||
int[] results = stmt.executeBatch();
|
||||
Assert.assertEquals(0, results[0]);
|
||||
Assert.assertEquals(0, results[1]);
|
||||
Assert.assertEquals(1, results[2]);
|
||||
Assert.assertEquals(Statement.SUCCESS_NO_INFO, results[3]);
|
||||
Assert.assertEquals(0, results[4]);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getConnection() {
|
||||
try {
|
||||
Connection connection = stmt.getConnection();
|
||||
Assert.assertNotNull(connection);
|
||||
Assert.assertTrue(this.conn == connection);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isClosed() {
|
||||
try {
|
||||
Assert.assertEquals(false, stmt.isClosed());
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() {
|
||||
try {
|
||||
Class.forName("com.taosdata.jdbc.TSDBDriver");
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8");
|
||||
properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8");
|
||||
properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8");
|
||||
conn = DriverManager.getConnection("jdbc:TAOS://" + host + ":6030/?user=root&password=taosdata", properties);
|
||||
stmt = conn.createStatement();
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() {
|
||||
try {
|
||||
if (stmt != null)
|
||||
stmt.close();
|
||||
if (conn != null)
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,187 @@
|
|||
package com.taosdata.jdbc.cases;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.Properties;
|
||||
|
||||
public class InvalidResultSetPointerTest {
|
||||
|
||||
private static String host = "127.0.0.1";
|
||||
private static final String dbName = "test";
|
||||
private static final String stbName = "stb";
|
||||
private static final String tbName = "tb";
|
||||
private static Connection connection;
|
||||
private static int numOfSTb = 30000;
|
||||
private static int numOfTb = 3;
|
||||
private static int numOfThreads = 100;
|
||||
|
||||
@Test
|
||||
public void test() throws SQLException {
|
||||
execute("drop database if exists " + dbName);
|
||||
execute("create database if not exists " + dbName);
|
||||
execute("use " + dbName);
|
||||
createSTable();
|
||||
createTable();
|
||||
insert();
|
||||
selectMultiThreading();
|
||||
close();
|
||||
}
|
||||
|
||||
private void insert() {
|
||||
for (int i = 0; i < numOfSTb; i++) {
|
||||
for (int j = 0; j < numOfTb; j++) {
|
||||
final String sql = "INSERT INTO " + dbName + "." + tbName + i + "_" + j + " (ts, temperature, humidity, name) values(now, 20.5, 34, \"" + i + "\")";
|
||||
System.out.println(sql);
|
||||
execute(sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void createSTable() {
|
||||
for (int i = 0; i < numOfSTb; i++) {
|
||||
final String sql = "create table if not exists " + dbName + "." + stbName + i + " (ts timestamp, temperature float, humidity int, name BINARY(" + (i % 73 + 10) + ")) TAGS (tag1 INT)";
|
||||
execute(sql);
|
||||
}
|
||||
}
|
||||
|
||||
private void createTable() {
|
||||
for (int i = 0; i < numOfSTb; i++) {
|
||||
for (int j = 0; j < numOfTb; j++) {
|
||||
final String sql = "create table if not exists " + dbName + "." + tbName + i + "_" + j + " USING " + stbName + i + " TAGS(" + j + ")";
|
||||
execute(sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void close() throws SQLException {
|
||||
if (connection != null) {
|
||||
this.connection.close();
|
||||
System.out.println("connection closed.");
|
||||
}
|
||||
}
|
||||
|
||||
private void selectMultiThreading() {
|
||||
int a = numOfSTb / numOfThreads;
|
||||
if (a < 1) {
|
||||
numOfThreads = numOfSTb;
|
||||
a = 1;
|
||||
}
|
||||
|
||||
int b = 0;
|
||||
if (numOfThreads != 0) {
|
||||
b = numOfSTb % numOfThreads;
|
||||
}
|
||||
|
||||
multiThreadingClass instance[] = new multiThreadingClass[numOfThreads];
|
||||
|
||||
int last = 0;
|
||||
for (int i = 0; i < numOfThreads; i++) {
|
||||
instance[i] = new multiThreadingClass();
|
||||
instance[i].id = i;
|
||||
instance[i].from = last;
|
||||
if (i < b) {
|
||||
instance[i].to = last + a;
|
||||
} else {
|
||||
instance[i].to = last + a - 1;
|
||||
}
|
||||
|
||||
last = instance[i].to + 1;
|
||||
instance[i].numOfTb = numOfTb;
|
||||
instance[i].connection = connection;
|
||||
instance[i].dbName = dbName;
|
||||
instance[i].tbName = tbName;
|
||||
instance[i].start();
|
||||
}
|
||||
|
||||
for (int i = 0; i < numOfThreads; i++) {
|
||||
try {
|
||||
instance[i].join();
|
||||
} catch (InterruptedException ie) {
|
||||
ie.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() {
|
||||
try {
|
||||
String url = "jdbc:TAOS://" + host + ":6030/?user=root&password=taosdata";
|
||||
Class.forName("com.taosdata.jdbc.TSDBDriver");
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty("charset", "UTF-8");
|
||||
properties.setProperty("locale", "en_US.UTF-8");
|
||||
properties.setProperty("timezone", "UTC-8");
|
||||
System.out.println("get connection starting...");
|
||||
connection = DriverManager.getConnection(url, properties);
|
||||
if (connection != null)
|
||||
System.out.println("[ OK ] Connection established.");
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void execute(String sql) {
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
long start = System.currentTimeMillis();
|
||||
statement.execute(sql);
|
||||
long end = System.currentTimeMillis();
|
||||
printSql(sql, (end - start));
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void printSql(String sql, long cost) {
|
||||
System.out.println("time cost: " + cost + " ms, execute statement ====> " + sql);
|
||||
}
|
||||
|
||||
private void executeQuery(String sql) {
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
long start = System.currentTimeMillis();
|
||||
ResultSet resultSet = statement.executeQuery(sql);
|
||||
long end = System.currentTimeMillis();
|
||||
printSql(sql, (end - start));
|
||||
// printResult(resultSet);
|
||||
resultSet.close();
|
||||
statement.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
class multiThreadingClass extends Thread {
|
||||
public int id;
|
||||
public int from, to;
|
||||
public int numOfTb;
|
||||
public Connection connection;
|
||||
public String dbName;
|
||||
public String tbName;
|
||||
|
||||
public void run() {
|
||||
System.out.println("ID: " + id + " from: " + from + " to: " + to);
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
System.out.println("Thread " + id + " interrupted.");
|
||||
}
|
||||
|
||||
for (int i = from; i < to; i++) {
|
||||
for (int j = 0; j < numOfTb; j++) {
|
||||
if (j % 1000 == 0) {
|
||||
try {
|
||||
System.out.print(id + "s.");
|
||||
Thread.sleep(1);
|
||||
} catch (InterruptedException e) {
|
||||
System.out.println("Thread " + id + " interrupted.");
|
||||
}
|
||||
}
|
||||
final String sql = "select last_row(humidity) from " + dbName + "." + tbName + i + "_" + j;
|
||||
executeQuery(sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package com.taosdata.jdbc.cases;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
public class TaosInfoMonitorTest {
|
||||
|
||||
@Test
|
||||
public void testCreateTooManyConnection() throws ClassNotFoundException {
|
||||
Class.forName("com.taosdata.jdbc.TSDBDriver");
|
||||
final String url = "jdbc:TAOS://127.0.0.1:6030/?user=root&password=taosdata";
|
||||
|
||||
List<Connection> connectionList = IntStream.range(0, 100).mapToObj(i -> {
|
||||
try {
|
||||
TimeUnit.MILLISECONDS.sleep(100);
|
||||
return DriverManager.getConnection(url);
|
||||
} catch (SQLException | InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
connectionList.stream().forEach(conn -> {
|
||||
try (Statement stmt = conn.createStatement()) {
|
||||
ResultSet rs = stmt.executeQuery("show databases");
|
||||
while (rs.next()) {
|
||||
|
||||
}
|
||||
TimeUnit.MILLISECONDS.sleep(100);
|
||||
} catch (SQLException | InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
|
||||
connectionList.stream().forEach(conn -> {
|
||||
try {
|
||||
conn.close();
|
||||
TimeUnit.MILLISECONDS.sleep(100);
|
||||
} catch (SQLException | InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -259,10 +259,12 @@ public class RestfulResultSetTest {
|
|||
rs.previous();
|
||||
}
|
||||
|
||||
@Test(expected = SQLException.class)
|
||||
@Test
|
||||
public void setFetchDirection() throws SQLException {
|
||||
rs.setFetchDirection(ResultSet.FETCH_FORWARD);
|
||||
Assert.assertEquals(ResultSet.FETCH_FORWARD, rs.getFetchDirection());
|
||||
rs.setFetchDirection(ResultSet.FETCH_UNKNOWN);
|
||||
Assert.assertEquals(ResultSet.FETCH_FORWARD, rs.getFetchDirection());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -270,14 +272,15 @@ public class RestfulResultSetTest {
|
|||
Assert.assertEquals(ResultSet.FETCH_FORWARD, rs.getFetchDirection());
|
||||
}
|
||||
|
||||
@Test(expected = SQLException.class)
|
||||
@Test
|
||||
public void setFetchSize() throws SQLException {
|
||||
rs.setFetchSize(0);
|
||||
Assert.assertEquals(0, rs.getFetchSize());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getFetchSize() throws SQLException {
|
||||
Assert.assertEquals(1, rs.getFetchSize());
|
||||
Assert.assertEquals(0, rs.getFetchSize());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -526,9 +529,12 @@ public class RestfulResultSetTest {
|
|||
rs.updateSQLXML(1, null);
|
||||
}
|
||||
|
||||
@Test(expected = SQLFeatureNotSupportedException.class)
|
||||
@Test
|
||||
public void getNString() throws SQLException {
|
||||
rs.getNString("f1");
|
||||
String f10 = rs.getNString("f10");
|
||||
Assert.assertEquals("涛思数据", f10);
|
||||
f10 = rs.getNString(10);
|
||||
Assert.assertEquals("涛思数据", f10);
|
||||
}
|
||||
|
||||
@Test(expected = SQLFeatureNotSupportedException.class)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CMAKE_MINIMUM_REQUIRED(VERSION 3.5)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
PROJECT(TDengine)
|
||||
|
||||
IF (TD_LINUX_64)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CMAKE_MINIMUM_REQUIRED(VERSION 3.5)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
PROJECT(TDengine)
|
||||
|
||||
IF (TD_LINUX_64)
|
||||
|
|
|
@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
|
|||
|
||||
setuptools.setup(
|
||||
name="taos",
|
||||
version="2.0.4",
|
||||
version="2.0.5",
|
||||
author="Taosdata Inc.",
|
||||
author_email="support@taosdata.com",
|
||||
description="TDengine python client package",
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
from .cinterface import CTaosInterface
|
||||
from .error import *
|
||||
from .constants import FieldType
|
||||
import threading
|
||||
|
||||
|
||||
class TDengineCursor(object):
|
||||
|
@ -36,7 +35,6 @@ class TDengineCursor(object):
|
|||
self._block_iter = 0
|
||||
self._affected_rows = 0
|
||||
self._logfile = ""
|
||||
self._threadId = threading.get_ident()
|
||||
|
||||
if connection is not None:
|
||||
self._connection = connection
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
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/>.
|
|
@ -0,0 +1 @@
|
|||
# TDengine python client interface
|
|
@ -0,0 +1,20 @@
|
|||
import setuptools
|
||||
|
||||
with open("README.md", "r") as fh:
|
||||
long_description = fh.read()
|
||||
|
||||
setuptools.setup(
|
||||
name="taos",
|
||||
version="2.0.4",
|
||||
author="Taosdata Inc.",
|
||||
author_email="support@taosdata.com",
|
||||
description="TDengine python client package",
|
||||
long_description=long_description,
|
||||
long_description_content_type="text/markdown",
|
||||
url="https://github.com/pypa/sampleproject",
|
||||
packages=setuptools.find_packages(),
|
||||
classifiers=[
|
||||
"Programming Language :: Python :: 3",
|
||||
"Operating System :: MacOS X",
|
||||
],
|
||||
)
|
|
@ -0,0 +1,24 @@
|
|||
|
||||
from .connection import TDengineConnection
|
||||
from .cursor import TDengineCursor
|
||||
|
||||
# Globals
|
||||
apilevel = '2.0.4'
|
||||
threadsafety = 0
|
||||
paramstyle = 'pyformat'
|
||||
|
||||
__all__ = ['connection', 'cursor']
|
||||
|
||||
def connect(*args, **kwargs):
|
||||
""" Function to return a TDengine connector object
|
||||
|
||||
Current supporting keyword parameters:
|
||||
@dsn: Data source name as string
|
||||
@user: Username as string(optional)
|
||||
@password: Password as string(optional)
|
||||
@host: Hostname(optional)
|
||||
@database: Database name(optional)
|
||||
|
||||
@rtype: TDengineConnector
|
||||
"""
|
||||
return TDengineConnection(*args, **kwargs)
|
|
@ -0,0 +1,477 @@
|
|||
import ctypes
|
||||
from .constants import FieldType
|
||||
from .error import *
|
||||
import math
|
||||
import datetime
|
||||
|
||||
def _convert_millisecond_to_datetime(milli):
|
||||
return datetime.datetime.fromtimestamp(milli/1000.0)
|
||||
|
||||
def _convert_microsecond_to_datetime(micro):
|
||||
return datetime.datetime.fromtimestamp(micro/1000000.0)
|
||||
|
||||
def _crow_timestamp_to_python(data, num_of_rows, nbytes=None, micro=False):
|
||||
"""Function to convert C bool row to python row
|
||||
"""
|
||||
_timestamp_converter = _convert_millisecond_to_datetime
|
||||
if micro:
|
||||
_timestamp_converter = _convert_microsecond_to_datetime
|
||||
|
||||
if num_of_rows > 0:
|
||||
return list(map(_timestamp_converter, ctypes.cast(data, ctypes.POINTER(ctypes.c_long))[:abs(num_of_rows)]))
|
||||
else:
|
||||
return list(map(_timestamp_converter, ctypes.cast(data, ctypes.POINTER(ctypes.c_long))[:abs(num_of_rows)]))
|
||||
|
||||
def _crow_bool_to_python(data, num_of_rows, nbytes=None, micro=False):
|
||||
"""Function to convert C bool row to python row
|
||||
"""
|
||||
if num_of_rows > 0:
|
||||
return [ None if ele == FieldType.C_BOOL_NULL else bool(ele) for ele in ctypes.cast(data, ctypes.POINTER(ctypes.c_byte))[:abs(num_of_rows)] ]
|
||||
else:
|
||||
return [ None if ele == FieldType.C_BOOL_NULL else bool(ele) for ele in ctypes.cast(data, ctypes.POINTER(ctypes.c_bool))[:abs(num_of_rows)] ]
|
||||
|
||||
def _crow_tinyint_to_python(data, num_of_rows, nbytes=None, micro=False):
|
||||
"""Function to convert C tinyint row to python row
|
||||
"""
|
||||
if num_of_rows > 0:
|
||||
return [ None if ele == FieldType.C_TINYINT_NULL else ele for ele in ctypes.cast(data, ctypes.POINTER(ctypes.c_byte))[:abs(num_of_rows)] ]
|
||||
else:
|
||||
return [ None if ele == FieldType.C_TINYINT_NULL else ele for ele in ctypes.cast(data, ctypes.POINTER(ctypes.c_byte))[:abs(num_of_rows)] ]
|
||||
|
||||
def _crow_smallint_to_python(data, num_of_rows, nbytes=None, micro=False):
|
||||
"""Function to convert C smallint row to python row
|
||||
"""
|
||||
if num_of_rows > 0:
|
||||
return [ None if ele == FieldType.C_SMALLINT_NULL else ele for ele in ctypes.cast(data, ctypes.POINTER(ctypes.c_short))[:abs(num_of_rows)]]
|
||||
else:
|
||||
return [ None if ele == FieldType.C_SMALLINT_NULL else ele for ele in ctypes.cast(data, ctypes.POINTER(ctypes.c_short))[:abs(num_of_rows)] ]
|
||||
|
||||
def _crow_int_to_python(data, num_of_rows, nbytes=None, micro=False):
|
||||
"""Function to convert C int row to python row
|
||||
"""
|
||||
if num_of_rows > 0:
|
||||
return [ None if ele == FieldType.C_INT_NULL else ele for ele in ctypes.cast(data, ctypes.POINTER(ctypes.c_int))[:abs(num_of_rows)] ]
|
||||
else:
|
||||
return [ None if ele == FieldType.C_INT_NULL else ele for ele in ctypes.cast(data, ctypes.POINTER(ctypes.c_int))[:abs(num_of_rows)] ]
|
||||
|
||||
def _crow_bigint_to_python(data, num_of_rows, nbytes=None, micro=False):
|
||||
"""Function to convert C bigint row to python row
|
||||
"""
|
||||
if num_of_rows > 0:
|
||||
return [ None if ele == FieldType.C_BIGINT_NULL else ele for ele in ctypes.cast(data, ctypes.POINTER(ctypes.c_long))[:abs(num_of_rows)] ]
|
||||
else:
|
||||
return [ None if ele == FieldType.C_BIGINT_NULL else ele for ele in ctypes.cast(data, ctypes.POINTER(ctypes.c_long))[:abs(num_of_rows)] ]
|
||||
|
||||
def _crow_float_to_python(data, num_of_rows, nbytes=None, micro=False):
|
||||
"""Function to convert C float row to python row
|
||||
"""
|
||||
if num_of_rows > 0:
|
||||
return [ None if math.isnan(ele) else ele for ele in ctypes.cast(data, ctypes.POINTER(ctypes.c_float))[:abs(num_of_rows)] ]
|
||||
else:
|
||||
return [ None if math.isnan(ele) else ele for ele in ctypes.cast(data, ctypes.POINTER(ctypes.c_float))[:abs(num_of_rows)] ]
|
||||
|
||||
def _crow_double_to_python(data, num_of_rows, nbytes=None, micro=False):
|
||||
"""Function to convert C double row to python row
|
||||
"""
|
||||
if num_of_rows > 0:
|
||||
return [ None if math.isnan(ele) else ele for ele in ctypes.cast(data, ctypes.POINTER(ctypes.c_double))[:abs(num_of_rows)] ]
|
||||
else:
|
||||
return [ None if math.isnan(ele) else ele for ele in ctypes.cast(data, ctypes.POINTER(ctypes.c_double))[:abs(num_of_rows)] ]
|
||||
|
||||
def _crow_binary_to_python(data, num_of_rows, nbytes=None, micro=False):
|
||||
"""Function to convert C binary row to python row
|
||||
"""
|
||||
assert(nbytes is not None)
|
||||
if num_of_rows > 0:
|
||||
return [ None if ele.value[0:1] == FieldType.C_BINARY_NULL else ele.value.decode('utf-8') for ele in (ctypes.cast(data, ctypes.POINTER(ctypes.c_char * nbytes)))[:abs(num_of_rows)]]
|
||||
else:
|
||||
return [ None if ele.value[0:1] == FieldType.C_BINARY_NULL else ele.value.decode('utf-8') for ele in (ctypes.cast(data, ctypes.POINTER(ctypes.c_char * nbytes)))[:abs(num_of_rows)]]
|
||||
|
||||
def _crow_nchar_to_python(data, num_of_rows, nbytes=None, micro=False):
|
||||
"""Function to convert C nchar row to python row
|
||||
"""
|
||||
assert(nbytes is not None)
|
||||
res=[]
|
||||
for i in range(abs(num_of_rows)):
|
||||
try:
|
||||
if num_of_rows >= 0:
|
||||
tmpstr = ctypes.c_char_p(data)
|
||||
res.append( tmpstr.value.decode() )
|
||||
else:
|
||||
res.append( (ctypes.cast(data+nbytes*i, ctypes.POINTER(ctypes.c_wchar * (nbytes//4))))[0].value )
|
||||
except ValueError:
|
||||
res.append(None)
|
||||
|
||||
return res
|
||||
|
||||
def _crow_binary_to_python_block(data, num_of_rows, nbytes=None, micro=False):
|
||||
"""Function to convert C binary row to python row
|
||||
"""
|
||||
assert(nbytes is not None)
|
||||
res=[]
|
||||
if num_of_rows > 0:
|
||||
for i in range(abs(num_of_rows)):
|
||||
try:
|
||||
rbyte=ctypes.cast(data+nbytes*i,ctypes.POINTER(ctypes.c_short))[:1].pop()
|
||||
tmpstr = ctypes.c_char_p(data+nbytes*i+2)
|
||||
res.append( tmpstr.value.decode()[0:rbyte] )
|
||||
except ValueError:
|
||||
res.append(None)
|
||||
else:
|
||||
for i in range(abs(num_of_rows)):
|
||||
try:
|
||||
rbyte=ctypes.cast(data+nbytes*i,ctypes.POINTER(ctypes.c_short))[:1].pop()
|
||||
tmpstr = ctypes.c_char_p(data+nbytes*i+2)
|
||||
res.append( tmpstr.value.decode()[0:rbyte] )
|
||||
except ValueError:
|
||||
res.append(None)
|
||||
return res
|
||||
|
||||
def _crow_nchar_to_python_block(data, num_of_rows, nbytes=None, micro=False):
|
||||
"""Function to convert C nchar row to python row
|
||||
"""
|
||||
assert(nbytes is not None)
|
||||
res=[]
|
||||
if num_of_rows >= 0:
|
||||
for i in range(abs(num_of_rows)):
|
||||
try:
|
||||
tmpstr = ctypes.c_char_p(data+nbytes*i+2)
|
||||
res.append( tmpstr.value.decode() )
|
||||
except ValueError:
|
||||
res.append(None)
|
||||
else:
|
||||
for i in range(abs(num_of_rows)):
|
||||
try:
|
||||
res.append( (ctypes.cast(data+nbytes*i+2, ctypes.POINTER(ctypes.c_wchar * (nbytes//4))))[0].value )
|
||||
except ValueError:
|
||||
res.append(None)
|
||||
return res
|
||||
|
||||
_CONVERT_FUNC = {
|
||||
FieldType.C_BOOL: _crow_bool_to_python,
|
||||
FieldType.C_TINYINT : _crow_tinyint_to_python,
|
||||
FieldType.C_SMALLINT : _crow_smallint_to_python,
|
||||
FieldType.C_INT : _crow_int_to_python,
|
||||
FieldType.C_BIGINT : _crow_bigint_to_python,
|
||||
FieldType.C_FLOAT : _crow_float_to_python,
|
||||
FieldType.C_DOUBLE : _crow_double_to_python,
|
||||
FieldType.C_BINARY: _crow_binary_to_python,
|
||||
FieldType.C_TIMESTAMP : _crow_timestamp_to_python,
|
||||
FieldType.C_NCHAR : _crow_nchar_to_python
|
||||
}
|
||||
|
||||
_CONVERT_FUNC_BLOCK = {
|
||||
FieldType.C_BOOL: _crow_bool_to_python,
|
||||
FieldType.C_TINYINT : _crow_tinyint_to_python,
|
||||
FieldType.C_SMALLINT : _crow_smallint_to_python,
|
||||
FieldType.C_INT : _crow_int_to_python,
|
||||
FieldType.C_BIGINT : _crow_bigint_to_python,
|
||||
FieldType.C_FLOAT : _crow_float_to_python,
|
||||
FieldType.C_DOUBLE : _crow_double_to_python,
|
||||
FieldType.C_BINARY: _crow_binary_to_python_block,
|
||||
FieldType.C_TIMESTAMP : _crow_timestamp_to_python,
|
||||
FieldType.C_NCHAR : _crow_nchar_to_python_block
|
||||
}
|
||||
|
||||
# Corresponding TAOS_FIELD structure in C
|
||||
class TaosField(ctypes.Structure):
|
||||
_fields_ = [('name', ctypes.c_char * 65),
|
||||
('type', ctypes.c_char),
|
||||
('bytes', ctypes.c_short)]
|
||||
|
||||
# C interface class
|
||||
class CTaosInterface(object):
|
||||
|
||||
libtaos = ctypes.CDLL('libtaos.dylib')
|
||||
|
||||
libtaos.taos_fetch_fields.restype = ctypes.POINTER(TaosField)
|
||||
libtaos.taos_init.restype = None
|
||||
libtaos.taos_connect.restype = ctypes.c_void_p
|
||||
#libtaos.taos_use_result.restype = ctypes.c_void_p
|
||||
libtaos.taos_fetch_row.restype = ctypes.POINTER(ctypes.c_void_p)
|
||||
libtaos.taos_errstr.restype = ctypes.c_char_p
|
||||
libtaos.taos_subscribe.restype = ctypes.c_void_p
|
||||
libtaos.taos_consume.restype = ctypes.c_void_p
|
||||
libtaos.taos_fetch_lengths.restype = ctypes.c_void_p
|
||||
libtaos.taos_free_result.restype = None
|
||||
libtaos.taos_errno.restype = ctypes.c_int
|
||||
libtaos.taos_query.restype = ctypes.POINTER(ctypes.c_void_p)
|
||||
|
||||
def __init__(self, config=None):
|
||||
'''
|
||||
Function to initialize the class
|
||||
@host : str, hostname to connect
|
||||
@user : str, username to connect to server
|
||||
@password : str, password to connect to server
|
||||
@db : str, default db to use when log in
|
||||
@config : str, config directory
|
||||
|
||||
@rtype : None
|
||||
'''
|
||||
if config is None:
|
||||
self._config = ctypes.c_char_p(None)
|
||||
else:
|
||||
try:
|
||||
self._config = ctypes.c_char_p(config.encode('utf-8'))
|
||||
except AttributeError:
|
||||
raise AttributeError("config is expected as a str")
|
||||
|
||||
if config != None:
|
||||
CTaosInterface.libtaos.taos_options(3, self._config)
|
||||
|
||||
CTaosInterface.libtaos.taos_init()
|
||||
|
||||
@property
|
||||
def config(self):
|
||||
""" Get current config
|
||||
"""
|
||||
return self._config
|
||||
|
||||
def connect(self, host=None, user="root", password="taosdata", db=None, port=0):
|
||||
'''
|
||||
Function to connect to server
|
||||
|
||||
@rtype: c_void_p, TDengine handle
|
||||
'''
|
||||
# host
|
||||
try:
|
||||
_host = ctypes.c_char_p(host.encode(
|
||||
"utf-8")) if host != None else ctypes.c_char_p(None)
|
||||
except AttributeError:
|
||||
raise AttributeError("host is expected as a str")
|
||||
|
||||
# user
|
||||
try:
|
||||
_user = ctypes.c_char_p(user.encode("utf-8"))
|
||||
except AttributeError:
|
||||
raise AttributeError("user is expected as a str")
|
||||
|
||||
# password
|
||||
try:
|
||||
_password = ctypes.c_char_p(password.encode("utf-8"))
|
||||
except AttributeError:
|
||||
raise AttributeError("password is expected as a str")
|
||||
|
||||
# db
|
||||
try:
|
||||
_db = ctypes.c_char_p(
|
||||
db.encode("utf-8")) if db != None else ctypes.c_char_p(None)
|
||||
except AttributeError:
|
||||
raise AttributeError("db is expected as a str")
|
||||
|
||||
# port
|
||||
try:
|
||||
_port = ctypes.c_int(port)
|
||||
except TypeError:
|
||||
raise TypeError("port is expected as an int")
|
||||
|
||||
connection = ctypes.c_void_p(CTaosInterface.libtaos.taos_connect(
|
||||
_host, _user, _password, _db, _port))
|
||||
|
||||
if connection.value == None:
|
||||
print('connect to TDengine failed')
|
||||
raise ConnectionError("connect to TDengine failed")
|
||||
# sys.exit(1)
|
||||
#else:
|
||||
# print('connect to TDengine success')
|
||||
|
||||
return connection
|
||||
|
||||
@staticmethod
|
||||
def close(connection):
|
||||
'''Close the TDengine handle
|
||||
'''
|
||||
CTaosInterface.libtaos.taos_close(connection)
|
||||
#print('connection is closed')
|
||||
|
||||
@staticmethod
|
||||
def query(connection, sql):
|
||||
'''Run SQL
|
||||
|
||||
@sql: str, sql string to run
|
||||
|
||||
@rtype: 0 on success and -1 on failure
|
||||
'''
|
||||
try:
|
||||
return CTaosInterface.libtaos.taos_query(connection, ctypes.c_char_p(sql.encode('utf-8')))
|
||||
except AttributeError:
|
||||
raise AttributeError("sql is expected as a string")
|
||||
# finally:
|
||||
# CTaosInterface.libtaos.close(connection)
|
||||
|
||||
@staticmethod
|
||||
def affectedRows(result):
|
||||
"""The affected rows after runing query
|
||||
"""
|
||||
return CTaosInterface.libtaos.taos_affected_rows(result)
|
||||
|
||||
@staticmethod
|
||||
def subscribe(connection, restart, topic, sql, interval):
|
||||
"""Create a subscription
|
||||
@restart boolean,
|
||||
@sql string, sql statement for data query, must be a 'select' statement.
|
||||
@topic string, name of this subscription
|
||||
"""
|
||||
return ctypes.c_void_p(CTaosInterface.libtaos.taos_subscribe(
|
||||
connection,
|
||||
1 if restart else 0,
|
||||
ctypes.c_char_p(topic.encode('utf-8')),
|
||||
ctypes.c_char_p(sql.encode('utf-8')),
|
||||
None,
|
||||
None,
|
||||
interval))
|
||||
|
||||
@staticmethod
|
||||
def consume(sub):
|
||||
"""Consume data of a subscription
|
||||
"""
|
||||
result = ctypes.c_void_p(CTaosInterface.libtaos.taos_consume(sub))
|
||||
fields = []
|
||||
pfields = CTaosInterface.fetchFields(result)
|
||||
for i in range(CTaosInterface.libtaos.taos_num_fields(result)):
|
||||
fields.append({'name': pfields[i].name.decode('utf-8'),
|
||||
'bytes': pfields[i].bytes,
|
||||
'type': ord(pfields[i].type)})
|
||||
return result, fields
|
||||
|
||||
@staticmethod
|
||||
def unsubscribe(sub, keepProgress):
|
||||
"""Cancel a subscription
|
||||
"""
|
||||
CTaosInterface.libtaos.taos_unsubscribe(sub, 1 if keepProgress else 0)
|
||||
|
||||
@staticmethod
|
||||
def useResult(result):
|
||||
'''Use result after calling self.query
|
||||
'''
|
||||
fields = []
|
||||
pfields = CTaosInterface.fetchFields(result)
|
||||
for i in range(CTaosInterface.fieldsCount(result)):
|
||||
fields.append({'name': pfields[i].name.decode('utf-8'),
|
||||
'bytes': pfields[i].bytes,
|
||||
'type': ord(pfields[i].type)})
|
||||
|
||||
return fields
|
||||
|
||||
@staticmethod
|
||||
def fetchBlock(result, fields):
|
||||
pblock = ctypes.c_void_p(0)
|
||||
num_of_rows = CTaosInterface.libtaos.taos_fetch_block(
|
||||
result, ctypes.byref(pblock))
|
||||
if num_of_rows == 0:
|
||||
return None, 0
|
||||
isMicro = (CTaosInterface.libtaos.taos_result_precision(result) == FieldType.C_TIMESTAMP_MICRO)
|
||||
blocks = [None] * len(fields)
|
||||
fieldL = CTaosInterface.libtaos.taos_fetch_lengths(result)
|
||||
fieldLen = [ele for ele in ctypes.cast(fieldL, ctypes.POINTER(ctypes.c_int))[:len(fields)]]
|
||||
for i in range(len(fields)):
|
||||
data = ctypes.cast(pblock, ctypes.POINTER(ctypes.c_void_p))[i]
|
||||
if fields[i]['type'] not in _CONVERT_FUNC_BLOCK:
|
||||
raise DatabaseError("Invalid data type returned from database")
|
||||
blocks[i] = _CONVERT_FUNC_BLOCK[fields[i]['type']](data, num_of_rows, fieldLen[i], isMicro)
|
||||
|
||||
return blocks, abs(num_of_rows)
|
||||
@staticmethod
|
||||
def fetchRow(result, fields):
|
||||
pblock = ctypes.c_void_p(0)
|
||||
pblock = CTaosInterface.libtaos.taos_fetch_row(result)
|
||||
if pblock :
|
||||
num_of_rows = 1
|
||||
isMicro = (CTaosInterface.libtaos.taos_result_precision(result) == FieldType.C_TIMESTAMP_MICRO)
|
||||
blocks = [None] * len(fields)
|
||||
fieldL = CTaosInterface.libtaos.taos_fetch_lengths(result)
|
||||
fieldLen = [ele for ele in ctypes.cast(fieldL, ctypes.POINTER(ctypes.c_int))[:len(fields)]]
|
||||
for i in range(len(fields)):
|
||||
data = ctypes.cast(pblock, ctypes.POINTER(ctypes.c_void_p))[i]
|
||||
if fields[i]['type'] not in _CONVERT_FUNC:
|
||||
raise DatabaseError("Invalid data type returned from database")
|
||||
if data is None:
|
||||
blocks[i] = [None]
|
||||
else:
|
||||
blocks[i] = _CONVERT_FUNC[fields[i]['type']](data, num_of_rows, fieldLen[i], isMicro)
|
||||
else:
|
||||
return None, 0
|
||||
return blocks, abs(num_of_rows)
|
||||
|
||||
@staticmethod
|
||||
def freeResult(result):
|
||||
CTaosInterface.libtaos.taos_free_result(result)
|
||||
result.value = None
|
||||
|
||||
@staticmethod
|
||||
def fieldsCount(result):
|
||||
return CTaosInterface.libtaos.taos_field_count(result)
|
||||
|
||||
@staticmethod
|
||||
def fetchFields(result):
|
||||
return CTaosInterface.libtaos.taos_fetch_fields(result)
|
||||
|
||||
# @staticmethod
|
||||
# def fetchRow(result, fields):
|
||||
# l = []
|
||||
# row = CTaosInterface.libtaos.taos_fetch_row(result)
|
||||
# if not row:
|
||||
# return None
|
||||
|
||||
# for i in range(len(fields)):
|
||||
# l.append(CTaosInterface.getDataValue(
|
||||
# row[i], fields[i]['type'], fields[i]['bytes']))
|
||||
|
||||
# return tuple(l)
|
||||
|
||||
# @staticmethod
|
||||
# def getDataValue(data, dtype, byte):
|
||||
# '''
|
||||
# '''
|
||||
# if not data:
|
||||
# return None
|
||||
|
||||
# if (dtype == CTaosInterface.TSDB_DATA_TYPE_BOOL):
|
||||
# return ctypes.cast(data, ctypes.POINTER(ctypes.c_bool))[0]
|
||||
# elif (dtype == CTaosInterface.TSDB_DATA_TYPE_TINYINT):
|
||||
# return ctypes.cast(data, ctypes.POINTER(ctypes.c_byte))[0]
|
||||
# elif (dtype == CTaosInterface.TSDB_DATA_TYPE_SMALLINT):
|
||||
# return ctypes.cast(data, ctypes.POINTER(ctypes.c_short))[0]
|
||||
# elif (dtype == CTaosInterface.TSDB_DATA_TYPE_INT):
|
||||
# return ctypes.cast(data, ctypes.POINTER(ctypes.c_int))[0]
|
||||
# elif (dtype == CTaosInterface.TSDB_DATA_TYPE_BIGINT):
|
||||
# return ctypes.cast(data, ctypes.POINTER(ctypes.c_long))[0]
|
||||
# elif (dtype == CTaosInterface.TSDB_DATA_TYPE_FLOAT):
|
||||
# return ctypes.cast(data, ctypes.POINTER(ctypes.c_float))[0]
|
||||
# elif (dtype == CTaosInterface.TSDB_DATA_TYPE_DOUBLE):
|
||||
# return ctypes.cast(data, ctypes.POINTER(ctypes.c_double))[0]
|
||||
# elif (dtype == CTaosInterface.TSDB_DATA_TYPE_BINARY):
|
||||
# return (ctypes.cast(data, ctypes.POINTER(ctypes.c_char))[0:byte]).rstrip('\x00')
|
||||
# elif (dtype == CTaosInterface.TSDB_DATA_TYPE_TIMESTAMP):
|
||||
# return ctypes.cast(data, ctypes.POINTER(ctypes.c_long))[0]
|
||||
# elif (dtype == CTaosInterface.TSDB_DATA_TYPE_NCHAR):
|
||||
# return (ctypes.cast(data, ctypes.c_char_p).value).rstrip('\x00')
|
||||
|
||||
@staticmethod
|
||||
def errno(result):
|
||||
"""Return the error number.
|
||||
"""
|
||||
return CTaosInterface.libtaos.taos_errno(result)
|
||||
|
||||
@staticmethod
|
||||
def errStr(result):
|
||||
"""Return the error styring
|
||||
"""
|
||||
return CTaosInterface.libtaos.taos_errstr(result).decode('utf-8')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
cinter = CTaosInterface()
|
||||
conn = cinter.connect()
|
||||
result = cinter.query(conn, 'show databases')
|
||||
|
||||
print('Query Affected rows: {}'.format(cinter.affectedRows(result)))
|
||||
|
||||
fields = CTaosInterface.useResult(result)
|
||||
|
||||
data, num_of_rows = CTaosInterface.fetchBlock(result, fields)
|
||||
|
||||
print(data)
|
||||
|
||||
cinter.freeResult(result)
|
||||
cinter.close(conn)
|
|
@ -0,0 +1,86 @@
|
|||
from .cursor import TDengineCursor
|
||||
from .subscription import TDengineSubscription
|
||||
from .cinterface import CTaosInterface
|
||||
|
||||
class TDengineConnection(object):
|
||||
""" TDengine connection object
|
||||
"""
|
||||
def __init__(self, *args, **kwargs):
|
||||
self._conn = None
|
||||
self._host = None
|
||||
self._user = "root"
|
||||
self._password = "taosdata"
|
||||
self._database = None
|
||||
self._port = 0
|
||||
self._config = None
|
||||
self._chandle = None
|
||||
|
||||
self.config(**kwargs)
|
||||
|
||||
def config(self, **kwargs):
|
||||
# host
|
||||
if 'host' in kwargs:
|
||||
self._host = kwargs['host']
|
||||
|
||||
# user
|
||||
if 'user' in kwargs:
|
||||
self._user = kwargs['user']
|
||||
|
||||
# password
|
||||
if 'password' in kwargs:
|
||||
self._password = kwargs['password']
|
||||
|
||||
# database
|
||||
if 'database' in kwargs:
|
||||
self._database = kwargs['database']
|
||||
|
||||
# port
|
||||
if 'port' in kwargs:
|
||||
self._port = kwargs['port']
|
||||
|
||||
# config
|
||||
if 'config' in kwargs:
|
||||
self._config = kwargs['config']
|
||||
|
||||
self._chandle = CTaosInterface(self._config)
|
||||
self._conn = self._chandle.connect(self._host, self._user, self._password, self._database, self._port)
|
||||
|
||||
def close(self):
|
||||
"""Close current connection.
|
||||
"""
|
||||
return CTaosInterface.close(self._conn)
|
||||
|
||||
def subscribe(self, restart, topic, sql, interval):
|
||||
"""Create a subscription.
|
||||
"""
|
||||
if self._conn is None:
|
||||
return None
|
||||
sub = CTaosInterface.subscribe(self._conn, restart, topic, sql, interval)
|
||||
return TDengineSubscription(sub)
|
||||
|
||||
def cursor(self):
|
||||
"""Return a new Cursor object using the connection.
|
||||
"""
|
||||
return TDengineCursor(self)
|
||||
|
||||
def commit(self):
|
||||
"""Commit any pending transaction to the database.
|
||||
|
||||
Since TDengine do not support transactions, the implement is void functionality.
|
||||
"""
|
||||
pass
|
||||
|
||||
def rollback(self):
|
||||
"""Void functionality
|
||||
"""
|
||||
pass
|
||||
|
||||
def clear_result_set(self):
|
||||
"""Clear unused result set on this connection.
|
||||
"""
|
||||
pass
|
||||
|
||||
if __name__ == "__main__":
|
||||
conn = TDengineConnection(host='192.168.1.107')
|
||||
conn.close()
|
||||
print("Hello world")
|
|
@ -0,0 +1,33 @@
|
|||
"""Constants in TDengine python
|
||||
"""
|
||||
|
||||
from .dbapi import *
|
||||
|
||||
class FieldType(object):
|
||||
"""TDengine Field Types
|
||||
"""
|
||||
# type_code
|
||||
C_NULL = 0
|
||||
C_BOOL = 1
|
||||
C_TINYINT = 2
|
||||
C_SMALLINT = 3
|
||||
C_INT = 4
|
||||
C_BIGINT = 5
|
||||
C_FLOAT = 6
|
||||
C_DOUBLE = 7
|
||||
C_BINARY = 8
|
||||
C_TIMESTAMP = 9
|
||||
C_NCHAR = 10
|
||||
# NULL value definition
|
||||
# NOTE: These values should change according to C definition in tsdb.h
|
||||
C_BOOL_NULL = 0x02
|
||||
C_TINYINT_NULL = -128
|
||||
C_SMALLINT_NULL = -32768
|
||||
C_INT_NULL = -2147483648
|
||||
C_BIGINT_NULL = -9223372036854775808
|
||||
C_FLOAT_NULL = float('nan')
|
||||
C_DOUBLE_NULL = float('nan')
|
||||
C_BINARY_NULL = bytearray([int('0xff', 16)])
|
||||
# Timestamp precision definition
|
||||
C_TIMESTAMP_MILLI = 0
|
||||
C_TIMESTAMP_MICRO = 1
|
|
@ -0,0 +1,271 @@
|
|||
from .cinterface import CTaosInterface
|
||||
from .error import *
|
||||
from .constants import FieldType
|
||||
import threading
|
||||
|
||||
# querySeqNum = 0
|
||||
|
||||
class TDengineCursor(object):
|
||||
"""Database cursor which is used to manage the context of a fetch operation.
|
||||
|
||||
Attributes:
|
||||
.description: Read-only attribute consists of 7-item sequences:
|
||||
|
||||
> name (mondatory)
|
||||
> type_code (mondatory)
|
||||
> display_size
|
||||
> internal_size
|
||||
> precision
|
||||
> scale
|
||||
> null_ok
|
||||
|
||||
This attribute will be None for operations that do not return rows or
|
||||
if the cursor has not had an operation invoked via the .execute*() method yet.
|
||||
|
||||
.rowcount:This read-only attribute specifies the number of rows that the last
|
||||
.execute*() produced (for DQL statements like SELECT) or affected
|
||||
"""
|
||||
|
||||
def __init__(self, connection=None):
|
||||
self._description = []
|
||||
self._rowcount = -1
|
||||
self._connection = None
|
||||
self._result = None
|
||||
self._fields = None
|
||||
self._block = None
|
||||
self._block_rows = -1
|
||||
self._block_iter = 0
|
||||
self._affected_rows = 0
|
||||
self._logfile = ""
|
||||
self._threadId = threading.get_ident()
|
||||
|
||||
if connection is not None:
|
||||
self._connection = connection
|
||||
|
||||
def __iter__(self):
|
||||
return self
|
||||
|
||||
def __next__(self):
|
||||
if self._result is None or self._fields is None:
|
||||
raise OperationalError("Invalid use of fetch iterator")
|
||||
|
||||
if self._block_rows <= self._block_iter:
|
||||
block, self._block_rows = CTaosInterface.fetchRow(
|
||||
self._result, self._fields)
|
||||
if self._block_rows == 0:
|
||||
raise StopIteration
|
||||
self._block = list(map(tuple, zip(*block)))
|
||||
self._block_iter = 0
|
||||
|
||||
data = self._block[self._block_iter]
|
||||
self._block_iter += 1
|
||||
|
||||
return data
|
||||
|
||||
@property
|
||||
def description(self):
|
||||
"""Return the description of the object.
|
||||
"""
|
||||
return self._description
|
||||
|
||||
@property
|
||||
def rowcount(self):
|
||||
"""Return the rowcount of the object
|
||||
"""
|
||||
return self._rowcount
|
||||
|
||||
@property
|
||||
def affected_rows(self):
|
||||
"""Return the rowcount of insertion
|
||||
"""
|
||||
return self._affected_rows
|
||||
|
||||
def callproc(self, procname, *args):
|
||||
"""Call a stored database procedure with the given name.
|
||||
|
||||
Void functionality since no stored procedures.
|
||||
"""
|
||||
pass
|
||||
|
||||
def log(self, logfile):
|
||||
self._logfile = logfile
|
||||
|
||||
def close(self):
|
||||
"""Close the cursor.
|
||||
"""
|
||||
if self._connection is None:
|
||||
return False
|
||||
|
||||
self._reset_result()
|
||||
self._connection = None
|
||||
|
||||
return True
|
||||
|
||||
def execute(self, operation, params=None):
|
||||
"""Prepare and execute a database operation (query or command).
|
||||
"""
|
||||
# if threading.get_ident() != self._threadId:
|
||||
# info ="Cursor execute:Thread ID not match,creater:"+str(self._threadId)+" caller:"+str(threading.get_ident())
|
||||
# raise OperationalError(info)
|
||||
# print(info)
|
||||
# return None
|
||||
|
||||
if not operation:
|
||||
return None
|
||||
|
||||
if not self._connection:
|
||||
# TODO : change the exception raised here
|
||||
raise ProgrammingError("Cursor is not connected")
|
||||
|
||||
self._reset_result()
|
||||
|
||||
stmt = operation
|
||||
if params is not None:
|
||||
pass
|
||||
|
||||
# global querySeqNum
|
||||
# querySeqNum += 1
|
||||
# localSeqNum = querySeqNum # avoid raice condition
|
||||
# print(" >> Exec Query ({}): {}".format(localSeqNum, str(stmt)))
|
||||
self._result = CTaosInterface.query(self._connection._conn, stmt)
|
||||
# print(" << Query ({}) Exec Done".format(localSeqNum))
|
||||
if (self._logfile):
|
||||
with open(self._logfile, "a") as logfile:
|
||||
logfile.write("%s;\n" % operation)
|
||||
|
||||
errno = CTaosInterface.libtaos.taos_errno(self._result)
|
||||
if errno == 0:
|
||||
if CTaosInterface.fieldsCount(self._result) == 0:
|
||||
self._affected_rows += CTaosInterface.affectedRows(
|
||||
self._result )
|
||||
return CTaosInterface.affectedRows(self._result )
|
||||
else:
|
||||
self._fields = CTaosInterface.useResult(
|
||||
self._result)
|
||||
return self._handle_result()
|
||||
else:
|
||||
raise ProgrammingError(
|
||||
CTaosInterface.errStr(
|
||||
self._result), errno)
|
||||
|
||||
def executemany(self, operation, seq_of_parameters):
|
||||
"""Prepare a database operation (query or command) and then execute it against all parameter sequences or mappings found in the sequence seq_of_parameters.
|
||||
"""
|
||||
pass
|
||||
|
||||
def fetchone(self):
|
||||
"""Fetch the next row of a query result set, returning a single sequence, or None when no more data is available.
|
||||
"""
|
||||
pass
|
||||
|
||||
def fetchmany(self):
|
||||
pass
|
||||
|
||||
def istype(self, col, dataType):
|
||||
if (dataType.upper() == "BOOL"):
|
||||
if (self._description[col][1] == FieldType.C_BOOL):
|
||||
return True
|
||||
if (dataType.upper() == "TINYINT"):
|
||||
if (self._description[col][1] == FieldType.C_TINYINT):
|
||||
return True
|
||||
if (dataType.upper() == "INT"):
|
||||
if (self._description[col][1] == FieldType.C_INT):
|
||||
return True
|
||||
if (dataType.upper() == "BIGINT"):
|
||||
if (self._description[col][1] == FieldType.C_INT):
|
||||
return True
|
||||
if (dataType.upper() == "FLOAT"):
|
||||
if (self._description[col][1] == FieldType.C_FLOAT):
|
||||
return True
|
||||
if (dataType.upper() == "DOUBLE"):
|
||||
if (self._description[col][1] == FieldType.C_DOUBLE):
|
||||
return True
|
||||
if (dataType.upper() == "BINARY"):
|
||||
if (self._description[col][1] == FieldType.C_BINARY):
|
||||
return True
|
||||
if (dataType.upper() == "TIMESTAMP"):
|
||||
if (self._description[col][1] == FieldType.C_TIMESTAMP):
|
||||
return True
|
||||
if (dataType.upper() == "NCHAR"):
|
||||
if (self._description[col][1] == FieldType.C_NCHAR):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def fetchall_row(self):
|
||||
"""Fetch all (remaining) rows of a query result, returning them as a sequence of sequences (e.g. a list of tuples). Note that the cursor's arraysize attribute can affect the performance of this operation.
|
||||
"""
|
||||
if self._result is None or self._fields is None:
|
||||
raise OperationalError("Invalid use of fetchall")
|
||||
|
||||
buffer = [[] for i in range(len(self._fields))]
|
||||
self._rowcount = 0
|
||||
while True:
|
||||
block, num_of_fields = CTaosInterface.fetchRow(self._result, self._fields)
|
||||
errno = CTaosInterface.libtaos.taos_errno(self._result)
|
||||
if errno != 0:
|
||||
raise ProgrammingError(CTaosInterface.errStr(self._result), errno)
|
||||
if num_of_fields == 0:
|
||||
break
|
||||
self._rowcount += num_of_fields
|
||||
for i in range(len(self._fields)):
|
||||
buffer[i].extend(block[i])
|
||||
return list(map(tuple, zip(*buffer)))
|
||||
|
||||
def fetchall(self):
|
||||
if self._result is None or self._fields is None:
|
||||
raise OperationalError("Invalid use of fetchall")
|
||||
|
||||
buffer = [[] for i in range(len(self._fields))]
|
||||
self._rowcount = 0
|
||||
while True:
|
||||
block, num_of_fields = CTaosInterface.fetchBlock(self._result, self._fields)
|
||||
errno = CTaosInterface.libtaos.taos_errno(self._result)
|
||||
if errno != 0:
|
||||
raise ProgrammingError(CTaosInterface.errStr(self._result), errno)
|
||||
if num_of_fields == 0: break
|
||||
self._rowcount += num_of_fields
|
||||
for i in range(len(self._fields)):
|
||||
buffer[i].extend(block[i])
|
||||
return list(map(tuple, zip(*buffer)))
|
||||
def nextset(self):
|
||||
"""
|
||||
"""
|
||||
pass
|
||||
|
||||
def setinputsize(self, sizes):
|
||||
pass
|
||||
|
||||
def setutputsize(self, size, column=None):
|
||||
pass
|
||||
|
||||
def _reset_result(self):
|
||||
"""Reset the result to unused version.
|
||||
"""
|
||||
self._description = []
|
||||
self._rowcount = -1
|
||||
if self._result is not None:
|
||||
CTaosInterface.freeResult(self._result)
|
||||
self._result = None
|
||||
self._fields = None
|
||||
self._block = None
|
||||
self._block_rows = -1
|
||||
self._block_iter = 0
|
||||
self._affected_rows = 0
|
||||
|
||||
def _handle_result(self):
|
||||
"""Handle the return result from query.
|
||||
"""
|
||||
# if threading.get_ident() != self._threadId:
|
||||
# info = "Cursor handleresult:Thread ID not match,creater:"+str(self._threadId)+" caller:"+str(threading.get_ident())
|
||||
# raise OperationalError(info)
|
||||
# print(info)
|
||||
# return None
|
||||
|
||||
self._description = []
|
||||
for ele in self._fields:
|
||||
self._description.append(
|
||||
(ele['name'], ele['type'], None, None, None, None, False))
|
||||
|
||||
return self._result
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue