Merge branch '3.0' of https://github.com/taosdata/TDengine into fix/long_query
This commit is contained in:
commit
c4b6a99caf
|
@ -159,6 +159,7 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_TSC_NO_EXEC_NODE TAOS_DEF_ERROR_CODE(0, 0X022E)
|
#define TSDB_CODE_TSC_NO_EXEC_NODE TAOS_DEF_ERROR_CODE(0, 0X022E)
|
||||||
#define TSDB_CODE_TSC_NOT_STABLE_ERROR TAOS_DEF_ERROR_CODE(0, 0X022F)
|
#define TSDB_CODE_TSC_NOT_STABLE_ERROR TAOS_DEF_ERROR_CODE(0, 0X022F)
|
||||||
#define TSDB_CODE_TSC_STMT_CACHE_ERROR TAOS_DEF_ERROR_CODE(0, 0X0230)
|
#define TSDB_CODE_TSC_STMT_CACHE_ERROR TAOS_DEF_ERROR_CODE(0, 0X0230)
|
||||||
|
#define TSDB_CODE_TSC_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0X0231)
|
||||||
|
|
||||||
// mnode-common
|
// mnode-common
|
||||||
// #define TSDB_CODE_MND_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0300) // 2.x
|
// #define TSDB_CODE_MND_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0300) // 2.x
|
||||||
|
@ -700,6 +701,7 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_SML_INVALID_DATA TAOS_DEF_ERROR_CODE(0, 0x3002)
|
#define TSDB_CODE_SML_INVALID_DATA TAOS_DEF_ERROR_CODE(0, 0x3002)
|
||||||
#define TSDB_CODE_SML_INVALID_DB_CONF TAOS_DEF_ERROR_CODE(0, 0x3003)
|
#define TSDB_CODE_SML_INVALID_DB_CONF TAOS_DEF_ERROR_CODE(0, 0x3003)
|
||||||
#define TSDB_CODE_SML_NOT_SAME_TYPE TAOS_DEF_ERROR_CODE(0, 0x3004)
|
#define TSDB_CODE_SML_NOT_SAME_TYPE TAOS_DEF_ERROR_CODE(0, 0x3004)
|
||||||
|
#define TSDB_CODE_SML_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x3005)
|
||||||
|
|
||||||
//tsma
|
//tsma
|
||||||
#define TSDB_CODE_TSMA_INIT_FAILED TAOS_DEF_ERROR_CODE(0, 0x3100)
|
#define TSDB_CODE_TSMA_INIT_FAILED TAOS_DEF_ERROR_CODE(0, 0x3100)
|
||||||
|
|
|
@ -1,319 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# Generate the deb package for ubuntu, or rpm package for centos, or tar.gz package for other linux os
|
|
||||||
|
|
||||||
set -e
|
|
||||||
# set -x
|
|
||||||
|
|
||||||
# release.sh -v [cluster | edge]
|
|
||||||
# -c [aarch32 | aarch64 | x64 | x86 | mips64 | loongarch64...]
|
|
||||||
# -o [Linux | Kylin | Alpine | Raspberrypi | Darwin | Windows | Ningsi60 | Ningsi80 |...]
|
|
||||||
# -V [stable | beta]
|
|
||||||
# -l [full | lite]
|
|
||||||
# -s [static | dynamic]
|
|
||||||
# -d [taos | ...]
|
|
||||||
# -n [2.0.0.3]
|
|
||||||
# -m [2.0.0.0]
|
|
||||||
# -H [ false | true]
|
|
||||||
|
|
||||||
# set parameters by default value
|
|
||||||
verMode=edge # [cluster, edge, cloud]
|
|
||||||
verType=stable # [stable, beta]
|
|
||||||
cpuType=x64 # [aarch32 | aarch64 | x64 | x86 | mips64 loongarch64...]
|
|
||||||
osType=Linux # [Linux | Kylin | Alpine | Raspberrypi | Darwin | Windows | Ningsi60 | Ningsi80 |...]
|
|
||||||
pagMode=full # [full | lite]
|
|
||||||
soMode=dynamic # [static | dynamic]
|
|
||||||
dbName=taos # [taos | ...]
|
|
||||||
allocator=glibc # [glibc | jemalloc]
|
|
||||||
verNumber=""
|
|
||||||
verNumberComp="3.0.0.0"
|
|
||||||
httpdBuild=false
|
|
||||||
|
|
||||||
while getopts "hv:V:c:o:l:s:d:a:n:m:H:" arg; do
|
|
||||||
case $arg in
|
|
||||||
v)
|
|
||||||
#echo "verMode=$OPTARG"
|
|
||||||
verMode=$(echo $OPTARG)
|
|
||||||
;;
|
|
||||||
V)
|
|
||||||
#echo "verType=$OPTARG"
|
|
||||||
verType=$(echo $OPTARG)
|
|
||||||
;;
|
|
||||||
c)
|
|
||||||
#echo "cpuType=$OPTARG"
|
|
||||||
cpuType=$(echo $OPTARG)
|
|
||||||
;;
|
|
||||||
l)
|
|
||||||
#echo "pagMode=$OPTARG"
|
|
||||||
pagMode=$(echo $OPTARG)
|
|
||||||
;;
|
|
||||||
s)
|
|
||||||
#echo "soMode=$OPTARG"
|
|
||||||
soMode=$(echo $OPTARG)
|
|
||||||
;;
|
|
||||||
d)
|
|
||||||
#echo "dbName=$OPTARG"
|
|
||||||
dbName=$(echo $OPTARG)
|
|
||||||
;;
|
|
||||||
a)
|
|
||||||
#echo "allocator=$OPTARG"
|
|
||||||
allocator=$(echo $OPTARG)
|
|
||||||
;;
|
|
||||||
n)
|
|
||||||
#echo "verNumber=$OPTARG"
|
|
||||||
verNumber=$(echo $OPTARG)
|
|
||||||
;;
|
|
||||||
m)
|
|
||||||
#echo "verNumberComp=$OPTARG"
|
|
||||||
verNumberComp=$(echo $OPTARG)
|
|
||||||
;;
|
|
||||||
o)
|
|
||||||
#echo "osType=$OPTARG"
|
|
||||||
osType=$(echo $OPTARG)
|
|
||||||
;;
|
|
||||||
H)
|
|
||||||
#echo "httpdBuild=$OPTARG"
|
|
||||||
httpdBuild=$(echo $OPTARG)
|
|
||||||
;;
|
|
||||||
h)
|
|
||||||
echo "Usage: $(basename $0) -v [cluster | edge] "
|
|
||||||
echo " -c [aarch32 | aarch64 | x64 | x86 | mips64 | loongarch64 ...] "
|
|
||||||
echo " -o [Linux | Kylin | Alpine | Raspberrypi | Darwin | Windows | Ningsi60 | Ningsi80 |...] "
|
|
||||||
echo " -V [stable | beta] "
|
|
||||||
echo " -l [full | lite] "
|
|
||||||
echo " -a [glibc | jemalloc] "
|
|
||||||
echo " -s [static | dynamic] "
|
|
||||||
echo " -d [taos | ...] "
|
|
||||||
echo " -n [version number] "
|
|
||||||
echo " -m [compatible version number] "
|
|
||||||
echo " -H [false | true] "
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
?) #unknow option
|
|
||||||
echo "unkonw argument"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
osType=$(uname)
|
|
||||||
|
|
||||||
echo "verMode=${verMode} verType=${verType} cpuType=${cpuType} osType=${osType} pagMode=${pagMode} soMode=${soMode} dbName=${dbName} allocator=${allocator} verNumber=${verNumber} verNumberComp=${verNumberComp} httpdBuild=${httpdBuild}"
|
|
||||||
|
|
||||||
curr_dir=$(pwd)
|
|
||||||
|
|
||||||
if [ "$osType" == "Darwin" ]; then
|
|
||||||
script_dir=$(dirname $0)
|
|
||||||
cd ${script_dir}
|
|
||||||
script_dir="$(pwd)"
|
|
||||||
top_dir=${script_dir}/..
|
|
||||||
else
|
|
||||||
script_dir="$(dirname $(readlink -f $0))"
|
|
||||||
top_dir="$(readlink -f ${script_dir}/..)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
csudo=""
|
|
||||||
#if command -v sudo > /dev/null; then
|
|
||||||
# csudo="sudo "
|
|
||||||
#fi
|
|
||||||
|
|
||||||
function is_valid_version() {
|
|
||||||
[ -z $1 ] && return 1 || :
|
|
||||||
|
|
||||||
rx='^([0-9]+\.){3}(\*|[0-9]+)$'
|
|
||||||
if [[ $1 =~ $rx ]]; then
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
function vercomp() {
|
|
||||||
if [[ $1 == $2 ]]; then
|
|
||||||
echo 0
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
local IFS=.
|
|
||||||
local i ver1=($1) ver2=($2)
|
|
||||||
|
|
||||||
# fill empty fields in ver1 with zeros
|
|
||||||
for ((i = ${#ver1[@]}; i < ${#ver2[@]}; i++)); do
|
|
||||||
ver1[i]=0
|
|
||||||
done
|
|
||||||
|
|
||||||
for ((i = 0; i < ${#ver1[@]}; i++)); do
|
|
||||||
if [[ -z ${ver2[i]} ]]; then
|
|
||||||
# fill empty fields in ver2 with zeros
|
|
||||||
ver2[i]=0
|
|
||||||
fi
|
|
||||||
if ((10#${ver1[i]} > 10#${ver2[i]})); then
|
|
||||||
echo 1
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
if ((10#${ver1[i]} < 10#${ver2[i]})); then
|
|
||||||
echo 2
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
echo 0
|
|
||||||
}
|
|
||||||
|
|
||||||
# 1. check version information
|
|
||||||
if ( (! is_valid_version $verNumber) || (! is_valid_version $verNumberComp) || [[ "$(vercomp $verNumber $verNumberComp)" == '2' ]]); then
|
|
||||||
echo "please enter correct version"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "=======================new version number: ${verNumber}, compatible version: ${verNumberComp}======================================"
|
|
||||||
|
|
||||||
build_time=$(date +"%F %R")
|
|
||||||
|
|
||||||
# get commint id from git
|
|
||||||
gitinfo=$(git rev-parse --verify HEAD)
|
|
||||||
|
|
||||||
if [[ "$verMode" == "cluster" ]] || [[ "$verMode" == "cloud" ]]; then
|
|
||||||
enterprise_dir="${top_dir}/../enterprise"
|
|
||||||
cd ${enterprise_dir}
|
|
||||||
gitinfoOfInternal=$(git rev-parse --verify HEAD)
|
|
||||||
else
|
|
||||||
gitinfoOfInternal=NULL
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd "${curr_dir}"
|
|
||||||
|
|
||||||
# 2. cmake executable file
|
|
||||||
compile_dir="${top_dir}/debug"
|
|
||||||
if [ -d ${compile_dir} ]; then
|
|
||||||
rm -rf ${compile_dir}
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -p ${compile_dir}
|
|
||||||
cd ${compile_dir}
|
|
||||||
|
|
||||||
if [[ "$allocator" == "jemalloc" ]]; then
|
|
||||||
allocator_macro="-DJEMALLOC_ENABLED=true"
|
|
||||||
else
|
|
||||||
allocator_macro=""
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$dbName" != "taos" ]]; then
|
|
||||||
source ${enterprise_dir}/packaging/oem/sed_$dbName.sh
|
|
||||||
replace_community_$dbName
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$httpdBuild" == "true" ]]; then
|
|
||||||
BUILD_HTTP=true
|
|
||||||
else
|
|
||||||
BUILD_HTTP=false
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$verMode" == "cluster" ]] || [[ "$verMode" == "cloud" ]]; then
|
|
||||||
BUILD_HTTP=internal
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$pagMode" == "full" ]]; then
|
|
||||||
BUILD_TOOLS=true
|
|
||||||
else
|
|
||||||
BUILD_TOOLS=false
|
|
||||||
fi
|
|
||||||
|
|
||||||
# check support cpu type
|
|
||||||
if [[ "$cpuType" == "x64" ]] || [[ "$cpuType" == "aarch64" ]] || [[ "$cpuType" == "aarch32" ]] || [[ "$cpuType" == "arm64" ]] || [[ "$cpuType" == "arm32" ]] || [[ "$cpuType" == "mips64" ]] || [[ "$cpuType" == "loongarch64" ]] ; then
|
|
||||||
if [ "$verMode" == "edge" ]; then
|
|
||||||
# community-version compile
|
|
||||||
cmake ../ -DCPUTYPE=${cpuType} -DWEBSOCKET=true -DOSTYPE=${osType} -DSOMODE=${soMode} -DDBNAME=${dbName} -DVERTYPE=${verType} -DVERDATE="${build_time}" -DGITINFO=${gitinfo} -DGITINFOI=${gitinfoOfInternal} -DVERNUMBER=${verNumber} -DVERCOMPATIBLE=${verNumberComp} -DPAGMODE=${pagMode} -DBUILD_HTTP=${BUILD_HTTP} -DBUILD_TOOLS=${BUILD_TOOLS} ${allocator_macro}
|
|
||||||
elif [ "$verMode" == "cloud" ]; then
|
|
||||||
cmake ../../ -DCPUTYPE=${cpuType} -DWEBSOCKET=true -DBUILD_TAOSX=true -DBUILD_CLOUD=true -DOSTYPE=${osType} -DSOMODE=${soMode} -DDBNAME=${dbName} -DVERTYPE=${verType} -DVERDATE="${build_time}" -DGITINFO=${gitinfo} -DGITINFOI=${gitinfoOfInternal} -DVERNUMBER=${verNumber} -DVERCOMPATIBLE=${verNumberComp} -DBUILD_HTTP=${BUILD_HTTP} -DBUILD_TOOLS=${BUILD_TOOLS} ${allocator_macro}
|
|
||||||
elif [ "$verMode" == "cluster" ]; then
|
|
||||||
if [[ "$dbName" != "taos" ]]; then
|
|
||||||
replace_enterprise_$dbName
|
|
||||||
fi
|
|
||||||
cmake ../../ -DCPUTYPE=${cpuType} -DWEBSOCKET=true -DBUILD_TAOSX=true -DOSTYPE=${osType} -DSOMODE=${soMode} -DDBNAME=${dbName} -DVERTYPE=${verType} -DVERDATE="${build_time}" -DGITINFO=${gitinfo} -DGITINFOI=${gitinfoOfInternal} -DVERNUMBER=${verNumber} -DVERCOMPATIBLE=${verNumberComp} -DBUILD_HTTP=${BUILD_HTTP} -DBUILD_TOOLS=${BUILD_TOOLS} ${allocator_macro}
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "input cpuType=${cpuType} error!!!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
ostype=`uname`
|
|
||||||
if [ "${ostype}" == "Darwin" ]; then
|
|
||||||
CORES=$(sysctl -n hw.ncpu)
|
|
||||||
else
|
|
||||||
CORES=$(grep -c ^processor /proc/cpuinfo)
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$allocator" == "jemalloc" ]]; then
|
|
||||||
# jemalloc need compile first, so disable parallel build
|
|
||||||
make -j ${CORES} && ${csudo}make install
|
|
||||||
else
|
|
||||||
make -j ${CORES} && ${csudo}make install
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd ${curr_dir}
|
|
||||||
|
|
||||||
# 3. Call the corresponding script for packaging
|
|
||||||
if [ "$osType" != "Darwin" ]; then
|
|
||||||
if [[ "$verMode" != "cluster" ]] && [[ "$verMode" != "cloud" ]] && [[ "$pagMode" == "full" ]] && [[ "$cpuType" == "x64" ]] && [[ "$dbName" == "taos" ]]; then
|
|
||||||
ret='0'
|
|
||||||
command -v dpkg >/dev/null 2>&1 || { ret='1'; }
|
|
||||||
if [ "$ret" -eq 0 ]; then
|
|
||||||
echo "====do deb package for the ubuntu system===="
|
|
||||||
output_dir="${top_dir}/debs"
|
|
||||||
if [ -d ${output_dir} ]; then
|
|
||||||
rm -rf ${output_dir}
|
|
||||||
fi
|
|
||||||
mkdir -p ${output_dir}
|
|
||||||
cd ${script_dir}/deb
|
|
||||||
${csudo}./makedeb.sh ${compile_dir} ${output_dir} ${verNumber} ${cpuType} ${osType} ${verMode} ${verType}
|
|
||||||
|
|
||||||
if [[ "$pagMode" == "full" ]]; then
|
|
||||||
if [ -d ${top_dir}/tools/taos-tools/packaging/deb ]; then
|
|
||||||
cd ${top_dir}/tools/taos-tools/packaging/deb
|
|
||||||
taos_tools_ver=$(git tag |grep -v taos | sort | tail -1)
|
|
||||||
[ -z "$taos_tools_ver" ] && taos_tools_ver="0.1.0"
|
|
||||||
|
|
||||||
${csudo}./make-taos-tools-deb.sh ${top_dir} \
|
|
||||||
${compile_dir} ${output_dir} ${taos_tools_ver} ${cpuType} ${osType} ${verMode} ${verType}
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "==========dpkg command not exist, so not release deb package!!!"
|
|
||||||
fi
|
|
||||||
ret='0'
|
|
||||||
command -v rpmbuild >/dev/null 2>&1 || { ret='1'; }
|
|
||||||
if [ "$ret" -eq 0 ]; then
|
|
||||||
echo "====do rpm package for the centos system===="
|
|
||||||
output_dir="${top_dir}/rpms"
|
|
||||||
if [ -d ${output_dir} ]; then
|
|
||||||
rm -rf ${output_dir}
|
|
||||||
fi
|
|
||||||
mkdir -p ${output_dir}
|
|
||||||
cd ${script_dir}/rpm
|
|
||||||
${csudo}./makerpm.sh ${compile_dir} ${output_dir} ${verNumber} ${cpuType} ${osType} ${verMode} ${verType}
|
|
||||||
|
|
||||||
if [[ "$pagMode" == "full" ]]; then
|
|
||||||
if [ -d ${top_dir}/tools/taos-tools/packaging/rpm ]; then
|
|
||||||
cd ${top_dir}/tools/taos-tools/packaging/rpm
|
|
||||||
taos_tools_ver=$(git tag |grep -v taos | sort | tail -1)
|
|
||||||
[ -z "$taos_tools_ver" ] && taos_tools_ver="0.1.0"
|
|
||||||
|
|
||||||
${csudo}./make-taos-tools-rpm.sh ${top_dir} \
|
|
||||||
${compile_dir} ${output_dir} ${taos_tools_ver} ${cpuType} ${osType} ${verMode} ${verType}
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "==========rpmbuild command not exist, so not release rpm package!!!"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "====do tar.gz package for all systems===="
|
|
||||||
cd ${script_dir}/tools
|
|
||||||
|
|
||||||
${csudo}./makepkg.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${verNumberComp} ${dbName}
|
|
||||||
${csudo}./makeclient.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName}
|
|
||||||
|
|
||||||
else
|
|
||||||
cd ${script_dir}/tools
|
|
||||||
./makepkg.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${verNumberComp} ${dbName}
|
|
||||||
./makeclient.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode} ${dbName}
|
|
||||||
fi
|
|
|
@ -109,6 +109,13 @@ function kill_taosadapter() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function kill_taoskeeper() {
|
||||||
|
pid=$(ps -ef | grep "taoskeeper" | grep -v "grep" | awk '{print $2}')
|
||||||
|
if [ -n "$pid" ]; then
|
||||||
|
${csudo}kill -9 $pid || :
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function kill_taosd() {
|
function kill_taosd() {
|
||||||
# ${csudo}pkill -f taosd || :
|
# ${csudo}pkill -f taosd || :
|
||||||
pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}')
|
pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}')
|
||||||
|
@ -161,6 +168,7 @@ function install_bin() {
|
||||||
${csudo}rm -f ${bin_link_dir}/udfd || :
|
${csudo}rm -f ${bin_link_dir}/udfd || :
|
||||||
${csudo}rm -f ${bin_link_dir}/taosadapter || :
|
${csudo}rm -f ${bin_link_dir}/taosadapter || :
|
||||||
${csudo}rm -f ${bin_link_dir}/taosBenchmark || :
|
${csudo}rm -f ${bin_link_dir}/taosBenchmark || :
|
||||||
|
${csudo}rm -f ${bin_link_dir}/taoskeeper || :
|
||||||
${csudo}rm -f ${bin_link_dir}/taosdemo || :
|
${csudo}rm -f ${bin_link_dir}/taosdemo || :
|
||||||
${csudo}rm -f ${bin_link_dir}/taosdump || :
|
${csudo}rm -f ${bin_link_dir}/taosdump || :
|
||||||
${csudo}rm -f ${bin_link_dir}/rmtaos || :
|
${csudo}rm -f ${bin_link_dir}/rmtaos || :
|
||||||
|
@ -179,6 +187,7 @@ function install_bin() {
|
||||||
[ -x ${bin_dir}/taosdump ] && ${csudo}ln -s ${bin_dir}/taosdump ${bin_link_dir}/taosdump || :
|
[ -x ${bin_dir}/taosdump ] && ${csudo}ln -s ${bin_dir}/taosdump ${bin_link_dir}/taosdump || :
|
||||||
[ -x ${bin_dir}/set_core.sh ] && ${csudo}ln -s ${bin_dir}/set_core.sh ${bin_link_dir}/set_core || :
|
[ -x ${bin_dir}/set_core.sh ] && ${csudo}ln -s ${bin_dir}/set_core.sh ${bin_link_dir}/set_core || :
|
||||||
[ -x ${bin_dir}/remove.sh ] && ${csudo}ln -s ${bin_dir}/remove.sh ${bin_link_dir}/rmtaos || :
|
[ -x ${bin_dir}/remove.sh ] && ${csudo}ln -s ${bin_dir}/remove.sh ${bin_link_dir}/rmtaos || :
|
||||||
|
[ -x ${bin_dir}/taoskeeper ] && ${csudo}ln -sf ${bin_dir}/taoskeeper ${bin_link_dir}/taoskeeper || :
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_newHostname_to_hosts() {
|
function add_newHostname_to_hosts() {
|
||||||
|
@ -351,6 +360,22 @@ function install_taosadapter_config() {
|
||||||
${csudo}ln -s ${cfg_install_dir}/taosadapter.toml ${cfg_dir}
|
${csudo}ln -s ${cfg_install_dir}/taosadapter.toml ${cfg_dir}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function install_taoskeeper_config() {
|
||||||
|
if [ ! -f "${cfg_install_dir}/keeper.toml" ]; then
|
||||||
|
[ ! -d %{cfg_install_dir} ] &&
|
||||||
|
${csudo}${csudo}mkdir -p ${cfg_install_dir}
|
||||||
|
[ -f ${cfg_dir}/keeper.toml ] && ${csudo}cp ${cfg_dir}/keeper.toml ${cfg_install_dir}
|
||||||
|
[ -f ${cfg_install_dir}/keeper.toml ] &&
|
||||||
|
${csudo}chmod 644 ${cfg_install_dir}/keeper.toml
|
||||||
|
fi
|
||||||
|
|
||||||
|
[ -f ${cfg_dir}/keeper.toml ] &&
|
||||||
|
${csudo}mv ${cfg_dir}/keeper.toml ${cfg_dir}/keeper.toml.new
|
||||||
|
|
||||||
|
[ -f ${cfg_install_dir}/keeper.toml ] &&
|
||||||
|
${csudo}ln -s ${cfg_install_dir}/keeper.toml ${cfg_dir}
|
||||||
|
}
|
||||||
|
|
||||||
function install_config() {
|
function install_config() {
|
||||||
if [ ! -f "${cfg_install_dir}/taos.cfg" ]; then
|
if [ ! -f "${cfg_install_dir}/taos.cfg" ]; then
|
||||||
${csudo}${csudo}mkdir -p ${cfg_install_dir}
|
${csudo}${csudo}mkdir -p ${cfg_install_dir}
|
||||||
|
@ -583,6 +608,7 @@ function install_TDengine() {
|
||||||
install_bin
|
install_bin
|
||||||
install_config
|
install_config
|
||||||
install_taosadapter_config
|
install_taosadapter_config
|
||||||
|
install_taoskeeper_config
|
||||||
install_taosadapter_service
|
install_taosadapter_service
|
||||||
install_service
|
install_service
|
||||||
install_app
|
install_app
|
||||||
|
|
|
@ -232,6 +232,7 @@ int32_t smlClearForRerun(SSmlHandle *info);
|
||||||
int32_t smlParseValue(SSmlKv *pVal, SSmlMsgBuf *msg);
|
int32_t smlParseValue(SSmlKv *pVal, SSmlMsgBuf *msg);
|
||||||
uint8_t smlGetTimestampLen(int64_t num);
|
uint8_t smlGetTimestampLen(int64_t num);
|
||||||
void clearColValArray(SArray* pCols);
|
void clearColValArray(SArray* pCols);
|
||||||
|
void smlDestroyTableInfo(SSmlHandle *info, SSmlTableInfo *tag);
|
||||||
|
|
||||||
int32_t smlParseInfluxString(SSmlHandle *info, char *sql, char *sqlEnd, SSmlLineInfo *elements);
|
int32_t smlParseInfluxString(SSmlHandle *info, char *sql, char *sqlEnd, SSmlLineInfo *elements);
|
||||||
int32_t smlParseTelnetString(SSmlHandle *info, char *sql, char *sqlEnd, SSmlLineInfo *elements);
|
int32_t smlParseTelnetString(SSmlHandle *info, char *sql, char *sqlEnd, SSmlLineInfo *elements);
|
||||||
|
|
|
@ -62,7 +62,10 @@ static int32_t registerRequest(SRequestObj *pRequest, STscObj *pTscObj) {
|
||||||
|
|
||||||
static void deregisterRequest(SRequestObj *pRequest) {
|
static void deregisterRequest(SRequestObj *pRequest) {
|
||||||
const static int64_t SLOW_QUERY_INTERVAL = 3000000L; // todo configurable
|
const static int64_t SLOW_QUERY_INTERVAL = 3000000L; // todo configurable
|
||||||
assert(pRequest != NULL);
|
if(pRequest == NULL){
|
||||||
|
tscError("pRequest == NULL");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
STscObj *pTscObj = pRequest->pTscObj;
|
STscObj *pTscObj = pRequest->pTscObj;
|
||||||
SAppClusterSummary *pActivity = &pTscObj->pAppInfo->summary;
|
SAppClusterSummary *pActivity = &pTscObj->pAppInfo->summary;
|
||||||
|
@ -412,7 +415,8 @@ void taos_init_imp(void) {
|
||||||
initQueryModuleMsgHandle();
|
initQueryModuleMsgHandle();
|
||||||
|
|
||||||
if (taosConvInit() != 0) {
|
if (taosConvInit() != 0) {
|
||||||
ASSERTS(0, "failed to init conv");
|
tscError("failed to init conv");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
rpcInit();
|
rpcInit();
|
||||||
|
|
|
@ -376,7 +376,6 @@ int32_t hbBuildQueryDesc(SQueryHbReqBasic *hbBasic, STscObj *pObj) {
|
||||||
desc.subPlanNum = 0;
|
desc.subPlanNum = 0;
|
||||||
}
|
}
|
||||||
desc.subPlanNum = taosArrayGetSize(desc.subDesc);
|
desc.subPlanNum = taosArrayGetSize(desc.subDesc);
|
||||||
ASSERT(desc.subPlanNum == taosArrayGetSize(desc.subDesc));
|
|
||||||
} else {
|
} else {
|
||||||
desc.subDesc = NULL;
|
desc.subDesc = NULL;
|
||||||
}
|
}
|
||||||
|
@ -813,7 +812,10 @@ static void hbStopThread() {
|
||||||
}
|
}
|
||||||
|
|
||||||
SAppHbMgr *appHbMgrInit(SAppInstInfo *pAppInstInfo, char *key) {
|
SAppHbMgr *appHbMgrInit(SAppInstInfo *pAppInstInfo, char *key) {
|
||||||
hbMgrInit();
|
if(hbMgrInit() != 0){
|
||||||
|
terrno = TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
SAppHbMgr *pAppHbMgr = taosMemoryMalloc(sizeof(SAppHbMgr));
|
SAppHbMgr *pAppHbMgr = taosMemoryMalloc(sizeof(SAppHbMgr));
|
||||||
if (pAppHbMgr == NULL) {
|
if (pAppHbMgr == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -899,16 +901,28 @@ int hbMgrInit() {
|
||||||
TdThreadMutexAttr attr = {0};
|
TdThreadMutexAttr attr = {0};
|
||||||
|
|
||||||
int ret = taosThreadMutexAttrInit(&attr);
|
int ret = taosThreadMutexAttrInit(&attr);
|
||||||
assert(ret == 0);
|
if(ret != 0){
|
||||||
|
uError("hbMgrInit:taosThreadMutexAttrInit error")
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
ret = taosThreadMutexAttrSetType(&attr, PTHREAD_MUTEX_RECURSIVE);
|
ret = taosThreadMutexAttrSetType(&attr, PTHREAD_MUTEX_RECURSIVE);
|
||||||
assert(ret == 0);
|
if(ret != 0){
|
||||||
|
uError("hbMgrInit:taosThreadMutexAttrSetType error")
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
ret = taosThreadMutexInit(&clientHbMgr.lock, &attr);
|
ret = taosThreadMutexInit(&clientHbMgr.lock, &attr);
|
||||||
assert(ret == 0);
|
if(ret != 0){
|
||||||
|
uError("hbMgrInit:taosThreadMutexInit error")
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
ret = taosThreadMutexAttrDestroy(&attr);
|
ret = taosThreadMutexAttrDestroy(&attr);
|
||||||
assert(ret == 0);
|
if(ret != 0){
|
||||||
|
uError("hbMgrInit:taosThreadMutexAttrDestroy error")
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
// init handle funcs
|
// init handle funcs
|
||||||
hbMgrInitHandle();
|
hbMgrInitHandle();
|
||||||
|
|
|
@ -452,7 +452,10 @@ int32_t getPlan(SRequestObj* pRequest, SQuery* pQuery, SQueryPlan** pPlan, SArra
|
||||||
}
|
}
|
||||||
|
|
||||||
void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t numOfCols) {
|
void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t numOfCols) {
|
||||||
ASSERT(pSchema != NULL && numOfCols > 0);
|
if(pResInfo == NULL || pSchema == NULL || numOfCols <= 0){
|
||||||
|
tscError("invalid paras, pResInfo == NULL || pSchema == NULL || numOfCols <= 0");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
pResInfo->numOfCols = numOfCols;
|
pResInfo->numOfCols = numOfCols;
|
||||||
if (pResInfo->fields != NULL) {
|
if (pResInfo->fields != NULL) {
|
||||||
|
@ -463,7 +466,10 @@ void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t
|
||||||
}
|
}
|
||||||
pResInfo->fields = taosMemoryCalloc(numOfCols, sizeof(TAOS_FIELD));
|
pResInfo->fields = taosMemoryCalloc(numOfCols, sizeof(TAOS_FIELD));
|
||||||
pResInfo->userFields = taosMemoryCalloc(numOfCols, sizeof(TAOS_FIELD));
|
pResInfo->userFields = taosMemoryCalloc(numOfCols, sizeof(TAOS_FIELD));
|
||||||
ASSERT(numOfCols == pResInfo->numOfCols);
|
if(numOfCols != pResInfo->numOfCols){
|
||||||
|
tscError("numOfCols:%d != pResInfo->numOfCols:%d", numOfCols, pResInfo->numOfCols);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < pResInfo->numOfCols; ++i) {
|
for (int32_t i = 0; i < pResInfo->numOfCols; ++i) {
|
||||||
pResInfo->fields[i].bytes = pSchema[i].bytes;
|
pResInfo->fields[i].bytes = pSchema[i].bytes;
|
||||||
|
@ -1339,7 +1345,10 @@ int32_t doProcessMsgFromServer(void* param) {
|
||||||
SEpSet* pEpSet = arg->pEpset;
|
SEpSet* pEpSet = arg->pEpset;
|
||||||
|
|
||||||
SMsgSendInfo* pSendInfo = (SMsgSendInfo*)pMsg->info.ahandle;
|
SMsgSendInfo* pSendInfo = (SMsgSendInfo*)pMsg->info.ahandle;
|
||||||
assert(pMsg->info.ahandle != NULL);
|
if(pMsg->info.ahandle == NULL){
|
||||||
|
tscError("doProcessMsgFromServer pMsg->info.ahandle == NULL");
|
||||||
|
return TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||||
|
}
|
||||||
STscObj* pTscObj = NULL;
|
STscObj* pTscObj = NULL;
|
||||||
|
|
||||||
STraceId* trace = &pMsg->info.traceId;
|
STraceId* trace = &pMsg->info.traceId;
|
||||||
|
@ -1352,8 +1361,10 @@ int32_t doProcessMsgFromServer(void* param) {
|
||||||
if (pSendInfo->requestObjRefId != 0) {
|
if (pSendInfo->requestObjRefId != 0) {
|
||||||
SRequestObj* pRequest = (SRequestObj*)taosAcquireRef(clientReqRefPool, pSendInfo->requestObjRefId);
|
SRequestObj* pRequest = (SRequestObj*)taosAcquireRef(clientReqRefPool, pSendInfo->requestObjRefId);
|
||||||
if (pRequest) {
|
if (pRequest) {
|
||||||
assert(pRequest->self == pSendInfo->requestObjRefId);
|
if(pRequest->self != pSendInfo->requestObjRefId){
|
||||||
|
tscError("doProcessMsgFromServer pRequest->self:%"PRId64" != pSendInfo->requestObjRefId:%"PRId64, pRequest->self, pSendInfo->requestObjRefId);
|
||||||
|
return TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||||
|
}
|
||||||
pRequest->metric.rsp = taosGetTimestampUs();
|
pRequest->metric.rsp = taosGetTimestampUs();
|
||||||
pTscObj = pRequest->pTscObj;
|
pTscObj = pRequest->pTscObj;
|
||||||
/*
|
/*
|
||||||
|
@ -1495,7 +1506,9 @@ void doSetOneRowPtr(SReqResultInfo* pResultInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void* doFetchRows(SRequestObj* pRequest, bool setupOneRowPtr, bool convertUcs4) {
|
void* doFetchRows(SRequestObj* pRequest, bool setupOneRowPtr, bool convertUcs4) {
|
||||||
assert(pRequest != NULL);
|
if(pRequest == NULL){
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
SReqResultInfo* pResultInfo = &pRequest->body.resInfo;
|
SReqResultInfo* pResultInfo = &pRequest->body.resInfo;
|
||||||
if (pResultInfo->pData == NULL || pResultInfo->current >= pResultInfo->numOfRows) {
|
if (pResultInfo->pData == NULL || pResultInfo->current >= pResultInfo->numOfRows) {
|
||||||
|
@ -1549,7 +1562,9 @@ static void syncFetchFn(void* param, TAOS_RES* res, int32_t numOfRows) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void* doAsyncFetchRows(SRequestObj* pRequest, bool setupOneRowPtr, bool convertUcs4) {
|
void* doAsyncFetchRows(SRequestObj* pRequest, bool setupOneRowPtr, bool convertUcs4) {
|
||||||
assert(pRequest != NULL);
|
if(pRequest == NULL){
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
SReqResultInfo* pResultInfo = &pRequest->body.resInfo;
|
SReqResultInfo* pResultInfo = &pRequest->body.resInfo;
|
||||||
if (pResultInfo->pData == NULL || pResultInfo->current >= pResultInfo->numOfRows) {
|
if (pResultInfo->pData == NULL || pResultInfo->current >= pResultInfo->numOfRows) {
|
||||||
|
@ -1613,8 +1628,10 @@ static int32_t doConvertUCS4(SReqResultInfo* pResultInfo, int32_t numOfRows, int
|
||||||
char* pStart = pCol->offset[j] + pCol->pData;
|
char* pStart = pCol->offset[j] + pCol->pData;
|
||||||
|
|
||||||
int32_t len = taosUcs4ToMbs((TdUcs4*)varDataVal(pStart), varDataLen(pStart), varDataVal(p));
|
int32_t len = taosUcs4ToMbs((TdUcs4*)varDataVal(pStart), varDataLen(pStart), varDataVal(p));
|
||||||
ASSERT(len <= bytes);
|
if(len > bytes || (p + len) >= (pResultInfo->convertBuf[i] + colLength[i])){
|
||||||
ASSERT((p + len) < (pResultInfo->convertBuf[i] + colLength[i]));
|
tscError("doConvertUCS4 error, invalid data. len:%d, bytes:%d, (p + len):%p, (pResultInfo->convertBuf[i] + colLength[i]):%p", len, bytes, (p + len), (pResultInfo->convertBuf[i] + colLength[i]));
|
||||||
|
return TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
varDataSetLen(p, len);
|
varDataSetLen(p, len);
|
||||||
pCol->offset[j] = (p - pResultInfo->convertBuf[i]);
|
pCol->offset[j] = (p - pResultInfo->convertBuf[i]);
|
||||||
|
@ -1631,9 +1648,6 @@ static int32_t doConvertUCS4(SReqResultInfo* pResultInfo, int32_t numOfRows, int
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t getVersion1BlockMetaSize(const char* p, int32_t numOfCols) {
|
int32_t getVersion1BlockMetaSize(const char* p, int32_t numOfCols) {
|
||||||
int32_t cols = *(int32_t*)(p + sizeof(int32_t) * 3);
|
|
||||||
ASSERT(numOfCols == cols);
|
|
||||||
|
|
||||||
return sizeof(int32_t) + sizeof(int32_t) + sizeof(int32_t) * 3 + sizeof(uint64_t) +
|
return sizeof(int32_t) + sizeof(int32_t) + sizeof(int32_t) * 3 + sizeof(uint64_t) +
|
||||||
numOfCols * (sizeof(int8_t) + sizeof(int32_t));
|
numOfCols * (sizeof(int8_t) + sizeof(int32_t));
|
||||||
}
|
}
|
||||||
|
@ -1643,6 +1657,12 @@ static int32_t estimateJsonLen(SReqResultInfo* pResultInfo, int32_t numOfCols, i
|
||||||
|
|
||||||
// | version | total length | total rows | total columns | flag seg| block group id | column schema | each column
|
// | version | total length | total rows | total columns | flag seg| block group id | column schema | each column
|
||||||
// length |
|
// length |
|
||||||
|
int32_t cols = *(int32_t*)(p + sizeof(int32_t) * 3);
|
||||||
|
if(ASSERT(numOfCols == cols)){
|
||||||
|
tscError("estimateJsonLen error: numOfCols:%d != cols:%d", numOfCols, cols);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t len = getVersion1BlockMetaSize(p, numOfCols);
|
int32_t len = getVersion1BlockMetaSize(p, numOfCols);
|
||||||
int32_t* colLength = (int32_t*)(p + len);
|
int32_t* colLength = (int32_t*)(p + len);
|
||||||
len += sizeof(int32_t) * numOfCols;
|
len += sizeof(int32_t) * numOfCols;
|
||||||
|
@ -1676,7 +1696,8 @@ static int32_t estimateJsonLen(SReqResultInfo* pResultInfo, int32_t numOfCols, i
|
||||||
} else if (jsonInnerType == TSDB_DATA_TYPE_BOOL) {
|
} else if (jsonInnerType == TSDB_DATA_TYPE_BOOL) {
|
||||||
len += (VARSTR_HEADER_SIZE + 5);
|
len += (VARSTR_HEADER_SIZE + 5);
|
||||||
} else {
|
} else {
|
||||||
ASSERT(0);
|
tscError("estimateJsonLen error: invalid type:%d", jsonInnerType);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (IS_VAR_DATA_TYPE(pResultInfo->fields[i].type)) {
|
} else if (IS_VAR_DATA_TYPE(pResultInfo->fields[i].type)) {
|
||||||
|
@ -1710,12 +1731,21 @@ static int32_t doConvertJson(SReqResultInfo* pResultInfo, int32_t numOfCols, int
|
||||||
|
|
||||||
char* p = (char*)pResultInfo->pData;
|
char* p = (char*)pResultInfo->pData;
|
||||||
int32_t dataLen = estimateJsonLen(pResultInfo, numOfCols, numOfRows);
|
int32_t dataLen = estimateJsonLen(pResultInfo, numOfCols, numOfRows);
|
||||||
|
if(dataLen <= 0){
|
||||||
|
return TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
pResultInfo->convertJson = taosMemoryCalloc(1, dataLen);
|
pResultInfo->convertJson = taosMemoryCalloc(1, dataLen);
|
||||||
if (pResultInfo->convertJson == NULL) return TSDB_CODE_OUT_OF_MEMORY;
|
if (pResultInfo->convertJson == NULL) return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
char* p1 = pResultInfo->convertJson;
|
char* p1 = pResultInfo->convertJson;
|
||||||
|
|
||||||
int32_t totalLen = 0;
|
int32_t totalLen = 0;
|
||||||
|
int32_t cols = *(int32_t*)(p + sizeof(int32_t) * 3);
|
||||||
|
if(ASSERT(numOfCols == cols)){
|
||||||
|
tscError("doConvertJson error: numOfCols:%d != cols:%d", numOfCols, cols);
|
||||||
|
return TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t len = getVersion1BlockMetaSize(p, numOfCols);
|
int32_t len = getVersion1BlockMetaSize(p, numOfCols);
|
||||||
memcpy(p1, p, len);
|
memcpy(p1, p, len);
|
||||||
|
|
||||||
|
@ -1736,8 +1766,10 @@ static int32_t doConvertJson(SReqResultInfo* pResultInfo, int32_t numOfCols, int
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
int32_t colLen = htonl(colLength[i]);
|
int32_t colLen = htonl(colLength[i]);
|
||||||
int32_t colLen1 = htonl(colLength1[i]);
|
int32_t colLen1 = htonl(colLength1[i]);
|
||||||
ASSERT(colLen < dataLen);
|
if(ASSERT(colLen < dataLen)){
|
||||||
|
tscError("doConvertJson error: colLen:%d >= dataLen:%d", colLen, dataLen);
|
||||||
|
return TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||||
|
}
|
||||||
if (pResultInfo->fields[i].type == TSDB_DATA_TYPE_JSON) {
|
if (pResultInfo->fields[i].type == TSDB_DATA_TYPE_JSON) {
|
||||||
int32_t* offset = (int32_t*)pStart;
|
int32_t* offset = (int32_t*)pStart;
|
||||||
int32_t* offset1 = (int32_t*)pStart1;
|
int32_t* offset1 = (int32_t*)pStart1;
|
||||||
|
@ -1782,7 +1814,8 @@ static int32_t doConvertJson(SReqResultInfo* pResultInfo, int32_t numOfCols, int
|
||||||
sprintf(varDataVal(dst), "%s", (*((char*)jsonInnerData) == 1) ? "true" : "false");
|
sprintf(varDataVal(dst), "%s", (*((char*)jsonInnerData) == 1) ? "true" : "false");
|
||||||
varDataSetLen(dst, strlen(varDataVal(dst)));
|
varDataSetLen(dst, strlen(varDataVal(dst)));
|
||||||
} else {
|
} else {
|
||||||
ASSERT(0);
|
tscError("doConvertJson error: invalid type:%d", jsonInnerType);
|
||||||
|
return TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
offset1[j] = len;
|
offset1[j] = len;
|
||||||
|
@ -1820,7 +1853,10 @@ static int32_t doConvertJson(SReqResultInfo* pResultInfo, int32_t numOfCols, int
|
||||||
|
|
||||||
int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32_t numOfCols, int32_t numOfRows,
|
int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32_t numOfCols, int32_t numOfRows,
|
||||||
bool convertUcs4) {
|
bool convertUcs4) {
|
||||||
assert(numOfCols > 0 && pFields != NULL && pResultInfo != NULL);
|
if(ASSERT(numOfCols > 0 && pFields != NULL && pResultInfo != NULL)){
|
||||||
|
tscError("setResultDataPtr paras error");
|
||||||
|
return TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||||
|
}
|
||||||
if (numOfRows == 0) {
|
if (numOfRows == 0) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -1849,7 +1885,10 @@ int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32
|
||||||
int32_t cols = *(int32_t*)p;
|
int32_t cols = *(int32_t*)p;
|
||||||
p += sizeof(int32_t);
|
p += sizeof(int32_t);
|
||||||
|
|
||||||
ASSERT(rows == numOfRows && cols == numOfCols);
|
if(ASSERT(rows == numOfRows && cols == numOfCols)){
|
||||||
|
tscError("setResultDataPtr paras error:rows;%d numOfRows:%d cols:%d numOfCols:%d", rows, numOfRows, cols, numOfCols);
|
||||||
|
return TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t hasColumnSeg = *(int32_t*)p;
|
int32_t hasColumnSeg = *(int32_t*)p;
|
||||||
p += sizeof(int32_t);
|
p += sizeof(int32_t);
|
||||||
|
@ -1876,7 +1915,7 @@ int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32
|
||||||
colLength[i] = htonl(colLength[i]);
|
colLength[i] = htonl(colLength[i]);
|
||||||
if (colLength[i] >= dataLen) {
|
if (colLength[i] >= dataLen) {
|
||||||
tscError("invalid colLength %d, dataLen %d", colLength[i], dataLen);
|
tscError("invalid colLength %d, dataLen %d", colLength[i], dataLen);
|
||||||
ASSERT(0);
|
return TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_VAR_DATA_TYPE(pResultInfo->fields[i].type)) {
|
if (IS_VAR_DATA_TYPE(pResultInfo->fields[i].type)) {
|
||||||
|
@ -1914,7 +1953,11 @@ char* getDbOfConnection(STscObj* pObj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void setConnectionDB(STscObj* pTscObj, const char* db) {
|
void setConnectionDB(STscObj* pTscObj, const char* db) {
|
||||||
assert(db != NULL && pTscObj != NULL);
|
if(db == NULL || pTscObj == NULL){
|
||||||
|
tscError("setConnectionDB para is NULL");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
taosThreadMutexLock(&pTscObj->mutex);
|
taosThreadMutexLock(&pTscObj->mutex);
|
||||||
tstrncpy(pTscObj->db, db, tListLen(pTscObj->db));
|
tstrncpy(pTscObj->db, db, tListLen(pTscObj->db));
|
||||||
taosThreadMutexUnlock(&pTscObj->mutex);
|
taosThreadMutexUnlock(&pTscObj->mutex);
|
||||||
|
@ -1932,7 +1975,10 @@ void resetConnectDB(STscObj* pTscObj) {
|
||||||
|
|
||||||
int32_t setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveTableRsp* pRsp, bool convertUcs4,
|
int32_t setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveTableRsp* pRsp, bool convertUcs4,
|
||||||
bool freeAfterUse) {
|
bool freeAfterUse) {
|
||||||
assert(pResultInfo != NULL && pRsp != NULL);
|
if(pResultInfo == NULL || pRsp == NULL){
|
||||||
|
tscError("setQueryResultFromRsp paras is null");
|
||||||
|
return TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if (freeAfterUse) taosMemoryFreeClear(pResultInfo->pRspMsg);
|
if (freeAfterUse) taosMemoryFreeClear(pResultInfo->pRspMsg);
|
||||||
|
|
||||||
|
|
|
@ -574,7 +574,11 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_fetchBlockImp(JNI
|
||||||
TAOS_RES *tres = (TAOS_RES *)res;
|
TAOS_RES *tres = (TAOS_RES *)res;
|
||||||
|
|
||||||
int32_t numOfFields = taos_num_fields(tres);
|
int32_t numOfFields = taos_num_fields(tres);
|
||||||
assert(numOfFields > 0);
|
if(numOfFields <= 0){
|
||||||
|
jniError("jobj:%p, conn:%p, query interrupted. taos_num_fields error code:%d, msg:%s", jobj, tscon, numOfFields,
|
||||||
|
taos_errstr(tres));
|
||||||
|
return JNI_RESULT_SET_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void *data;
|
void *data;
|
||||||
int32_t numOfRows;
|
int32_t numOfRows;
|
||||||
|
|
|
@ -291,7 +291,6 @@ TAOS_ROW taos_fetch_row(TAOS_RES *res) {
|
||||||
tscError("invalid result passed to taos_fetch_row");
|
tscError("invalid result passed to taos_fetch_row");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields) {
|
int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields) {
|
||||||
|
@ -355,9 +354,13 @@ int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields)
|
||||||
case TSDB_DATA_TYPE_NCHAR: {
|
case TSDB_DATA_TYPE_NCHAR: {
|
||||||
int32_t charLen = varDataLen((char *)row[i] - VARSTR_HEADER_SIZE);
|
int32_t charLen = varDataLen((char *)row[i] - VARSTR_HEADER_SIZE);
|
||||||
if (fields[i].type == TSDB_DATA_TYPE_BINARY) {
|
if (fields[i].type == TSDB_DATA_TYPE_BINARY) {
|
||||||
assert(charLen <= fields[i].bytes && charLen >= 0);
|
if(ASSERT(charLen <= fields[i].bytes && charLen >= 0)){
|
||||||
|
tscError("taos_print_row error binary. charLen:%d, fields[i].bytes:%d", charLen, fields[i].bytes);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
assert(charLen <= fields[i].bytes * TSDB_NCHAR_SIZE && charLen >= 0);
|
if(ASSERT(charLen <= fields[i].bytes * TSDB_NCHAR_SIZE && charLen >= 0)){
|
||||||
|
tscError("taos_print_row error. charLen:%d, fields[i].bytes:%d", charLen, fields[i].bytes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(str + len, row[i], charLen);
|
memcpy(str + len, row[i], charLen);
|
||||||
|
@ -577,7 +580,7 @@ int taos_fetch_block_s(TAOS_RES *res, int *numOfRows, TAOS_ROW *rows) {
|
||||||
(*numOfRows) = pResultInfo->numOfRows;
|
(*numOfRows) = pResultInfo->numOfRows;
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
ASSERT(0);
|
tscError("taos_fetch_block_s invalid res type");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1000,8 +1003,14 @@ static void fetchCallback(void *pResult, void *param, int32_t code) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void taos_fetch_rows_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
|
void taos_fetch_rows_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
|
||||||
ASSERT(res != NULL && fp != NULL);
|
if(ASSERT(res != NULL && fp != NULL)){
|
||||||
ASSERT(TD_RES_QUERY(res));
|
tscError("taos_fetch_rows_a invalid paras");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(ASSERT(TD_RES_QUERY(res))){
|
||||||
|
tscError("taos_fetch_rows_a res is NULL");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SRequestObj *pRequest = res;
|
SRequestObj *pRequest = res;
|
||||||
pRequest->body.fetchFp = fp;
|
pRequest->body.fetchFp = fp;
|
||||||
|
@ -1044,9 +1053,14 @@ void taos_fetch_rows_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void taos_fetch_raw_block_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
|
void taos_fetch_raw_block_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
|
||||||
ASSERT(res != NULL && fp != NULL);
|
if(ASSERT(res != NULL && fp != NULL)){
|
||||||
ASSERT(TD_RES_QUERY(res));
|
tscError("taos_fetch_rows_a invalid paras");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(ASSERT(TD_RES_QUERY(res))){
|
||||||
|
tscError("taos_fetch_rows_a res is NULL");
|
||||||
|
return;
|
||||||
|
}
|
||||||
SRequestObj *pRequest = res;
|
SRequestObj *pRequest = res;
|
||||||
SReqResultInfo *pResultInfo = &pRequest->body.resInfo;
|
SReqResultInfo *pResultInfo = &pRequest->body.resInfo;
|
||||||
|
|
||||||
|
@ -1058,8 +1072,14 @@ void taos_fetch_raw_block_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const void *taos_get_raw_block(TAOS_RES *res) {
|
const void *taos_get_raw_block(TAOS_RES *res) {
|
||||||
ASSERT(res != NULL);
|
if(ASSERT(res != NULL)){
|
||||||
ASSERT(TD_RES_QUERY(res));
|
tscError("taos_fetch_rows_a invalid paras");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if(ASSERT(TD_RES_QUERY(res))){
|
||||||
|
tscError("taos_fetch_rows_a res is NULL");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
SRequestObj *pRequest = res;
|
SRequestObj *pRequest = res;
|
||||||
|
|
||||||
return pRequest->body.resInfo.pData;
|
return pRequest->body.resInfo.pData;
|
||||||
|
|
|
@ -149,7 +149,6 @@ SMsgSendInfo* buildMsgInfoImpl(SRequestObj* pRequest) {
|
||||||
pMsgSendInfo->msgType = pRequest->type;
|
pMsgSendInfo->msgType = pRequest->type;
|
||||||
pMsgSendInfo->target.type = TARGET_TYPE_MNODE;
|
pMsgSendInfo->target.type = TARGET_TYPE_MNODE;
|
||||||
|
|
||||||
assert(pRequest != NULL);
|
|
||||||
pMsgSendInfo->msgInfo = pRequest->body.requestMsg;
|
pMsgSendInfo->msgInfo = pRequest->body.requestMsg;
|
||||||
pMsgSendInfo->fp = getMsgRspHandle(pRequest->type);
|
pMsgSendInfo->fp = getMsgRspHandle(pRequest->type);
|
||||||
return pMsgSendInfo;
|
return pMsgSendInfo;
|
||||||
|
@ -273,7 +272,9 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t processCreateSTableRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
int32_t processCreateSTableRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
assert(pMsg != NULL && param != NULL);
|
if(pMsg == NULL || param == NULL){
|
||||||
|
return TSDB_CODE_TSC_INVALID_INPUT;
|
||||||
|
}
|
||||||
SRequestObj* pRequest = param;
|
SRequestObj* pRequest = param;
|
||||||
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -454,7 +455,10 @@ static int32_t buildShowVariablesRsp(SArray* pVars, SRetrieveTableRsp** pRsp) {
|
||||||
(*pRsp)->numOfCols = htonl(SHOW_VARIABLES_RESULT_COLS);
|
(*pRsp)->numOfCols = htonl(SHOW_VARIABLES_RESULT_COLS);
|
||||||
|
|
||||||
int32_t len = blockEncode(pBlock, (*pRsp)->data, SHOW_VARIABLES_RESULT_COLS);
|
int32_t len = blockEncode(pBlock, (*pRsp)->data, SHOW_VARIABLES_RESULT_COLS);
|
||||||
ASSERT(len == rspSize - sizeof(SRetrieveTableRsp));
|
if(len != rspSize - sizeof(SRetrieveTableRsp)){
|
||||||
|
uError("buildShowVariablesRsp error, len:%d != rspSize - sizeof(SRetrieveTableRsp):%" PRIu64, len, (uint64_t) (rspSize - sizeof(SRetrieveTableRsp)));
|
||||||
|
return TSDB_CODE_TSC_INVALID_INPUT;
|
||||||
|
}
|
||||||
|
|
||||||
blockDataDestroy(pBlock);
|
blockDataDestroy(pBlock);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
|
@ -373,7 +373,10 @@ static char* processCreateTable(SMqMetaRsp* metaRsp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static char* processAutoCreateTable(STaosxRsp* rsp) {
|
static char* processAutoCreateTable(STaosxRsp* rsp) {
|
||||||
ASSERT(rsp->createTableNum != 0);
|
if(rsp->createTableNum <= 0){
|
||||||
|
uError("WriteRaw:processAutoCreateTable rsp->createTableNum <= 0");
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
|
||||||
SDecoder* decoder = taosMemoryCalloc(rsp->createTableNum, sizeof(SDecoder));
|
SDecoder* decoder = taosMemoryCalloc(rsp->createTableNum, sizeof(SDecoder));
|
||||||
SVCreateTbReq* pCreateReq = taosMemoryCalloc(rsp->createTableNum, sizeof(SVCreateTbReq));
|
SVCreateTbReq* pCreateReq = taosMemoryCalloc(rsp->createTableNum, sizeof(SVCreateTbReq));
|
||||||
|
@ -389,7 +392,10 @@ static char* processAutoCreateTable(STaosxRsp* rsp) {
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(pCreateReq[iReq].type == TSDB_CHILD_TABLE);
|
if(pCreateReq[iReq].type != TSDB_CHILD_TABLE){
|
||||||
|
uError("WriteRaw:processAutoCreateTable pCreateReq[iReq].type != TSDB_CHILD_TABLE");
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
string = buildCreateCTableJson(pCreateReq, rsp->createTableNum);
|
string = buildCreateCTableJson(pCreateReq, rsp->createTableNum);
|
||||||
|
|
||||||
|
@ -494,7 +500,10 @@ static char* processAlterTable(SMqMetaRsp* metaRsp) {
|
||||||
char* buf = NULL;
|
char* buf = NULL;
|
||||||
|
|
||||||
if (vAlterTbReq.tagType == TSDB_DATA_TYPE_JSON) {
|
if (vAlterTbReq.tagType == TSDB_DATA_TYPE_JSON) {
|
||||||
ASSERT(tTagIsJson(vAlterTbReq.pTagVal) == true);
|
if(!tTagIsJson(vAlterTbReq.pTagVal)){
|
||||||
|
uError("processAlterTable isJson false");
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
buf = parseTagDatatoJson(vAlterTbReq.pTagVal);
|
buf = parseTagDatatoJson(vAlterTbReq.pTagVal);
|
||||||
} else {
|
} else {
|
||||||
buf = taosMemoryCalloc(vAlterTbReq.nTagVal + 1, 1);
|
buf = taosMemoryCalloc(vAlterTbReq.nTagVal + 1, 1);
|
||||||
|
@ -1610,7 +1619,11 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(pCreateReq.type == TSDB_CHILD_TABLE);
|
if(pCreateReq.type != TSDB_CHILD_TABLE){
|
||||||
|
uError("WriteRaw:pCreateReq.type != TSDB_CHILD_TABLE. table name: %s", tbName);
|
||||||
|
code = TSDB_CODE_TSC_INVALID_VALUE;
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
if (strcmp(tbName, pCreateReq.name) == 0) {
|
if (strcmp(tbName, pCreateReq.name) == 0) {
|
||||||
strcpy(pName.tname, pCreateReq.ctb.stbName);
|
strcpy(pName.tname, pCreateReq.ctb.stbName);
|
||||||
tDecoderClear(&decoderTmp);
|
tDecoderClear(&decoderTmp);
|
||||||
|
|
|
@ -523,7 +523,10 @@ STableMeta *smlGetMeta(SSmlHandle *info, const void *measure, int32_t measureLen
|
||||||
memset(pName.tname, 0, TSDB_TABLE_NAME_LEN);
|
memset(pName.tname, 0, TSDB_TABLE_NAME_LEN);
|
||||||
memcpy(pName.tname, measure, measureLen);
|
memcpy(pName.tname, measure, measureLen);
|
||||||
|
|
||||||
catalogGetSTableMeta(info->pCatalog, &conn, &pName, &pTableMeta);
|
int32_t code = catalogGetSTableMeta(info->pCatalog, &conn, &pName, &pTableMeta);
|
||||||
|
if(code != TSDB_CODE_SUCCESS){
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
return pTableMeta;
|
return pTableMeta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -996,7 +999,10 @@ static int32_t smlUpdateMeta(SHashObj *metaHash, SArray *metaArray, SArray *cols
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
size_t tmp = taosArrayGetSize(metaArray);
|
size_t tmp = taosArrayGetSize(metaArray);
|
||||||
ASSERT(tmp <= INT16_MAX);
|
if(tmp > INT16_MAX){
|
||||||
|
uError("too many cols or tags");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
int16_t size = tmp;
|
int16_t size = tmp;
|
||||||
int ret = taosHashPut(metaHash, kv->key, kv->keyLen, &size, SHORT_BYTES);
|
int ret = taosHashPut(metaHash, kv->key, kv->keyLen, &size, SHORT_BYTES);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
|
@ -1008,7 +1014,7 @@ static int32_t smlUpdateMeta(SHashObj *metaHash, SArray *metaArray, SArray *cols
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void smlDestroyTableInfo(SSmlHandle *info, SSmlTableInfo *tag) {
|
void smlDestroyTableInfo(SSmlHandle *info, SSmlTableInfo *tag) {
|
||||||
for (size_t i = 0; i < taosArrayGetSize(tag->cols); i++) {
|
for (size_t i = 0; i < taosArrayGetSize(tag->cols); i++) {
|
||||||
SHashObj *kvHash = (SHashObj *)taosArrayGetP(tag->cols, i);
|
SHashObj *kvHash = (SHashObj *)taosArrayGetP(tag->cols, i);
|
||||||
taosHashCleanup(kvHash);
|
taosHashCleanup(kvHash);
|
||||||
|
@ -1229,7 +1235,10 @@ static int32_t smlInsertData(SSmlHandle *info) {
|
||||||
|
|
||||||
SSmlSTableMeta *pMeta =
|
SSmlSTableMeta *pMeta =
|
||||||
(SSmlSTableMeta *)nodeListGet(info->superTables, tableData->sTableName, tableData->sTableNameLen, NULL);
|
(SSmlSTableMeta *)nodeListGet(info->superTables, tableData->sTableName, tableData->sTableNameLen, NULL);
|
||||||
ASSERT(NULL != pMeta);
|
if(unlikely(NULL == pMeta || NULL == pMeta->tableMeta)){
|
||||||
|
uError("SML:0x%" PRIx64 " NULL == pMeta. table name: %s", info->id, tableData->childTableName);
|
||||||
|
return TSDB_CODE_SML_INTERNAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
// use tablemeta of stable to save vgid and uid of child table
|
// use tablemeta of stable to save vgid and uid of child table
|
||||||
pMeta->tableMeta->vgId = vg.vgId;
|
pMeta->tableMeta->vgId = vg.vgId;
|
||||||
|
@ -1365,9 +1374,8 @@ static int32_t smlParseLine(SSmlHandle *info, char *lines[], char *rawLine, char
|
||||||
} else {
|
} else {
|
||||||
code = smlParseTelnetString(info, (char *)tmp, (char *)tmp + len, info->lines + i);
|
code = smlParseTelnetString(info, (char *)tmp, (char *)tmp + len, info->lines + i);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
ASSERT(0);
|
code = TSDB_CODE_SML_INVALID_PROTOCOL_TYPE;
|
||||||
}
|
}
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
uError("SML:0x%" PRIx64 " smlParseLine failed. line %d : %s", info->id, i, tmp);
|
uError("SML:0x%" PRIx64 " smlParseLine failed. line %d : %s", info->id, i, tmp);
|
||||||
|
|
|
@ -143,7 +143,10 @@ while(*(start)){\
|
||||||
// if(unlikely(kv.length > preKV->length)){
|
// if(unlikely(kv.length > preKV->length)){
|
||||||
// preKV->length = kv.length;
|
// preKV->length = kv.length;
|
||||||
// SSmlSTableMeta *tableMeta = (SSmlSTableMeta *)nodeListGet(info->superTables, elements->measure, elements->measureLen, NULL);
|
// SSmlSTableMeta *tableMeta = (SSmlSTableMeta *)nodeListGet(info->superTables, elements->measure, elements->measureLen, NULL);
|
||||||
// ASSERT(tableMeta != NULL);
|
// if(unlikely(NULL == tableMeta)){
|
||||||
|
// uError("SML:0x%" PRIx64 " NULL == tableMeta", info->id);
|
||||||
|
// return TSDB_CODE_SML_INTERNAL_ERROR;
|
||||||
|
// }
|
||||||
//
|
//
|
||||||
// SSmlKv *oldKV = (SSmlKv *)taosArrayGet(tableMeta->tags, cnt);
|
// SSmlKv *oldKV = (SSmlKv *)taosArrayGet(tableMeta->tags, cnt);
|
||||||
// oldKV->length = kv.length;
|
// oldKV->length = kv.length;
|
||||||
|
@ -723,7 +726,10 @@ static int32_t smlParseTagsFromJSON(SSmlHandle *info, cJSON *tags, SSmlLineInfo
|
||||||
if(unlikely(kv.length > maxKV->length)){
|
if(unlikely(kv.length > maxKV->length)){
|
||||||
maxKV->length = kv.length;
|
maxKV->length = kv.length;
|
||||||
SSmlSTableMeta *tableMeta = (SSmlSTableMeta *)nodeListGet(info->superTables, elements->measure, elements->measureLen, NULL);
|
SSmlSTableMeta *tableMeta = (SSmlSTableMeta *)nodeListGet(info->superTables, elements->measure, elements->measureLen, NULL);
|
||||||
ASSERT(tableMeta != NULL);
|
if(unlikely(NULL == tableMeta)){
|
||||||
|
uError("SML:0x%" PRIx64 " NULL == tableMeta", info->id);
|
||||||
|
return TSDB_CODE_SML_INTERNAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
SSmlKv *oldKV = (SSmlKv *)taosArrayGet(tableMeta->tags, cnt);
|
SSmlKv *oldKV = (SSmlKv *)taosArrayGet(tableMeta->tags, cnt);
|
||||||
oldKV->length = kv.length;
|
oldKV->length = kv.length;
|
||||||
|
@ -780,6 +786,7 @@ static int32_t smlParseTagsFromJSON(SSmlHandle *info, cJSON *tags, SSmlLineInfo
|
||||||
tinfo->tableDataCtx = smlInitTableDataCtx(info->pQuery, info->currSTableMeta);
|
tinfo->tableDataCtx = smlInitTableDataCtx(info->pQuery, info->currSTableMeta);
|
||||||
if (tinfo->tableDataCtx == NULL) {
|
if (tinfo->tableDataCtx == NULL) {
|
||||||
smlBuildInvalidDataMsg(&info->msgBuf, "smlInitTableDataCtx error", NULL);
|
smlBuildInvalidDataMsg(&info->msgBuf, "smlInitTableDataCtx error", NULL);
|
||||||
|
smlDestroyTableInfo(info, tinfo);
|
||||||
return TSDB_CODE_SML_INVALID_DATA;
|
return TSDB_CODE_SML_INVALID_DATA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -259,7 +259,10 @@ static int32_t smlParseTagKv(SSmlHandle *info, char **sql, char *sqlEnd,
|
||||||
if(unlikely(kv.length > maxKV->length)){
|
if(unlikely(kv.length > maxKV->length)){
|
||||||
maxKV->length = kv.length;
|
maxKV->length = kv.length;
|
||||||
SSmlSTableMeta *tableMeta = (SSmlSTableMeta *)nodeListGet(info->superTables, currElement->measure, currElement->measureLen, NULL);
|
SSmlSTableMeta *tableMeta = (SSmlSTableMeta *)nodeListGet(info->superTables, currElement->measure, currElement->measureLen, NULL);
|
||||||
ASSERT(tableMeta != NULL);
|
if(unlikely(NULL == tableMeta)){
|
||||||
|
uError("SML:0x%" PRIx64 " NULL == tableMeta", info->id);
|
||||||
|
return TSDB_CODE_SML_INTERNAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
SSmlKv *oldKV = (SSmlKv *)taosArrayGet(tableMeta->tags, cnt);
|
SSmlKv *oldKV = (SSmlKv *)taosArrayGet(tableMeta->tags, cnt);
|
||||||
oldKV->length = kv.length;
|
oldKV->length = kv.length;
|
||||||
|
@ -484,7 +487,10 @@ static int32_t smlParseColKv(SSmlHandle *info, char **sql, char *sqlEnd,
|
||||||
if(unlikely(IS_VAR_DATA_TYPE(kv.type) && kv.length > maxKV->length)){
|
if(unlikely(IS_VAR_DATA_TYPE(kv.type) && kv.length > maxKV->length)){
|
||||||
maxKV->length = kv.length;
|
maxKV->length = kv.length;
|
||||||
SSmlSTableMeta *tableMeta = (SSmlSTableMeta *)nodeListGet(info->superTables, currElement->measure, currElement->measureLen, NULL);
|
SSmlSTableMeta *tableMeta = (SSmlSTableMeta *)nodeListGet(info->superTables, currElement->measure, currElement->measureLen, NULL);
|
||||||
ASSERT(tableMeta != NULL);
|
if(unlikely(NULL == tableMeta)){
|
||||||
|
uError("SML:0x%" PRIx64 " NULL == tableMeta", info->id);
|
||||||
|
return TSDB_CODE_SML_INTERNAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
SSmlKv *oldKV = (SSmlKv *)taosArrayGet(tableMeta->cols, cnt);
|
SSmlKv *oldKV = (SSmlKv *)taosArrayGet(tableMeta->cols, cnt);
|
||||||
oldKV->length = kv.length;
|
oldKV->length = kv.length;
|
||||||
|
|
|
@ -184,7 +184,10 @@ static int32_t smlParseTelnetTags(SSmlHandle *info, char *data, char *sqlEnd, SS
|
||||||
if(unlikely(kv.length > maxKV->length)){
|
if(unlikely(kv.length > maxKV->length)){
|
||||||
maxKV->length = kv.length;
|
maxKV->length = kv.length;
|
||||||
SSmlSTableMeta *tableMeta = (SSmlSTableMeta *)nodeListGet(info->superTables, elements->measure, elements->measureLen, NULL);
|
SSmlSTableMeta *tableMeta = (SSmlSTableMeta *)nodeListGet(info->superTables, elements->measure, elements->measureLen, NULL);
|
||||||
ASSERT(tableMeta != NULL);
|
if(unlikely(NULL == tableMeta)){
|
||||||
|
uError("SML:0x%" PRIx64 " NULL == tableMeta", info->id);
|
||||||
|
return TSDB_CODE_SML_INTERNAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
SSmlKv *oldKV = (SSmlKv *)taosArrayGet(tableMeta->tags, cnt);
|
SSmlKv *oldKV = (SSmlKv *)taosArrayGet(tableMeta->tags, cnt);
|
||||||
oldKV->length = kv.length;
|
oldKV->length = kv.length;
|
||||||
|
@ -240,6 +243,7 @@ static int32_t smlParseTelnetTags(SSmlHandle *info, char *data, char *sqlEnd, SS
|
||||||
tinfo->tableDataCtx = smlInitTableDataCtx(info->pQuery, info->currSTableMeta);
|
tinfo->tableDataCtx = smlInitTableDataCtx(info->pQuery, info->currSTableMeta);
|
||||||
if (tinfo->tableDataCtx == NULL) {
|
if (tinfo->tableDataCtx == NULL) {
|
||||||
smlBuildInvalidDataMsg(&info->msgBuf, "smlInitTableDataCtx error", NULL);
|
smlBuildInvalidDataMsg(&info->msgBuf, "smlInitTableDataCtx error", NULL);
|
||||||
|
smlDestroyTableInfo(info, tinfo);
|
||||||
return TSDB_CODE_SML_INVALID_DATA;
|
return TSDB_CODE_SML_INVALID_DATA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -296,7 +296,6 @@ int32_t stmtCleanExecInfo(STscStmt* pStmt, bool keepTable, bool deepClean) {
|
||||||
STableMeta* pMeta = qGetTableMetaInDataBlock(pBlocks);
|
STableMeta* pMeta = qGetTableMetaInDataBlock(pBlocks);
|
||||||
|
|
||||||
if (keepTable && pBlocks == pStmt->exec.pCurrBlock) {
|
if (keepTable && pBlocks == pStmt->exec.pCurrBlock) {
|
||||||
ASSERT(NULL == pBlocks->pData);
|
|
||||||
TSWAP(pBlocks->pData, pStmt->exec.pCurrTbData);
|
TSWAP(pBlocks->pData, pStmt->exec.pCurrTbData);
|
||||||
STMT_ERR_RET(qResetStmtDataBlock(pBlocks, false));
|
STMT_ERR_RET(qResetStmtDataBlock(pBlocks, false));
|
||||||
|
|
||||||
|
@ -394,7 +393,10 @@ int32_t stmtGetFromCache(STscStmt* pStmt) {
|
||||||
|
|
||||||
if (NULL == pStmt->sql.pTableCache || taosHashGetSize(pStmt->sql.pTableCache) <= 0) {
|
if (NULL == pStmt->sql.pTableCache || taosHashGetSize(pStmt->sql.pTableCache) <= 0) {
|
||||||
if (pStmt->bInfo.inExecCache) {
|
if (pStmt->bInfo.inExecCache) {
|
||||||
ASSERT(taosHashGetSize(pStmt->exec.pBlockHash) == 1);
|
if(ASSERT(taosHashGetSize(pStmt->exec.pBlockHash) == 1)){
|
||||||
|
tscError("stmtGetFromCache error");
|
||||||
|
return TSDB_CODE_TSC_STMT_CACHE_ERROR;
|
||||||
|
}
|
||||||
pStmt->bInfo.needParse = false;
|
pStmt->bInfo.needParse = false;
|
||||||
tscDebug("reuse stmt block for tb %s in execBlock", pStmt->bInfo.tbFName);
|
tscDebug("reuse stmt block for tb %s in execBlock", pStmt->bInfo.tbFName);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
|
@ -418,7 +418,10 @@ int32_t tmqCommitDone(SMqCommitCbParamSet* pParamSet) {
|
||||||
|
|
||||||
static void tmqCommitRspCountDown(SMqCommitCbParamSet* pParamSet) {
|
static void tmqCommitRspCountDown(SMqCommitCbParamSet* pParamSet) {
|
||||||
int32_t waitingRspNum = atomic_sub_fetch_32(&pParamSet->waitingRspNum, 1);
|
int32_t waitingRspNum = atomic_sub_fetch_32(&pParamSet->waitingRspNum, 1);
|
||||||
ASSERT(waitingRspNum >= 0);
|
if(ASSERT(waitingRspNum >= 0)){
|
||||||
|
tscError("tmqCommitRspCountDown error:%d", waitingRspNum);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (waitingRspNum == 0) {
|
if (waitingRspNum == 0) {
|
||||||
tmqCommitDone(pParamSet);
|
tmqCommitDone(pParamSet);
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,8 +109,8 @@ static int32_t dmStartNodes(SDnode *pDnode) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dInfo("TDengine initialized successfully");
|
dInfo("The daemon initialized successfully");
|
||||||
dmReportStartup("TDengine", "initialized successfully");
|
dmReportStartup("The daemon", "initialized successfully");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ int32_t dmRunDnode(SDnode *pDnode) {
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (pDnode->stop) {
|
if (pDnode->stop) {
|
||||||
dInfo("TDengine is about to stop");
|
dInfo("The daemon is about to stop");
|
||||||
dmSetStatus(pDnode, DND_STAT_STOPPED);
|
dmSetStatus(pDnode, DND_STAT_STOPPED);
|
||||||
dmStopNodes(pDnode);
|
dmStopNodes(pDnode);
|
||||||
dmCloseNodes(pDnode);
|
dmCloseNodes(pDnode);
|
||||||
|
|
|
@ -353,6 +353,7 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
||||||
|
|
||||||
ret = tdbTbcGet(pTbDbc, NULL, NULL, &pData, &nData);
|
ret = tdbTbcGet(pTbDbc, NULL, NULL, &pData, &nData);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
tdbTbcClose(pUidIdxc);
|
||||||
tdbTbcClose(pTbDbc);
|
tdbTbcClose(pTbDbc);
|
||||||
|
|
||||||
terrno = TSDB_CODE_TDB_STB_NOT_EXIST;
|
terrno = TSDB_CODE_TDB_STB_NOT_EXIST;
|
||||||
|
@ -1210,6 +1211,8 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p
|
||||||
ret = metaDecodeEntry(&dc, &entry);
|
ret = metaDecodeEntry(&dc, &entry);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
tDecoderClear(&dc);
|
tDecoderClear(&dc);
|
||||||
|
tdbTbcClose(pUidIdxc);
|
||||||
|
tdbTbcClose(pTbDbc);
|
||||||
metaError("meta/table: invalide ret: %" PRId32 " alt tb options failed.", ret);
|
metaError("meta/table: invalide ret: %" PRId32 " alt tb options failed.", ret);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,10 +148,6 @@ int32_t smaOpen(SVnode *pVnode, int8_t rollback) {
|
||||||
SMA_OPEN_RSMA_IMPL(pVnode, 1);
|
SMA_OPEN_RSMA_IMPL(pVnode, 1);
|
||||||
} else if (i == TSDB_RETENTION_L2) {
|
} else if (i == TSDB_RETENTION_L2) {
|
||||||
SMA_OPEN_RSMA_IMPL(pVnode, 2);
|
SMA_OPEN_RSMA_IMPL(pVnode, 2);
|
||||||
} else {
|
|
||||||
code = TSDB_CODE_APP_ERROR;
|
|
||||||
smaError("vgId:%d, sma open failed since %s, level:%d", TD_VID(pVnode), tstrerror(code), i);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -237,8 +237,8 @@ int32_t rsmaSnapRead(SRSmaSnapReader* pReader, uint8_t** ppData) {
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
rsmaSnapReaderClose(&pReader);
|
|
||||||
smaError("vgId:%d, vnode snapshot rsma read failed since %s", SMA_VID(pReader->pSma), tstrerror(code));
|
smaError("vgId:%d, vnode snapshot rsma read failed since %s", SMA_VID(pReader->pSma), tstrerror(code));
|
||||||
|
rsmaSnapReaderClose(&pReader);
|
||||||
} else {
|
} else {
|
||||||
smaInfo("vgId:%d, vnode snapshot rsma read succeed", SMA_VID(pReader->pSma));
|
smaInfo("vgId:%d, vnode snapshot rsma read succeed", SMA_VID(pReader->pSma));
|
||||||
}
|
}
|
||||||
|
@ -432,7 +432,7 @@ _exit:
|
||||||
if (pInFD) taosCloseFile(&pInFD);
|
if (pInFD) taosCloseFile(&pInFD);
|
||||||
smaError("vgId:%d, vnode snapshot rsma writer close failed since %s", SMA_VID(pSma), tstrerror(code));
|
smaError("vgId:%d, vnode snapshot rsma writer close failed since %s", SMA_VID(pSma), tstrerror(code));
|
||||||
} else {
|
} else {
|
||||||
smaInfo("vgId:%d, vnode snapshot rsma writer close succeed", SMA_VID(pSma));
|
smaInfo("vgId:%d, vnode snapshot rsma writer close succeed", pSma ? SMA_VID(pSma) : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
|
|
@ -73,7 +73,7 @@ void tMemBucketDestroy(tMemBucket *pBucket);
|
||||||
|
|
||||||
int32_t tMemBucketPut(tMemBucket *pBucket, const void *data, size_t size);
|
int32_t tMemBucketPut(tMemBucket *pBucket, const void *data, size_t size);
|
||||||
|
|
||||||
double getPercentile(tMemBucket *pMemBucket, double percent);
|
int32_t getPercentile(tMemBucket *pMemBucket, double percent, double *result);
|
||||||
|
|
||||||
#endif // TDENGINE_TPERCENTILE_H
|
#endif // TDENGINE_TPERCENTILE_H
|
||||||
|
|
||||||
|
|
|
@ -1670,15 +1670,14 @@ int32_t percentileFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
|
|
||||||
tMemBucket* pMemBucket = ppInfo->pMemBucket;
|
tMemBucket* pMemBucket = ppInfo->pMemBucket;
|
||||||
if (pMemBucket != NULL && pMemBucket->total > 0) { // check for null
|
if (pMemBucket != NULL && pMemBucket->total > 0) { // check for null
|
||||||
SET_DOUBLE_VAL(&ppInfo->result, getPercentile(pMemBucket, v));
|
int32_t code = getPercentile(pMemBucket, v, &ppInfo->result);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
tMemBucketDestroy(pMemBucket);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tMemBucketDestroy(pMemBucket);
|
tMemBucketDestroy(pMemBucket);
|
||||||
|
|
||||||
if (ppInfo->result < 0) {
|
|
||||||
return TSDB_CODE_NO_AVAIL_DISK;
|
|
||||||
}
|
|
||||||
|
|
||||||
return functionFinalize(pCtx, pBlock);
|
return functionFinalize(pCtx, pBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -97,7 +97,7 @@ static void resetPosInfo(SSlotInfo *pInfo) {
|
||||||
pInfo->data = NULL;
|
pInfo->data = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
double findOnlyResult(tMemBucket *pMemBucket) {
|
int32_t findOnlyResult(tMemBucket *pMemBucket, double *result) {
|
||||||
ASSERT(pMemBucket->total == 1);
|
ASSERT(pMemBucket->total == 1);
|
||||||
|
|
||||||
for (int32_t i = 0; i < pMemBucket->numOfSlots; ++i) {
|
for (int32_t i = 0; i < pMemBucket->numOfSlots; ++i) {
|
||||||
|
@ -115,17 +115,17 @@ double findOnlyResult(tMemBucket *pMemBucket) {
|
||||||
int32_t *pageId = taosArrayGet(list, 0);
|
int32_t *pageId = taosArrayGet(list, 0);
|
||||||
SFilePage *pPage = getBufPage(pMemBucket->pBuffer, *pageId);
|
SFilePage *pPage = getBufPage(pMemBucket->pBuffer, *pageId);
|
||||||
if (pPage == NULL) {
|
if (pPage == NULL) {
|
||||||
return -1;
|
return TSDB_CODE_NO_AVAIL_DISK;
|
||||||
}
|
}
|
||||||
ASSERT(pPage->num == 1);
|
ASSERT(pPage->num == 1);
|
||||||
|
|
||||||
double v = 0;
|
GET_TYPED_DATA(*result, double, pMemBucket->type, pPage->data);
|
||||||
GET_TYPED_DATA(v, double, pMemBucket->type, pPage->data);
|
return TSDB_CODE_SUCCESS;
|
||||||
return v;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
*result = 0.0;
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tBucketIntHash(tMemBucket *pBucket, const void *value) {
|
int32_t tBucketIntHash(tMemBucket *pBucket, const void *value) {
|
||||||
|
@ -447,7 +447,7 @@ static double getIdenticalDataVal(tMemBucket *pMemBucket, int32_t slotIndex) {
|
||||||
return finalResult;
|
return finalResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
double getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction) {
|
int32_t getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction, double *result) {
|
||||||
int32_t num = 0;
|
int32_t num = 0;
|
||||||
|
|
||||||
for (int32_t i = 0; i < pMemBucket->numOfSlots; ++i) {
|
for (int32_t i = 0; i < pMemBucket->numOfSlots; ++i) {
|
||||||
|
@ -480,15 +480,15 @@ double getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction)
|
||||||
|
|
||||||
ASSERT(minOfNextSlot > maxOfThisSlot);
|
ASSERT(minOfNextSlot > maxOfThisSlot);
|
||||||
|
|
||||||
double val = (1 - fraction) * maxOfThisSlot + fraction * minOfNextSlot;
|
*result = (1 - fraction) * maxOfThisSlot + fraction * minOfNextSlot;
|
||||||
return val;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pSlot->info.size <= pMemBucket->maxCapacity) {
|
if (pSlot->info.size <= pMemBucket->maxCapacity) {
|
||||||
// data in buffer and file are merged together to be processed.
|
// data in buffer and file are merged together to be processed.
|
||||||
SFilePage *buffer = loadDataFromFilePage(pMemBucket, i);
|
SFilePage *buffer = loadDataFromFilePage(pMemBucket, i);
|
||||||
if (buffer == NULL) {
|
if (buffer == NULL) {
|
||||||
return -1;
|
return TSDB_CODE_NO_AVAIL_DISK;
|
||||||
}
|
}
|
||||||
int32_t currentIdx = count - num;
|
int32_t currentIdx = count - num;
|
||||||
|
|
||||||
|
@ -499,13 +499,14 @@ double getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction)
|
||||||
GET_TYPED_DATA(td, double, pMemBucket->type, thisVal);
|
GET_TYPED_DATA(td, double, pMemBucket->type, thisVal);
|
||||||
GET_TYPED_DATA(nd, double, pMemBucket->type, nextVal);
|
GET_TYPED_DATA(nd, double, pMemBucket->type, nextVal);
|
||||||
|
|
||||||
double val = (1 - fraction) * td + fraction * nd;
|
*result = (1 - fraction) * td + fraction * nd;
|
||||||
taosMemoryFreeClear(buffer);
|
taosMemoryFreeClear(buffer);
|
||||||
|
|
||||||
return val;
|
return TSDB_CODE_SUCCESS;
|
||||||
} else { // incur a second round bucket split
|
} else { // incur a second round bucket split
|
||||||
if (isIdenticalData(pMemBucket, i)) {
|
if (isIdenticalData(pMemBucket, i)) {
|
||||||
return getIdenticalDataVal(pMemBucket, i);
|
*result = getIdenticalDataVal(pMemBucket, i);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// try next round
|
// try next round
|
||||||
|
@ -534,37 +535,37 @@ double getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction)
|
||||||
int32_t *pageId = taosArrayGet(list, f);
|
int32_t *pageId = taosArrayGet(list, f);
|
||||||
SFilePage *pg = getBufPage(pMemBucket->pBuffer, *pageId);
|
SFilePage *pg = getBufPage(pMemBucket->pBuffer, *pageId);
|
||||||
if (pg == NULL) {
|
if (pg == NULL) {
|
||||||
return -1;
|
return TSDB_CODE_NO_AVAIL_DISK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = tMemBucketPut(pMemBucket, pg->data, (int32_t)pg->num);
|
int32_t code = tMemBucketPut(pMemBucket, pg->data, (int32_t)pg->num);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return -1;
|
return code;
|
||||||
}
|
}
|
||||||
setBufPageDirty(pg, true);
|
setBufPageDirty(pg, true);
|
||||||
releaseBufPage(pMemBucket->pBuffer, pg);
|
releaseBufPage(pMemBucket->pBuffer, pg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return getPercentileImpl(pMemBucket, count - num, fraction);
|
return getPercentileImpl(pMemBucket, count - num, fraction, result);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
num += pSlot->info.size;
|
num += pSlot->info.size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
*result = 0;
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
double getPercentile(tMemBucket *pMemBucket, double percent) {
|
int32_t getPercentile(tMemBucket *pMemBucket, double percent, double *result) {
|
||||||
if (pMemBucket->total == 0) {
|
if (pMemBucket->total == 0) {
|
||||||
return 0.0;
|
*result = 0.0;
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if only one elements exists, return it
|
// if only one elements exists, return it
|
||||||
if (pMemBucket->total == 1) {
|
if (pMemBucket->total == 1) {
|
||||||
if (findOnlyResult(pMemBucket) < 0) {
|
return findOnlyResult(pMemBucket, result);
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
percent = fabs(percent);
|
percent = fabs(percent);
|
||||||
|
@ -574,21 +575,21 @@ double getPercentile(tMemBucket *pMemBucket, double percent) {
|
||||||
MinMaxEntry *pRange = &pMemBucket->range;
|
MinMaxEntry *pRange = &pMemBucket->range;
|
||||||
|
|
||||||
if (IS_SIGNED_NUMERIC_TYPE(pMemBucket->type)) {
|
if (IS_SIGNED_NUMERIC_TYPE(pMemBucket->type)) {
|
||||||
double v = (double)(fabs(percent - 100) < DBL_EPSILON ? pRange->i64MaxVal : pRange->i64MinVal);
|
*result = (double)(fabs(percent - 100) < DBL_EPSILON ? pRange->i64MaxVal : pRange->i64MinVal);
|
||||||
return v;
|
|
||||||
} else if (IS_UNSIGNED_NUMERIC_TYPE(pMemBucket->type)) {
|
} else if (IS_UNSIGNED_NUMERIC_TYPE(pMemBucket->type)) {
|
||||||
double v = (double)(fabs(percent - 100) < DBL_EPSILON ? pRange->u64MaxVal : pRange->u64MinVal);
|
*result = (double)(fabs(percent - 100) < DBL_EPSILON ? pRange->u64MaxVal : pRange->u64MinVal);
|
||||||
return v;
|
|
||||||
} else {
|
} else {
|
||||||
return fabs(percent - 100) < DBL_EPSILON ? pRange->dMaxVal : pRange->dMinVal;
|
*result = fabs(percent - 100) < DBL_EPSILON ? pRange->dMaxVal : pRange->dMinVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
double percentVal = (percent * (pMemBucket->total - 1)) / ((double)100.0);
|
double percentVal = (percent * (pMemBucket->total - 1)) / ((double)100.0);
|
||||||
|
|
||||||
// do put data by using buckets
|
// do put data by using buckets
|
||||||
int32_t orderIdx = (int32_t)percentVal;
|
int32_t orderIdx = (int32_t)percentVal;
|
||||||
return getPercentileImpl(pMemBucket, orderIdx, percentVal - orderIdx);
|
return getPercentileImpl(pMemBucket, orderIdx, percentVal - orderIdx, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -368,6 +368,9 @@ int64_t taosReadFile(TdFilePtr pFile, void *buf, int64_t count) {
|
||||||
#endif
|
#endif
|
||||||
ASSERT(pFile->fd >= 0); // Please check if you have closed the file.
|
ASSERT(pFile->fd >= 0); // Please check if you have closed the file.
|
||||||
if (pFile->fd < 0) {
|
if (pFile->fd < 0) {
|
||||||
|
#if FILE_WITH_LOCK
|
||||||
|
taosThreadRwlockUnlock(&(pFile->rwlock));
|
||||||
|
#endif
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
int64_t leftbytes = count;
|
int64_t leftbytes = count;
|
||||||
|
@ -415,6 +418,9 @@ int64_t taosPReadFile(TdFilePtr pFile, void *buf, int64_t count, int64_t offset)
|
||||||
#endif
|
#endif
|
||||||
ASSERT(pFile->fd >= 0); // Please check if you have closed the file.
|
ASSERT(pFile->fd >= 0); // Please check if you have closed the file.
|
||||||
if (pFile->fd < 0) {
|
if (pFile->fd < 0) {
|
||||||
|
#if FILE_WITH_LOCK
|
||||||
|
taosThreadRwlockUnlock(&(pFile->rwlock));
|
||||||
|
#endif
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
|
@ -479,6 +485,9 @@ int64_t taosPWriteFile(TdFilePtr pFile, const void *buf, int64_t count, int64_t
|
||||||
#endif
|
#endif
|
||||||
ASSERT(pFile->fd >= 0); // Please check if you have closed the file.
|
ASSERT(pFile->fd >= 0); // Please check if you have closed the file.
|
||||||
if (pFile->fd < 0) {
|
if (pFile->fd < 0) {
|
||||||
|
#if FILE_WITH_LOCK
|
||||||
|
taosThreadRwlockUnlock(&(pFile->rwlock));
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
|
|
|
@ -71,7 +71,7 @@ char *taosCharsetReplace(char *charsetstr) {
|
||||||
* seems does not response as expected.
|
* seems does not response as expected.
|
||||||
*
|
*
|
||||||
* In some Linux systems, setLocale(LC_CTYPE, "") may return NULL, in which case the launch of
|
* In some Linux systems, setLocale(LC_CTYPE, "") may return NULL, in which case the launch of
|
||||||
* both the TDengine Server and the Client may be interrupted.
|
* both the Server and the Client may be interrupted.
|
||||||
*
|
*
|
||||||
* In case that the setLocale failed to be executed, the right charset needs to be set.
|
* In case that the setLocale failed to be executed, the right charset needs to be set.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -217,7 +217,7 @@ void taosReleaseConv(int32_t idx, iconv_t conv, ConvType type) {
|
||||||
|
|
||||||
bool taosMbsToUcs4(const char *mbs, size_t mbsLength, TdUcs4 *ucs4, int32_t ucs4_max_len, int32_t *len) {
|
bool taosMbsToUcs4(const char *mbs, size_t mbsLength, TdUcs4 *ucs4, int32_t ucs4_max_len, int32_t *len) {
|
||||||
#ifdef DISALLOW_NCHAR_WITHOUT_ICONV
|
#ifdef DISALLOW_NCHAR_WITHOUT_ICONV
|
||||||
printf("Nchar cannot be read and written without iconv, please install iconv library and recompile TDengine.\n");
|
printf("Nchar cannot be read and written without iconv, please install iconv library and recompile.\n");
|
||||||
return -1;
|
return -1;
|
||||||
#else
|
#else
|
||||||
memset(ucs4, 0, ucs4_max_len);
|
memset(ucs4, 0, ucs4_max_len);
|
||||||
|
@ -245,7 +245,7 @@ bool taosMbsToUcs4(const char *mbs, size_t mbsLength, TdUcs4 *ucs4, int32_t ucs4
|
||||||
|
|
||||||
int32_t taosUcs4ToMbs(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs) {
|
int32_t taosUcs4ToMbs(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs) {
|
||||||
#ifdef DISALLOW_NCHAR_WITHOUT_ICONV
|
#ifdef DISALLOW_NCHAR_WITHOUT_ICONV
|
||||||
printf("Nchar cannot be read and written without iconv, please install iconv library and recompile TDengine.\n");
|
printf("Nchar cannot be read and written without iconv, please install iconv library and recompile.\n");
|
||||||
return -1;
|
return -1;
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
@ -263,7 +263,7 @@ int32_t taosUcs4ToMbs(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs) {
|
||||||
}
|
}
|
||||||
bool taosValidateEncodec(const char *encodec) {
|
bool taosValidateEncodec(const char *encodec) {
|
||||||
#ifdef DISALLOW_NCHAR_WITHOUT_ICONV
|
#ifdef DISALLOW_NCHAR_WITHOUT_ICONV
|
||||||
printf("Nchar cannot be read and written without iconv, please install iconv library and recompile TDengine.\n");
|
printf("Nchar cannot be read and written without iconv, please install iconv library and recompile.\n");
|
||||||
return true;
|
return true;
|
||||||
#else
|
#else
|
||||||
iconv_t cd = iconv_open(encodec, DEFAULT_UNICODE_ENCODEC);
|
iconv_t cd = iconv_open(encodec, DEFAULT_UNICODE_ENCODEC);
|
||||||
|
|
|
@ -138,6 +138,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TSC_QUERY_KILLED, "Query killed")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_NO_EXEC_NODE, "No available execution node in current query policy configuration")
|
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_NO_EXEC_NODE, "No available execution node in current query policy configuration")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_NOT_STABLE_ERROR, "Table is not a super table")
|
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_NOT_STABLE_ERROR, "Table is not a super table")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_STMT_CACHE_ERROR, "Stmt cache error")
|
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_STMT_CACHE_ERROR, "Stmt cache error")
|
||||||
|
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INTERNAL_ERROR, "Internal error")
|
||||||
|
|
||||||
// mnode-common
|
// mnode-common
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_NO_RIGHTS, "Insufficient privilege for operation")
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_NO_RIGHTS, "Insufficient privilege for operation")
|
||||||
|
@ -578,6 +579,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_SML_INVALID_PRECISION_TYPE, "Invalid timestamp p
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_SML_INVALID_DATA, "Invalid data format")
|
TAOS_DEFINE_ERROR(TSDB_CODE_SML_INVALID_DATA, "Invalid data format")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_SML_INVALID_DB_CONF, "Invalid schemaless db config")
|
TAOS_DEFINE_ERROR(TSDB_CODE_SML_INVALID_DB_CONF, "Invalid schemaless db config")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_SML_NOT_SAME_TYPE, "Not the same type like before")
|
TAOS_DEFINE_ERROR(TSDB_CODE_SML_NOT_SAME_TYPE, "Not the same type like before")
|
||||||
|
TAOS_DEFINE_ERROR(TSDB_CODE_SML_INTERNAL_ERROR, "Internal error")
|
||||||
|
|
||||||
//tsma
|
//tsma
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_INIT_FAILED, "Tsma init failed")
|
TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_INIT_FAILED, "Tsma init failed")
|
||||||
|
|
|
@ -26,6 +26,10 @@ ELSE ()
|
||||||
SET(LINK_WEBSOCKET "")
|
SET(LINK_WEBSOCKET "")
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
|
IF (CUS_NAME OR CUS_PROMPT)
|
||||||
|
ADD_DEFINITIONS(-I${CMAKE_CURRENT_SOURCE_DIR}/../../../enterprise/packaging)
|
||||||
|
ENDIF (CUS_NAME)
|
||||||
|
|
||||||
if(TD_WINDOWS)
|
if(TD_WINDOWS)
|
||||||
target_link_libraries(shell PUBLIC taos_static ${LINK_WEBSOCKET})
|
target_link_libraries(shell PUBLIC taos_static ${LINK_WEBSOCKET})
|
||||||
else()
|
else()
|
||||||
|
|
|
@ -24,13 +24,13 @@ void pressTabKey(SShellCmd* cmd);
|
||||||
// press othr key
|
// press othr key
|
||||||
void pressOtherKey(char c);
|
void pressOtherKey(char c);
|
||||||
|
|
||||||
// init shell auto funciton , shell start call once
|
// init shell auto function , shell start call once
|
||||||
bool shellAutoInit();
|
bool shellAutoInit();
|
||||||
|
|
||||||
// set conn
|
// set conn
|
||||||
void shellSetConn(TAOS* conn);
|
void shellSetConn(TAOS* conn);
|
||||||
|
|
||||||
// exit shell auto funciton, shell exit call once
|
// exit shell auto function, shell exit call once
|
||||||
void shellAutoExit();
|
void shellAutoExit();
|
||||||
|
|
||||||
// callback autotab module
|
// callback autotab module
|
||||||
|
|
|
@ -80,8 +80,9 @@ typedef struct {
|
||||||
} SShellArgs;
|
} SShellArgs;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char* clientVersion;
|
const char *clientVersion;
|
||||||
const char* promptHeader;
|
char cusName[32];
|
||||||
|
char promptHeader[32];
|
||||||
const char* promptContinue;
|
const char* promptContinue;
|
||||||
const char* osname;
|
const char* osname;
|
||||||
int32_t promptSize;
|
int32_t promptSize;
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
//
|
//
|
||||||
// The prefix search tree is a efficient storage words and search words tree, it support 95 visible ascii code character
|
// The prefix search tree is a efficient storage words and search words tree, it support 95 visible ascii code character
|
||||||
//
|
//
|
||||||
#define FIRST_ASCII 40 // first visiable char is '0'
|
#define FIRST_ASCII 40 // first visible char is '0'
|
||||||
#define LAST_ASCII 122 // last visilbe char is 'z'
|
#define LAST_ASCII 122 // last visilbe char is 'z'
|
||||||
|
|
||||||
// capacity save char is 95
|
// capacity save char is 95
|
||||||
|
|
|
@ -19,10 +19,25 @@
|
||||||
|
|
||||||
#include "shellInt.h"
|
#include "shellInt.h"
|
||||||
|
|
||||||
#define TAOS_CONSOLE_PROMPT_HEADER "taos> "
|
#ifndef CUS_NAME
|
||||||
|
char cusName[] = "TDengine";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CUS_PROMPT
|
||||||
|
char cusPrompt[] = "taos";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CUS_EMAIL
|
||||||
|
char cusEmail[] = "<support@taosdata.com>";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CUS_NAME) || defined(CUS_PROMPT) || defined(CUS_EMAIL)
|
||||||
|
#include "cus_name.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define TAOS_CONSOLE_PROMPT_CONTINUE " -> "
|
#define TAOS_CONSOLE_PROMPT_CONTINUE " -> "
|
||||||
|
|
||||||
#define SHELL_HOST "TDengine server FQDN to connect. The default host is localhost."
|
#define SHELL_HOST "The server FQDN to connect. The default host is localhost."
|
||||||
#define SHELL_PORT "The TCP/IP port number to use for the connection."
|
#define SHELL_PORT "The TCP/IP port number to use for the connection."
|
||||||
#define SHELL_USER "The user name to use when connecting to the server."
|
#define SHELL_USER "The user name to use when connecting to the server."
|
||||||
#define SHELL_PASSWORD "The password to use when connecting to the server."
|
#define SHELL_PASSWORD "The password to use when connecting to the server."
|
||||||
|
@ -41,7 +56,6 @@
|
||||||
#define SHELL_PKT_LEN "Packet length used for net test, default is 1024 bytes."
|
#define SHELL_PKT_LEN "Packet length used for net test, default is 1024 bytes."
|
||||||
#define SHELL_PKT_NUM "Packet numbers used for net test, default is 100."
|
#define SHELL_PKT_NUM "Packet numbers used for net test, default is 100."
|
||||||
#define SHELL_VERSION "Print program version."
|
#define SHELL_VERSION "Print program version."
|
||||||
#define SHELL_EMAIL "<support@taosdata.com>"
|
|
||||||
|
|
||||||
#ifdef WEBSOCKET
|
#ifdef WEBSOCKET
|
||||||
#define SHELL_DSN "The dsn to use when connecting to cloud server."
|
#define SHELL_DSN "The dsn to use when connecting to cloud server."
|
||||||
|
@ -78,7 +92,7 @@ void shellPrintHelp() {
|
||||||
#endif
|
#endif
|
||||||
printf("%s%s%s%s\r\n", indent, "-w,", indent, SHELL_WIDTH);
|
printf("%s%s%s%s\r\n", indent, "-w,", indent, SHELL_WIDTH);
|
||||||
printf("%s%s%s%s\r\n", indent, "-V,", indent, SHELL_VERSION);
|
printf("%s%s%s%s\r\n", indent, "-V,", indent, SHELL_VERSION);
|
||||||
printf("\r\n\r\nReport bugs to %s.\r\n", SHELL_EMAIL);
|
printf("\r\n\r\nReport bugs to %s.\r\n", cusEmail);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LINUX
|
#ifdef LINUX
|
||||||
|
@ -86,7 +100,7 @@ void shellPrintHelp() {
|
||||||
#include <termio.h>
|
#include <termio.h>
|
||||||
|
|
||||||
const char *argp_program_version = version;
|
const char *argp_program_version = version;
|
||||||
const char *argp_program_bug_address = SHELL_EMAIL;
|
const char *argp_program_bug_address = cusEmail;
|
||||||
|
|
||||||
static struct argp_option shellOptions[] = {
|
static struct argp_option shellOptions[] = {
|
||||||
{"host", 'h', "HOST", 0, SHELL_HOST},
|
{"host", 'h', "HOST", 0, SHELL_HOST},
|
||||||
|
@ -389,11 +403,12 @@ static int32_t shellCheckArgs() {
|
||||||
int32_t shellParseArgs(int32_t argc, char *argv[]) {
|
int32_t shellParseArgs(int32_t argc, char *argv[]) {
|
||||||
shellInitArgs(argc, argv);
|
shellInitArgs(argc, argv);
|
||||||
shell.info.clientVersion =
|
shell.info.clientVersion =
|
||||||
"Welcome to the TDengine Command Line Interface, Client Version:%s\r\n"
|
"Welcome to the %s Command Line Interface, Client Version:%s\r\n"
|
||||||
"Copyright (c) 2022 by TDengine, all rights reserved.\r\n\r\n";
|
"Copyright (c) 2022 by %s, all rights reserved.\r\n\r\n";
|
||||||
shell.info.promptHeader = TAOS_CONSOLE_PROMPT_HEADER;
|
strcpy(shell.info.cusName, cusName);
|
||||||
|
sprintf(shell.info.promptHeader, "%s> ", cusPrompt);
|
||||||
shell.info.promptContinue = TAOS_CONSOLE_PROMPT_CONTINUE;
|
shell.info.promptContinue = TAOS_CONSOLE_PROMPT_CONTINUE;
|
||||||
shell.info.promptSize = 6;
|
shell.info.promptSize = strlen(shell.info.promptHeader);
|
||||||
snprintf(shell.info.programVersion, sizeof(shell.info.programVersion), "version: %s", version);
|
snprintf(shell.info.programVersion, sizeof(shell.info.programVersion), "version: %s", version);
|
||||||
|
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
||||||
|
|
|
@ -264,7 +264,7 @@ char* key_tags[] = {"tags("};
|
||||||
char* key_select[] = {"select "};
|
char* key_select[] = {"select "};
|
||||||
|
|
||||||
//
|
//
|
||||||
// ------- gobal variant define ---------
|
// ------- global variant define ---------
|
||||||
//
|
//
|
||||||
int32_t firstMatchIndex = -1; // first match shellCommands index
|
int32_t firstMatchIndex = -1; // first match shellCommands index
|
||||||
int32_t lastMatchIndex = -1; // last match shellCommands index
|
int32_t lastMatchIndex = -1; // last match shellCommands index
|
||||||
|
@ -329,7 +329,15 @@ int cntDel = 0; // delete byte count after next press tab
|
||||||
// show auto tab introduction
|
// show auto tab introduction
|
||||||
void printfIntroduction() {
|
void printfIntroduction() {
|
||||||
printf(" ****************************** Tab Completion **********************************\n");
|
printf(" ****************************** Tab Completion **********************************\n");
|
||||||
printf(" * The TDengine CLI supports tab completion for a variety of items, *\n");
|
char secondLine[160] = "\0";
|
||||||
|
sprintf(secondLine, " * The %s CLI supports tab completion for a variety of items, ",
|
||||||
|
shell.info.cusName);
|
||||||
|
printf("%s", secondLine);
|
||||||
|
int secondLineLen = strlen(secondLine);
|
||||||
|
while (84-(secondLineLen++) > 0) {
|
||||||
|
printf(" ");
|
||||||
|
}
|
||||||
|
printf("*\n");
|
||||||
printf(" * including database names, table names, function names and keywords. *\n");
|
printf(" * including database names, table names, function names and keywords. *\n");
|
||||||
printf(" * The full list of shortcut keys is as follows: *\n");
|
printf(" * The full list of shortcut keys is as follows: *\n");
|
||||||
printf(" * [ TAB ] ...... complete the current word *\n");
|
printf(" * [ TAB ] ...... complete the current word *\n");
|
||||||
|
@ -344,7 +352,7 @@ void printfIntroduction() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void showHelp() {
|
void showHelp() {
|
||||||
printf("\nThe TDengine CLI supports the following commands:");
|
printf("\nThe %s CLI supports the following commands:", shell.info.cusName);
|
||||||
printf(
|
printf(
|
||||||
"\n\
|
"\n\
|
||||||
----- A ----- \n\
|
----- A ----- \n\
|
||||||
|
@ -595,7 +603,7 @@ void GenerateVarType(int type, char** p, int count) {
|
||||||
// -------------------- shell auto ----------------
|
// -------------------- shell auto ----------------
|
||||||
//
|
//
|
||||||
|
|
||||||
// init shell auto funciton , shell start call once
|
// init shell auto function , shell start call once
|
||||||
bool shellAutoInit() {
|
bool shellAutoInit() {
|
||||||
// command
|
// command
|
||||||
int32_t count = SHELL_COMMAND_COUNT();
|
int32_t count = SHELL_COMMAND_COUNT();
|
||||||
|
@ -628,7 +636,7 @@ bool shellAutoInit() {
|
||||||
// set conn
|
// set conn
|
||||||
void shellSetConn(TAOS* conn) { varCon = conn; }
|
void shellSetConn(TAOS* conn) { varCon = conn; }
|
||||||
|
|
||||||
// exit shell auto funciton, shell exit call once
|
// exit shell auto function, shell exit call once
|
||||||
void shellAutoExit() {
|
void shellAutoExit() {
|
||||||
// free command
|
// free command
|
||||||
int32_t count = SHELL_COMMAND_COUNT();
|
int32_t count = SHELL_COMMAND_COUNT();
|
||||||
|
@ -645,7 +653,7 @@ void shellAutoExit() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
taosThreadMutexUnlock(&tiresMutex);
|
taosThreadMutexUnlock(&tiresMutex);
|
||||||
// destory
|
// destroy
|
||||||
taosThreadMutexDestroy(&tiresMutex);
|
taosThreadMutexDestroy(&tiresMutex);
|
||||||
|
|
||||||
// free threads
|
// free threads
|
||||||
|
@ -666,7 +674,7 @@ void shellAutoExit() {
|
||||||
//
|
//
|
||||||
// ------------------- auto ptr for tires --------------------------
|
// ------------------- auto ptr for tires --------------------------
|
||||||
//
|
//
|
||||||
bool setNewAuotPtr(int type, STire* pNew) {
|
bool setNewAutoPtr(int type, STire* pNew) {
|
||||||
if (pNew == NULL) return false;
|
if (pNew == NULL) return false;
|
||||||
|
|
||||||
taosThreadMutexLock(&tiresMutex);
|
taosThreadMutexLock(&tiresMutex);
|
||||||
|
@ -709,16 +717,13 @@ void putBackAutoPtr(int type, STire* tire) {
|
||||||
if (tires[type] != tire) {
|
if (tires[type] != tire) {
|
||||||
// update by out, can't put back , so free
|
// update by out, can't put back , so free
|
||||||
if (--tire->ref == 1) {
|
if (--tire->ref == 1) {
|
||||||
// support multi thread getAuotPtr
|
// support multi thread getAutoPtr
|
||||||
freeTire(tire);
|
freeTire(tire);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
tires[type]->ref--;
|
tires[type]->ref--;
|
||||||
ASSERT(tires[type]->ref > 0);
|
ASSERT(tires[type]->ref > 0);
|
||||||
if (tires[type]->ref <= 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
taosThreadMutexUnlock(&tiresMutex);
|
taosThreadMutexUnlock(&tiresMutex);
|
||||||
|
|
||||||
|
@ -767,7 +772,7 @@ int writeVarNames(int type, TAOS_RES* tres) {
|
||||||
} while (row != NULL);
|
} while (row != NULL);
|
||||||
|
|
||||||
// replace old tire
|
// replace old tire
|
||||||
setNewAuotPtr(type, tire);
|
setNewAutoPtr(type, tire);
|
||||||
|
|
||||||
return numOfRows;
|
return numOfRows;
|
||||||
}
|
}
|
||||||
|
@ -1035,7 +1040,7 @@ SWords* matchCommand(SWords* input, bool continueSearch) {
|
||||||
for (int32_t i = 0; i < count; i++) {
|
for (int32_t i = 0; i < count; i++) {
|
||||||
SWords* shellCommand = shellCommands + i;
|
SWords* shellCommand = shellCommands + i;
|
||||||
if (continueSearch && lastMatchIndex != -1 && i <= lastMatchIndex) {
|
if (continueSearch && lastMatchIndex != -1 && i <= lastMatchIndex) {
|
||||||
// new match must greate than lastMatchIndex
|
// new match must greater than lastMatchIndex
|
||||||
if (varMode && i == lastMatchIndex) {
|
if (varMode && i == lastMatchIndex) {
|
||||||
// do nothing, var match on lastMatchIndex
|
// do nothing, var match on lastMatchIndex
|
||||||
} else {
|
} else {
|
||||||
|
@ -1164,7 +1169,7 @@ void createInputFromFirst(SWords* input, SWords* firstMatch) {
|
||||||
for (int i = 0; i < firstMatch->matchIndex && word; i++) {
|
for (int i = 0; i < firstMatch->matchIndex && word; i++) {
|
||||||
// combine source from each word
|
// combine source from each word
|
||||||
strncpy(input->source + input->source_len, word->word, word->len);
|
strncpy(input->source + input->source_len, word->word, word->len);
|
||||||
strcat(input->source, " "); // append blank splite
|
strcat(input->source, " "); // append blank space
|
||||||
input->source_len += word->len + 1; // 1 is blank length
|
input->source_len += word->len + 1; // 1 is blank length
|
||||||
// move next
|
// move next
|
||||||
word = word->next;
|
word = word->next;
|
||||||
|
@ -1393,7 +1398,7 @@ bool appendAfterSelect(TAOS* con, SShellCmd* cmd, char* sql, int32_t len) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// fill funciton
|
// fill function
|
||||||
if (fieldEnd) {
|
if (fieldEnd) {
|
||||||
// fields is end , need match keyword
|
// fields is end , need match keyword
|
||||||
ret = fillWithType(con, cmd, last, WT_VAR_KEYWORD);
|
ret = fillWithType(con, cmd, last, WT_VAR_KEYWORD);
|
||||||
|
@ -1576,7 +1581,7 @@ bool matchCreateTable(TAOS* con, SShellCmd* cmd) {
|
||||||
|
|
||||||
// tb options
|
// tb options
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
// find like create talbe st (...) tags(..) <here is fill tb option area>
|
// find like create table st (...) tags(..) <here is fill tb option area>
|
||||||
char* p1 = strchr(ps, ')'); // first ')' end
|
char* p1 = strchr(ps, ')'); // first ')' end
|
||||||
if (p1) {
|
if (p1) {
|
||||||
if (strchr(p1 + 1, ')')) { // second ')' end
|
if (strchr(p1 + 1, ')')) { // second ')' end
|
||||||
|
|
|
@ -1072,7 +1072,8 @@ void *shellThreadLoop(void *arg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t shellExecute() {
|
int32_t shellExecute() {
|
||||||
printf(shell.info.clientVersion, taos_get_client_info());
|
printf(shell.info.clientVersion, shell.info.cusName,
|
||||||
|
taos_get_client_info(), shell.info.cusName);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
SShellArgs *pArgs = &shell.args;
|
SShellArgs *pArgs = &shell.args;
|
||||||
|
@ -1127,7 +1128,7 @@ int32_t shellExecute() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tsem_init(&shell.cancelSem, 0, 0) != 0) {
|
if (tsem_init(&shell.cancelSem, 0, 0) != 0) {
|
||||||
printf("failed to create cancel semphore\r\n");
|
printf("failed to create cancel semaphore\r\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,19 +50,19 @@ bool shellRegexMatch(const char *s, const char *reg, int32_t cflags) {
|
||||||
|
|
||||||
int32_t shellCheckIntSize() {
|
int32_t shellCheckIntSize() {
|
||||||
if (sizeof(int8_t) != 1) {
|
if (sizeof(int8_t) != 1) {
|
||||||
printf("taos int8 size is %d(!= 1)", (int)sizeof(int8_t));
|
printf("int8 size is %d(!= 1)", (int)sizeof(int8_t));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (sizeof(int16_t) != 2) {
|
if (sizeof(int16_t) != 2) {
|
||||||
printf("taos int16 size is %d(!= 2)", (int)sizeof(int16_t));
|
printf("int16 size is %d(!= 2)", (int)sizeof(int16_t));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (sizeof(int32_t) != 4) {
|
if (sizeof(int32_t) != 4) {
|
||||||
printf("taos int32 size is %d(!= 4)", (int)sizeof(int32_t));
|
printf("int32 size is %d(!= 4)", (int)sizeof(int32_t));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (sizeof(int64_t) != 8) {
|
if (sizeof(int64_t) != 8) {
|
||||||
printf("taos int64 size is %d(!= 8)", (int)sizeof(int64_t));
|
printf("int64 size is %d(!= 8)", (int)sizeof(int64_t));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -80,7 +80,7 @@ void shellGenerateAuth() {
|
||||||
void shellDumpConfig() {
|
void shellDumpConfig() {
|
||||||
SConfig *pCfg = taosGetCfg();
|
SConfig *pCfg = taosGetCfg();
|
||||||
if (pCfg == NULL) {
|
if (pCfg == NULL) {
|
||||||
printf("TDengine read global config failed!\r\n");
|
printf("read global config failed!\r\n");
|
||||||
} else {
|
} else {
|
||||||
cfgDumpCfg(pCfg, 1, true);
|
cfgDumpCfg(pCfg, 1, true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -235,7 +235,7 @@ void shellRunSingleCommandWebsocketImp(char *command) {
|
||||||
if (reconnectNum == 0) {
|
if (reconnectNum == 0) {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "TDengine server is disconnected, will try to reconnect\n");
|
fprintf(stderr, "The server is disconnected, will try to reconnect\n");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue