Merge remote-tracking branch 'origin/develop' into hotfix/sync
This commit is contained in:
commit
3e9834c907
|
@ -1,42 +1,65 @@
|
||||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||||
PROJECT(TDengine)
|
PROJECT(TDengine)
|
||||||
|
|
||||||
SET(TD_VER_1 "2")
|
IF (DEFINED VERNUMBER)
|
||||||
SET(TD_VER_2 "0")
|
SET(TD_VER_NUMBER ${VERNUMBER})
|
||||||
SET(TD_VER_3 "2")
|
ELSE ()
|
||||||
SET(TD_VER_4 "3")
|
SET(TD_VER_NUMBER "2.0.2.0")
|
||||||
SET(TD_VER_GIT "d711657139620f6c50f362597020705b8ad26bd2")
|
ENDIF ()
|
||||||
SET(TD_VER_GIT_INTERNAL "1d74ae24c541ffbb280e8630883c0236cd45f8c7")
|
|
||||||
|
|
||||||
SET(TD_VER_VERTYPE "stable")
|
IF (DEFINED VERCOMPATIBLE)
|
||||||
SET(TD_VER_CPUTYPE "x64")
|
SET(TD_VER_COMPATIBLE ${VERCOMPATIBLE})
|
||||||
SET(TD_VER_OSTYPE "Linux")
|
ELSE ()
|
||||||
|
SET(TD_VER_COMPATIBLE "2.0.0.0")
|
||||||
|
ENDIF ()
|
||||||
|
|
||||||
SET(TD_VER_COMPATIBLE "2.0.0.0")
|
IF (DEFINED GITINFO)
|
||||||
STRING(TIMESTAMP TD_VER_DATE "%Y-%m-%d %H:%M:%S")
|
SET(TD_VER_GIT ${GITINFO})
|
||||||
|
ELSE ()
|
||||||
|
SET(TD_VER_GIT "community")
|
||||||
|
ENDIF ()
|
||||||
|
|
||||||
IF (TD_LINUX_64)
|
IF (DEFINED GITINFOI)
|
||||||
|
SET(TD_VER_GIT_INTERNAL ${GITINFOI})
|
||||||
|
ELSE ()
|
||||||
|
SET(TD_VER_GIT_INTERNAL "internal")
|
||||||
|
ENDIF ()
|
||||||
|
|
||||||
|
IF (DEFINED VERDATE)
|
||||||
|
SET(TD_VER_DATE ${VERDATE})
|
||||||
|
ELSE ()
|
||||||
|
STRING(TIMESTAMP TD_VER_DATE "%Y-%m-%d %H:%M:%S")
|
||||||
|
ENDIF ()
|
||||||
|
|
||||||
|
IF (DEFINED VERTYPE)
|
||||||
|
SET(TD_VER_VERTYPE ${VERTYPE})
|
||||||
|
ELSE ()
|
||||||
|
SET(TD_VER_VERTYPE "stable")
|
||||||
|
ENDIF ()
|
||||||
|
|
||||||
|
IF (DEFINED CPUTYPE)
|
||||||
|
SET(TD_VER_CPUTYPE ${CPUTYPE})
|
||||||
|
ELSE ()
|
||||||
SET(TD_VER_CPUTYPE "x64")
|
SET(TD_VER_CPUTYPE "x64")
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
IF (TD_LINUX_32)
|
IF (DEFINED OSTYPE)
|
||||||
SET(TD_VER_CPUTYPE "x86")
|
SET(TD_VER_OSTYPE ${OSTYPE})
|
||||||
|
ELSE ()
|
||||||
|
SET(TD_VER_OSTYPE "Linux")
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
IF (TD_ARM_64)
|
MESSAGE(STATUS "============= compile version parameter information start ============= ")
|
||||||
SET(TD_VER_CPUTYPE "aarch64")
|
MESSAGE(STATUS "ver number:" ${TD_VER_NUMBER})
|
||||||
ENDIF ()
|
MESSAGE(STATUS "compatible ver number:" ${TD_VER_COMPATIBLE})
|
||||||
|
MESSAGE(STATUS "communit commit id:" ${TD_VER_GIT})
|
||||||
|
MESSAGE(STATUS "internal commit id:" ${TD_VER_GIT_INTERNAL})
|
||||||
|
MESSAGE(STATUS "build date:" ${TD_VER_DATE})
|
||||||
|
MESSAGE(STATUS "ver type:" ${TD_VER_VERTYPE})
|
||||||
|
MESSAGE(STATUS "ver cpu:" ${TD_VER_CPUTYPE})
|
||||||
|
MESSAGE(STATUS "os type:" ${TD_VER_OSTYPE})
|
||||||
|
MESSAGE(STATUS "============= compile version parameter information end ============= ")
|
||||||
|
|
||||||
IF (TD_ARM_32)
|
STRING(REPLACE "." "_" TD_LIB_VER_NUMBER ${TD_VER_NUMBER})
|
||||||
SET(TD_VER_CPUTYPE "aarch32")
|
|
||||||
ENDIF ()
|
|
||||||
|
|
||||||
IF (TD_WINDOWS_64)
|
|
||||||
SET(TD_VER_CPUTYPE "x64")
|
|
||||||
ENDIF ()
|
|
||||||
|
|
||||||
IF (TD_WINDOWS_32)
|
|
||||||
SET(TD_VER_CPUTYPE "x86")
|
|
||||||
ENDIF ()
|
|
||||||
|
|
||||||
CONFIGURE_FILE("${TD_COMMUNITY_DIR}/src/util/src/version.c.in" "${TD_COMMUNITY_DIR}/src/util/src/version.c")
|
CONFIGURE_FILE("${TD_COMMUNITY_DIR}/src/util/src/version.c.in" "${TD_COMMUNITY_DIR}/src/util/src/version.c")
|
||||||
|
|
|
@ -153,10 +153,10 @@ TDengine系统的前台交互客户端应用程序为taos,它与taosd共享同
|
||||||
系统管理员可以在CLI界面里添加、删除用户,也可以修改密码。CLI里SQL语法如下:
|
系统管理员可以在CLI界面里添加、删除用户,也可以修改密码。CLI里SQL语法如下:
|
||||||
|
|
||||||
```
|
```
|
||||||
CREATE USER <user_name> PASS <‘password’>;
|
CREATE USER <user_name> PASS <'password'>;
|
||||||
```
|
```
|
||||||
|
|
||||||
创建用户,并指定用户名和密码,密码需要用单引号引起来
|
创建用户,并指定用户名和密码,密码需要用单引号引起来,单引号为英文半角
|
||||||
|
|
||||||
```
|
```
|
||||||
DROP USER <user_name>;
|
DROP USER <user_name>;
|
||||||
|
@ -165,10 +165,10 @@ DROP USER <user_name>;
|
||||||
删除用户,限root用户使用
|
删除用户,限root用户使用
|
||||||
|
|
||||||
```
|
```
|
||||||
ALTER USER <user_name> PASS <‘password’>;
|
ALTER USER <user_name> PASS <'password'>;
|
||||||
```
|
```
|
||||||
|
|
||||||
修改用户密码, 为避免被转换为小写,密码需要用单引号引用
|
修改用户密码, 为避免被转换为小写,密码需要用单引号引用,单引号为英文半角
|
||||||
|
|
||||||
```
|
```
|
||||||
SHOW USERS;
|
SHOW USERS;
|
||||||
|
|
|
@ -82,7 +82,7 @@ TDengine 分布式架构的逻辑结构图如下:
|
||||||
### 节点之间的通讯
|
### 节点之间的通讯
|
||||||
**通讯方式:**TDengine系统的各个节点之间的通讯是通过TCP/UDP进行的。因为考虑到物联网场景,数据写入的包一般不大,因此TDengine 除采用TCP做传输之外,还采用UDP方式,因为UDP 更加高效,而且不受连接数的限制。TDengine实现了自己的超时、重传、确认等机制,以确保UDP的可靠传输。对于数据量不到15K的数据包,采取UDP的方式进行传输,超过15K的,或者是查询类的操作,自动采取TCP的方式进行传输。同时,TDengine根据配置和数据包,会自动对数据进行压缩/解压缩,数字签名/认证等处理。对于数据节点之间的数据复制,只采用TCP方式进行数据传输。
|
**通讯方式:**TDengine系统的各个节点之间的通讯是通过TCP/UDP进行的。因为考虑到物联网场景,数据写入的包一般不大,因此TDengine 除采用TCP做传输之外,还采用UDP方式,因为UDP 更加高效,而且不受连接数的限制。TDengine实现了自己的超时、重传、确认等机制,以确保UDP的可靠传输。对于数据量不到15K的数据包,采取UDP的方式进行传输,超过15K的,或者是查询类的操作,自动采取TCP的方式进行传输。同时,TDengine根据配置和数据包,会自动对数据进行压缩/解压缩,数字签名/认证等处理。对于数据节点之间的数据复制,只采用TCP方式进行数据传输。
|
||||||
|
|
||||||
**FQDN配置**:一个数据节点有一个或多个FQDN,可以在系统配置文件taos.cfg通过选项“fqdn"进行指定,如果没有指定,系统将自动获取FQDN。如果节点没有配置FQDN,可以直接使用IP地址作为FQDN,但不建议使用,因为IP地址可变,一旦变化,将让集群无法正常工作。一个数据节点的EP(End Point)由FQDN + Port组成。
|
**FQDN配置**:一个数据节点有一个或多个FQDN,可以在系统配置文件taos.cfg通过参数“fqdn"进行指定,如果没有指定,系统将自动获取FQDN。如果节点没有配置FQDN,可以直接将该节点的配置参数fqdn设置为它的IP地址。但不建议使用IP,因为IP地址可变,一旦变化,将让集群无法正常工作。一个数据节点的EP(End Point)由FQDN + Port组成。采用FQDN,需要保证DNS服务正常工作,或者在节点以及应用所在的节点配置好hosts文件。
|
||||||
|
|
||||||
**端口配置:**一个数据节点对外的端口由TDengine的系统配置参数serverPort决定,对集群内部通讯的端口是serverPort+5。集群内数据节点之间的数据复制操作还占有一个TCP端口,是serverPort+10. 为支持多线程高效的处理UDP数据,每个对内和对外的UDP链接,都需要占用5个连续的端口。因此一个数据节点总的端口范围为serverPort到serverPort + 10,总共11个TCP/UDP端口。使用时,需要确保防火墙将这些端口打开。每个数据节点可以配置不同的serverPort。
|
**端口配置:**一个数据节点对外的端口由TDengine的系统配置参数serverPort决定,对集群内部通讯的端口是serverPort+5。集群内数据节点之间的数据复制操作还占有一个TCP端口,是serverPort+10. 为支持多线程高效的处理UDP数据,每个对内和对外的UDP链接,都需要占用5个连续的端口。因此一个数据节点总的端口范围为serverPort到serverPort + 10,总共11个TCP/UDP端口。使用时,需要确保防火墙将这些端口打开。每个数据节点可以配置不同的serverPort。
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ set -e
|
||||||
# -l [full | lite]
|
# -l [full | lite]
|
||||||
# -s [static | dynamic]
|
# -s [static | dynamic]
|
||||||
# -n [2.0.0.3]
|
# -n [2.0.0.3]
|
||||||
|
# -m [2.0.0.0]
|
||||||
|
|
||||||
# set parameters by default value
|
# set parameters by default value
|
||||||
verMode=edge # [cluster, edge]
|
verMode=edge # [cluster, edge]
|
||||||
|
@ -21,8 +22,9 @@ osType=Linux # [Linux | Kylin | Alpine | Raspberrypi | Darwin | Windows | Ni
|
||||||
pagMode=full # [full | lite]
|
pagMode=full # [full | lite]
|
||||||
soMode=dynamic # [static | dynamic]
|
soMode=dynamic # [static | dynamic]
|
||||||
verNumber=""
|
verNumber=""
|
||||||
|
verNumberComp="2.0.0.0"
|
||||||
|
|
||||||
while getopts "hv:V:c:o:l:s:n:" arg
|
while getopts "hv:V:c:o:l:s:n:m:" arg
|
||||||
do
|
do
|
||||||
case $arg in
|
case $arg in
|
||||||
v)
|
v)
|
||||||
|
@ -49,6 +51,10 @@ do
|
||||||
#echo "verNumber=$OPTARG"
|
#echo "verNumber=$OPTARG"
|
||||||
verNumber=$(echo $OPTARG)
|
verNumber=$(echo $OPTARG)
|
||||||
;;
|
;;
|
||||||
|
m)
|
||||||
|
#echo "verNumberComp=$OPTARG"
|
||||||
|
verNumberComp=$(echo $OPTARG)
|
||||||
|
;;
|
||||||
o)
|
o)
|
||||||
#echo "osType=$OPTARG"
|
#echo "osType=$OPTARG"
|
||||||
osType=$(echo $OPTARG)
|
osType=$(echo $OPTARG)
|
||||||
|
@ -61,6 +67,7 @@ do
|
||||||
echo " -l [full | lite] "
|
echo " -l [full | lite] "
|
||||||
echo " -s [static | dynamic] "
|
echo " -s [static | dynamic] "
|
||||||
echo " -n [version number] "
|
echo " -n [version number] "
|
||||||
|
echo " -m [compatible version number] "
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
?) #unknow option
|
?) #unknow option
|
||||||
|
@ -70,7 +77,7 @@ do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "verMode=${verMode} verType=${verType} cpuType=${cpuType} osType=${osType} pagMode=${pagMode} soMode=${soMode} verNumber=${verNumber}"
|
echo "verMode=${verMode} verType=${verType} cpuType=${cpuType} osType=${osType} pagMode=${pagMode} soMode=${soMode} verNumber=${verNumber} verNumberComp=${verNumberComp}"
|
||||||
|
|
||||||
curr_dir=$(pwd)
|
curr_dir=$(pwd)
|
||||||
|
|
||||||
|
@ -84,8 +91,6 @@ else
|
||||||
top_dir=${script_dir}/..
|
top_dir=${script_dir}/..
|
||||||
fi
|
fi
|
||||||
|
|
||||||
versioninfo="${top_dir}/src/util/src/version.c"
|
|
||||||
|
|
||||||
csudo=""
|
csudo=""
|
||||||
#if command -v sudo > /dev/null; then
|
#if command -v sudo > /dev/null; then
|
||||||
# csudo="sudo"
|
# csudo="sudo"
|
||||||
|
@ -132,87 +137,22 @@ function vercomp () {
|
||||||
echo 0
|
echo 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# 1. Read version information
|
# 1. check version information
|
||||||
version=$(cat ${versioninfo} | grep " version" | cut -d '"' -f2)
|
if (( ! is_valid_version $verNumber ) || ( ! is_valid_version $verNumberComp ) || [[ "$(vercomp $verNumber $verNumberComp)" == '2' ]]); then
|
||||||
compatible_version=$(cat ${versioninfo} | grep " compatible_version" | cut -d '"' -f2)
|
echo "please enter correct version"
|
||||||
|
exit 0
|
||||||
if [ -z ${verNumber} ]; then
|
|
||||||
while true; do
|
|
||||||
read -p "Do you want to release a new version? [y/N]: " is_version_change
|
|
||||||
|
|
||||||
if [[ ( "${is_version_change}" == "y") || ( "${is_version_change}" == "Y") ]]; then
|
|
||||||
read -p "Please enter the new version: " tversion
|
|
||||||
while true; do
|
|
||||||
if (! is_valid_version $tversion) || [ "$(vercomp $tversion $version)" = '2' ]; then
|
|
||||||
read -p "Please enter a correct version: " tversion
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
version=${tversion}
|
|
||||||
break
|
|
||||||
done
|
|
||||||
|
|
||||||
echo
|
|
||||||
|
|
||||||
read -p "Enter the oldest compatible version: " tversion
|
|
||||||
while true; do
|
|
||||||
|
|
||||||
if [ -z $tversion ]; then
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
|
|
||||||
if (! is_valid_version $tversion) || [ "$(vercomp $version $tversion)" = '2' ]; then
|
|
||||||
read -p "enter correct compatible version: " tversion
|
|
||||||
else
|
|
||||||
compatible_version=$tversion
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
break
|
|
||||||
elif [[ ( "${is_version_change}" == "n") || ( "${is_version_change}" == "N") ]]; then
|
|
||||||
echo "Use old version: ${version} compatible version: ${compatible_version}."
|
|
||||||
break
|
|
||||||
else
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
else
|
|
||||||
echo "old version: $version, new version: $verNumber"
|
|
||||||
#if ( ! is_valid_version $verNumber ) || [[ "$(vercomp $version $verNumber)" == '2' ]]; then
|
|
||||||
# echo "please enter correct version"
|
|
||||||
# exit 0
|
|
||||||
#else
|
|
||||||
version=${verNumber}
|
|
||||||
#fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "=======================new version number: ${version}======================================"
|
echo "=======================new version number: ${verNumber}, compatible version: ${verNumberComp}======================================"
|
||||||
|
|
||||||
# output the version info to the buildinfo file.
|
|
||||||
build_time=$(date +"%F %R")
|
build_time=$(date +"%F %R")
|
||||||
echo "char version[12] = \"${version}\";" > ${versioninfo}
|
|
||||||
echo "char compatible_version[12] = \"${compatible_version}\";" >> ${versioninfo}
|
# get commint id from git
|
||||||
echo "char gitinfo[48] = \"$(git rev-parse --verify HEAD)\";" >> ${versioninfo}
|
gitinfo=$(git rev-parse --verify HEAD)
|
||||||
if [ "$verMode" != "cluster" ]; then
|
enterprise_dir="${top_dir}/../enterprise"
|
||||||
echo "char gitinfoOfInternal[48] = \"\";" >> ${versioninfo}
|
cd ${enterprise_dir}
|
||||||
else
|
gitinfoOfInternal=$(git rev-parse --verify HEAD)
|
||||||
enterprise_dir="${top_dir}/../enterprise"
|
cd ${curr_dir}
|
||||||
cd ${enterprise_dir}
|
|
||||||
echo "char gitinfoOfInternal[48] = \"$(git rev-parse --verify HEAD)\";" >> ${versioninfo}
|
|
||||||
cd ${curr_dir}
|
|
||||||
fi
|
|
||||||
echo "char buildinfo[64] = \"Built by ${USER} at ${build_time}\";" >> ${versioninfo}
|
|
||||||
echo "" >> ${versioninfo}
|
|
||||||
tmp_version=$(echo $version | tr -s "." "_")
|
|
||||||
if [ "$verMode" == "cluster" ]; then
|
|
||||||
libtaos_info=${tmp_version}_${osType}_${cpuType}
|
|
||||||
else
|
|
||||||
libtaos_info=edge_${tmp_version}_${osType}_${cpuType}
|
|
||||||
fi
|
|
||||||
if [ "$verType" == "beta" ]; then
|
|
||||||
libtaos_info=${libtaos_info}_${verType}
|
|
||||||
fi
|
|
||||||
echo "void libtaos_${libtaos_info}() {};" >> ${versioninfo}
|
|
||||||
|
|
||||||
# 2. cmake executable file
|
# 2. cmake executable file
|
||||||
compile_dir="${top_dir}/debug"
|
compile_dir="${top_dir}/debug"
|
||||||
|
@ -230,9 +170,9 @@ cd ${compile_dir}
|
||||||
# check support cpu type
|
# check support cpu type
|
||||||
if [[ "$cpuType" == "x64" ]] || [[ "$cpuType" == "aarch64" ]] || [[ "$cpuType" == "aarch32" ]] || [[ "$cpuType" == "mips64" ]] ; then
|
if [[ "$cpuType" == "x64" ]] || [[ "$cpuType" == "aarch64" ]] || [[ "$cpuType" == "aarch32" ]] || [[ "$cpuType" == "mips64" ]] ; then
|
||||||
if [ "$verMode" != "cluster" ]; then
|
if [ "$verMode" != "cluster" ]; then
|
||||||
cmake ../ -DCPUTYPE=${cpuType} -DPAGMODE=${pagMode} -DOSTYPE=${osType} -DSOMODE=${soMode}
|
cmake ../ -DCPUTYPE=${cpuType} -DOSTYPE=${osType} -DSOMODE=${soMode} -DVERTYPE=${verType} -DVERDATE="${build_time}" -DGITINFO=${gitinfo} -DGITINFOI=${gitinfoOfInternal} -DVERNUMBER=${verNumber} -DVERCOMPATIBLE=${verNumberComp} -DPAGMODE=${pagMode}
|
||||||
else
|
else
|
||||||
cmake ../../ -DCPUTYPE=${cpuType} -DOSTYPE=${osType} -DSOMODE=${soMode}
|
cmake ../../ -DCPUTYPE=${cpuType} -DOSTYPE=${osType} -DSOMODE=${soMode} -DVERTYPE=${verType} -DVERDATE="${build_time}" -DGITINFO=${gitinfo} -DGITINFOI=${gitinfoOfInternal} -DVERNUMBER=${verNumber} -DVERCOMPATIBLE=${verNumberComp}
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "input cpuType=${cpuType} error!!!"
|
echo "input cpuType=${cpuType} error!!!"
|
||||||
|
@ -243,11 +183,7 @@ make
|
||||||
|
|
||||||
cd ${curr_dir}
|
cd ${curr_dir}
|
||||||
|
|
||||||
# 3. judge the operating system type, then Call the corresponding script for packaging
|
# 3. Call the corresponding script for packaging
|
||||||
#osinfo=$(awk -F= '/^NAME/{print $2}' /etc/os-release)
|
|
||||||
#osinfo=$(cat /etc/os-release | grep "NAME" | cut -d '"' -f2)
|
|
||||||
#echo "osinfo: ${osinfo}"
|
|
||||||
|
|
||||||
if [ "$osType" != "Darwin" ]; then
|
if [ "$osType" != "Darwin" ]; then
|
||||||
if [[ "$verMode" != "cluster" ]] && [[ "$cpuType" == "x64" ]]; then
|
if [[ "$verMode" != "cluster" ]] && [[ "$cpuType" == "x64" ]]; then
|
||||||
echo "====do deb package for the ubuntu system===="
|
echo "====do deb package for the ubuntu system===="
|
||||||
|
@ -257,7 +193,7 @@ if [ "$osType" != "Darwin" ]; then
|
||||||
fi
|
fi
|
||||||
${csudo} mkdir -p ${output_dir}
|
${csudo} mkdir -p ${output_dir}
|
||||||
cd ${script_dir}/deb
|
cd ${script_dir}/deb
|
||||||
${csudo} ./makedeb.sh ${compile_dir} ${output_dir} ${version} ${cpuType} ${osType} ${verMode} ${verType}
|
${csudo} ./makedeb.sh ${compile_dir} ${output_dir} ${verNumber} ${cpuType} ${osType} ${verMode} ${verType}
|
||||||
|
|
||||||
echo "====do rpm package for the centos system===="
|
echo "====do rpm package for the centos system===="
|
||||||
output_dir="${top_dir}/rpms"
|
output_dir="${top_dir}/rpms"
|
||||||
|
@ -266,20 +202,17 @@ if [ "$osType" != "Darwin" ]; then
|
||||||
fi
|
fi
|
||||||
${csudo} mkdir -p ${output_dir}
|
${csudo} mkdir -p ${output_dir}
|
||||||
cd ${script_dir}/rpm
|
cd ${script_dir}/rpm
|
||||||
${csudo} ./makerpm.sh ${compile_dir} ${output_dir} ${version} ${cpuType} ${osType} ${verMode} ${verType}
|
${csudo} ./makerpm.sh ${compile_dir} ${output_dir} ${verNumber} ${cpuType} ${osType} ${verMode} ${verType}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "====do tar.gz package for all systems===="
|
echo "====do tar.gz package for all systems===="
|
||||||
cd ${script_dir}/tools
|
cd ${script_dir}/tools
|
||||||
|
|
||||||
${csudo} ./makepkg.sh ${compile_dir} ${version} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode}
|
${csudo} ./makepkg.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode}
|
||||||
${csudo} ./makeclient.sh ${compile_dir} ${version} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode}
|
${csudo} ./makeclient.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode}
|
||||||
${csudo} ./makearbi.sh ${compile_dir} ${version} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode}
|
${csudo} ./makearbi.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode}
|
||||||
else
|
else
|
||||||
cd ${script_dir}/tools
|
cd ${script_dir}/tools
|
||||||
./makeclient.sh ${compile_dir} ${version} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType}
|
./makeclient.sh ${compile_dir} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 4. Clean up temporary compile directories
|
|
||||||
#${csudo} rm -rf ${compile_dir}
|
|
||||||
|
|
||||||
|
|
|
@ -705,6 +705,7 @@ function install_TDengine() {
|
||||||
echo
|
echo
|
||||||
echo -e "\033[44;32;1mTDengine client is installed successfully!${NC}"
|
echo -e "\033[44;32;1mTDengine client is installed successfully!${NC}"
|
||||||
fi
|
fi
|
||||||
|
touch ~/.taos_history
|
||||||
|
|
||||||
rm -rf $(tar -tf taos.tar.gz)
|
rm -rf $(tar -tf taos.tar.gz)
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,6 @@ typedef struct SRetrieveSupport {
|
||||||
SSqlObj * pParentSql;
|
SSqlObj * pParentSql;
|
||||||
tFilePage * localBuffer; // temp buffer, there is a buffer for each vnode to
|
tFilePage * localBuffer; // temp buffer, there is a buffer for each vnode to
|
||||||
uint32_t numOfRetry; // record the number of retry times
|
uint32_t numOfRetry; // record the number of retry times
|
||||||
pthread_mutex_t queryMutex;
|
|
||||||
} SRetrieveSupport;
|
} SRetrieveSupport;
|
||||||
|
|
||||||
int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOrderDescriptor **pDesc,
|
int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOrderDescriptor **pDesc,
|
||||||
|
|
|
@ -138,10 +138,10 @@ bool tscIsProjectionQuery(SQueryInfo* pQueryInfo);
|
||||||
bool tscIsTwoStageSTableQuery(SQueryInfo* pQueryInfo, int32_t tableIndex);
|
bool tscIsTwoStageSTableQuery(SQueryInfo* pQueryInfo, int32_t tableIndex);
|
||||||
bool tscQueryTags(SQueryInfo* pQueryInfo);
|
bool tscQueryTags(SQueryInfo* pQueryInfo);
|
||||||
|
|
||||||
void tscAddSpecialColumnForSelect(SQueryInfo* pQueryInfo, int32_t outputColIndex, int16_t functionId, SColumnIndex* pIndex,
|
SSqlExpr* tscAddSpecialColumnForSelect(SQueryInfo* pQueryInfo, int32_t outputColIndex, int16_t functionId,
|
||||||
SSchema* pColSchema, int16_t colType);
|
SColumnIndex* pIndex, SSchema* pColSchema, int16_t colType);
|
||||||
|
|
||||||
int32_t tscSetTableFullName(STableMetaInfo* pTableMetaInfo, SSQLToken* pzTableName, SSqlObj* pSql);
|
int32_t tscSetTableFullName(STableMetaInfo* pTableMetaInfo, SStrToken* pzTableName, SSqlObj* pSql);
|
||||||
void tscClearInterpInfo(SQueryInfo* pQueryInfo);
|
void tscClearInterpInfo(SQueryInfo* pQueryInfo);
|
||||||
|
|
||||||
bool tscIsInsertData(char* sqlstr);
|
bool tscIsInsertData(char* sqlstr);
|
||||||
|
@ -194,11 +194,11 @@ SColumn* tscColumnListInsert(SArray* pColList, SColumnIndex* colIndex);
|
||||||
SArray* tscColumnListClone(const SArray* src, int16_t tableIndex);
|
SArray* tscColumnListClone(const SArray* src, int16_t tableIndex);
|
||||||
void tscColumnListDestroy(SArray* pColList);
|
void tscColumnListDestroy(SArray* pColList);
|
||||||
|
|
||||||
int32_t tscValidateName(SSQLToken* pToken);
|
int32_t tscValidateName(SStrToken* pToken);
|
||||||
|
|
||||||
void tscIncStreamExecutionCount(void* pStream);
|
void tscIncStreamExecutionCount(void* pStream);
|
||||||
|
|
||||||
bool tscValidateColumnId(STableMetaInfo* pTableMetaInfo, int32_t colId);
|
bool tscValidateColumnId(STableMetaInfo* pTableMetaInfo, int32_t colId, int32_t numOfParams);
|
||||||
|
|
||||||
// get starter position of metric query condition (query on tags) in SSqlCmd.payload
|
// get starter position of metric query condition (query on tags) in SSqlCmd.payload
|
||||||
SCond* tsGetSTableQueryCond(STagCond* pCond, uint64_t uid);
|
SCond* tsGetSTableQueryCond(STagCond* pCond, uint64_t uid);
|
||||||
|
@ -217,7 +217,7 @@ STableMetaInfo* tscGetTableMetaInfoFromCmd(SSqlCmd *pCmd, int32_t subClauseIndex
|
||||||
STableMetaInfo* tscGetMetaInfo(SQueryInfo *pQueryInfo, int32_t tableIndex);
|
STableMetaInfo* tscGetMetaInfo(SQueryInfo *pQueryInfo, int32_t tableIndex);
|
||||||
|
|
||||||
SQueryInfo *tscGetQueryInfoDetail(SSqlCmd* pCmd, int32_t subClauseIndex);
|
SQueryInfo *tscGetQueryInfoDetail(SSqlCmd* pCmd, int32_t subClauseIndex);
|
||||||
int32_t tscGetQueryInfoDetailSafely(SSqlCmd *pCmd, int32_t subClauseIndex, SQueryInfo** pQueryInfo);
|
SQueryInfo *tscGetQueryInfoDetailSafely(SSqlCmd *pCmd, int32_t subClauseIndex);
|
||||||
|
|
||||||
void tscClearTableMetaInfo(STableMetaInfo* pTableMetaInfo, bool removeFromCache);
|
void tscClearTableMetaInfo(STableMetaInfo* pTableMetaInfo, bool removeFromCache);
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,40 @@ extern "C" {
|
||||||
#include "qTsbuf.h"
|
#include "qTsbuf.h"
|
||||||
#include "tcmdtype.h"
|
#include "tcmdtype.h"
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
static UNUSED_FUNC void *u_malloc (size_t __size) {
|
||||||
|
uint32_t v = rand();
|
||||||
|
|
||||||
|
if (v % 5000 <= 0) {
|
||||||
|
return NULL;
|
||||||
|
} else {
|
||||||
|
return malloc(__size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static UNUSED_FUNC void* u_calloc(size_t num, size_t __size) {
|
||||||
|
uint32_t v = rand();
|
||||||
|
if (v % 5000 <= 0) {
|
||||||
|
return NULL;
|
||||||
|
} else {
|
||||||
|
return calloc(num, __size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static UNUSED_FUNC void* u_realloc(void* p, size_t __size) {
|
||||||
|
uint32_t v = rand();
|
||||||
|
if (v % 5000 <= 0) {
|
||||||
|
return NULL;
|
||||||
|
} else {
|
||||||
|
return realloc(p, __size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define calloc u_calloc
|
||||||
|
#define malloc u_malloc
|
||||||
|
#define realloc u_realloc
|
||||||
|
#endif
|
||||||
|
|
||||||
// forward declaration
|
// forward declaration
|
||||||
struct SSqlInfo;
|
struct SSqlInfo;
|
||||||
struct SLocalReducer;
|
struct SLocalReducer;
|
||||||
|
@ -195,9 +229,9 @@ typedef struct STableDataBlocks {
|
||||||
|
|
||||||
typedef struct SQueryInfo {
|
typedef struct SQueryInfo {
|
||||||
int16_t command; // the command may be different for each subclause, so keep it seperately.
|
int16_t command; // the command may be different for each subclause, so keep it seperately.
|
||||||
uint32_t type; // query/insert/import type
|
uint32_t type; // query/insert type
|
||||||
char slidingTimeUnit;
|
char slidingTimeUnit;
|
||||||
STimeWindow window;
|
STimeWindow window; // query time window
|
||||||
int64_t intervalTime; // aggregation time interval
|
int64_t intervalTime; // aggregation time interval
|
||||||
int64_t slidingTime; // sliding window in mseconds
|
int64_t slidingTime; // sliding window in mseconds
|
||||||
SSqlGroupbyExpr groupbyExpr; // group by tags info
|
SSqlGroupbyExpr groupbyExpr; // group by tags info
|
||||||
|
@ -216,6 +250,7 @@ typedef struct SQueryInfo {
|
||||||
char * msg; // pointer to the pCmd->payload to keep error message temporarily
|
char * msg; // pointer to the pCmd->payload to keep error message temporarily
|
||||||
int64_t clauseLimit; // limit for current sub clause
|
int64_t clauseLimit; // limit for current sub clause
|
||||||
int64_t prjOffset; // offset value in the original sql expression, only applied at client side
|
int64_t prjOffset; // offset value in the original sql expression, only applied at client side
|
||||||
|
int32_t udColumnId; // current user-defined constant output field column id, monotonically decreases from TSDB_UD_COLUMN_INDEX
|
||||||
} SQueryInfo;
|
} SQueryInfo;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -431,16 +466,25 @@ static FORCE_INLINE void tscGetResultColumnChr(SSqlRes* pRes, SFieldInfo* pField
|
||||||
int32_t bytes = pInfo->pSqlExpr->resBytes;
|
int32_t bytes = pInfo->pSqlExpr->resBytes;
|
||||||
|
|
||||||
char* pData = pRes->data + pInfo->pSqlExpr->offset * pRes->numOfRows + bytes * pRes->row;
|
char* pData = pRes->data + pInfo->pSqlExpr->offset * pRes->numOfRows + bytes * pRes->row;
|
||||||
|
|
||||||
|
// user defined constant value output columns
|
||||||
|
if (pInfo->pSqlExpr->colInfo.flag == TSDB_COL_UDC) {
|
||||||
|
if (type == TSDB_DATA_TYPE_NCHAR || type == TSDB_DATA_TYPE_BINARY) {
|
||||||
|
pData = pInfo->pSqlExpr->param[1].pz;
|
||||||
|
pRes->length[columnIndex] = pInfo->pSqlExpr->param[1].nLen;
|
||||||
|
pRes->tsrow[columnIndex] = (pInfo->pSqlExpr->param[1].nType == TSDB_DATA_TYPE_NULL) ? NULL : pData;
|
||||||
|
} else {
|
||||||
|
assert(bytes == tDataTypeDesc[type].nSize);
|
||||||
|
|
||||||
|
pRes->tsrow[columnIndex] = isNull(pData, type) ? NULL : &pInfo->pSqlExpr->param[1].i64Key;
|
||||||
|
pRes->length[columnIndex] = bytes;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (type == TSDB_DATA_TYPE_NCHAR || type == TSDB_DATA_TYPE_BINARY) {
|
if (type == TSDB_DATA_TYPE_NCHAR || type == TSDB_DATA_TYPE_BINARY) {
|
||||||
int32_t realLen = varDataLen(pData);
|
int32_t realLen = varDataLen(pData);
|
||||||
assert(realLen <= bytes - VARSTR_HEADER_SIZE);
|
assert(realLen <= bytes - VARSTR_HEADER_SIZE);
|
||||||
|
|
||||||
if (isNull(pData, type)) {
|
pRes->tsrow[columnIndex] = (isNull(pData, type)) ? NULL : ((tstr *)pData)->data;
|
||||||
pRes->tsrow[columnIndex] = NULL;
|
|
||||||
} else {
|
|
||||||
pRes->tsrow[columnIndex] = ((tstr*)pData)->data;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (realLen < pInfo->pSqlExpr->resBytes - VARSTR_HEADER_SIZE) { // todo refactor
|
if (realLen < pInfo->pSqlExpr->resBytes - VARSTR_HEADER_SIZE) { // todo refactor
|
||||||
*(pData + realLen + VARSTR_HEADER_SIZE) = 0;
|
*(pData + realLen + VARSTR_HEADER_SIZE) = 0;
|
||||||
}
|
}
|
||||||
|
@ -449,14 +493,10 @@ static FORCE_INLINE void tscGetResultColumnChr(SSqlRes* pRes, SFieldInfo* pField
|
||||||
} else {
|
} else {
|
||||||
assert(bytes == tDataTypeDesc[type].nSize);
|
assert(bytes == tDataTypeDesc[type].nSize);
|
||||||
|
|
||||||
if (isNull(pData, type)) {
|
pRes->tsrow[columnIndex] = isNull(pData, type) ? NULL : pData;
|
||||||
pRes->tsrow[columnIndex] = NULL;
|
|
||||||
} else {
|
|
||||||
pRes->tsrow[columnIndex] = pData;
|
|
||||||
}
|
|
||||||
|
|
||||||
pRes->length[columnIndex] = bytes;
|
pRes->length[columnIndex] = bytes;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void * tscCacheHandle;
|
extern void * tscCacheHandle;
|
||||||
|
|
|
@ -89,6 +89,14 @@ JNIEXPORT jstring JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_getErrMsgImp
|
||||||
JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_getResultSetImp
|
JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_getResultSetImp
|
||||||
(JNIEnv *env, jobject jobj, jlong con, jlong tres);
|
(JNIEnv *env, jobject jobj, jlong con, jlong tres);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: com_taosdata_jdbc_TSDBJNIConnector
|
||||||
|
* Method: isUpdateQueryImp
|
||||||
|
* Signature: (J)J
|
||||||
|
*/
|
||||||
|
JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_isUpdateQueryImp
|
||||||
|
(JNIEnv *env, jobject jobj, jlong con, jlong tres);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: com_taosdata_jdbc_TSDBJNIConnector
|
* Class: com_taosdata_jdbc_TSDBJNIConnector
|
||||||
* Method: freeResultSetImp
|
* Method: freeResultSetImp
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
1 VERSIONINFO
|
1 VERSIONINFO
|
||||||
FILEVERSION ${TD_VER_1}, ${TD_VER_2}, ${TD_VER_3}
|
FILEVERSION ${TD_VER_NUMBER}
|
||||||
PRODUCTVERSION ${TD_VER_1}, ${TD_VER_2}, ${TD_VER_3}
|
PRODUCTVERSION ${TD_VER_NUMBER}
|
||||||
FILEFLAGSMASK 0x17L
|
FILEFLAGSMASK 0x17L
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
FILEFLAGS 0x1L
|
FILEFLAGS 0x1L
|
||||||
|
@ -16,12 +16,12 @@ BEGIN
|
||||||
BLOCK "040904b0"
|
BLOCK "040904b0"
|
||||||
BEGIN
|
BEGIN
|
||||||
VALUE "FileDescription", "Native C Driver for TDengine"
|
VALUE "FileDescription", "Native C Driver for TDengine"
|
||||||
VALUE "FileVersion", "${TD_VER_1}, ${TD_VER_2}, ${TD_VER_3}"
|
VALUE "FileVersion", "${TD_VER_NUMBER}"
|
||||||
VALUE "InternalName", "taos.dll(${TD_VER_CPUTYPE})"
|
VALUE "InternalName", "taos.dll(${TD_VER_CPUTYPE})"
|
||||||
VALUE "LegalCopyright", "Copyright (C) 2020 TAOS Data"
|
VALUE "LegalCopyright", "Copyright (C) 2020 TAOS Data"
|
||||||
VALUE "OriginalFilename", ""
|
VALUE "OriginalFilename", ""
|
||||||
VALUE "ProductName", "taos.dll(${TD_VER_CPUTYPE})"
|
VALUE "ProductName", "taos.dll(${TD_VER_CPUTYPE})"
|
||||||
VALUE "ProductVersion", "${TD_VER_1}.${TD_VER_2}.${TD_VER_3}.${TD_VER_4}"
|
VALUE "ProductVersion", "${TD_VER_NUMBER}"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
|
|
@ -433,7 +433,8 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
|
||||||
tscError("%p get tableMeta failed, code:%s", pSql, tstrerror(code));
|
tscError("%p get tableMeta failed, code:%s", pSql, tstrerror(code));
|
||||||
goto _error;
|
goto _error;
|
||||||
} else {
|
} else {
|
||||||
tscDebug("%p get tableMeta successfully", pSql);
|
const char* msg = (pCmd->command == TSDB_SQL_STABLEVGROUP)? "vgroup-list":"table-meta";
|
||||||
|
tscDebug("%p get %s successfully", pSql, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pSql->pStream == NULL) {
|
if (pSql->pStream == NULL) {
|
||||||
|
|
|
@ -1813,23 +1813,19 @@ static void last_dist_func_second_merge(SQLFunctionCtx *pCtx) {
|
||||||
* NOTE: last_row does not use the interResultBuf to keep the result
|
* NOTE: last_row does not use the interResultBuf to keep the result
|
||||||
*/
|
*/
|
||||||
static void last_row_function(SQLFunctionCtx *pCtx) {
|
static void last_row_function(SQLFunctionCtx *pCtx) {
|
||||||
assert(pCtx->size == 1);
|
assert(pCtx->size >= 1);
|
||||||
|
|
||||||
char *pData = GET_INPUT_CHAR(pCtx);
|
char *pData = GET_INPUT_CHAR(pCtx);
|
||||||
assignVal(pCtx->aOutputBuf, pData, pCtx->inputBytes, pCtx->inputType);
|
|
||||||
|
// assign the last element in current data block
|
||||||
|
assignVal(pCtx->aOutputBuf, pData + (pCtx->size - 1) * pCtx->inputBytes, pCtx->inputBytes, pCtx->inputType);
|
||||||
|
|
||||||
SResultInfo *pResInfo = GET_RES_INFO(pCtx);
|
SResultInfo *pResInfo = GET_RES_INFO(pCtx);
|
||||||
pResInfo->hasResult = DATA_SET_FLAG;
|
pResInfo->hasResult = DATA_SET_FLAG;
|
||||||
|
|
||||||
SLastrowInfo *pInfo = (SLastrowInfo *)pResInfo->interResultBuf;
|
// set the result to final result buffer in case of super table query
|
||||||
pInfo->ts = pCtx->ptsList[0];
|
|
||||||
|
|
||||||
pInfo->hasResult = DATA_SET_FLAG;
|
|
||||||
|
|
||||||
// set the result to final result buffer
|
|
||||||
if (pResInfo->superTableQ) {
|
if (pResInfo->superTableQ) {
|
||||||
SLastrowInfo *pInfo1 = (SLastrowInfo *)(pCtx->aOutputBuf + pCtx->inputBytes);
|
SLastrowInfo *pInfo1 = (SLastrowInfo *)(pCtx->aOutputBuf + pCtx->inputBytes);
|
||||||
pInfo1->ts = pCtx->ptsList[0];
|
pInfo1->ts = pCtx->ptsList[pCtx->size - 1];
|
||||||
pInfo1->hasResult = DATA_SET_FLAG;
|
pInfo1->hasResult = DATA_SET_FLAG;
|
||||||
|
|
||||||
DO_UPDATE_TAG_COLUMNS(pCtx, pInfo1->ts);
|
DO_UPDATE_TAG_COLUMNS(pCtx, pInfo1->ts);
|
||||||
|
@ -2038,7 +2034,7 @@ static void copyTopBotRes(SQLFunctionCtx *pCtx, int32_t type) {
|
||||||
tValuePair **tvp = pRes->res;
|
tValuePair **tvp = pRes->res;
|
||||||
|
|
||||||
int32_t step = QUERY_ASC_FORWARD_STEP;
|
int32_t step = QUERY_ASC_FORWARD_STEP;
|
||||||
int32_t len = GET_RES_INFO(pCtx)->numOfRes;
|
int32_t len = (int32_t)(GET_RES_INFO(pCtx)->numOfRes);
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case TSDB_DATA_TYPE_INT: {
|
case TSDB_DATA_TYPE_INT: {
|
||||||
|
@ -2412,10 +2408,10 @@ static void top_bottom_func_finalizer(SQLFunctionCtx *pCtx) {
|
||||||
// user specify the order of output by sort the result according to timestamp
|
// user specify the order of output by sort the result according to timestamp
|
||||||
if (pCtx->param[1].i64Key == PRIMARYKEY_TIMESTAMP_COL_INDEX) {
|
if (pCtx->param[1].i64Key == PRIMARYKEY_TIMESTAMP_COL_INDEX) {
|
||||||
__compar_fn_t comparator = (pCtx->param[2].i64Key == TSDB_ORDER_ASC) ? resAscComparFn : resDescComparFn;
|
__compar_fn_t comparator = (pCtx->param[2].i64Key == TSDB_ORDER_ASC) ? resAscComparFn : resDescComparFn;
|
||||||
qsort(tvp, pResInfo->numOfRes, POINTER_BYTES, comparator);
|
qsort(tvp, (size_t)pResInfo->numOfRes, POINTER_BYTES, comparator);
|
||||||
} else if (pCtx->param[1].i64Key > PRIMARYKEY_TIMESTAMP_COL_INDEX) {
|
} else if (pCtx->param[1].i64Key > PRIMARYKEY_TIMESTAMP_COL_INDEX) {
|
||||||
__compar_fn_t comparator = (pCtx->param[2].i64Key == TSDB_ORDER_ASC) ? resDataAscComparFn : resDataDescComparFn;
|
__compar_fn_t comparator = (pCtx->param[2].i64Key == TSDB_ORDER_ASC) ? resDataAscComparFn : resDataDescComparFn;
|
||||||
qsort(tvp, pResInfo->numOfRes, POINTER_BYTES, comparator);
|
qsort(tvp, (size_t)pResInfo->numOfRes, POINTER_BYTES, comparator);
|
||||||
}
|
}
|
||||||
|
|
||||||
GET_TRUE_DATA_TYPE();
|
GET_TRUE_DATA_TYPE();
|
||||||
|
@ -2909,11 +2905,16 @@ static FORCE_INLINE void date_col_output_function_f(SQLFunctionCtx *pCtx, int32_
|
||||||
}
|
}
|
||||||
|
|
||||||
static void col_project_function(SQLFunctionCtx *pCtx) {
|
static void col_project_function(SQLFunctionCtx *pCtx) {
|
||||||
|
// the number of output rows should not affect the final number of rows, so set it to be 0
|
||||||
|
if (pCtx->numOfParams == 2) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
INC_INIT_VAL(pCtx, pCtx->size);
|
INC_INIT_VAL(pCtx, pCtx->size);
|
||||||
|
|
||||||
char *pData = GET_INPUT_CHAR(pCtx);
|
char *pData = GET_INPUT_CHAR(pCtx);
|
||||||
if (pCtx->order == TSDB_ORDER_ASC) {
|
if (pCtx->order == TSDB_ORDER_ASC) {
|
||||||
memcpy(pCtx->aOutputBuf, pData, (size_t)pCtx->size * pCtx->inputBytes);
|
memcpy(pCtx->aOutputBuf, pData, (size_t) pCtx->size * pCtx->inputBytes);
|
||||||
} else {
|
} else {
|
||||||
for(int32_t i = 0; i < pCtx->size; ++i) {
|
for(int32_t i = 0; i < pCtx->size; ++i) {
|
||||||
memcpy(pCtx->aOutputBuf + (pCtx->size - 1 - i) * pCtx->inputBytes, pData + i * pCtx->inputBytes,
|
memcpy(pCtx->aOutputBuf + (pCtx->size - 1 - i) * pCtx->inputBytes, pData + i * pCtx->inputBytes,
|
||||||
|
@ -2926,6 +2927,9 @@ static void col_project_function(SQLFunctionCtx *pCtx) {
|
||||||
|
|
||||||
static void col_project_function_f(SQLFunctionCtx *pCtx, int32_t index) {
|
static void col_project_function_f(SQLFunctionCtx *pCtx, int32_t index) {
|
||||||
SResultInfo *pResInfo = GET_RES_INFO(pCtx);
|
SResultInfo *pResInfo = GET_RES_INFO(pCtx);
|
||||||
|
if (pCtx->numOfParams == 2) { // the number of output rows should not affect the final number of rows, so set it to be 0
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// only one output
|
// only one output
|
||||||
if (pCtx->param[0].i64Key == 1 && pResInfo->numOfRes >= 1) {
|
if (pCtx->param[0].i64Key == 1 && pResInfo->numOfRes >= 1) {
|
||||||
|
@ -3903,11 +3907,11 @@ static void ts_comp_function(SQLFunctionCtx *pCtx) {
|
||||||
|
|
||||||
// primary ts must be existed, so no need to check its existance
|
// primary ts must be existed, so no need to check its existance
|
||||||
if (pCtx->order == TSDB_ORDER_ASC) {
|
if (pCtx->order == TSDB_ORDER_ASC) {
|
||||||
tsBufAppend(pTSbuf, 0, pCtx->tag.i64Key, input, pCtx->size * TSDB_KEYSIZE);
|
tsBufAppend(pTSbuf, 0, &pCtx->tag, input, pCtx->size * TSDB_KEYSIZE);
|
||||||
} else {
|
} else {
|
||||||
for (int32_t i = pCtx->size - 1; i >= 0; --i) {
|
for (int32_t i = pCtx->size - 1; i >= 0; --i) {
|
||||||
char *d = GET_INPUT_CHAR_INDEX(pCtx, i);
|
char *d = GET_INPUT_CHAR_INDEX(pCtx, i);
|
||||||
tsBufAppend(pTSbuf, 0, pCtx->tag.i64Key, d, TSDB_KEYSIZE);
|
tsBufAppend(pTSbuf, 0, &pCtx->tag, d, TSDB_KEYSIZE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3926,7 +3930,7 @@ static void ts_comp_function_f(SQLFunctionCtx *pCtx, int32_t index) {
|
||||||
|
|
||||||
STSBuf *pTSbuf = pInfo->pTSBuf;
|
STSBuf *pTSbuf = pInfo->pTSBuf;
|
||||||
|
|
||||||
tsBufAppend(pTSbuf, 0, pCtx->tag.i64Key, pData, TSDB_KEYSIZE);
|
tsBufAppend(pTSbuf, 0, &pCtx->tag, pData, TSDB_KEYSIZE);
|
||||||
SET_VAL(pCtx, pCtx->size, 1);
|
SET_VAL(pCtx, pCtx->size, 1);
|
||||||
|
|
||||||
pResInfo->hasResult = DATA_SET_FLAG;
|
pResInfo->hasResult = DATA_SET_FLAG;
|
||||||
|
|
|
@ -370,7 +370,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
|
||||||
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
|
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
|
||||||
STableComInfo tinfo = tscGetTableInfo(pTableMetaInfo->pTableMeta);
|
STableComInfo tinfo = tscGetTableInfo(pTableMetaInfo->pTableMeta);
|
||||||
|
|
||||||
TSKEY stime = MIN(pQueryInfo->window.skey, pQueryInfo->window.ekey);
|
TSKEY stime = (pQueryInfo->order.order == TSDB_ORDER_ASC)? pQueryInfo->window.skey : pQueryInfo->window.ekey;
|
||||||
int64_t revisedSTime =
|
int64_t revisedSTime =
|
||||||
taosGetIntervalStartTimestamp(stime, pQueryInfo->slidingTime, pQueryInfo->intervalTime, pQueryInfo->slidingTimeUnit, tinfo.precision);
|
taosGetIntervalStartTimestamp(stime, pQueryInfo->slidingTime, pQueryInfo->intervalTime, pQueryInfo->slidingTimeUnit, tinfo.precision);
|
||||||
|
|
||||||
|
@ -843,28 +843,6 @@ void savePrevRecordAndSetupFillInfo(SLocalReducer *pLocalReducer, SQueryInfo *pQ
|
||||||
tColModelAppend(pModel, pLocalReducer->discardData, pLocalReducer->prevRowOfInput, 0, 1, 1);
|
tColModelAppend(pModel, pLocalReducer->discardData, pLocalReducer->prevRowOfInput, 0, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void reversedCopyFromInterpolationToDstBuf(SQueryInfo *pQueryInfo, SSqlRes *pRes, tFilePage **pResPages,
|
|
||||||
SLocalReducer *pLocalReducer) {
|
|
||||||
assert(0);
|
|
||||||
size_t size = tscSqlExprNumOfExprs(pQueryInfo);
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < size; ++i) {
|
|
||||||
TAOS_FIELD *pField = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, i);
|
|
||||||
|
|
||||||
int32_t offset = tscFieldInfoGetOffset(pQueryInfo, i);
|
|
||||||
assert(offset == getColumnModelOffset(pLocalReducer->resColModel, i));
|
|
||||||
|
|
||||||
char *src = pResPages[i]->data + (pRes->numOfRows - 1) * pField->bytes;
|
|
||||||
char *dst = pRes->data + pRes->numOfRows * offset;
|
|
||||||
|
|
||||||
for (int32_t j = 0; j < pRes->numOfRows; ++j) {
|
|
||||||
memcpy(dst, src, (size_t)pField->bytes);
|
|
||||||
dst += pField->bytes;
|
|
||||||
src -= pField->bytes;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void genFinalResWithoutFill(SSqlRes* pRes, SLocalReducer *pLocalReducer, SQueryInfo* pQueryInfo) {
|
static void genFinalResWithoutFill(SSqlRes* pRes, SLocalReducer *pLocalReducer, SQueryInfo* pQueryInfo) {
|
||||||
assert(pQueryInfo->intervalTime == 0 || pQueryInfo->fillType == TSDB_FILL_NONE);
|
assert(pQueryInfo->intervalTime == 0 || pQueryInfo->fillType == TSDB_FILL_NONE);
|
||||||
|
|
||||||
|
@ -925,7 +903,8 @@ static void doFillResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool doneO
|
||||||
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
||||||
SFillInfo *pFillInfo = pLocalReducer->pFillInfo;
|
SFillInfo *pFillInfo = pLocalReducer->pFillInfo;
|
||||||
|
|
||||||
int64_t actualETime = MAX(pQueryInfo->window.skey, pQueryInfo->window.ekey);
|
// todo extract function
|
||||||
|
int64_t actualETime = (pQueryInfo->order.order == TSDB_ORDER_ASC)? pQueryInfo->window.ekey: pQueryInfo->window.skey;
|
||||||
|
|
||||||
tFilePage **pResPages = malloc(POINTER_BYTES * pQueryInfo->fieldsInfo.numOfOutput);
|
tFilePage **pResPages = malloc(POINTER_BYTES * pQueryInfo->fieldsInfo.numOfOutput);
|
||||||
for (int32_t i = 0; i < pQueryInfo->fieldsInfo.numOfOutput; ++i) {
|
for (int32_t i = 0; i < pQueryInfo->fieldsInfo.numOfOutput; ++i) {
|
||||||
|
@ -984,15 +963,11 @@ static void doFillResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool doneO
|
||||||
savePrevRecordAndSetupFillInfo(pLocalReducer, pQueryInfo, pFillInfo);
|
savePrevRecordAndSetupFillInfo(pLocalReducer, pQueryInfo, pFillInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pQueryInfo->order.order == TSDB_ORDER_ASC) {
|
|
||||||
for (int32_t i = 0; i < pQueryInfo->fieldsInfo.numOfOutput; ++i) {
|
for (int32_t i = 0; i < pQueryInfo->fieldsInfo.numOfOutput; ++i) {
|
||||||
TAOS_FIELD *pField = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, i);
|
TAOS_FIELD *pField = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, i);
|
||||||
int16_t offset = getColumnModelOffset(pLocalReducer->resColModel, i);
|
int16_t offset = getColumnModelOffset(pLocalReducer->resColModel, i);
|
||||||
memcpy(pRes->data + offset * pRes->numOfRows, pResPages[i]->data, (size_t)(pField->bytes * pRes->numOfRows));
|
memcpy(pRes->data + offset * pRes->numOfRows, pResPages[i]->data, (size_t)(pField->bytes * pRes->numOfRows));
|
||||||
}
|
}
|
||||||
} else { // todo bug??
|
|
||||||
reversedCopyFromInterpolationToDstBuf(pQueryInfo, pRes, pResPages, pLocalReducer);
|
|
||||||
}
|
|
||||||
|
|
||||||
pRes->numOfRowsGroup += pRes->numOfRows;
|
pRes->numOfRowsGroup += pRes->numOfRows;
|
||||||
pRes->numOfClauseTotal += pRes->numOfRows;
|
pRes->numOfClauseTotal += pRes->numOfRows;
|
||||||
|
@ -1249,15 +1224,15 @@ bool genFinalResults(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool noMoreCur
|
||||||
// tColModelDisplay(pLocalReducer->resColModel, pLocalReducer->pBufForInterpo, pResBuf->num, pResBuf->num);
|
// tColModelDisplay(pLocalReducer->resColModel, pLocalReducer->pBufForInterpo, pResBuf->num, pResBuf->num);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// no interval query, no fill operation
|
// no interval query, no fill operation
|
||||||
if (pQueryInfo->intervalTime == 0 || pQueryInfo->fillType == TSDB_FILL_NONE) {
|
if (pQueryInfo->intervalTime == 0 || pQueryInfo->fillType == TSDB_FILL_NONE) {
|
||||||
genFinalResWithoutFill(pRes, pLocalReducer, pQueryInfo);
|
genFinalResWithoutFill(pRes, pLocalReducer, pQueryInfo);
|
||||||
} else {
|
} else {
|
||||||
SFillInfo* pFillInfo = pLocalReducer->pFillInfo;
|
SFillInfo* pFillInfo = pLocalReducer->pFillInfo;
|
||||||
if (pFillInfo != NULL) {
|
if (pFillInfo != NULL) {
|
||||||
taosFillSetStartInfo(pFillInfo, (int32_t)pResBuf->num, pQueryInfo->window.ekey);
|
TSKEY ekey = (pQueryInfo->order.order == TSDB_ORDER_ASC)? pQueryInfo->window.ekey: pQueryInfo->window.skey;
|
||||||
|
|
||||||
|
taosFillSetStartInfo(pFillInfo, (int32_t)pResBuf->num, ekey);
|
||||||
taosFillCopyInputDataFromOneFilePage(pFillInfo, pResBuf);
|
taosFillCopyInputDataFromOneFilePage(pFillInfo, pResBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1292,7 +1267,7 @@ static void resetEnvForNewResultset(SSqlRes *pRes, SSqlCmd *pCmd, SLocalReducer
|
||||||
|
|
||||||
// for group result interpolation, do not return if not data is generated
|
// for group result interpolation, do not return if not data is generated
|
||||||
if (pQueryInfo->fillType != TSDB_FILL_NONE) {
|
if (pQueryInfo->fillType != TSDB_FILL_NONE) {
|
||||||
TSKEY skey = MIN(pQueryInfo->window.skey, pQueryInfo->window.ekey);
|
TSKEY skey = (pQueryInfo->order.order == TSDB_ORDER_ASC)? pQueryInfo->window.skey:pQueryInfo->window.ekey;//MIN(pQueryInfo->window.skey, pQueryInfo->window.ekey);
|
||||||
int64_t newTime =
|
int64_t newTime =
|
||||||
taosGetIntervalStartTimestamp(skey, pQueryInfo->slidingTime, pQueryInfo->intervalTime, pQueryInfo->slidingTimeUnit, precision);
|
taosGetIntervalStartTimestamp(skey, pQueryInfo->slidingTime, pQueryInfo->intervalTime, pQueryInfo->slidingTimeUnit, precision);
|
||||||
taosResetFillInfo(pLocalReducer->pFillInfo, newTime);
|
taosResetFillInfo(pLocalReducer->pFillInfo, newTime);
|
||||||
|
@ -1345,7 +1320,7 @@ static bool doHandleLastRemainData(SSqlObj *pSql) {
|
||||||
// if fillType == TSDB_FILL_NONE, return directly
|
// if fillType == TSDB_FILL_NONE, return directly
|
||||||
if (pQueryInfo->fillType != TSDB_FILL_NONE &&
|
if (pQueryInfo->fillType != TSDB_FILL_NONE &&
|
||||||
((pRes->numOfRowsGroup < pQueryInfo->limit.limit && pQueryInfo->limit.limit > 0) || (pQueryInfo->limit.limit < 0))) {
|
((pRes->numOfRowsGroup < pQueryInfo->limit.limit && pQueryInfo->limit.limit > 0) || (pQueryInfo->limit.limit < 0))) {
|
||||||
int64_t etime = (pQueryInfo->window.skey < pQueryInfo->window.ekey) ? pQueryInfo->window.ekey : pQueryInfo->window.skey;
|
int64_t etime = (pQueryInfo->order.order == TSDB_ORDER_ASC)? pQueryInfo->window.ekey : pQueryInfo->window.skey;
|
||||||
|
|
||||||
int32_t rows = (int32_t)getFilledNumOfRes(pFillInfo, etime, pLocalReducer->resColModel->capacity);
|
int32_t rows = (int32_t)getFilledNumOfRes(pFillInfo, etime, pLocalReducer->resColModel->capacity);
|
||||||
if (rows > 0) {
|
if (rows > 0) {
|
||||||
|
@ -1402,13 +1377,12 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) {
|
||||||
tscResetForNextRetrieve(pRes);
|
tscResetForNextRetrieve(pRes);
|
||||||
|
|
||||||
if (pSql->signature != pSql || pRes == NULL || pRes->pLocalReducer == NULL) { // all data has been processed
|
if (pSql->signature != pSql || pRes == NULL || pRes->pLocalReducer == NULL) { // all data has been processed
|
||||||
tscDebug("%p %s call the drop local reducer", pSql, __FUNCTION__);
|
tscError("%p local merge abort due to error occurs, code:%s", pSql, tstrerror(pRes->code));
|
||||||
tscDestroyLocalReducer(pSql);
|
return pRes->code;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SLocalReducer *pLocalReducer = pRes->pLocalReducer;
|
SLocalReducer *pLocalReducer = pRes->pLocalReducer;
|
||||||
SQueryInfo * pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
||||||
|
|
||||||
// set the data merge in progress
|
// set the data merge in progress
|
||||||
int32_t prevStatus =
|
int32_t prevStatus =
|
||||||
|
@ -1503,8 +1477,8 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) {
|
||||||
* so the processing of previous group is completed.
|
* so the processing of previous group is completed.
|
||||||
*/
|
*/
|
||||||
int32_t numOfRes = finalizeRes(pQueryInfo, pLocalReducer);
|
int32_t numOfRes = finalizeRes(pQueryInfo, pLocalReducer);
|
||||||
|
|
||||||
bool sameGroup = isSameGroup(pCmd, pLocalReducer, pLocalReducer->prevRowOfInput, tmpBuffer);
|
bool sameGroup = isSameGroup(pCmd, pLocalReducer, pLocalReducer->prevRowOfInput, tmpBuffer);
|
||||||
|
|
||||||
tFilePage *pResBuf = pLocalReducer->pResultBuf;
|
tFilePage *pResBuf = pLocalReducer->pResultBuf;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -40,7 +40,7 @@ enum {
|
||||||
|
|
||||||
static int32_t tscAllocateMemIfNeed(STableDataBlocks *pDataBlock, int32_t rowSize, int32_t * numOfRows);
|
static int32_t tscAllocateMemIfNeed(STableDataBlocks *pDataBlock, int32_t rowSize, int32_t * numOfRows);
|
||||||
|
|
||||||
static int32_t tscToInteger(SSQLToken *pToken, int64_t *value, char **endPtr) {
|
static int32_t tscToInteger(SStrToken *pToken, int64_t *value, char **endPtr) {
|
||||||
if (pToken->n == 0) {
|
if (pToken->n == 0) {
|
||||||
return TK_ILLEGAL;
|
return TK_ILLEGAL;
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ static int32_t tscToInteger(SSQLToken *pToken, int64_t *value, char **endPtr) {
|
||||||
return pToken->type;
|
return pToken->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t tscToDouble(SSQLToken *pToken, double *value, char **endPtr) {
|
static int32_t tscToDouble(SStrToken *pToken, double *value, char **endPtr) {
|
||||||
if (pToken->n == 0) {
|
if (pToken->n == 0) {
|
||||||
return TK_ILLEGAL;
|
return TK_ILLEGAL;
|
||||||
}
|
}
|
||||||
|
@ -89,9 +89,9 @@ static int32_t tscToDouble(SSQLToken *pToken, double *value, char **endPtr) {
|
||||||
return pToken->type;
|
return pToken->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tsParseTime(SSQLToken *pToken, int64_t *time, char **next, char *error, int16_t timePrec) {
|
int tsParseTime(SStrToken *pToken, int64_t *time, char **next, char *error, int16_t timePrec) {
|
||||||
int32_t index = 0;
|
int32_t index = 0;
|
||||||
SSQLToken sToken;
|
SStrToken sToken;
|
||||||
int64_t interval;
|
int64_t interval;
|
||||||
int64_t useconds = 0;
|
int64_t useconds = 0;
|
||||||
char * pTokenEnd = *next;
|
char * pTokenEnd = *next;
|
||||||
|
@ -128,7 +128,7 @@ int tsParseTime(SSQLToken *pToken, int64_t *time, char **next, char *error, int1
|
||||||
* time expression:
|
* time expression:
|
||||||
* e.g., now+12a, now-5h
|
* e.g., now+12a, now-5h
|
||||||
*/
|
*/
|
||||||
SSQLToken valueToken;
|
SStrToken valueToken;
|
||||||
index = 0;
|
index = 0;
|
||||||
sToken = tStrGetToken(pTokenEnd, &index, false, 0, NULL);
|
sToken = tStrGetToken(pTokenEnd, &index, false, 0, NULL);
|
||||||
pTokenEnd += index;
|
pTokenEnd += index;
|
||||||
|
@ -163,7 +163,7 @@ int tsParseTime(SSQLToken *pToken, int64_t *time, char **next, char *error, int1
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsParseOneColumnData(SSchema *pSchema, SSQLToken *pToken, char *payload, char *msg, char **str, bool primaryKey,
|
int32_t tsParseOneColumnData(SSchema *pSchema, SStrToken *pToken, char *payload, char *msg, char **str, bool primaryKey,
|
||||||
int16_t timePrec) {
|
int16_t timePrec) {
|
||||||
int64_t iv;
|
int64_t iv;
|
||||||
int32_t numType;
|
int32_t numType;
|
||||||
|
@ -409,7 +409,7 @@ static int32_t tsCheckTimestamp(STableDataBlocks *pDataBlocks, const char *start
|
||||||
int tsParseOneRowData(char **str, STableDataBlocks *pDataBlocks, SSchema schema[], SParsedDataColInfo *spd, char *error,
|
int tsParseOneRowData(char **str, STableDataBlocks *pDataBlocks, SSchema schema[], SParsedDataColInfo *spd, char *error,
|
||||||
int16_t timePrec, int32_t *code, char *tmpTokenBuf) {
|
int16_t timePrec, int32_t *code, char *tmpTokenBuf) {
|
||||||
int32_t index = 0;
|
int32_t index = 0;
|
||||||
SSQLToken sToken = {0};
|
SStrToken sToken = {0};
|
||||||
char * payload = pDataBlocks->pData + pDataBlocks->size;
|
char * payload = pDataBlocks->pData + pDataBlocks->size;
|
||||||
|
|
||||||
// 1. set the parsed value from sql string
|
// 1. set the parsed value from sql string
|
||||||
|
@ -524,7 +524,7 @@ static int32_t rowDataCompar(const void *lhs, const void *rhs) {
|
||||||
int tsParseValues(char **str, STableDataBlocks *pDataBlock, STableMeta *pTableMeta, int maxRows,
|
int tsParseValues(char **str, STableDataBlocks *pDataBlock, STableMeta *pTableMeta, int maxRows,
|
||||||
SParsedDataColInfo *spd, char *error, int32_t *code, char *tmpTokenBuf) {
|
SParsedDataColInfo *spd, char *error, int32_t *code, char *tmpTokenBuf) {
|
||||||
int32_t index = 0;
|
int32_t index = 0;
|
||||||
SSQLToken sToken;
|
SStrToken sToken;
|
||||||
|
|
||||||
int16_t numOfRows = 0;
|
int16_t numOfRows = 0;
|
||||||
|
|
||||||
|
@ -734,8 +734,8 @@ static int32_t doParseInsertStatement(SSqlObj *pSql, void *pTableList, char **st
|
||||||
|
|
||||||
static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
|
static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
|
||||||
int32_t index = 0;
|
int32_t index = 0;
|
||||||
SSQLToken sToken = {0};
|
SStrToken sToken = {0};
|
||||||
SSQLToken tableToken = {0};
|
SStrToken tableToken = {0};
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
const int32_t TABLE_INDEX = 0;
|
const int32_t TABLE_INDEX = 0;
|
||||||
|
@ -993,7 +993,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int validateTableName(char *tblName, int len, SSQLToken* psTblToken) {
|
int validateTableName(char *tblName, int len, SStrToken* psTblToken) {
|
||||||
tstrncpy(psTblToken->z, tblName, TSDB_TABLE_FNAME_LEN);
|
tstrncpy(psTblToken->z, tblName, TSDB_TABLE_FNAME_LEN);
|
||||||
|
|
||||||
psTblToken->n = len;
|
psTblToken->n = len;
|
||||||
|
@ -1031,11 +1031,11 @@ int tsParseInsertSql(SSqlObj *pSql) {
|
||||||
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, 0);
|
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, 0);
|
||||||
assert(pQueryInfo != NULL);
|
assert(pQueryInfo != NULL);
|
||||||
|
|
||||||
STableMetaInfo *pTableMetaInfo = NULL;
|
STableMetaInfo *pTableMetaInfo = (pQueryInfo->numOfTables == 0)? tscAddEmptyMetaInfo(pQueryInfo):tscGetMetaInfo(pQueryInfo, 0);
|
||||||
if (pQueryInfo->numOfTables == 0) {
|
if (pTableMetaInfo == NULL) {
|
||||||
pTableMetaInfo = tscAddEmptyMetaInfo(pQueryInfo);
|
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
} else {
|
code = terrno;
|
||||||
pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((code = tscAllocPayload(pCmd, TSDB_DEFAULT_PAYLOAD_SIZE)) != TSDB_CODE_SUCCESS) {
|
if ((code = tscAllocPayload(pCmd, TSDB_DEFAULT_PAYLOAD_SIZE)) != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -1057,7 +1057,7 @@ int tsParseInsertSql(SSqlObj *pSql) {
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
int32_t index = 0;
|
int32_t index = 0;
|
||||||
SSQLToken sToken = tStrGetToken(str, &index, false, 0, NULL);
|
SStrToken sToken = tStrGetToken(str, &index, false, 0, NULL);
|
||||||
|
|
||||||
// no data in the sql string anymore.
|
// no data in the sql string anymore.
|
||||||
if (sToken.n == 0) {
|
if (sToken.n == 0) {
|
||||||
|
@ -1083,7 +1083,7 @@ int tsParseInsertSql(SSqlObj *pSql) {
|
||||||
|
|
||||||
pCmd->curSql = sToken.z;
|
pCmd->curSql = sToken.z;
|
||||||
char buf[TSDB_TABLE_FNAME_LEN];
|
char buf[TSDB_TABLE_FNAME_LEN];
|
||||||
SSQLToken sTblToken;
|
SStrToken sTblToken;
|
||||||
sTblToken.z = buf;
|
sTblToken.z = buf;
|
||||||
// Check if the table name available or not
|
// Check if the table name available or not
|
||||||
if (validateTableName(sToken.z, sToken.n, &sTblToken) != TSDB_CODE_SUCCESS) {
|
if (validateTableName(sToken.z, sToken.n, &sTblToken) != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -1285,15 +1285,14 @@ int tsInsertInitialCheck(SSqlObj *pSql) {
|
||||||
int32_t index = 0;
|
int32_t index = 0;
|
||||||
SSqlCmd *pCmd = &pSql->cmd;
|
SSqlCmd *pCmd = &pSql->cmd;
|
||||||
|
|
||||||
SSQLToken sToken = tStrGetToken(pSql->sqlstr, &index, false, 0, NULL);
|
SStrToken sToken = tStrGetToken(pSql->sqlstr, &index, false, 0, NULL);
|
||||||
assert(sToken.type == TK_INSERT || sToken.type == TK_IMPORT);
|
assert(sToken.type == TK_INSERT || sToken.type == TK_IMPORT);
|
||||||
|
|
||||||
pCmd->count = 0;
|
pCmd->count = 0;
|
||||||
pCmd->command = TSDB_SQL_INSERT;
|
pCmd->command = TSDB_SQL_INSERT;
|
||||||
pSql->res.numOfRows = 0;
|
pSql->res.numOfRows = 0;
|
||||||
|
|
||||||
SQueryInfo *pQueryInfo = NULL;
|
SQueryInfo *pQueryInfo = tscGetQueryInfoDetailSafely(pCmd, pCmd->clauseIndex);
|
||||||
tscGetQueryInfoDetailSafely(pCmd, pCmd->clauseIndex, &pQueryInfo);
|
|
||||||
|
|
||||||
TSDB_QUERY_SET_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_INSERT | pCmd->insertType);
|
TSDB_QUERY_SET_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_INSERT | pCmd->insertType);
|
||||||
|
|
||||||
|
|
|
@ -155,7 +155,7 @@ static int normalStmtPrepare(STscStmt* stmt) {
|
||||||
uint32_t i = 0, start = 0;
|
uint32_t i = 0, start = 0;
|
||||||
|
|
||||||
while (sql[i] != 0) {
|
while (sql[i] != 0) {
|
||||||
SSQLToken token = {0};
|
SStrToken token = {0};
|
||||||
token.n = tSQLGetToken(sql + i, &token.type);
|
token.n = tSQLGetToken(sql + i, &token.type);
|
||||||
|
|
||||||
if (token.type == TK_QUESTION) {
|
if (token.type == TK_QUESTION) {
|
||||||
|
|
|
@ -285,10 +285,10 @@ void tscKillConnection(STscObj *pObj) {
|
||||||
|
|
||||||
SSqlObj *pSql = pObj->sqlList;
|
SSqlObj *pSql = pObj->sqlList;
|
||||||
while (pSql) {
|
while (pSql) {
|
||||||
//taosStopRpcConn(pSql->thandle);
|
|
||||||
pSql = pSql->next;
|
pSql = pSql->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SSqlStream *pStream = pObj->streamList;
|
SSqlStream *pStream = pObj->streamList;
|
||||||
while (pStream) {
|
while (pStream) {
|
||||||
SSqlStream *tmp = pStream->next;
|
SSqlStream *tmp = pStream->next;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -226,13 +226,17 @@ int tscSendMsgToServer(SSqlObj *pSql) {
|
||||||
.handle = &pSql->pRpcCtx,
|
.handle = &pSql->pRpcCtx,
|
||||||
.code = 0
|
.code = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
// NOTE: the rpc context should be acquired before sending data to server.
|
// NOTE: the rpc context should be acquired before sending data to server.
|
||||||
// Otherwise, the pSql object may have been released already during the response function, which is
|
// Otherwise, the pSql object may have been released already during the response function, which is
|
||||||
// processMsgFromServer function. In the meanwhile, the assignment of the rpc context to sql object will absolutely
|
// processMsgFromServer function. In the meanwhile, the assignment of the rpc context to sql object will absolutely
|
||||||
// cause crash.
|
// cause crash.
|
||||||
|
if (pObj != NULL && pObj->signature == pObj) {
|
||||||
rpcSendRequest(pObj->pDnodeConn, &pSql->epSet, &rpcMsg);
|
rpcSendRequest(pObj->pDnodeConn, &pSql->epSet, &rpcMsg);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
} else {
|
||||||
|
//pObj->signature has been reset by other thread, ignore concurrency problem
|
||||||
|
return TSDB_CODE_TSC_CONN_KILLED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcEpSet *pEpSet) {
|
void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcEpSet *pEpSet) {
|
||||||
|
@ -314,10 +318,10 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcEpSet *pEpSet) {
|
||||||
|
|
||||||
pRes->rspLen = 0;
|
pRes->rspLen = 0;
|
||||||
|
|
||||||
if (pRes->code != TSDB_CODE_TSC_QUERY_CANCELLED) {
|
if (pRes->code == TSDB_CODE_TSC_QUERY_CANCELLED) {
|
||||||
pRes->code = (rpcMsg->code != TSDB_CODE_SUCCESS) ? rpcMsg->code : TSDB_CODE_RPC_NETWORK_UNAVAIL;
|
|
||||||
} else {
|
|
||||||
tscDebug("%p query is cancelled, code:%s", pSql, tstrerror(pRes->code));
|
tscDebug("%p query is cancelled, code:%s", pSql, tstrerror(pRes->code));
|
||||||
|
} else {
|
||||||
|
pRes->code = rpcMsg->code;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pRes->code == TSDB_CODE_SUCCESS) {
|
if (pRes->code == TSDB_CODE_SUCCESS) {
|
||||||
|
@ -454,35 +458,21 @@ void tscKillSTableQuery(SSqlObj *pSql) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pSql->res.code = TSDB_CODE_TSC_QUERY_CANCELLED;
|
||||||
|
|
||||||
for (int i = 0; i < pSql->numOfSubs; ++i) {
|
for (int i = 0; i < pSql->numOfSubs; ++i) {
|
||||||
|
// NOTE: pSub may have been released already here
|
||||||
SSqlObj *pSub = pSql->pSubs[i];
|
SSqlObj *pSub = pSql->pSubs[i];
|
||||||
if (pSub == NULL) {
|
if (pSub == NULL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* here, we cannot set the command = TSDB_SQL_KILL_QUERY. Otherwise, it may cause
|
|
||||||
* sub-queries not correctly released and master sql object of super table query reaches an abnormal state.
|
|
||||||
*/
|
|
||||||
rpcCancelRequest(pSub->pRpcCtx);
|
|
||||||
pSub->res.code = TSDB_CODE_TSC_QUERY_CANCELLED;
|
pSub->res.code = TSDB_CODE_TSC_QUERY_CANCELLED;
|
||||||
tscQueueAsyncRes(pSub);
|
if (pSub->pRpcCtx != NULL) {
|
||||||
|
rpcCancelRequest(pSub->pRpcCtx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
tscQueueAsyncRes(pSub); // async res? not other functions?
|
||||||
* 1. if the subqueries are not launched or partially launched, we need to waiting the launched
|
|
||||||
* query return to successfully free allocated resources.
|
|
||||||
* 2. if no any subqueries are launched yet, which means the super table query only in parse sql stage,
|
|
||||||
* set the res.code, and return.
|
|
||||||
*/
|
|
||||||
const int64_t MAX_WAITING_TIME = 10000; // 10 Sec.
|
|
||||||
int64_t stime = taosGetTimestampMs();
|
|
||||||
|
|
||||||
while (pCmd->command != TSDB_SQL_RETRIEVE_LOCALMERGE && pCmd->command != TSDB_SQL_RETRIEVE_EMPTY_RESULT) {
|
|
||||||
taosMsleep(100);
|
|
||||||
if (taosGetTimestampMs() - stime > MAX_WAITING_TIME) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tscDebug("%p super table query cancelled", pSql);
|
tscDebug("%p super table query cancelled", pSql);
|
||||||
|
@ -638,26 +628,29 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, size)) {
|
if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, size)) {
|
||||||
tscError("%p failed to malloc for query msg", pSql);
|
tscError("%p failed to malloc for query msg", pSql);
|
||||||
return -1; // todo add test for this
|
return TSDB_CODE_TSC_INVALID_SQL; // todo add test for this
|
||||||
}
|
}
|
||||||
|
|
||||||
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
||||||
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||||
STableMeta * pTableMeta = pTableMetaInfo->pTableMeta;
|
STableMeta * pTableMeta = pTableMetaInfo->pTableMeta;
|
||||||
|
|
||||||
if (taosArrayGetSize(pQueryInfo->colList) <= 0 && !tscQueryTags(pQueryInfo)) {
|
size_t numOfSrcCols = taosArrayGetSize(pQueryInfo->colList);
|
||||||
tscError("%p illegal value of numOfCols in query msg: %d", pSql, tscGetNumOfColumns(pTableMeta));
|
if (numOfSrcCols <= 0 && !tscQueryTags(pQueryInfo)) {
|
||||||
return -1;
|
tscError("%p illegal value of numOfCols in query msg: %"PRIu64", table cols:%d", pSql, numOfSrcCols,
|
||||||
|
tscGetNumOfColumns(pTableMeta));
|
||||||
|
|
||||||
|
return TSDB_CODE_TSC_INVALID_SQL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pQueryInfo->intervalTime < 0) {
|
if (pQueryInfo->intervalTime < 0) {
|
||||||
tscError("%p illegal value of aggregation time interval in query msg: %ld", pSql, pQueryInfo->intervalTime);
|
tscError("%p illegal value of aggregation time interval in query msg: %ld", pSql, pQueryInfo->intervalTime);
|
||||||
return -1;
|
return TSDB_CODE_TSC_INVALID_SQL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pQueryInfo->groupbyExpr.numOfGroupCols < 0) {
|
if (pQueryInfo->groupbyExpr.numOfGroupCols < 0) {
|
||||||
tscError("%p illegal value of numOfGroupCols in query msg: %d", pSql, pQueryInfo->groupbyExpr.numOfGroupCols);
|
tscError("%p illegal value of numOfGroupCols in query msg: %d", pSql, pQueryInfo->groupbyExpr.numOfGroupCols);
|
||||||
return -1;
|
return TSDB_CODE_TSC_INVALID_SQL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SQueryTableMsg *pQueryMsg = (SQueryTableMsg *)pCmd->payload;
|
SQueryTableMsg *pQueryMsg = (SQueryTableMsg *)pCmd->payload;
|
||||||
|
@ -735,7 +728,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
|
|
||||||
if (pColFilter->lowerRelOptr == TSDB_RELATION_INVALID && pColFilter->upperRelOptr == TSDB_RELATION_INVALID) {
|
if (pColFilter->lowerRelOptr == TSDB_RELATION_INVALID && pColFilter->upperRelOptr == TSDB_RELATION_INVALID) {
|
||||||
tscError("invalid filter info");
|
tscError("invalid filter info");
|
||||||
return -1;
|
return TSDB_CODE_TSC_INVALID_SQL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -744,10 +737,10 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
for (int32_t i = 0; i < tscSqlExprNumOfExprs(pQueryInfo); ++i) {
|
for (int32_t i = 0; i < tscSqlExprNumOfExprs(pQueryInfo); ++i) {
|
||||||
SSqlExpr *pExpr = tscSqlExprGet(pQueryInfo, i);
|
SSqlExpr *pExpr = tscSqlExprGet(pQueryInfo, i);
|
||||||
|
|
||||||
if (!tscValidateColumnId(pTableMetaInfo, pExpr->colInfo.colId)) {
|
if (!tscValidateColumnId(pTableMetaInfo, pExpr->colInfo.colId, pExpr->numOfParams)) {
|
||||||
/* column id is not valid according to the cached table meta, the table meta is expired */
|
/* column id is not valid according to the cached table meta, the table meta is expired */
|
||||||
tscError("%p table schema is not matched with parsed sql", pSql);
|
tscError("%p table schema is not matched with parsed sql", pSql);
|
||||||
return -1;
|
return TSDB_CODE_TSC_INVALID_SQL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pSqlFuncExpr->colInfo.colId = htons(pExpr->colInfo.colId);
|
pSqlFuncExpr->colInfo.colId = htons(pExpr->colInfo.colId);
|
||||||
|
@ -944,8 +937,8 @@ int32_t tscBuildAcctMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
|
|
||||||
SCMCreateAcctMsg *pAlterMsg = (SCMCreateAcctMsg *)pCmd->payload;
|
SCMCreateAcctMsg *pAlterMsg = (SCMCreateAcctMsg *)pCmd->payload;
|
||||||
|
|
||||||
SSQLToken *pName = &pInfo->pDCLInfo->user.user;
|
SStrToken *pName = &pInfo->pDCLInfo->user.user;
|
||||||
SSQLToken *pPwd = &pInfo->pDCLInfo->user.passwd;
|
SStrToken *pPwd = &pInfo->pDCLInfo->user.passwd;
|
||||||
|
|
||||||
strncpy(pAlterMsg->user, pName->z, pName->n);
|
strncpy(pAlterMsg->user, pName->z, pName->n);
|
||||||
strncpy(pAlterMsg->pass, pPwd->z, pPwd->n);
|
strncpy(pAlterMsg->pass, pPwd->z, pPwd->n);
|
||||||
|
@ -1147,13 +1140,13 @@ int32_t tscBuildShowMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
pShowMsg->type = pShowInfo->showType;
|
pShowMsg->type = pShowInfo->showType;
|
||||||
|
|
||||||
if (pShowInfo->showType != TSDB_MGMT_TABLE_VNODES) {
|
if (pShowInfo->showType != TSDB_MGMT_TABLE_VNODES) {
|
||||||
SSQLToken *pPattern = &pShowInfo->pattern;
|
SStrToken *pPattern = &pShowInfo->pattern;
|
||||||
if (pPattern->type > 0) { // only show tables support wildcard query
|
if (pPattern->type > 0) { // only show tables support wildcard query
|
||||||
strncpy(pShowMsg->payload, pPattern->z, pPattern->n);
|
strncpy(pShowMsg->payload, pPattern->z, pPattern->n);
|
||||||
pShowMsg->payloadLen = htons(pPattern->n);
|
pShowMsg->payloadLen = htons(pPattern->n);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SSQLToken *pEpAddr = &pShowInfo->prefix;
|
SStrToken *pEpAddr = &pShowInfo->prefix;
|
||||||
assert(pEpAddr->n > 0 && pEpAddr->type > 0);
|
assert(pEpAddr->n > 0 && pEpAddr->type > 0);
|
||||||
|
|
||||||
strncpy(pShowMsg->payload, pEpAddr->z, pEpAddr->n);
|
strncpy(pShowMsg->payload, pEpAddr->z, pEpAddr->n);
|
||||||
|
@ -1295,7 +1288,7 @@ int tscBuildAlterTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
int size = tscEstimateAlterTableMsgLength(pCmd);
|
int size = tscEstimateAlterTableMsgLength(pCmd);
|
||||||
if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, size)) {
|
if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, size)) {
|
||||||
tscError("%p failed to malloc for alter table msg", pSql);
|
tscError("%p failed to malloc for alter table msg", pSql);
|
||||||
return -1;
|
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
SCMAlterTableMsg *pAlterTableMsg = (SCMAlterTableMsg *)pCmd->payload;
|
SCMAlterTableMsg *pAlterTableMsg = (SCMAlterTableMsg *)pCmd->payload;
|
||||||
|
@ -1443,6 +1436,12 @@ int tscProcessRetrieveLocalMergeRsp(SSqlObj *pSql) {
|
||||||
SSqlRes *pRes = &pSql->res;
|
SSqlRes *pRes = &pSql->res;
|
||||||
SSqlCmd *pCmd = &pSql->cmd;
|
SSqlCmd *pCmd = &pSql->cmd;
|
||||||
|
|
||||||
|
int32_t code = pRes->code;
|
||||||
|
if (pRes->code != TSDB_CODE_SUCCESS) {
|
||||||
|
tscQueueAsyncRes(pSql);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
pRes->code = tscDoLocalMerge(pSql);
|
pRes->code = tscDoLocalMerge(pSql);
|
||||||
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
||||||
|
|
||||||
|
@ -1453,7 +1452,7 @@ int tscProcessRetrieveLocalMergeRsp(SSqlObj *pSql) {
|
||||||
pRes->row = 0;
|
pRes->row = 0;
|
||||||
pRes->completed = (pRes->numOfRows == 0);
|
pRes->completed = (pRes->numOfRows == 0);
|
||||||
|
|
||||||
int32_t code = pRes->code;
|
code = pRes->code;
|
||||||
if (pRes->code == TSDB_CODE_SUCCESS) {
|
if (pRes->code == TSDB_CODE_SUCCESS) {
|
||||||
(*pSql->fp)(pSql->param, pSql, pRes->numOfRows);
|
(*pSql->fp)(pSql->param, pSql, pRes->numOfRows);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1647,7 +1646,7 @@ int tscBuildHeartBeatMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, size)) {
|
if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, size)) {
|
||||||
pthread_mutex_unlock(&pObj->mutex);
|
pthread_mutex_unlock(&pObj->mutex);
|
||||||
tscError("%p failed to malloc for heartbeat msg", pSql);
|
tscError("%p failed to malloc for heartbeat msg", pSql);
|
||||||
return -1;
|
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
SCMHeartBeatMsg *pHeartbeat = (SCMHeartBeatMsg *)pCmd->payload;
|
SCMHeartBeatMsg *pHeartbeat = (SCMHeartBeatMsg *)pCmd->payload;
|
||||||
|
@ -1717,7 +1716,7 @@ int tscProcessTableMetaRsp(SSqlObj *pSql) {
|
||||||
assert(pTableMetaInfo->pTableMeta == NULL);
|
assert(pTableMetaInfo->pTableMeta == NULL);
|
||||||
|
|
||||||
pTableMetaInfo->pTableMeta = (STableMeta *) taosCachePut(tscCacheHandle, pTableMetaInfo->name,
|
pTableMetaInfo->pTableMeta = (STableMeta *) taosCachePut(tscCacheHandle, pTableMetaInfo->name,
|
||||||
strlen(pTableMetaInfo->name), pTableMeta, size, tsTableMetaKeepTimer);
|
strlen(pTableMetaInfo->name), pTableMeta, size, tsTableMetaKeepTimer * 1000);
|
||||||
|
|
||||||
// todo handle out of memory case
|
// todo handle out of memory case
|
||||||
if (pTableMetaInfo->pTableMeta == NULL) {
|
if (pTableMetaInfo->pTableMeta == NULL) {
|
||||||
|
@ -1921,7 +1920,7 @@ int tscProcessShowRsp(SSqlObj *pSql) {
|
||||||
STableMeta* pTableMeta = tscCreateTableMetaFromMsg(pMetaMsg, &size);
|
STableMeta* pTableMeta = tscCreateTableMetaFromMsg(pMetaMsg, &size);
|
||||||
|
|
||||||
pTableMetaInfo->pTableMeta = taosCachePut(tscCacheHandle, key, strlen(key), (char *)pTableMeta, size,
|
pTableMetaInfo->pTableMeta = taosCachePut(tscCacheHandle, key, strlen(key), (char *)pTableMeta, size,
|
||||||
tsTableMetaKeepTimer);
|
tsTableMetaKeepTimer * 1000);
|
||||||
SSchema *pTableSchema = tscGetTableSchema(pTableMetaInfo->pTableMeta);
|
SSchema *pTableSchema = tscGetTableSchema(pTableMetaInfo->pTableMeta);
|
||||||
|
|
||||||
if (pQueryInfo->colList == NULL) {
|
if (pQueryInfo->colList == NULL) {
|
||||||
|
@ -1961,8 +1960,12 @@ static void createHBObj(STscObj* pObj) {
|
||||||
|
|
||||||
pSql->fp = tscProcessHeartBeatRsp;
|
pSql->fp = tscProcessHeartBeatRsp;
|
||||||
|
|
||||||
SQueryInfo *pQueryInfo = NULL;
|
SQueryInfo *pQueryInfo = tscGetQueryInfoDetailSafely(&pSql->cmd, 0);
|
||||||
tscGetQueryInfoDetailSafely(&pSql->cmd, 0, &pQueryInfo);
|
if (pQueryInfo == NULL) {
|
||||||
|
pSql->res.code = terrno;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
pQueryInfo->command = TSDB_SQL_HB;
|
pQueryInfo->command = TSDB_SQL_HB;
|
||||||
|
|
||||||
pSql->cmd.command = pQueryInfo->command;
|
pSql->cmd.command = pQueryInfo->command;
|
||||||
|
@ -2147,8 +2150,7 @@ static int32_t getTableMetaFromMgmt(SSqlObj *pSql, STableMetaInfo *pTableMetaInf
|
||||||
|
|
||||||
tscAddSubqueryInfo(&pNew->cmd);
|
tscAddSubqueryInfo(&pNew->cmd);
|
||||||
|
|
||||||
SQueryInfo *pNewQueryInfo = NULL;
|
SQueryInfo *pNewQueryInfo = tscGetQueryInfoDetailSafely(&pNew->cmd, 0);
|
||||||
tscGetQueryInfoDetailSafely(&pNew->cmd, 0, &pNewQueryInfo);
|
|
||||||
|
|
||||||
pNew->cmd.autoCreated = pSql->cmd.autoCreated; // create table if not exists
|
pNew->cmd.autoCreated = pSql->cmd.autoCreated; // create table if not exists
|
||||||
if (TSDB_CODE_SUCCESS != tscAllocPayload(&pNew->cmd, TSDB_DEFAULT_PAYLOAD_SIZE + pSql->cmd.payloadLen)) {
|
if (TSDB_CODE_SUCCESS != tscAllocPayload(&pNew->cmd, TSDB_DEFAULT_PAYLOAD_SIZE + pSql->cmd.payloadLen)) {
|
||||||
|
@ -2251,8 +2253,8 @@ int tscGetSTableVgroupInfo(SSqlObj *pSql, int32_t clauseIndex) {
|
||||||
|
|
||||||
pNew->cmd.command = TSDB_SQL_STABLEVGROUP;
|
pNew->cmd.command = TSDB_SQL_STABLEVGROUP;
|
||||||
|
|
||||||
SQueryInfo *pNewQueryInfo = NULL;
|
SQueryInfo *pNewQueryInfo = tscGetQueryInfoDetailSafely(&pNew->cmd, 0);
|
||||||
if ((code = tscGetQueryInfoDetailSafely(&pNew->cmd, 0, &pNewQueryInfo)) != TSDB_CODE_SUCCESS) {
|
if (pNewQueryInfo == NULL) {
|
||||||
tscFreeSqlObj(pNew);
|
tscFreeSqlObj(pNew);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -655,27 +655,30 @@ int* taos_fetch_lengths(TAOS_RES *res) {
|
||||||
char *taos_get_client_info() { return version; }
|
char *taos_get_client_info() { return version; }
|
||||||
|
|
||||||
void taos_stop_query(TAOS_RES *res) {
|
void taos_stop_query(TAOS_RES *res) {
|
||||||
if (res == NULL) {
|
SSqlObj *pSql = (SSqlObj *)res;
|
||||||
|
if (pSql == NULL || pSql->signature != pSql) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSqlObj *pSql = (SSqlObj *)res;
|
tscDebug("%p start to cancel query", res);
|
||||||
SSqlCmd *pCmd = &pSql->cmd;
|
SSqlCmd *pCmd = &pSql->cmd;
|
||||||
|
|
||||||
if (pSql->signature != pSql) return;
|
// TODO there are multi-thread problem.
|
||||||
tscDebug("%p start to cancel query", res);
|
// It may have been released by the other thread already.
|
||||||
|
// The ref count may fix this problem.
|
||||||
|
|
||||||
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
||||||
if (tscIsTwoStageSTableQuery(pQueryInfo, 0)) {
|
|
||||||
tscKillSTableQuery(pSql);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// set the error code for master pSqlObj firstly
|
||||||
|
pSql->res.code = TSDB_CODE_TSC_QUERY_CANCELLED;
|
||||||
|
|
||||||
|
if (tscIsTwoStageSTableQuery(pQueryInfo, 0)) {
|
||||||
|
assert(pSql->pRpcCtx == NULL);
|
||||||
|
tscKillSTableQuery(pSql);
|
||||||
|
} else {
|
||||||
if (pSql->cmd.command < TSDB_SQL_LOCAL) {
|
if (pSql->cmd.command < TSDB_SQL_LOCAL) {
|
||||||
rpcCancelRequest(pSql->pRpcCtx);
|
rpcCancelRequest(pSql->pRpcCtx);
|
||||||
}
|
}
|
||||||
pSql->res.code = TSDB_CODE_TSC_QUERY_CANCELLED;
|
}
|
||||||
tscQueueAsyncRes(pSql);
|
|
||||||
|
|
||||||
tscDebug("%p query is cancelled", res);
|
tscDebug("%p query is cancelled", res);
|
||||||
}
|
}
|
||||||
|
@ -824,8 +827,11 @@ static int tscParseTblNameList(SSqlObj *pSql, const char *tblNameList, int32_t t
|
||||||
int code = TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH;
|
int code = TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH;
|
||||||
char *str = (char *)tblNameList;
|
char *str = (char *)tblNameList;
|
||||||
|
|
||||||
SQueryInfo *pQueryInfo = NULL;
|
SQueryInfo *pQueryInfo = tscGetQueryInfoDetailSafely(pCmd, pCmd->clauseIndex);
|
||||||
tscGetQueryInfoDetailSafely(pCmd, pCmd->clauseIndex, &pQueryInfo);
|
if (pQueryInfo == NULL) {
|
||||||
|
pSql->res.code = terrno;
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
|
||||||
STableMetaInfo *pTableMetaInfo = tscAddEmptyMetaInfo(pQueryInfo);
|
STableMetaInfo *pTableMetaInfo = tscAddEmptyMetaInfo(pQueryInfo);
|
||||||
|
|
||||||
|
@ -850,7 +856,7 @@ static int tscParseTblNameList(SSqlObj *pSql, const char *tblNameList, int32_t t
|
||||||
str = nextStr + 1;
|
str = nextStr + 1;
|
||||||
len = (int32_t)strtrim(tblName);
|
len = (int32_t)strtrim(tblName);
|
||||||
|
|
||||||
SSQLToken sToken = {.n = len, .type = TK_ID, .z = tblName};
|
SStrToken sToken = {.n = len, .type = TK_ID, .z = tblName};
|
||||||
tSQLGetToken(tblName, &sToken.type);
|
tSQLGetToken(tblName, &sToken.type);
|
||||||
|
|
||||||
// Check if the table name available or not
|
// Check if the table name available or not
|
||||||
|
|
|
@ -95,13 +95,14 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, SJoinSupporter* pSupporter1, SJ
|
||||||
tscInfo("%" PRId64 ", tags:%d \t %" PRId64 ", tags:%d", elem1.ts, elem1.tag, elem2.ts, elem2.tag);
|
tscInfo("%" PRId64 ", tags:%d \t %" PRId64 ", tags:%d", elem1.ts, elem1.tag, elem2.ts, elem2.tag);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (elem1.tag < elem2.tag || (elem1.tag == elem2.tag && tsCompare(order, elem1.ts, elem2.ts))) {
|
int32_t res = tVariantCompare(&elem1.tag, &elem2.tag);
|
||||||
|
if (res == -1 || (res == 0 && tsCompare(order, elem1.ts, elem2.ts))) {
|
||||||
if (!tsBufNextPos(pSupporter1->pTSBuf)) {
|
if (!tsBufNextPos(pSupporter1->pTSBuf)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
numOfInput1++;
|
numOfInput1++;
|
||||||
} else if (elem1.tag > elem2.tag || (elem1.tag == elem2.tag && tsCompare(order, elem2.ts, elem1.ts))) {
|
} else if ((res > 0) || (res == 0 && tsCompare(order, elem2.ts, elem1.ts))) {
|
||||||
if (!tsBufNextPos(pSupporter2->pTSBuf)) {
|
if (!tsBufNextPos(pSupporter2->pTSBuf)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -121,8 +122,8 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, SJoinSupporter* pSupporter1, SJ
|
||||||
win->ekey = elem1.ts;
|
win->ekey = elem1.ts;
|
||||||
}
|
}
|
||||||
|
|
||||||
tsBufAppend(output1, elem1.vnode, elem1.tag, (const char*)&elem1.ts, sizeof(elem1.ts));
|
tsBufAppend(output1, elem1.vnode, &elem1.tag, (const char*)&elem1.ts, sizeof(elem1.ts));
|
||||||
tsBufAppend(output2, elem2.vnode, elem2.tag, (const char*)&elem2.ts, sizeof(elem2.ts));
|
tsBufAppend(output2, elem2.vnode, &elem2.tag, (const char*)&elem2.ts, sizeof(elem2.ts));
|
||||||
} else {
|
} else {
|
||||||
pLimit->offset -= 1;
|
pLimit->offset -= 1;
|
||||||
}
|
}
|
||||||
|
@ -354,11 +355,12 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) {
|
||||||
pExpr = tscSqlExprGet(pQueryInfo, 0);
|
pExpr = tscSqlExprGet(pQueryInfo, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the join condition tag column info, to do extract method
|
// set the join condition tag column info, todo extract method
|
||||||
if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) {
|
if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) {
|
||||||
assert(pQueryInfo->tagCond.joinInfo.hasJoin);
|
assert(pQueryInfo->tagCond.joinInfo.hasJoin);
|
||||||
int16_t colId = tscGetJoinTagColIdByUid(&pQueryInfo->tagCond, pTableMetaInfo->pTableMeta->id.uid);
|
int16_t colId = tscGetJoinTagColIdByUid(&pQueryInfo->tagCond, pTableMetaInfo->pTableMeta->id.uid);
|
||||||
|
|
||||||
|
// set the tag column id for executor to extract correct tag value
|
||||||
pExpr->param[0].i64Key = colId;
|
pExpr->param[0].i64Key = colId;
|
||||||
pExpr->numOfParams = 1;
|
pExpr->numOfParams = 1;
|
||||||
}
|
}
|
||||||
|
@ -435,6 +437,7 @@ int32_t tscCompareTidTags(const void* p1, const void* p2) {
|
||||||
if (t1->vgId != t2->vgId) {
|
if (t1->vgId != t2->vgId) {
|
||||||
return (t1->vgId > t2->vgId) ? 1 : -1;
|
return (t1->vgId > t2->vgId) ? 1 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t1->tid != t2->tid) {
|
if (t1->tid != t2->tid) {
|
||||||
return (t1->tid > t2->tid) ? 1 : -1;
|
return (t1->tid > t2->tid) ? 1 : -1;
|
||||||
}
|
}
|
||||||
|
@ -541,6 +544,7 @@ static bool checkForDuplicateTagVal(SQueryInfo* pQueryInfo, SJoinSupporter* p1,
|
||||||
for(int32_t i = 1; i < p1->num; ++i) {
|
for(int32_t i = 1; i < p1->num; ++i) {
|
||||||
STidTags* prev = (STidTags*) varDataVal(p1->pIdTagList + (i - 1) * p1->tagSize);
|
STidTags* prev = (STidTags*) varDataVal(p1->pIdTagList + (i - 1) * p1->tagSize);
|
||||||
STidTags* p = (STidTags*) varDataVal(p1->pIdTagList + i * p1->tagSize);
|
STidTags* p = (STidTags*) varDataVal(p1->pIdTagList + i * p1->tagSize);
|
||||||
|
assert(prev->vgId >= 1 && p->vgId >= 1);
|
||||||
|
|
||||||
if (doCompare(prev->tag, p->tag, pColSchema->type, pColSchema->bytes) == 0) {
|
if (doCompare(prev->tag, p->tag, pColSchema->type, pColSchema->bytes) == 0) {
|
||||||
tscError("%p join tags have same value for different table, free all sub SqlObj and quit", pPSqlObj);
|
tscError("%p join tags have same value for different table, free all sub SqlObj and quit", pPSqlObj);
|
||||||
|
@ -577,6 +581,7 @@ static int32_t getIntersectionOfTableTuple(SQueryInfo* pQueryInfo, SSqlObj* pPar
|
||||||
while(i < p1->num && j < p2->num) {
|
while(i < p1->num && j < p2->num) {
|
||||||
STidTags* pp1 = (STidTags*) varDataVal(p1->pIdTagList + i * p1->tagSize);
|
STidTags* pp1 = (STidTags*) varDataVal(p1->pIdTagList + i * p1->tagSize);
|
||||||
STidTags* pp2 = (STidTags*) varDataVal(p2->pIdTagList + j * p2->tagSize);
|
STidTags* pp2 = (STidTags*) varDataVal(p2->pIdTagList + j * p2->tagSize);
|
||||||
|
assert(pp1->tid != 0 && pp2->tid != 0);
|
||||||
|
|
||||||
int32_t ret = doCompare(pp1->tag, pp2->tag, pColSchema->type, pColSchema->bytes);
|
int32_t ret = doCompare(pp1->tag, pp2->tag, pColSchema->type, pColSchema->bytes);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
|
@ -686,6 +691,7 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
|
||||||
freeJoinSubqueryObj(pParentSql);
|
freeJoinSubqueryObj(pParentSql);
|
||||||
pParentSql->res.code = code;
|
pParentSql->res.code = code;
|
||||||
tscQueueAsyncRes(pParentSql);
|
tscQueueAsyncRes(pParentSql);
|
||||||
|
|
||||||
taosArrayDestroy(s1);
|
taosArrayDestroy(s1);
|
||||||
taosArrayDestroy(s2);
|
taosArrayDestroy(s2);
|
||||||
return;
|
return;
|
||||||
|
@ -1145,7 +1151,7 @@ void tscJoinQueryCallback(void* param, TAOS_RES* tres, int code) {
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////
|
||||||
static void tscRetrieveDataRes(void *param, TAOS_RES *tres, int code);
|
static void tscRetrieveDataRes(void *param, TAOS_RES *tres, int code);
|
||||||
|
|
||||||
static SSqlObj *tscCreateSqlObjForSubquery(SSqlObj *pSql, SRetrieveSupport *trsupport, SSqlObj *prevSqlObj);
|
static SSqlObj *tscCreateSTableSubquery(SSqlObj *pSql, SRetrieveSupport *trsupport, SSqlObj *prevSqlObj);
|
||||||
|
|
||||||
int32_t tscLaunchJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter *pSupporter) {
|
int32_t tscLaunchJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter *pSupporter) {
|
||||||
SSqlCmd * pCmd = &pSql->cmd;
|
SSqlCmd * pCmd = &pSql->cmd;
|
||||||
|
@ -1218,6 +1224,16 @@ int32_t tscLaunchJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter
|
||||||
int32_t tagColId = tscGetJoinTagColIdByUid(pTagCond, pTableMetaInfo->pTableMeta->id.uid);
|
int32_t tagColId = tscGetJoinTagColIdByUid(pTagCond, pTableMetaInfo->pTableMeta->id.uid);
|
||||||
SSchema* s = tscGetTableColumnSchemaById(pTableMetaInfo->pTableMeta, tagColId);
|
SSchema* s = tscGetTableColumnSchemaById(pTableMetaInfo->pTableMeta, tagColId);
|
||||||
|
|
||||||
|
// get the tag colId column index
|
||||||
|
int32_t numOfTags = tscGetNumOfTags(pTableMetaInfo->pTableMeta);
|
||||||
|
SSchema* pSchema = tscGetTableTagSchema(pTableMetaInfo->pTableMeta);
|
||||||
|
for(int32_t i = 0; i < numOfTags; ++i) {
|
||||||
|
if (pSchema[i].colId == tagColId) {
|
||||||
|
index.columnIndex = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int16_t bytes = 0;
|
int16_t bytes = 0;
|
||||||
int16_t type = 0;
|
int16_t type = 0;
|
||||||
int32_t inter = 0;
|
int32_t inter = 0;
|
||||||
|
@ -1288,7 +1304,13 @@ int32_t tscHandleMasterJoinQuery(SSqlObj* pSql) {
|
||||||
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
||||||
assert((pQueryInfo->type & TSDB_QUERY_TYPE_SUBQUERY) == 0);
|
assert((pQueryInfo->type & TSDB_QUERY_TYPE_SUBQUERY) == 0);
|
||||||
|
|
||||||
|
// todo add test
|
||||||
SSubqueryState *pState = calloc(1, sizeof(SSubqueryState));
|
SSubqueryState *pState = calloc(1, sizeof(SSubqueryState));
|
||||||
|
if (pState == NULL) {
|
||||||
|
pSql->res.code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
|
return pSql->res.code;
|
||||||
|
}
|
||||||
|
|
||||||
pState->numOfTotal = pQueryInfo->numOfTables;
|
pState->numOfTotal = pQueryInfo->numOfTables;
|
||||||
pState->numOfRemain = pState->numOfTotal;
|
pState->numOfRemain = pState->numOfTotal;
|
||||||
|
|
||||||
|
@ -1332,10 +1354,6 @@ static void doCleanupSubqueries(SSqlObj *pSql, int32_t numOfSubs, SSubqueryState
|
||||||
SRetrieveSupport* pSupport = pSub->param;
|
SRetrieveSupport* pSupport = pSub->param;
|
||||||
|
|
||||||
taosTFree(pSupport->localBuffer);
|
taosTFree(pSupport->localBuffer);
|
||||||
|
|
||||||
pthread_mutex_unlock(&pSupport->queryMutex);
|
|
||||||
pthread_mutex_destroy(&pSupport->queryMutex);
|
|
||||||
|
|
||||||
taosTFree(pSupport);
|
taosTFree(pSupport);
|
||||||
|
|
||||||
tscFreeSqlObj(pSub);
|
tscFreeSqlObj(pSub);
|
||||||
|
@ -1408,14 +1426,7 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
|
||||||
trs->pParentSql = pSql;
|
trs->pParentSql = pSql;
|
||||||
trs->pFinalColModel = pModel;
|
trs->pFinalColModel = pModel;
|
||||||
|
|
||||||
pthread_mutexattr_t mutexattr;
|
SSqlObj *pNew = tscCreateSTableSubquery(pSql, trs, NULL);
|
||||||
memset(&mutexattr, 0, sizeof(pthread_mutexattr_t));
|
|
||||||
|
|
||||||
pthread_mutexattr_settype(&mutexattr, PTHREAD_MUTEX_RECURSIVE_NP);
|
|
||||||
pthread_mutex_init(&trs->queryMutex, &mutexattr);
|
|
||||||
pthread_mutexattr_destroy(&mutexattr);
|
|
||||||
|
|
||||||
SSqlObj *pNew = tscCreateSqlObjForSubquery(pSql, trs, NULL);
|
|
||||||
if (pNew == NULL) {
|
if (pNew == NULL) {
|
||||||
tscError("%p failed to malloc buffer for subObj, orderOfSub:%d, reason:%s", pSql, i, strerror(errno));
|
tscError("%p failed to malloc buffer for subObj, orderOfSub:%d, reason:%s", pSql, i, strerror(errno));
|
||||||
taosTFree(trs->localBuffer);
|
taosTFree(trs->localBuffer);
|
||||||
|
@ -1460,15 +1471,16 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tscFreeSubSqlObj(SRetrieveSupport *trsupport, SSqlObj *pSql) {
|
static void tscFreeSubSqlObj(SRetrieveSupport *trsupport, SSqlObj *pSql) {
|
||||||
tscDebug("%p start to free subquery result", pSql);
|
tscDebug("%p start to free subquery obj", pSql);
|
||||||
|
|
||||||
|
int32_t index = trsupport->subqueryIndex;
|
||||||
|
SSqlObj *pParentSql = trsupport->pParentSql;
|
||||||
|
|
||||||
|
assert(pSql == pParentSql->pSubs[index]);
|
||||||
|
pParentSql->pSubs[index] = NULL;
|
||||||
|
|
||||||
taos_free_result(pSql);
|
taos_free_result(pSql);
|
||||||
|
|
||||||
taosTFree(trsupport->localBuffer);
|
taosTFree(trsupport->localBuffer);
|
||||||
|
|
||||||
pthread_mutex_unlock(&trsupport->queryMutex);
|
|
||||||
pthread_mutex_destroy(&trsupport->queryMutex);
|
|
||||||
|
|
||||||
taosTFree(trsupport);
|
taosTFree(trsupport);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1477,23 +1489,11 @@ static void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, i
|
||||||
|
|
||||||
static void tscAbortFurtherRetryRetrieval(SRetrieveSupport *trsupport, TAOS_RES *tres, int32_t code) {
|
static void tscAbortFurtherRetryRetrieval(SRetrieveSupport *trsupport, TAOS_RES *tres, int32_t code) {
|
||||||
// set no disk space error info
|
// set no disk space error info
|
||||||
#ifdef WINDOWS
|
|
||||||
LPVOID lpMsgBuf;
|
|
||||||
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
|
|
||||||
GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
|
|
||||||
(LPTSTR)&lpMsgBuf, 0, NULL);
|
|
||||||
tscError("sub:%p failed to flush data to disk:reason:%s", tres, lpMsgBuf);
|
|
||||||
LocalFree(lpMsgBuf);
|
|
||||||
#else
|
|
||||||
tscError("sub:%p failed to flush data to disk, reason:%s", tres, tstrerror(code));
|
tscError("sub:%p failed to flush data to disk, reason:%s", tres, tstrerror(code));
|
||||||
#endif
|
|
||||||
|
|
||||||
SSqlObj* pParentSql = trsupport->pParentSql;
|
SSqlObj* pParentSql = trsupport->pParentSql;
|
||||||
|
|
||||||
pParentSql->res.code = code;
|
pParentSql->res.code = code;
|
||||||
trsupport->numOfRetry = MAX_NUM_OF_SUBQUERY_RETRY;
|
trsupport->numOfRetry = MAX_NUM_OF_SUBQUERY_RETRY;
|
||||||
|
|
||||||
pthread_mutex_unlock(&trsupport->queryMutex);
|
|
||||||
tscHandleSubqueryError(trsupport, tres, pParentSql->res.code);
|
tscHandleSubqueryError(trsupport, tres, pParentSql->res.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1512,13 +1512,10 @@ static int32_t tscReissueSubquery(SRetrieveSupport *trsupport, SSqlObj *pSql, in
|
||||||
|
|
||||||
// clear local saved number of results
|
// clear local saved number of results
|
||||||
trsupport->localBuffer->num = 0;
|
trsupport->localBuffer->num = 0;
|
||||||
pthread_mutex_unlock(&trsupport->queryMutex);
|
tscError("%p sub:%p retrieve/query failed, code:%s, orderOfSub:%d, retry:%d", trsupport->pParentSql, pSql,
|
||||||
|
|
||||||
tscTrace("%p sub:%p retrieve failed, code:%s, orderOfSub:%d, retry:%d", trsupport->pParentSql, pSql,
|
|
||||||
tstrerror(code), subqueryIndex, trsupport->numOfRetry);
|
tstrerror(code), subqueryIndex, trsupport->numOfRetry);
|
||||||
|
|
||||||
SSqlObj *pNew = tscCreateSqlObjForSubquery(trsupport->pParentSql, trsupport, pSql);
|
SSqlObj *pNew = tscCreateSTableSubquery(trsupport->pParentSql, trsupport, pSql);
|
||||||
|
|
||||||
if (pNew == NULL) {
|
if (pNew == NULL) {
|
||||||
tscError("%p sub:%p failed to create new subquery due to error:%s, abort retry, vgId:%d, orderOfSub:%d",
|
tscError("%p sub:%p failed to create new subquery due to error:%s, abort retry, vgId:%d, orderOfSub:%d",
|
||||||
trsupport->pParentSql, pSql, tstrerror(terrno), pVgroup->vgId, trsupport->subqueryIndex);
|
trsupport->pParentSql, pSql, tstrerror(terrno), pVgroup->vgId, trsupport->subqueryIndex);
|
||||||
|
@ -1529,8 +1526,15 @@ static int32_t tscReissueSubquery(SRetrieveSupport *trsupport, SSqlObj *pSql, in
|
||||||
return pParentSql->res.code;
|
return pParentSql->res.code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t ret = tscProcessSql(pNew);
|
||||||
|
|
||||||
|
// if failed to process sql, let following code handle the pSql
|
||||||
|
if (ret == TSDB_CODE_SUCCESS) {
|
||||||
taos_free_result(pSql);
|
taos_free_result(pSql);
|
||||||
return tscProcessSql(pNew);
|
return ret;
|
||||||
|
} else {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numOfRows) {
|
void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numOfRows) {
|
||||||
|
@ -1550,14 +1554,14 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO
|
||||||
*/
|
*/
|
||||||
pSql->res.numOfRows = 0;
|
pSql->res.numOfRows = 0;
|
||||||
trsupport->numOfRetry = MAX_NUM_OF_SUBQUERY_RETRY; // disable retry efforts
|
trsupport->numOfRetry = MAX_NUM_OF_SUBQUERY_RETRY; // disable retry efforts
|
||||||
tscDebug("%p query is cancelled, sub:%p, orderOfSub:%d abort retrieve, code:%d", pParentSql, pSql,
|
tscDebug("%p query is cancelled, sub:%p, orderOfSub:%d abort retrieve, code:%s", pParentSql, pSql,
|
||||||
subqueryIndex, pParentSql->res.code);
|
subqueryIndex, tstrerror(pParentSql->res.code));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numOfRows >= 0) { // current query is successful, but other sub query failed, still abort current query.
|
if (numOfRows >= 0) { // current query is successful, but other sub query failed, still abort current query.
|
||||||
tscDebug("%p sub:%p retrieve numOfRows:%d,orderOfSub:%d", pParentSql, pSql, numOfRows, subqueryIndex);
|
tscDebug("%p sub:%p retrieve numOfRows:%d,orderOfSub:%d", pParentSql, pSql, numOfRows, subqueryIndex);
|
||||||
tscError("%p sub:%p abort further retrieval due to other queries failure,orderOfSub:%d,code:%d", pParentSql, pSql,
|
tscError("%p sub:%p abort further retrieval due to other queries failure,orderOfSub:%d,code:%s", pParentSql, pSql,
|
||||||
subqueryIndex, pParentSql->res.code);
|
subqueryIndex, tstrerror(pParentSql->res.code));
|
||||||
} else {
|
} else {
|
||||||
if (trsupport->numOfRetry++ < MAX_NUM_OF_SUBQUERY_RETRY && pParentSql->res.code == TSDB_CODE_SUCCESS) {
|
if (trsupport->numOfRetry++ < MAX_NUM_OF_SUBQUERY_RETRY && pParentSql->res.code == TSDB_CODE_SUCCESS) {
|
||||||
if (tscReissueSubquery(trsupport, pSql, numOfRows) == TSDB_CODE_SUCCESS) {
|
if (tscReissueSubquery(trsupport, pSql, numOfRows) == TSDB_CODE_SUCCESS) {
|
||||||
|
@ -1687,24 +1691,22 @@ static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfR
|
||||||
int32_t idx = trsupport->subqueryIndex;
|
int32_t idx = trsupport->subqueryIndex;
|
||||||
SSqlObj * pParentSql = trsupport->pParentSql;
|
SSqlObj * pParentSql = trsupport->pParentSql;
|
||||||
|
|
||||||
|
assert(tres != NULL);
|
||||||
SSqlObj *pSql = (SSqlObj *)tres;
|
SSqlObj *pSql = (SSqlObj *)tres;
|
||||||
if (pSql == NULL) { // sql object has been released in error process, return immediately
|
// if (pSql == NULL) { // sql object has been released in error process, return immediately
|
||||||
tscDebug("%p subquery has been released, idx:%d, abort", pParentSql, idx);
|
// tscDebug("%p subquery has been released, idx:%d, abort", pParentSql, idx);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
SSubqueryState* pState = trsupport->pState;
|
SSubqueryState* pState = trsupport->pState;
|
||||||
assert(pState->numOfRemain <= pState->numOfTotal && pState->numOfRemain >= 0 && pParentSql->numOfSubs == pState->numOfTotal);
|
assert(pState->numOfRemain <= pState->numOfTotal && pState->numOfRemain >= 0 && pParentSql->numOfSubs == pState->numOfTotal);
|
||||||
|
|
||||||
// query process and cancel query process may execute at the same time
|
|
||||||
pthread_mutex_lock(&trsupport->queryMutex);
|
|
||||||
|
|
||||||
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(&pSql->cmd, 0, 0);
|
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(&pSql->cmd, 0, 0);
|
||||||
SCMVgroupInfo* pVgroup = &pTableMetaInfo->vgroupList->vgroups[0];
|
SCMVgroupInfo *pVgroup = &pTableMetaInfo->vgroupList->vgroups[0];
|
||||||
|
|
||||||
if (pParentSql->res.code != TSDB_CODE_SUCCESS) {
|
if (pParentSql->res.code != TSDB_CODE_SUCCESS) {
|
||||||
trsupport->numOfRetry = MAX_NUM_OF_SUBQUERY_RETRY;
|
trsupport->numOfRetry = MAX_NUM_OF_SUBQUERY_RETRY;
|
||||||
tscTrace("%p query cancelled or failed, sub:%p, vgId:%d, orderOfSub:%d, code:%s, global code:%s",
|
tscDebug("%p query cancelled/failed, sub:%p, vgId:%d, orderOfSub:%d, code:%s, global code:%s",
|
||||||
pParentSql, pSql, pVgroup->vgId, trsupport->subqueryIndex, tstrerror(numOfRows), tstrerror(pParentSql->res.code));
|
pParentSql, pSql, pVgroup->vgId, trsupport->subqueryIndex, tstrerror(numOfRows), tstrerror(pParentSql->res.code));
|
||||||
|
|
||||||
tscHandleSubqueryError(param, tres, numOfRows);
|
tscHandleSubqueryError(param, tres, numOfRows);
|
||||||
|
@ -1715,13 +1717,13 @@ static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfR
|
||||||
assert(numOfRows == taos_errno(pSql));
|
assert(numOfRows == taos_errno(pSql));
|
||||||
|
|
||||||
if (trsupport->numOfRetry++ < MAX_NUM_OF_SUBQUERY_RETRY) {
|
if (trsupport->numOfRetry++ < MAX_NUM_OF_SUBQUERY_RETRY) {
|
||||||
tscTrace("%p sub:%p failed code:%s, retry:%d", pParentSql, pSql, tstrerror(numOfRows), trsupport->numOfRetry);
|
tscError("%p sub:%p failed code:%s, retry:%d", pParentSql, pSql, tstrerror(numOfRows), trsupport->numOfRetry);
|
||||||
|
|
||||||
if (tscReissueSubquery(trsupport, pSql, numOfRows) == TSDB_CODE_SUCCESS) {
|
if (tscReissueSubquery(trsupport, pSql, numOfRows) == TSDB_CODE_SUCCESS) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tscTrace("%p sub:%p reach the max retry times, set global code:%s", pParentSql, pSql, tstrerror(numOfRows));
|
tscDebug("%p sub:%p reach the max retry times, set global code:%s", pParentSql, pSql, tstrerror(numOfRows));
|
||||||
atomic_val_compare_exchange_32(&pParentSql->res.code, TSDB_CODE_SUCCESS, numOfRows); // set global code and abort
|
atomic_val_compare_exchange_32(&pParentSql->res.code, TSDB_CODE_SUCCESS, numOfRows); // set global code and abort
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1766,13 +1768,9 @@ static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfR
|
||||||
(int32_t)pRes->numOfRows, pQueryInfo->groupbyExpr.orderType);
|
(int32_t)pRes->numOfRows, pQueryInfo->groupbyExpr.orderType);
|
||||||
if (ret != 0) { // set no disk space error info, and abort retry
|
if (ret != 0) { // set no disk space error info, and abort retry
|
||||||
tscAbortFurtherRetryRetrieval(trsupport, tres, TSDB_CODE_TSC_NO_DISKSPACE);
|
tscAbortFurtherRetryRetrieval(trsupport, tres, TSDB_CODE_TSC_NO_DISKSPACE);
|
||||||
|
|
||||||
} else if (pRes->completed) {
|
} else if (pRes->completed) {
|
||||||
tscAllDataRetrievedFromDnode(trsupport, pSql);
|
tscAllDataRetrievedFromDnode(trsupport, pSql);
|
||||||
return;
|
|
||||||
|
|
||||||
} else { // continue fetch data from dnode
|
} else { // continue fetch data from dnode
|
||||||
pthread_mutex_unlock(&trsupport->queryMutex);
|
|
||||||
taos_fetch_rows_a(tres, tscRetrieveFromDnodeCallBack, param);
|
taos_fetch_rows_a(tres, tscRetrieveFromDnodeCallBack, param);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1781,15 +1779,15 @@ static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfR
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static SSqlObj *tscCreateSqlObjForSubquery(SSqlObj *pSql, SRetrieveSupport *trsupport, SSqlObj *prevSqlObj) {
|
static SSqlObj *tscCreateSTableSubquery(SSqlObj *pSql, SRetrieveSupport *trsupport, SSqlObj *prevSqlObj) {
|
||||||
const int32_t table_index = 0;
|
const int32_t table_index = 0;
|
||||||
|
|
||||||
SSqlObj *pNew = createSubqueryObj(pSql, table_index, tscRetrieveDataRes, trsupport, TSDB_SQL_SELECT, prevSqlObj);
|
SSqlObj *pNew = createSubqueryObj(pSql, table_index, tscRetrieveDataRes, trsupport, TSDB_SQL_SELECT, prevSqlObj);
|
||||||
if (pNew != NULL) { // the sub query of two-stage super table query
|
if (pNew != NULL) { // the sub query of two-stage super table query
|
||||||
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(&pNew->cmd, 0);
|
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(&pNew->cmd, 0);
|
||||||
pQueryInfo->type |= TSDB_QUERY_TYPE_STABLE_SUBQUERY;
|
|
||||||
|
|
||||||
assert(pQueryInfo->numOfTables == 1 && pNew->cmd.numOfClause == 1);
|
pQueryInfo->type |= TSDB_QUERY_TYPE_STABLE_SUBQUERY;
|
||||||
|
assert(pQueryInfo->numOfTables == 1 && pNew->cmd.numOfClause == 1 && trsupport->subqueryIndex < pSql->numOfSubs);
|
||||||
|
|
||||||
// launch subquery for each vnode, so the subquery index equals to the vgroupIndex.
|
// launch subquery for each vnode, so the subquery index equals to the vgroupIndex.
|
||||||
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, table_index);
|
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, table_index);
|
||||||
|
@ -1816,7 +1814,7 @@ void tscRetrieveDataRes(void *param, TAOS_RES *tres, int code) {
|
||||||
// stable query killed or other subquery failed, all query stopped
|
// stable query killed or other subquery failed, all query stopped
|
||||||
if (pParentSql->res.code != TSDB_CODE_SUCCESS) {
|
if (pParentSql->res.code != TSDB_CODE_SUCCESS) {
|
||||||
trsupport->numOfRetry = MAX_NUM_OF_SUBQUERY_RETRY;
|
trsupport->numOfRetry = MAX_NUM_OF_SUBQUERY_RETRY;
|
||||||
tscTrace("%p query cancelled or failed, sub:%p, vgId:%d, orderOfSub:%d, code:%s, global code:%s",
|
tscError("%p query cancelled or failed, sub:%p, vgId:%d, orderOfSub:%d, code:%s, global code:%s",
|
||||||
pParentSql, pSql, pVgroup->vgId, trsupport->subqueryIndex, tstrerror(code), tstrerror(pParentSql->res.code));
|
pParentSql, pSql, pVgroup->vgId, trsupport->subqueryIndex, tstrerror(code), tstrerror(pParentSql->res.code));
|
||||||
|
|
||||||
tscHandleSubqueryError(param, tres, code);
|
tscHandleSubqueryError(param, tres, code);
|
||||||
|
@ -1834,12 +1832,12 @@ void tscRetrieveDataRes(void *param, TAOS_RES *tres, int code) {
|
||||||
assert(code == taos_errno(pSql));
|
assert(code == taos_errno(pSql));
|
||||||
|
|
||||||
if (trsupport->numOfRetry++ < MAX_NUM_OF_SUBQUERY_RETRY) {
|
if (trsupport->numOfRetry++ < MAX_NUM_OF_SUBQUERY_RETRY) {
|
||||||
tscTrace("%p sub:%p failed code:%s, retry:%d", pParentSql, pSql, tstrerror(code), trsupport->numOfRetry);
|
tscError("%p sub:%p failed code:%s, retry:%d", pParentSql, pSql, tstrerror(code), trsupport->numOfRetry);
|
||||||
if (tscReissueSubquery(trsupport, pSql, code) == TSDB_CODE_SUCCESS) {
|
if (tscReissueSubquery(trsupport, pSql, code) == TSDB_CODE_SUCCESS) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tscTrace("%p sub:%p reach the max retry times, set global code:%s", pParentSql, pSql, tstrerror(code));
|
tscError("%p sub:%p reach the max retry times, set global code:%s", pParentSql, pSql, tstrerror(code));
|
||||||
atomic_val_compare_exchange_32(&pParentSql->res.code, TSDB_CODE_SUCCESS, code); // set global code and abort
|
atomic_val_compare_exchange_32(&pParentSql->res.code, TSDB_CODE_SUCCESS, code); // set global code and abort
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1847,7 +1845,7 @@ void tscRetrieveDataRes(void *param, TAOS_RES *tres, int code) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tscTrace("%p sub:%p query complete, ep:%s, vgId:%d, orderOfSub:%d, retrieve data", trsupport->pParentSql, pSql,
|
tscDebug("%p sub:%p query complete, ep:%s, vgId:%d, orderOfSub:%d, retrieve data", trsupport->pParentSql, pSql,
|
||||||
pVgroup->epAddr[0].fqdn, pVgroup->vgId, trsupport->subqueryIndex);
|
pVgroup->epAddr[0].fqdn, pVgroup->vgId, trsupport->subqueryIndex);
|
||||||
|
|
||||||
if (pSql->res.qhandle == 0) { // qhandle is NULL, code is TSDB_CODE_SUCCESS means no results generated from this vnode
|
if (pSql->res.qhandle == 0) { // qhandle is NULL, code is TSDB_CODE_SUCCESS means no results generated from this vnode
|
||||||
|
@ -1926,8 +1924,14 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) {
|
||||||
size_t size = taosArrayGetSize(pCmd->pDataBlocks);
|
size_t size = taosArrayGetSize(pCmd->pDataBlocks);
|
||||||
assert(size > 0);
|
assert(size > 0);
|
||||||
|
|
||||||
pSql->pSubs = calloc(size, POINTER_BYTES);
|
// the number of already initialized subqueries
|
||||||
|
int32_t numOfSub = 0;
|
||||||
|
|
||||||
pSql->numOfSubs = (uint16_t)size;
|
pSql->numOfSubs = (uint16_t)size;
|
||||||
|
pSql->pSubs = calloc(size, POINTER_BYTES);
|
||||||
|
if (pSql->pSubs == NULL) {
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
|
|
||||||
tscDebug("%p submit data to %" PRIzu " vnode(s)", pSql, size);
|
tscDebug("%p submit data to %" PRIzu " vnode(s)", pSql, size);
|
||||||
|
|
||||||
|
@ -1936,10 +1940,13 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) {
|
||||||
pState->numOfRemain = pSql->numOfSubs;
|
pState->numOfRemain = pSql->numOfSubs;
|
||||||
|
|
||||||
pRes->code = TSDB_CODE_SUCCESS;
|
pRes->code = TSDB_CODE_SUCCESS;
|
||||||
int32_t numOfSub = 0;
|
|
||||||
|
|
||||||
while(numOfSub < pSql->numOfSubs) {
|
while(numOfSub < pSql->numOfSubs) {
|
||||||
SInsertSupporter* pSupporter = calloc(1, sizeof(SInsertSupporter));
|
SInsertSupporter* pSupporter = calloc(1, sizeof(SInsertSupporter));
|
||||||
|
if (pSupporter == NULL) {
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
|
|
||||||
pSupporter->pSql = pSql;
|
pSupporter->pSql = pSql;
|
||||||
pSupporter->pState = pState;
|
pSupporter->pState = pState;
|
||||||
pSupporter->index = numOfSub;
|
pSupporter->index = numOfSub;
|
||||||
|
@ -1972,7 +1979,7 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) {
|
||||||
if (numOfSub < pSql->numOfSubs) {
|
if (numOfSub < pSql->numOfSubs) {
|
||||||
tscError("%p failed to prepare subObj structure and launch sub-insertion", pSql);
|
tscError("%p failed to prepare subObj structure and launch sub-insertion", pSql);
|
||||||
pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
return pRes->code; // free all allocated resource
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
pCmd->pDataBlocks = tscDestroyBlockArrayList(pCmd->pDataBlocks);
|
pCmd->pDataBlocks = tscDestroyBlockArrayList(pCmd->pDataBlocks);
|
||||||
|
@ -2070,46 +2077,8 @@ void tscBuildResFromSubqueries(SSqlObj *pSql) {
|
||||||
|
|
||||||
doBuildResFromSubqueries(pSql);
|
doBuildResFromSubqueries(pSql);
|
||||||
tsem_post(&pSql->rspSem);
|
tsem_post(&pSql->rspSem);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// continue retrieve data from vnode
|
|
||||||
// if (!tscHasRemainDataInSubqueryResultSet(pSql)) {
|
|
||||||
// tscDebug("%p at least one subquery exhausted, free all other %d subqueries", pSql, pSql->numOfSubs - 1);
|
|
||||||
// SSubqueryState* pState = NULL;
|
|
||||||
//
|
|
||||||
// // free all sub sqlobj
|
|
||||||
// for (int32_t i = 0; i < pSql->numOfSubs; ++i) {
|
|
||||||
// SSqlObj* pChildObj = pSql->pSubs[i];
|
|
||||||
// if (pChildObj == NULL) {
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// SJoinSupporter* pSupporter = (SJoinSupporter*)pChildObj->param;
|
|
||||||
// pState = pSupporter->pState;
|
|
||||||
//
|
|
||||||
// tscDestroyJoinSupporter(pChildObj->param);
|
|
||||||
// taos_free_result(pChildObj);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// free(pState);
|
|
||||||
//
|
|
||||||
// pRes->completed = true; // set query completed
|
|
||||||
// tsem_post(&pSql->rspSem);
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// tscFetchDatablockFromSubquery(pSql);
|
|
||||||
// if (pRes->code != TSDB_CODE_SUCCESS) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (pSql->res.code == TSDB_CODE_SUCCESS) {
|
|
||||||
// (*pSql->fp)(pSql->param, pSql, pRes->numOfRows);
|
|
||||||
// } else {
|
|
||||||
// tscQueueAsyncRes(pSql);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void transferNcharData(SSqlObj *pSql, int32_t columnIndex, TAOS_FIELD *pField) {
|
static void transferNcharData(SSqlObj *pSql, int32_t columnIndex, TAOS_FIELD *pField) {
|
||||||
|
@ -2159,7 +2128,6 @@ void **doSetResultRowData(SSqlObj *pSql, bool finalResult) {
|
||||||
SSqlRes *pRes = &pSql->res;
|
SSqlRes *pRes = &pSql->res;
|
||||||
|
|
||||||
assert(pRes->row >= 0 && pRes->row <= pRes->numOfRows);
|
assert(pRes->row >= 0 && pRes->row <= pRes->numOfRows);
|
||||||
|
|
||||||
if (pRes->row >= pRes->numOfRows) { // all the results has returned to invoker
|
if (pRes->row >= pRes->numOfRows) { // all the results has returned to invoker
|
||||||
taosTFree(pRes->tsrow);
|
taosTFree(pRes->tsrow);
|
||||||
return pRes->tsrow;
|
return pRes->tsrow;
|
||||||
|
|
|
@ -388,6 +388,7 @@ void tscFreeSqlObj(SSqlObj* pSql) {
|
||||||
|
|
||||||
taosTFree(pSql->sqlstr);
|
taosTFree(pSql->sqlstr);
|
||||||
tsem_destroy(&pSql->rspSem);
|
tsem_destroy(&pSql->rspSem);
|
||||||
|
|
||||||
free(pSql);
|
free(pSql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -485,15 +486,6 @@ int32_t tscCopyDataBlockToPayload(SSqlObj* pSql, STableDataBlocks* pDataBlock) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
//void tscFreeUnusedDataBlocks(SDataBlockList* pList) {
|
|
||||||
// /* release additional memory consumption */
|
|
||||||
// for (int32_t i = 0; i < pList->nSize; ++i) {
|
|
||||||
// STableDataBlocks* pDataBlock = pList->pData[i];
|
|
||||||
// pDataBlock->pData = realloc(pDataBlock->pData, pDataBlock->size);
|
|
||||||
// pDataBlock->nAllocSize = (uint32_t)pDataBlock->size;
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create the in-memory buffer for each table to keep the submitted data block
|
* create the in-memory buffer for each table to keep the submitted data block
|
||||||
* @param initialSize
|
* @param initialSize
|
||||||
|
@ -518,6 +510,11 @@ int32_t tscCreateDataBlock(size_t initialSize, int32_t rowSize, int32_t startOff
|
||||||
}
|
}
|
||||||
|
|
||||||
dataBuf->pData = calloc(1, dataBuf->nAllocSize);
|
dataBuf->pData = calloc(1, dataBuf->nAllocSize);
|
||||||
|
if (dataBuf->pData == NULL) {
|
||||||
|
tscError("failed to allocated memory, reason:%s", strerror(errno));
|
||||||
|
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
dataBuf->ordered = true;
|
dataBuf->ordered = true;
|
||||||
dataBuf->prevTS = INT64_MIN;
|
dataBuf->prevTS = INT64_MIN;
|
||||||
|
|
||||||
|
@ -742,7 +739,7 @@ bool tscIsInsertData(char* sqlstr) {
|
||||||
int32_t index = 0;
|
int32_t index = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
SSQLToken t0 = tStrGetToken(sqlstr, &index, false, 0, NULL);
|
SStrToken t0 = tStrGetToken(sqlstr, &index, false, 0, NULL);
|
||||||
if (t0.type != TK_LP) {
|
if (t0.type != TK_LP) {
|
||||||
return t0.type == TK_INSERT || t0.type == TK_IMPORT;
|
return t0.type == TK_INSERT || t0.type == TK_IMPORT;
|
||||||
}
|
}
|
||||||
|
@ -926,17 +923,23 @@ void tscFieldInfoClear(SFieldInfo* pFieldInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static SSqlExpr* doBuildSqlExpr(SQueryInfo* pQueryInfo, int16_t functionId, SColumnIndex* pColIndex, int16_t type,
|
static SSqlExpr* doBuildSqlExpr(SQueryInfo* pQueryInfo, int16_t functionId, SColumnIndex* pColIndex, int16_t type,
|
||||||
int16_t size, int16_t interSize, bool isTagCol) {
|
int16_t size, int16_t interSize, int32_t colType) {
|
||||||
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, pColIndex->tableIndex);
|
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, pColIndex->tableIndex);
|
||||||
|
|
||||||
SSqlExpr* pExpr = calloc(1, sizeof(SSqlExpr));
|
SSqlExpr* pExpr = calloc(1, sizeof(SSqlExpr));
|
||||||
|
if (pExpr == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
pExpr->functionId = functionId;
|
pExpr->functionId = functionId;
|
||||||
|
|
||||||
// set the correct columnIndex index
|
// set the correct columnIndex index
|
||||||
if (pColIndex->columnIndex == TSDB_TBNAME_COLUMN_INDEX) {
|
if (pColIndex->columnIndex == TSDB_TBNAME_COLUMN_INDEX) {
|
||||||
pExpr->colInfo.colId = TSDB_TBNAME_COLUMN_INDEX;
|
pExpr->colInfo.colId = TSDB_TBNAME_COLUMN_INDEX;
|
||||||
|
} else if (pColIndex->columnIndex <= TSDB_UD_COLUMN_INDEX) {
|
||||||
|
pExpr->colInfo.colId = pColIndex->columnIndex;
|
||||||
} else {
|
} else {
|
||||||
if (isTagCol) {
|
if (TSDB_COL_IS_TAG(colType)) {
|
||||||
SSchema* pSchema = tscGetTableTagSchema(pTableMetaInfo->pTableMeta);
|
SSchema* pSchema = tscGetTableTagSchema(pTableMetaInfo->pTableMeta);
|
||||||
pExpr->colInfo.colId = pSchema[pColIndex->columnIndex].colId;
|
pExpr->colInfo.colId = pSchema[pColIndex->columnIndex].colId;
|
||||||
tstrncpy(pExpr->colInfo.name, pSchema[pColIndex->columnIndex].name, sizeof(pExpr->colInfo.name));
|
tstrncpy(pExpr->colInfo.name, pSchema[pColIndex->columnIndex].name, sizeof(pExpr->colInfo.name));
|
||||||
|
@ -948,9 +951,9 @@ static SSqlExpr* doBuildSqlExpr(SQueryInfo* pQueryInfo, int16_t functionId, SCol
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pExpr->colInfo.flag = isTagCol? TSDB_COL_TAG:TSDB_COL_NORMAL;
|
pExpr->colInfo.flag = colType;
|
||||||
|
|
||||||
pExpr->colInfo.colIndex = pColIndex->columnIndex;
|
pExpr->colInfo.colIndex = pColIndex->columnIndex;
|
||||||
|
|
||||||
pExpr->resType = type;
|
pExpr->resType = type;
|
||||||
pExpr->resBytes = size;
|
pExpr->resBytes = size;
|
||||||
pExpr->interBytes = interSize;
|
pExpr->interBytes = interSize;
|
||||||
|
@ -1060,8 +1063,11 @@ void tscSqlExprCopy(SArray* dst, const SArray* src, uint64_t uid, bool deepcopy)
|
||||||
|
|
||||||
if (deepcopy) {
|
if (deepcopy) {
|
||||||
SSqlExpr* p1 = calloc(1, sizeof(SSqlExpr));
|
SSqlExpr* p1 = calloc(1, sizeof(SSqlExpr));
|
||||||
*p1 = *pExpr;
|
if (p1 == NULL) {
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
*p1 = *pExpr;
|
||||||
for (int32_t j = 0; j < pExpr->numOfParams; ++j) {
|
for (int32_t j = 0; j < pExpr->numOfParams; ++j) {
|
||||||
tVariantAssign(&p1->param[j], &pExpr->param[j]);
|
tVariantAssign(&p1->param[j], &pExpr->param[j]);
|
||||||
}
|
}
|
||||||
|
@ -1097,16 +1103,22 @@ SColumn* tscColumnListInsert(SArray* pColumnList, SColumnIndex* pColIndex) {
|
||||||
|
|
||||||
if (i >= numOfCols || numOfCols == 0) {
|
if (i >= numOfCols || numOfCols == 0) {
|
||||||
SColumn* b = calloc(1, sizeof(SColumn));
|
SColumn* b = calloc(1, sizeof(SColumn));
|
||||||
b->colIndex = *pColIndex;
|
if (b == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
b->colIndex = *pColIndex;
|
||||||
taosArrayInsert(pColumnList, i, &b);
|
taosArrayInsert(pColumnList, i, &b);
|
||||||
} else {
|
} else {
|
||||||
SColumn* pCol = taosArrayGetP(pColumnList, i);
|
SColumn* pCol = taosArrayGetP(pColumnList, i);
|
||||||
|
|
||||||
if (i < numOfCols && (pCol->colIndex.columnIndex > col || pCol->colIndex.tableIndex != pColIndex->tableIndex)) {
|
if (i < numOfCols && (pCol->colIndex.columnIndex > col || pCol->colIndex.tableIndex != pColIndex->tableIndex)) {
|
||||||
SColumn* b = calloc(1, sizeof(SColumn));
|
SColumn* b = calloc(1, sizeof(SColumn));
|
||||||
b->colIndex = *pColIndex;
|
if (b == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
b->colIndex = *pColIndex;
|
||||||
taosArrayInsert(pColumnList, i, &b);
|
taosArrayInsert(pColumnList, i, &b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1128,6 +1140,9 @@ SColumn* tscColumnClone(const SColumn* src) {
|
||||||
assert(src != NULL);
|
assert(src != NULL);
|
||||||
|
|
||||||
SColumn* dst = calloc(1, sizeof(SColumn));
|
SColumn* dst = calloc(1, sizeof(SColumn));
|
||||||
|
if (dst == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
dst->colIndex = src->colIndex;
|
dst->colIndex = src->colIndex;
|
||||||
dst->numOfFilters = src->numOfFilters;
|
dst->numOfFilters = src->numOfFilters;
|
||||||
|
@ -1183,7 +1198,7 @@ void tscColumnListDestroy(SArray* pColumnList) {
|
||||||
* 'first_part.second_part'
|
* 'first_part.second_part'
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static int32_t validateQuoteToken(SSQLToken* pToken) {
|
static int32_t validateQuoteToken(SStrToken* pToken) {
|
||||||
strdequote(pToken->z);
|
strdequote(pToken->z);
|
||||||
pToken->n = (uint32_t)strtrim(pToken->z);
|
pToken->n = (uint32_t)strtrim(pToken->z);
|
||||||
|
|
||||||
|
@ -1199,7 +1214,7 @@ static int32_t validateQuoteToken(SSQLToken* pToken) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tscValidateName(SSQLToken* pToken) {
|
int32_t tscValidateName(SStrToken* pToken) {
|
||||||
if (pToken->type != TK_STRING && pToken->type != TK_ID) {
|
if (pToken->type != TK_STRING && pToken->type != TK_ID) {
|
||||||
return TSDB_CODE_TSC_INVALID_SQL;
|
return TSDB_CODE_TSC_INVALID_SQL;
|
||||||
}
|
}
|
||||||
|
@ -1286,12 +1301,12 @@ void tscIncStreamExecutionCount(void* pStream) {
|
||||||
ps->num += 1;
|
ps->num += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tscValidateColumnId(STableMetaInfo* pTableMetaInfo, int32_t colId) {
|
bool tscValidateColumnId(STableMetaInfo* pTableMetaInfo, int32_t colId, int32_t numOfParams) {
|
||||||
if (pTableMetaInfo->pTableMeta == NULL) {
|
if (pTableMetaInfo->pTableMeta == NULL) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (colId == TSDB_TBNAME_COLUMN_INDEX) {
|
if (colId == TSDB_TBNAME_COLUMN_INDEX || (colId <= TSDB_UD_COLUMN_INDEX && numOfParams == 2)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1338,6 +1353,10 @@ void tscTagCondCopy(STagCond* dest, const STagCond* src) {
|
||||||
if (pCond->len > 0) {
|
if (pCond->len > 0) {
|
||||||
assert(pCond->cond != NULL);
|
assert(pCond->cond != NULL);
|
||||||
c.cond = malloc(c.len);
|
c.cond = malloc(c.len);
|
||||||
|
if (c.cond == NULL) {
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
memcpy(c.cond, pCond->cond, c.len);
|
memcpy(c.cond, pCond->cond, c.len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1463,20 +1482,20 @@ STableMetaInfo* tscGetMetaInfo(SQueryInfo* pQueryInfo, int32_t tableIndex) {
|
||||||
return pQueryInfo->pTableMetaInfo[tableIndex];
|
return pQueryInfo->pTableMetaInfo[tableIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tscGetQueryInfoDetailSafely(SSqlCmd* pCmd, int32_t subClauseIndex, SQueryInfo** pQueryInfo) {
|
SQueryInfo* tscGetQueryInfoDetailSafely(SSqlCmd* pCmd, int32_t subClauseIndex) {
|
||||||
|
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, subClauseIndex);
|
||||||
int32_t ret = TSDB_CODE_SUCCESS;
|
int32_t ret = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
*pQueryInfo = tscGetQueryInfoDetail(pCmd, subClauseIndex);
|
while ((pQueryInfo) == NULL) {
|
||||||
|
|
||||||
while ((*pQueryInfo) == NULL) {
|
|
||||||
if ((ret = tscAddSubqueryInfo(pCmd)) != TSDB_CODE_SUCCESS) {
|
if ((ret = tscAddSubqueryInfo(pCmd)) != TSDB_CODE_SUCCESS) {
|
||||||
return ret;
|
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
(*pQueryInfo) = tscGetQueryInfoDetail(pCmd, subClauseIndex);
|
pQueryInfo = tscGetQueryInfoDetail(pCmd, subClauseIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return pQueryInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
STableMetaInfo* tscGetTableMetaInfoByUid(SQueryInfo* pQueryInfo, uint64_t uid, int32_t* index) {
|
STableMetaInfo* tscGetTableMetaInfoByUid(SQueryInfo* pQueryInfo, uint64_t uid, int32_t* index) {
|
||||||
|
@ -1507,6 +1526,7 @@ void tscInitQueryInfo(SQueryInfo* pQueryInfo) {
|
||||||
assert(pQueryInfo->exprList == NULL);
|
assert(pQueryInfo->exprList == NULL);
|
||||||
pQueryInfo->exprList = taosArrayInit(4, POINTER_BYTES);
|
pQueryInfo->exprList = taosArrayInit(4, POINTER_BYTES);
|
||||||
pQueryInfo->colList = taosArrayInit(4, POINTER_BYTES);
|
pQueryInfo->colList = taosArrayInit(4, POINTER_BYTES);
|
||||||
|
pQueryInfo->udColumnId = TSDB_UD_COLUMN_INDEX;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tscAddSubqueryInfo(SSqlCmd* pCmd) {
|
int32_t tscAddSubqueryInfo(SSqlCmd* pCmd) {
|
||||||
|
@ -1522,8 +1542,11 @@ int32_t tscAddSubqueryInfo(SSqlCmd* pCmd) {
|
||||||
pCmd->pQueryInfo = (SQueryInfo**)tmp;
|
pCmd->pQueryInfo = (SQueryInfo**)tmp;
|
||||||
|
|
||||||
SQueryInfo* pQueryInfo = calloc(1, sizeof(SQueryInfo));
|
SQueryInfo* pQueryInfo = calloc(1, sizeof(SQueryInfo));
|
||||||
tscInitQueryInfo(pQueryInfo);
|
if (pQueryInfo == NULL) {
|
||||||
|
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
tscInitQueryInfo(pQueryInfo);
|
||||||
pQueryInfo->msg = pCmd->payload; // pointer to the parent error message buffer
|
pQueryInfo->msg = pCmd->payload; // pointer to the parent error message buffer
|
||||||
|
|
||||||
pCmd->pQueryInfo[pCmd->numOfClause++] = pQueryInfo;
|
pCmd->pQueryInfo[pCmd->numOfClause++] = pQueryInfo;
|
||||||
|
@ -1584,14 +1607,18 @@ STableMetaInfo* tscAddTableMetaInfo(SQueryInfo* pQueryInfo, const char* name, ST
|
||||||
SVgroupsInfo* vgroupList, SArray* pTagCols) {
|
SVgroupsInfo* vgroupList, SArray* pTagCols) {
|
||||||
void* pAlloc = realloc(pQueryInfo->pTableMetaInfo, (pQueryInfo->numOfTables + 1) * POINTER_BYTES);
|
void* pAlloc = realloc(pQueryInfo->pTableMetaInfo, (pQueryInfo->numOfTables + 1) * POINTER_BYTES);
|
||||||
if (pAlloc == NULL) {
|
if (pAlloc == NULL) {
|
||||||
|
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pQueryInfo->pTableMetaInfo = pAlloc;
|
pQueryInfo->pTableMetaInfo = pAlloc;
|
||||||
pQueryInfo->pTableMetaInfo[pQueryInfo->numOfTables] = calloc(1, sizeof(STableMetaInfo));
|
STableMetaInfo* pTableMetaInfo = calloc(1, sizeof(STableMetaInfo));
|
||||||
|
if (pTableMetaInfo == NULL) {
|
||||||
|
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
STableMetaInfo* pTableMetaInfo = pQueryInfo->pTableMetaInfo[pQueryInfo->numOfTables];
|
pQueryInfo->pTableMetaInfo[pQueryInfo->numOfTables] = pTableMetaInfo;
|
||||||
assert(pTableMetaInfo != NULL);
|
|
||||||
|
|
||||||
if (name != NULL) {
|
if (name != NULL) {
|
||||||
tstrncpy(pTableMetaInfo->name, name, sizeof(pTableMetaInfo->name));
|
tstrncpy(pTableMetaInfo->name, name, sizeof(pTableMetaInfo->name));
|
||||||
|
@ -1602,10 +1629,18 @@ STableMetaInfo* tscAddTableMetaInfo(SQueryInfo* pQueryInfo, const char* name, ST
|
||||||
if (vgroupList != NULL) {
|
if (vgroupList != NULL) {
|
||||||
size_t size = sizeof(SVgroupsInfo) + sizeof(SCMVgroupInfo) * vgroupList->numOfVgroups;
|
size_t size = sizeof(SVgroupsInfo) + sizeof(SCMVgroupInfo) * vgroupList->numOfVgroups;
|
||||||
pTableMetaInfo->vgroupList = malloc(size);
|
pTableMetaInfo->vgroupList = malloc(size);
|
||||||
|
if (pTableMetaInfo->vgroupList == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
memcpy(pTableMetaInfo->vgroupList, vgroupList, size);
|
memcpy(pTableMetaInfo->vgroupList, vgroupList, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
pTableMetaInfo->tagColList = taosArrayInit(4, POINTER_BYTES);
|
pTableMetaInfo->tagColList = taosArrayInit(4, POINTER_BYTES);
|
||||||
|
if (pTableMetaInfo->tagColList == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (pTagCols != NULL) {
|
if (pTagCols != NULL) {
|
||||||
tscColumnListCopy(pTableMetaInfo->tagColList, pTagCols, -1);
|
tscColumnListCopy(pTableMetaInfo->tagColList, pTagCols, -1);
|
||||||
}
|
}
|
||||||
|
@ -1671,8 +1706,7 @@ SSqlObj* createSimpleSubObj(SSqlObj* pSql, void (*fp)(), void* param, int32_t cm
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SQueryInfo* pQueryInfo = NULL;
|
SQueryInfo* pQueryInfo = tscGetQueryInfoDetailSafely(pCmd, 0);
|
||||||
tscGetQueryInfoDetailSafely(pCmd, 0, &pQueryInfo);
|
|
||||||
|
|
||||||
assert(pSql->cmd.clauseIndex == 0);
|
assert(pSql->cmd.clauseIndex == 0);
|
||||||
STableMetaInfo* pMasterTableMetaInfo = tscGetTableMetaInfoFromCmd(&pSql->cmd, pSql->cmd.clauseIndex, 0);
|
STableMetaInfo* pMasterTableMetaInfo = tscGetTableMetaInfoFromCmd(&pSql->cmd, pSql->cmd.clauseIndex, 0);
|
||||||
|
@ -1754,6 +1788,7 @@ static void doSetSqlExprAndResultFieldInfo(SQueryInfo* pQueryInfo, SQueryInfo* p
|
||||||
|
|
||||||
SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void* param, int32_t cmd, SSqlObj* pPrevSql) {
|
SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void* param, int32_t cmd, SSqlObj* pPrevSql) {
|
||||||
SSqlCmd* pCmd = &pSql->cmd;
|
SSqlCmd* pCmd = &pSql->cmd;
|
||||||
|
|
||||||
SSqlObj* pNew = (SSqlObj*)calloc(1, sizeof(SSqlObj));
|
SSqlObj* pNew = (SSqlObj*)calloc(1, sizeof(SSqlObj));
|
||||||
if (pNew == NULL) {
|
if (pNew == NULL) {
|
||||||
tscError("%p new subquery failed, tableIndex:%d", pSql, tableIndex);
|
tscError("%p new subquery failed, tableIndex:%d", pSql, tableIndex);
|
||||||
|
@ -1769,10 +1804,8 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
|
||||||
pNew->sqlstr = strdup(pSql->sqlstr);
|
pNew->sqlstr = strdup(pSql->sqlstr);
|
||||||
if (pNew->sqlstr == NULL) {
|
if (pNew->sqlstr == NULL) {
|
||||||
tscError("%p new subquery failed, tableIndex:%d, vgroupIndex:%d", pSql, tableIndex, pTableMetaInfo->vgroupIndex);
|
tscError("%p new subquery failed, tableIndex:%d, vgroupIndex:%d", pSql, tableIndex, pTableMetaInfo->vgroupIndex);
|
||||||
|
|
||||||
free(pNew);
|
|
||||||
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
return NULL;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSqlCmd* pnCmd = &pNew->cmd;
|
SSqlCmd* pnCmd = &pNew->cmd;
|
||||||
|
@ -1789,9 +1822,8 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
|
||||||
pnCmd->parseFinished = 1;
|
pnCmd->parseFinished = 1;
|
||||||
|
|
||||||
if (tscAddSubqueryInfo(pnCmd) != TSDB_CODE_SUCCESS) {
|
if (tscAddSubqueryInfo(pnCmd) != TSDB_CODE_SUCCESS) {
|
||||||
tscFreeSqlObj(pNew);
|
|
||||||
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
return NULL;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
SQueryInfo* pNewQueryInfo = tscGetQueryInfoDetail(pnCmd, 0);
|
SQueryInfo* pNewQueryInfo = tscGetQueryInfoDetail(pnCmd, 0);
|
||||||
|
@ -1816,20 +1848,28 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
|
||||||
pNewQueryInfo->groupbyExpr = pQueryInfo->groupbyExpr;
|
pNewQueryInfo->groupbyExpr = pQueryInfo->groupbyExpr;
|
||||||
if (pQueryInfo->groupbyExpr.columnInfo != NULL) {
|
if (pQueryInfo->groupbyExpr.columnInfo != NULL) {
|
||||||
pNewQueryInfo->groupbyExpr.columnInfo = taosArrayClone(pQueryInfo->groupbyExpr.columnInfo);
|
pNewQueryInfo->groupbyExpr.columnInfo = taosArrayClone(pQueryInfo->groupbyExpr.columnInfo);
|
||||||
|
if (pNewQueryInfo->groupbyExpr.columnInfo == NULL) {
|
||||||
|
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tscTagCondCopy(&pNewQueryInfo->tagCond, &pQueryInfo->tagCond);
|
tscTagCondCopy(&pNewQueryInfo->tagCond, &pQueryInfo->tagCond);
|
||||||
|
|
||||||
if (pQueryInfo->fillType != TSDB_FILL_NONE) {
|
if (pQueryInfo->fillType != TSDB_FILL_NONE) {
|
||||||
pNewQueryInfo->fillVal = malloc(pQueryInfo->fieldsInfo.numOfOutput * sizeof(int64_t));
|
pNewQueryInfo->fillVal = malloc(pQueryInfo->fieldsInfo.numOfOutput * sizeof(int64_t));
|
||||||
|
if (pNewQueryInfo->fillVal == NULL) {
|
||||||
|
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
|
|
||||||
memcpy(pNewQueryInfo->fillVal, pQueryInfo->fillVal, pQueryInfo->fieldsInfo.numOfOutput * sizeof(int64_t));
|
memcpy(pNewQueryInfo->fillVal, pQueryInfo->fillVal, pQueryInfo->fieldsInfo.numOfOutput * sizeof(int64_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tscAllocPayload(pnCmd, TSDB_DEFAULT_PAYLOAD_SIZE) != TSDB_CODE_SUCCESS) {
|
if (tscAllocPayload(pnCmd, TSDB_DEFAULT_PAYLOAD_SIZE) != TSDB_CODE_SUCCESS) {
|
||||||
tscError("%p new subquery failed, tableIndex:%d, vgroupIndex:%d", pSql, tableIndex, pTableMetaInfo->vgroupIndex);
|
tscError("%p new subquery failed, tableIndex:%d, vgroupIndex:%d", pSql, tableIndex, pTableMetaInfo->vgroupIndex);
|
||||||
tscFreeSqlObj(pNew);
|
|
||||||
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
return NULL;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
tscColumnListCopy(pNewQueryInfo->colList, pQueryInfo->colList, (int16_t)tableIndex);
|
tscColumnListCopy(pNewQueryInfo->colList, pQueryInfo->colList, (int16_t)tableIndex);
|
||||||
|
@ -1872,16 +1912,15 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
|
||||||
|
|
||||||
if (pFinalInfo->pTableMeta == NULL) {
|
if (pFinalInfo->pTableMeta == NULL) {
|
||||||
tscError("%p new subquery failed since no tableMeta in cache, name:%s", pSql, name);
|
tscError("%p new subquery failed since no tableMeta in cache, name:%s", pSql, name);
|
||||||
tscFreeSqlObj(pNew);
|
|
||||||
|
|
||||||
if (pPrevSql != NULL) {
|
if (pPrevSql != NULL) { // pass the previous error to client
|
||||||
assert(pPrevSql->res.code != TSDB_CODE_SUCCESS);
|
assert(pPrevSql->res.code != TSDB_CODE_SUCCESS);
|
||||||
terrno = pPrevSql->res.code;
|
terrno = pPrevSql->res.code;
|
||||||
} else {
|
} else {
|
||||||
terrno = TSDB_CODE_TSC_APP_ERROR;
|
terrno = TSDB_CODE_TSC_APP_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(pNewQueryInfo->numOfTables == 1);
|
assert(pNewQueryInfo->numOfTables == 1);
|
||||||
|
@ -1906,6 +1945,10 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
|
||||||
}
|
}
|
||||||
|
|
||||||
return pNew;
|
return pNew;
|
||||||
|
|
||||||
|
_error:
|
||||||
|
tscFreeSqlObj(pNew);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "taosmsg.h"
|
#include "taosmsg.h"
|
||||||
#include "tstoken.h"
|
#include "tstoken.h"
|
||||||
|
#include "tvariant.h"
|
||||||
|
|
||||||
typedef struct SDataStatis {
|
typedef struct SDataStatis {
|
||||||
int16_t colId;
|
int16_t colId;
|
||||||
|
@ -24,10 +25,12 @@ void extractTableName(const char *tableId, char *name);
|
||||||
|
|
||||||
char* extractDBName(const char *tableId, char *name);
|
char* extractDBName(const char *tableId, char *name);
|
||||||
|
|
||||||
void extractTableNameFromToken(SSQLToken *pToken, SSQLToken* pTable);
|
void extractTableNameFromToken(SStrToken *pToken, SStrToken* pTable);
|
||||||
|
|
||||||
SSchema tGetTableNameColumnSchema();
|
SSchema tGetTableNameColumnSchema();
|
||||||
|
|
||||||
|
SSchema tGetUserSpecifiedColumnSchema(tVariant* pVal, SStrToken* exprStr, const char* name);
|
||||||
|
|
||||||
bool tscValidateTableNameLength(size_t len);
|
bool tscValidateTableNameLength(size_t len);
|
||||||
|
|
||||||
SColumnFilterInfo* tscFilterInfoClone(const SColumnFilterInfo* src, int32_t numOfFilters);
|
SColumnFilterInfo* tscFilterInfoClone(const SColumnFilterInfo* src, int32_t numOfFilters);
|
||||||
|
|
|
@ -36,7 +36,7 @@ typedef struct tVariant {
|
||||||
};
|
};
|
||||||
} tVariant;
|
} tVariant;
|
||||||
|
|
||||||
void tVariantCreate(tVariant *pVar, SSQLToken *token);
|
void tVariantCreate(tVariant *pVar, SStrToken *token);
|
||||||
|
|
||||||
void tVariantCreateFromString(tVariant *pVar, char *pz, uint32_t len, uint32_t type);
|
void tVariantCreateFromString(tVariant *pVar, char *pz, uint32_t len, uint32_t type);
|
||||||
|
|
||||||
|
@ -46,6 +46,8 @@ void tVariantDestroy(tVariant *pV);
|
||||||
|
|
||||||
void tVariantAssign(tVariant *pDst, const tVariant *pSrc);
|
void tVariantAssign(tVariant *pDst, const tVariant *pSrc);
|
||||||
|
|
||||||
|
int32_t tVariantCompare(const tVariant* p1, const tVariant* p2);
|
||||||
|
|
||||||
int32_t tVariantToString(tVariant *pVar, char *dst);
|
int32_t tVariantToString(tVariant *pVar, char *dst);
|
||||||
|
|
||||||
int32_t tVariantDump(tVariant *pVariant, char *payload, int16_t type, bool includeLengthPrefix);
|
int32_t tVariantDump(tVariant *pVariant, char *payload, int16_t type, bool includeLengthPrefix);
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "tname.h"
|
#include "tname.h"
|
||||||
#include "tstoken.h"
|
#include "tstoken.h"
|
||||||
#include "ttokendef.h"
|
#include "ttokendef.h"
|
||||||
|
#include "tvariant.h"
|
||||||
|
|
||||||
// todo refactor
|
// todo refactor
|
||||||
UNUSED_FUNC static FORCE_INLINE const char* skipSegments(const char* input, char delim, int32_t num) {
|
UNUSED_FUNC static FORCE_INLINE const char* skipSegments(const char* input, char delim, int32_t num) {
|
||||||
|
@ -43,7 +44,30 @@ SSchema tGetTableNameColumnSchema() {
|
||||||
s.bytes = TSDB_TABLE_NAME_LEN - 1 + VARSTR_HEADER_SIZE;
|
s.bytes = TSDB_TABLE_NAME_LEN - 1 + VARSTR_HEADER_SIZE;
|
||||||
s.type = TSDB_DATA_TYPE_BINARY;
|
s.type = TSDB_DATA_TYPE_BINARY;
|
||||||
s.colId = TSDB_TBNAME_COLUMN_INDEX;
|
s.colId = TSDB_TBNAME_COLUMN_INDEX;
|
||||||
strncpy(s.name, TSQL_TBNAME_L, TSDB_COL_NAME_LEN);
|
tstrncpy(s.name, TSQL_TBNAME_L, TSDB_COL_NAME_LEN);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
SSchema tGetUserSpecifiedColumnSchema(tVariant* pVal, SStrToken* exprStr, const char* name) {
|
||||||
|
SSchema s = {0};
|
||||||
|
|
||||||
|
s.type = pVal->nType;
|
||||||
|
if (s.type == TSDB_DATA_TYPE_BINARY || s.type == TSDB_DATA_TYPE_NCHAR) {
|
||||||
|
s.bytes = (int16_t)(pVal->nLen + VARSTR_HEADER_SIZE);
|
||||||
|
} else {
|
||||||
|
s.bytes = tDataTypeDesc[pVal->nType].nSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
s.colId = TSDB_UD_COLUMN_INDEX;
|
||||||
|
if (name != NULL) {
|
||||||
|
tstrncpy(s.name, name, sizeof(s.name));
|
||||||
|
} else {
|
||||||
|
size_t len = strdequote(exprStr->z);
|
||||||
|
size_t tlen = MIN(sizeof(s.name), len + 1);
|
||||||
|
|
||||||
|
tstrncpy(s.name, exprStr->z, tlen);
|
||||||
|
}
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +134,7 @@ int64_t taosGetIntervalStartTimestamp(int64_t startTime, int64_t slidingTime, in
|
||||||
* tablePrefix.columnName
|
* tablePrefix.columnName
|
||||||
* extract table name and save it in pTable, with only column name in pToken
|
* extract table name and save it in pTable, with only column name in pToken
|
||||||
*/
|
*/
|
||||||
void extractTableNameFromToken(SSQLToken* pToken, SSQLToken* pTable) {
|
void extractTableNameFromToken(SStrToken* pToken, SStrToken* pTable) {
|
||||||
const char sep = TS_PATH_DELIMITER[0];
|
const char sep = TS_PATH_DELIMITER[0];
|
||||||
|
|
||||||
if (pToken == pTable || pToken == NULL || pTable == NULL) {
|
if (pToken == pTable || pToken == NULL || pTable == NULL) {
|
||||||
|
|
|
@ -12,12 +12,10 @@
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
#include "os.h"
|
||||||
|
|
||||||
#include "tvariant.h"
|
#include "tvariant.h"
|
||||||
#include "hash.h"
|
#include "hash.h"
|
||||||
#include "hashfunc.h"
|
|
||||||
#include "os.h"
|
|
||||||
#include "hash.h"
|
|
||||||
#include "taos.h"
|
#include "taos.h"
|
||||||
#include "taosdef.h"
|
#include "taosdef.h"
|
||||||
#include "tstoken.h"
|
#include "tstoken.h"
|
||||||
|
@ -25,7 +23,7 @@
|
||||||
#include "tutil.h"
|
#include "tutil.h"
|
||||||
|
|
||||||
// todo support scientific expression number and oct number
|
// todo support scientific expression number and oct number
|
||||||
void tVariantCreate(tVariant *pVar, SSQLToken *token) { tVariantCreateFromString(pVar, token->z, token->n, token->type); }
|
void tVariantCreate(tVariant *pVar, SStrToken *token) { tVariantCreateFromString(pVar, token->z, token->n, token->type); }
|
||||||
|
|
||||||
void tVariantCreateFromString(tVariant *pVar, char *pz, uint32_t len, uint32_t type) {
|
void tVariantCreateFromString(tVariant *pVar, char *pz, uint32_t len, uint32_t type) {
|
||||||
memset(pVar, 0, sizeof(tVariant));
|
memset(pVar, 0, sizeof(tVariant));
|
||||||
|
@ -102,10 +100,9 @@ void tVariantCreateFromBinary(tVariant *pVar, const char *pz, size_t len, uint32
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_NCHAR: { // here we get the nchar length from raw binary bits length
|
case TSDB_DATA_TYPE_NCHAR: { // here we get the nchar length from raw binary bits length
|
||||||
size_t lenInwchar = len / TSDB_NCHAR_SIZE;
|
size_t lenInwchar = len / TSDB_NCHAR_SIZE;
|
||||||
pVar->wpz = calloc(1, (lenInwchar + 1) * TSDB_NCHAR_SIZE);
|
|
||||||
|
|
||||||
wcsncpy(pVar->wpz, (wchar_t *)pz, lenInwchar);
|
pVar->wpz = calloc(1, (lenInwchar + 1) * TSDB_NCHAR_SIZE);
|
||||||
pVar->wpz[lenInwchar] = 0;
|
memcpy(pVar->wpz, pz, lenInwchar * TSDB_NCHAR_SIZE);
|
||||||
pVar->nLen = (int32_t)len;
|
pVar->nLen = (int32_t)len;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -169,6 +166,50 @@ void tVariantAssign(tVariant *pDst, const tVariant *pSrc) {
|
||||||
char* n = strdup(p);
|
char* n = strdup(p);
|
||||||
taosArrayPush(pDst->arr, &n);
|
taosArrayPush(pDst->arr, &n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pDst->nLen = tDataTypeDesc[pDst->nType].nSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tVariantCompare(const tVariant* p1, const tVariant* p2) {
|
||||||
|
if (p1->nType == TSDB_DATA_TYPE_NULL && p2->nType == TSDB_DATA_TYPE_NULL) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p1->nType == TSDB_DATA_TYPE_NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p2->nType == TSDB_DATA_TYPE_NULL) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (p1->nType) {
|
||||||
|
case TSDB_DATA_TYPE_BINARY:
|
||||||
|
case TSDB_DATA_TYPE_NCHAR: {
|
||||||
|
if (p1->nLen == p2->nLen) {
|
||||||
|
return memcmp(p1->pz, p2->pz, p1->nLen);
|
||||||
|
} else {
|
||||||
|
return p1->nLen > p2->nLen? 1:-1;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
case TSDB_DATA_TYPE_FLOAT:
|
||||||
|
case TSDB_DATA_TYPE_DOUBLE:
|
||||||
|
if (p1->dKey == p2->dKey) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
return p1->dKey > p2->dKey? 1:-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
if (p1->i64Key == p2->i64Key) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
return p1->i64Key > p2->i64Key? 1:-1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,7 +269,7 @@ static int32_t doConvertToInteger(tVariant *pVariant, char *pDest, int32_t type,
|
||||||
errno = 0;
|
errno = 0;
|
||||||
char *endPtr = NULL;
|
char *endPtr = NULL;
|
||||||
|
|
||||||
SSQLToken token = {0};
|
SStrToken token = {0};
|
||||||
token.n = tSQLGetToken(pVariant->pz, &token.type);
|
token.n = tSQLGetToken(pVariant->pz, &token.type);
|
||||||
|
|
||||||
if (token.type == TK_MINUS || token.type == TK_PLUS) {
|
if (token.type == TK_MINUS || token.type == TK_PLUS) {
|
||||||
|
@ -277,7 +318,7 @@ static int32_t doConvertToInteger(tVariant *pVariant, char *pDest, int32_t type,
|
||||||
errno = 0;
|
errno = 0;
|
||||||
wchar_t *endPtr = NULL;
|
wchar_t *endPtr = NULL;
|
||||||
|
|
||||||
SSQLToken token = {0};
|
SStrToken token = {0};
|
||||||
token.n = tSQLGetToken(pVariant->pz, &token.type);
|
token.n = tSQLGetToken(pVariant->pz, &token.type);
|
||||||
|
|
||||||
if (token.type == TK_MINUS || token.type == TK_PLUS) {
|
if (token.type == TK_MINUS || token.type == TK_PLUS) {
|
||||||
|
@ -436,7 +477,7 @@ static int32_t toNchar(tVariant *pVariant, char **pDest, int32_t *pDestSize) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int32_t convertToDouble(char *pStr, int32_t len, double *value) {
|
static FORCE_INLINE int32_t convertToDouble(char *pStr, int32_t len, double *value) {
|
||||||
SSQLToken stoken = {.z = pStr, .n = len};
|
SStrToken stoken = {.z = pStr, .n = len};
|
||||||
|
|
||||||
if (TK_ILLEGAL == isValidNumber(&stoken)) {
|
if (TK_ILLEGAL == isValidNumber(&stoken)) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -462,7 +503,7 @@ static FORCE_INLINE int32_t convertToInteger(tVariant *pVariant, int64_t *result
|
||||||
errno = 0;
|
errno = 0;
|
||||||
char *endPtr = NULL;
|
char *endPtr = NULL;
|
||||||
|
|
||||||
SSQLToken token = {0};
|
SStrToken token = {0};
|
||||||
token.n = tSQLGetToken(pVariant->pz, &token.type);
|
token.n = tSQLGetToken(pVariant->pz, &token.type);
|
||||||
|
|
||||||
if (token.type == TK_MINUS || token.type == TK_PLUS) {
|
if (token.type == TK_MINUS || token.type == TK_PLUS) {
|
||||||
|
@ -479,7 +520,7 @@ static FORCE_INLINE int32_t convertToInteger(tVariant *pVariant, int64_t *result
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSQLToken sToken = {.z = pVariant->pz, .n = pVariant->nLen};
|
SStrToken sToken = {.z = pVariant->pz, .n = pVariant->nLen};
|
||||||
if (TK_ILLEGAL == isValidNumber(&sToken)) {
|
if (TK_ILLEGAL == isValidNumber(&sToken)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -515,7 +556,7 @@ static FORCE_INLINE int32_t convertToInteger(tVariant *pVariant, int64_t *result
|
||||||
errno = 0;
|
errno = 0;
|
||||||
wchar_t *endPtr = NULL;
|
wchar_t *endPtr = NULL;
|
||||||
|
|
||||||
SSQLToken token = {0};
|
SStrToken token = {0};
|
||||||
token.n = tSQLGetToken(pVariant->pz, &token.type);
|
token.n = tSQLGetToken(pVariant->pz, &token.type);
|
||||||
|
|
||||||
if (token.type == TK_MINUS || token.type == TK_PLUS) {
|
if (token.type == TK_MINUS || token.type == TK_PLUS) {
|
||||||
|
|
|
@ -28,22 +28,5 @@
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="src" path="target/generated-sources/annotations">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="optional" value="true"/>
|
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
|
||||||
<attribute name="ignore_optional_problems" value="true"/>
|
|
||||||
<attribute name="m2e-apt" value="true"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="optional" value="true"/>
|
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
|
||||||
<attribute name="ignore_optional_problems" value="true"/>
|
|
||||||
<attribute name="m2e-apt" value="true"/>
|
|
||||||
<attribute name="test" value="true"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry kind="output" path="target/classes"/>
|
<classpathentry kind="output" path="target/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
|
@ -119,11 +119,8 @@ int32_t main(int32_t argc, char *argv[]) {
|
||||||
|
|
||||||
syslog(LOG_INFO, "Started TDengine service successfully.");
|
syslog(LOG_INFO, "Started TDengine service successfully.");
|
||||||
|
|
||||||
for (int res = tsem_wait(&exitSem); res != 0; res = tsem_wait(&exitSem)) {
|
if (tsem_wait(&exitSem) != 0) {
|
||||||
if (res != EINTR) {
|
syslog(LOG_ERR, "failed to wait exit semphore: %s", strerror(errno));
|
||||||
syslog(LOG_ERR, "failed to wait exit semphore: %d", res);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dnodeCleanUpSystem();
|
dnodeCleanUpSystem();
|
||||||
|
|
|
@ -287,6 +287,7 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size);
|
||||||
#define TSDB_MAX_REPLICA 5
|
#define TSDB_MAX_REPLICA 5
|
||||||
|
|
||||||
#define TSDB_TBNAME_COLUMN_INDEX (-1)
|
#define TSDB_TBNAME_COLUMN_INDEX (-1)
|
||||||
|
#define TSDB_UD_COLUMN_INDEX (-100)
|
||||||
#define TSDB_MULTI_METERMETA_MAX_NUM 100000 // maximum batch size allowed to load metermeta
|
#define TSDB_MULTI_METERMETA_MAX_NUM 100000 // maximum batch size allowed to load metermeta
|
||||||
|
|
||||||
#define TSDB_MIN_CACHE_BLOCK_SIZE 1
|
#define TSDB_MIN_CACHE_BLOCK_SIZE 1
|
||||||
|
|
|
@ -97,6 +97,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TSC_APP_ERROR, 0, 0x0211, "Applicatio
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_ACTION_IN_PROGRESS, 0, 0x0212, "Action in progress")
|
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_ACTION_IN_PROGRESS, 0, 0x0212, "Action in progress")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_DISCONNECTED, 0, 0x0213, "Disconnected from service")
|
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_DISCONNECTED, 0, 0x0213, "Disconnected from service")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_NO_WRITE_AUTH, 0, 0x0214, "No write permission")
|
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_NO_WRITE_AUTH, 0, 0x0214, "No write permission")
|
||||||
|
TAOS_DEFINE_ERROR(TSDB_CODE_TSC_CONN_KILLED, 0, 0x0215, "Connection killed")
|
||||||
|
|
||||||
// mnode
|
// mnode
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_MSG_NOT_PROCESSED, 0, 0x0300, "Message not processed")
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_MSG_NOT_PROCESSED, 0, 0x0300, "Message not processed")
|
||||||
|
@ -221,6 +222,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_QRY_EXCEED_TAGS_LIMIT, 0, 0x0706, "Tag condit
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_NOT_READY, 0, 0x0707, "Query not ready")
|
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_NOT_READY, 0, 0x0707, "Query not ready")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_HAS_RSP, 0, 0x0708, "Query should response")
|
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_HAS_RSP, 0, 0x0708, "Query should response")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_IN_EXEC, 0, 0x0709, "Multiple retrieval of this query")
|
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_IN_EXEC, 0, 0x0709, "Multiple retrieval of this query")
|
||||||
|
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_TOO_MANY_TIMEWINDOW, 0, 0x070A, "Too many time window in query")
|
||||||
|
|
||||||
// grant
|
// grant
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_EXPIRED, 0, 0x0800, "License expired")
|
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_EXPIRED, 0, 0x0800, "License expired")
|
||||||
|
|
|
@ -133,7 +133,7 @@ enum _mgmt_table {
|
||||||
TSDB_MGMT_TABLE_MODULE,
|
TSDB_MGMT_TABLE_MODULE,
|
||||||
TSDB_MGMT_TABLE_QUERIES,
|
TSDB_MGMT_TABLE_QUERIES,
|
||||||
TSDB_MGMT_TABLE_STREAMS,
|
TSDB_MGMT_TABLE_STREAMS,
|
||||||
TSDB_MGMT_TABLE_CONFIGS,
|
TSDB_MGMT_TABLE_VARIABLES,
|
||||||
TSDB_MGMT_TABLE_CONNS,
|
TSDB_MGMT_TABLE_CONNS,
|
||||||
TSDB_MGMT_TABLE_SCORES,
|
TSDB_MGMT_TABLE_SCORES,
|
||||||
TSDB_MGMT_TABLE_GRANTS,
|
TSDB_MGMT_TABLE_GRANTS,
|
||||||
|
@ -167,9 +167,9 @@ enum _mgmt_table {
|
||||||
#define TSDB_VN_WRITE_ACCCESS ((char)0x2)
|
#define TSDB_VN_WRITE_ACCCESS ((char)0x2)
|
||||||
#define TSDB_VN_ALL_ACCCESS (TSDB_VN_READ_ACCCESS | TSDB_VN_WRITE_ACCCESS)
|
#define TSDB_VN_ALL_ACCCESS (TSDB_VN_READ_ACCCESS | TSDB_VN_WRITE_ACCCESS)
|
||||||
|
|
||||||
#define TSDB_COL_NORMAL 0x0u
|
#define TSDB_COL_NORMAL 0x0u // the normal column of the table
|
||||||
#define TSDB_COL_TAG 0x1u
|
#define TSDB_COL_TAG 0x1u // the tag column type
|
||||||
#define TSDB_COL_JOIN 0x2u
|
#define TSDB_COL_UDC 0x2u // the user specified normal string column, it is a dummy column
|
||||||
|
|
||||||
extern char *taosMsg[];
|
extern char *taosMsg[];
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@
|
||||||
#define TK_QUERIES 51
|
#define TK_QUERIES 51
|
||||||
#define TK_CONNECTIONS 52
|
#define TK_CONNECTIONS 52
|
||||||
#define TK_STREAMS 53
|
#define TK_STREAMS 53
|
||||||
#define TK_CONFIGS 54
|
#define TK_VARIABLES 54
|
||||||
#define TK_SCORES 55
|
#define TK_SCORES 55
|
||||||
#define TK_GRANTS 56
|
#define TK_GRANTS 56
|
||||||
#define TK_VNODES 57
|
#define TK_VNODES 57
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
#include "taosdef.h"
|
#include "taosdef.h"
|
||||||
#include "taoserror.h"
|
#include "taoserror.h"
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
|
#include "tsclient.h"
|
||||||
|
|
||||||
#include <regex.h>
|
#include <regex.h>
|
||||||
|
|
||||||
/**************** Global variables ****************/
|
/**************** Global variables ****************/
|
||||||
|
@ -64,11 +66,6 @@ TAOS *shellInit(SShellArguments *args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
taos_init();
|
taos_init();
|
||||||
/*
|
|
||||||
* set tsTableMetaKeepTimer = 3000ms
|
|
||||||
* means not save cache in shell
|
|
||||||
*/
|
|
||||||
tsTableMetaKeepTimer = 3000;
|
|
||||||
|
|
||||||
// Connect to the database.
|
// Connect to the database.
|
||||||
TAOS *con = NULL;
|
TAOS *con = NULL;
|
||||||
|
@ -287,7 +284,7 @@ void shellRunCommandOnServer(TAOS *con, char command[]) {
|
||||||
st = taosGetTimestampUs();
|
st = taosGetTimestampUs();
|
||||||
|
|
||||||
TAOS_RES* pSql = taos_query(con, command);
|
TAOS_RES* pSql = taos_query(con, command);
|
||||||
result = pSql; // set it into the global variable
|
atomic_store_ptr(&result, pSql); // set the global TAOS_RES pointer
|
||||||
|
|
||||||
if (taos_errno(pSql)) {
|
if (taos_errno(pSql)) {
|
||||||
taos_error(pSql);
|
taos_error(pSql);
|
||||||
|
@ -298,17 +295,16 @@ void shellRunCommandOnServer(TAOS *con, char command[]) {
|
||||||
fprintf(stdout, "Database changed.\n\n");
|
fprintf(stdout, "Database changed.\n\n");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
result = NULL;
|
atomic_store_ptr(&result, 0);
|
||||||
taos_free_result(pSql);
|
taos_free_result(pSql);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int num_fields = taos_field_count(pSql);
|
if (!tscIsUpdateQuery(pSql)) { // select and show kinds of commands
|
||||||
if (num_fields != 0) { // select and show kinds of commands
|
|
||||||
int error_no = 0;
|
int error_no = 0;
|
||||||
int numOfRows = shellDumpResult(pSql, fname, &error_no, printMode);
|
int numOfRows = shellDumpResult(pSql, fname, &error_no, printMode);
|
||||||
if (numOfRows < 0) {
|
if (numOfRows < 0) {
|
||||||
result = NULL;
|
atomic_store_ptr(&result, 0);
|
||||||
taos_free_result(pSql);
|
taos_free_result(pSql);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -331,7 +327,7 @@ void shellRunCommandOnServer(TAOS *con, char command[]) {
|
||||||
wordfree(&full_path);
|
wordfree(&full_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
result = NULL;
|
atomic_store_ptr(&result, 0);
|
||||||
taos_free_result(pSql);
|
taos_free_result(pSql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -497,7 +493,6 @@ static int dumpResultToFile(const char* fname, TAOS_RES* tres) {
|
||||||
} while( row != NULL);
|
} while( row != NULL);
|
||||||
|
|
||||||
result = NULL;
|
result = NULL;
|
||||||
//taos_free_result(tres);
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
return numOfRows;
|
return numOfRows;
|
||||||
|
@ -802,8 +797,8 @@ void write_history() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void taos_error(TAOS_RES *tres) {
|
void taos_error(TAOS_RES *tres) {
|
||||||
|
atomic_store_ptr(&result, 0);
|
||||||
fprintf(stderr, "\nDB error: %s\n", taos_errstr(tres));
|
fprintf(stderr, "\nDB error: %s\n", taos_errstr(tres));
|
||||||
result = NULL;
|
|
||||||
taos_free_result(tres);
|
taos_free_result(tres);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,11 +18,10 @@
|
||||||
|
|
||||||
pthread_t pid;
|
pthread_t pid;
|
||||||
|
|
||||||
// TODO: IMPLEMENT INTERRUPT HANDLER.
|
void shellQueryInterruptHandler(int signum) {
|
||||||
void interruptHandler(int signum) {
|
|
||||||
#ifdef LINUX
|
#ifdef LINUX
|
||||||
taos_stop_query(result);
|
void* pResHandle = atomic_val_compare_exchange_64(&result, result, 0);
|
||||||
result = NULL;
|
taos_stop_query(pResHandle);
|
||||||
#else
|
#else
|
||||||
printf("\nReceive ctrl+c or other signal, quit shell.\n");
|
printf("\nReceive ctrl+c or other signal, quit shell.\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
|
@ -86,7 +85,7 @@ int main(int argc, char* argv[]) {
|
||||||
struct sigaction act;
|
struct sigaction act;
|
||||||
memset(&act, 0, sizeof(struct sigaction));
|
memset(&act, 0, sizeof(struct sigaction));
|
||||||
|
|
||||||
act.sa_handler = interruptHandler;
|
act.sa_handler = shellQueryInterruptHandler;
|
||||||
sigaction(SIGTERM, &act, NULL);
|
sigaction(SIGTERM, &act, NULL);
|
||||||
sigaction(SIGINT, &act, NULL);
|
sigaction(SIGINT, &act, NULL);
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ static int32_t mnodeProcessCreateDnodeMsg(SMnodeMsg *pMsg);
|
||||||
static int32_t mnodeProcessDropDnodeMsg(SMnodeMsg *pMsg);
|
static int32_t mnodeProcessDropDnodeMsg(SMnodeMsg *pMsg);
|
||||||
static int32_t mnodeProcessCfgDnodeMsg(SMnodeMsg *pMsg);
|
static int32_t mnodeProcessCfgDnodeMsg(SMnodeMsg *pMsg);
|
||||||
static void mnodeProcessCfgDnodeMsgRsp(SRpcMsg *rpcMsg) ;
|
static void mnodeProcessCfgDnodeMsgRsp(SRpcMsg *rpcMsg) ;
|
||||||
static int32_t mnodeProcessDnodeStatusMsg(SMnodeMsg *rpcMsg);
|
static int32_t mnodeProcessDnodeStatusMsg(SMnodeMsg *pMsg);
|
||||||
static int32_t mnodeGetModuleMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn);
|
static int32_t mnodeGetModuleMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn);
|
||||||
static int32_t mnodeRetrieveModules(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
static int32_t mnodeRetrieveModules(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
||||||
static int32_t mnodeGetConfigMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn);
|
static int32_t mnodeGetConfigMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn);
|
||||||
|
@ -161,8 +161,8 @@ int32_t mnodeInitDnodes() {
|
||||||
mnodeAddPeerMsgHandle(TSDB_MSG_TYPE_DM_STATUS, mnodeProcessDnodeStatusMsg);
|
mnodeAddPeerMsgHandle(TSDB_MSG_TYPE_DM_STATUS, mnodeProcessDnodeStatusMsg);
|
||||||
mnodeAddShowMetaHandle(TSDB_MGMT_TABLE_MODULE, mnodeGetModuleMeta);
|
mnodeAddShowMetaHandle(TSDB_MGMT_TABLE_MODULE, mnodeGetModuleMeta);
|
||||||
mnodeAddShowRetrieveHandle(TSDB_MGMT_TABLE_MODULE, mnodeRetrieveModules);
|
mnodeAddShowRetrieveHandle(TSDB_MGMT_TABLE_MODULE, mnodeRetrieveModules);
|
||||||
mnodeAddShowMetaHandle(TSDB_MGMT_TABLE_CONFIGS, mnodeGetConfigMeta);
|
mnodeAddShowMetaHandle(TSDB_MGMT_TABLE_VARIABLES, mnodeGetConfigMeta);
|
||||||
mnodeAddShowRetrieveHandle(TSDB_MGMT_TABLE_CONFIGS, mnodeRetrieveConfigs);
|
mnodeAddShowRetrieveHandle(TSDB_MGMT_TABLE_VARIABLES, mnodeRetrieveConfigs);
|
||||||
mnodeAddShowMetaHandle(TSDB_MGMT_TABLE_VNODES, mnodeGetVnodeMeta);
|
mnodeAddShowMetaHandle(TSDB_MGMT_TABLE_VNODES, mnodeGetVnodeMeta);
|
||||||
mnodeAddShowRetrieveHandle(TSDB_MGMT_TABLE_VNODES, mnodeRetrieveVnodes);
|
mnodeAddShowRetrieveHandle(TSDB_MGMT_TABLE_VNODES, mnodeRetrieveVnodes);
|
||||||
mnodeAddShowMetaHandle(TSDB_MGMT_TABLE_DNODE, mnodeGetDnodeMeta);
|
mnodeAddShowMetaHandle(TSDB_MGMT_TABLE_DNODE, mnodeGetDnodeMeta);
|
||||||
|
@ -733,7 +733,7 @@ static int32_t mnodeRetrieveDnodes(SShowObj *pShow, char *data, int32_t rows, vo
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool mnodeCheckModuleInDnode(SDnodeObj *pDnode, int32_t moduleType) {
|
static bool mnodeCheckModuleInDnode(SDnodeObj *pDnode, int32_t moduleType) {
|
||||||
uint32_t status = pDnode->moduleStatus & (1 << moduleType);
|
uint32_t status = pDnode->moduleStatus & (1u << moduleType);
|
||||||
return status > 0;
|
return status > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -758,7 +758,7 @@ static int32_t mnodeGetModuleMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *p
|
||||||
|
|
||||||
pShow->bytes[cols] = 40 + VARSTR_HEADER_SIZE;
|
pShow->bytes[cols] = 40 + VARSTR_HEADER_SIZE;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||||
strcpy(pSchema[cols].name, "end point");
|
strcpy(pSchema[cols].name, "end_point");
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
cols++;
|
cols++;
|
||||||
|
|
||||||
|
@ -792,7 +792,9 @@ static int32_t mnodeGetModuleMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *p
|
||||||
|
|
||||||
int32_t mnodeRetrieveModules(SShowObj *pShow, char *data, int32_t rows, void *pConn) {
|
int32_t mnodeRetrieveModules(SShowObj *pShow, char *data, int32_t rows, void *pConn) {
|
||||||
int32_t numOfRows = 0;
|
int32_t numOfRows = 0;
|
||||||
char * pWrite;
|
|
||||||
|
char* pWrite;
|
||||||
|
char* moduleName[5] = { "MNODE", "HTTP", "MONITOR", "MQTT", "UNKNOWN" };
|
||||||
|
|
||||||
while (numOfRows < rows) {
|
while (numOfRows < rows) {
|
||||||
SDnodeObj *pDnode = NULL;
|
SDnodeObj *pDnode = NULL;
|
||||||
|
@ -807,28 +809,18 @@ int32_t mnodeRetrieveModules(SShowObj *pShow, char *data, int32_t rows, void *pC
|
||||||
cols++;
|
cols++;
|
||||||
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
strncpy(pWrite, pDnode->dnodeEp, pShow->bytes[cols]-1);
|
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pDnode->dnodeEp, pShow->bytes[cols] - 1);
|
||||||
cols++;
|
cols++;
|
||||||
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
switch (moduleType) {
|
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, moduleName[moduleType], pShow->bytes[cols]);
|
||||||
case TSDB_MOD_MNODE:
|
|
||||||
strcpy(pWrite, "mnode");
|
|
||||||
break;
|
|
||||||
case TSDB_MOD_HTTP:
|
|
||||||
strcpy(pWrite, "http");
|
|
||||||
break;
|
|
||||||
case TSDB_MOD_MONITOR:
|
|
||||||
strcpy(pWrite, "monitor");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
strcpy(pWrite, "unknown");
|
|
||||||
}
|
|
||||||
cols++;
|
cols++;
|
||||||
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
bool enable = mnodeCheckModuleInDnode(pDnode, moduleType);
|
bool enable = mnodeCheckModuleInDnode(pDnode, moduleType);
|
||||||
strcpy(pWrite, enable ? "enable" : "disable");
|
|
||||||
|
char* v = enable? "enable":"disable";
|
||||||
|
STR_TO_VARSTR(pWrite, v);
|
||||||
cols++;
|
cols++;
|
||||||
|
|
||||||
numOfRows++;
|
numOfRows++;
|
||||||
|
@ -862,13 +854,13 @@ static int32_t mnodeGetConfigMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *p
|
||||||
|
|
||||||
pShow->bytes[cols] = TSDB_CFG_OPTION_LEN + VARSTR_HEADER_SIZE;
|
pShow->bytes[cols] = TSDB_CFG_OPTION_LEN + VARSTR_HEADER_SIZE;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||||
strcpy(pSchema[cols].name, "config name");
|
tstrncpy(pSchema[cols].name, "name", sizeof(pSchema[cols].name));
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
cols++;
|
cols++;
|
||||||
|
|
||||||
pShow->bytes[cols] = TSDB_CFG_VALUE_LEN + VARSTR_HEADER_SIZE;
|
pShow->bytes[cols] = TSDB_CFG_VALUE_LEN + VARSTR_HEADER_SIZE;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||||
strcpy(pSchema[cols].name, "config value");
|
tstrncpy(pSchema[cols].name, "value", sizeof(pSchema[cols].name));
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
cols++;
|
cols++;
|
||||||
|
|
||||||
|
@ -903,27 +895,32 @@ static int32_t mnodeRetrieveConfigs(SShowObj *pShow, char *data, int32_t rows, v
|
||||||
int32_t cols = 0;
|
int32_t cols = 0;
|
||||||
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
snprintf(pWrite, TSDB_CFG_OPTION_LEN, "%s", cfg->option);
|
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, cfg->option, TSDB_CFG_OPTION_LEN);
|
||||||
|
|
||||||
cols++;
|
cols++;
|
||||||
|
int32_t t = 0;
|
||||||
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
switch (cfg->valType) {
|
switch (cfg->valType) {
|
||||||
case TAOS_CFG_VTYPE_INT16:
|
case TAOS_CFG_VTYPE_INT16:
|
||||||
snprintf(pWrite, TSDB_CFG_VALUE_LEN, "%d", *((int16_t *)cfg->ptr));
|
t = snprintf(varDataVal(pWrite), TSDB_CFG_VALUE_LEN, "%d", *((int16_t *)cfg->ptr));
|
||||||
|
varDataSetLen(pWrite, t);
|
||||||
numOfRows++;
|
numOfRows++;
|
||||||
break;
|
break;
|
||||||
case TAOS_CFG_VTYPE_INT32:
|
case TAOS_CFG_VTYPE_INT32:
|
||||||
snprintf(pWrite, TSDB_CFG_VALUE_LEN, "%d", *((int32_t *)cfg->ptr));
|
t = snprintf(varDataVal(pWrite), TSDB_CFG_VALUE_LEN, "%d", *((int32_t *)cfg->ptr));
|
||||||
|
varDataSetLen(pWrite, t);
|
||||||
numOfRows++;
|
numOfRows++;
|
||||||
break;
|
break;
|
||||||
case TAOS_CFG_VTYPE_FLOAT:
|
case TAOS_CFG_VTYPE_FLOAT:
|
||||||
snprintf(pWrite, TSDB_CFG_VALUE_LEN, "%f", *((float *)cfg->ptr));
|
t = snprintf(varDataVal(pWrite), TSDB_CFG_VALUE_LEN, "%f", *((float *)cfg->ptr));
|
||||||
|
varDataSetLen(pWrite, t);
|
||||||
numOfRows++;
|
numOfRows++;
|
||||||
break;
|
break;
|
||||||
case TAOS_CFG_VTYPE_STRING:
|
case TAOS_CFG_VTYPE_STRING:
|
||||||
case TAOS_CFG_VTYPE_IPSTR:
|
case TAOS_CFG_VTYPE_IPSTR:
|
||||||
case TAOS_CFG_VTYPE_DIRECTORY:
|
case TAOS_CFG_VTYPE_DIRECTORY:
|
||||||
snprintf(pWrite, TSDB_CFG_VALUE_LEN, "%s", (char *)cfg->ptr);
|
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, cfg->ptr, TSDB_CFG_VALUE_LEN);
|
||||||
numOfRows++;
|
numOfRows++;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -100,7 +100,7 @@ SConnObj *mnodeCreateConn(char *user, uint32_t ip, uint16_t port) {
|
||||||
};
|
};
|
||||||
tstrncpy(connObj.user, user, sizeof(connObj.user));
|
tstrncpy(connObj.user, user, sizeof(connObj.user));
|
||||||
|
|
||||||
SConnObj *pConn = taosCachePut(tsMnodeConnCache, &connId, sizeof(int32_t), &connObj, sizeof(connObj), CONN_KEEP_TIME*1000);
|
SConnObj *pConn = taosCachePut(tsMnodeConnCache, &connId, sizeof(int32_t), &connObj, sizeof(connObj), CONN_KEEP_TIME * 1000);
|
||||||
|
|
||||||
mDebug("connId:%d, is created, user:%s ip:%s:%u", connId, user, taosIpStr(ip), port);
|
mDebug("connId:%d, is created, user:%s ip:%s:%u", connId, user, taosIpStr(ip), port);
|
||||||
return pConn;
|
return pConn;
|
||||||
|
|
|
@ -98,7 +98,7 @@ static char *mnodeGetShowType(int32_t showType) {
|
||||||
case TSDB_MGMT_TABLE_MODULE: return "show modules";
|
case TSDB_MGMT_TABLE_MODULE: return "show modules";
|
||||||
case TSDB_MGMT_TABLE_QUERIES: return "show queries";
|
case TSDB_MGMT_TABLE_QUERIES: return "show queries";
|
||||||
case TSDB_MGMT_TABLE_STREAMS: return "show streams";
|
case TSDB_MGMT_TABLE_STREAMS: return "show streams";
|
||||||
case TSDB_MGMT_TABLE_CONFIGS: return "show configs";
|
case TSDB_MGMT_TABLE_VARIABLES: return "show configs";
|
||||||
case TSDB_MGMT_TABLE_CONNS: return "show connections";
|
case TSDB_MGMT_TABLE_CONNS: return "show connections";
|
||||||
case TSDB_MGMT_TABLE_SCORES: return "show scores";
|
case TSDB_MGMT_TABLE_SCORES: return "show scores";
|
||||||
case TSDB_MGMT_TABLE_GRANTS: return "show grants";
|
case TSDB_MGMT_TABLE_GRANTS: return "show grants";
|
||||||
|
|
|
@ -23,7 +23,7 @@ extern "C" {
|
||||||
#ifndef TAOS_OS_FUNC_SEMPHONE
|
#ifndef TAOS_OS_FUNC_SEMPHONE
|
||||||
#define tsem_t sem_t
|
#define tsem_t sem_t
|
||||||
#define tsem_init sem_init
|
#define tsem_init sem_init
|
||||||
#define tsem_wait sem_wait
|
int tsem_wait(tsem_t* sem);
|
||||||
#define tsem_post sem_post
|
#define tsem_post sem_post
|
||||||
#define tsem_destroy sem_destroy
|
#define tsem_destroy sem_destroy
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -16,6 +16,18 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
|
||||||
|
#ifndef TAOS_OS_FUNC_SEMPHONE
|
||||||
|
|
||||||
|
int tsem_wait(tsem_t* sem) {
|
||||||
|
int ret = 0;
|
||||||
|
do {
|
||||||
|
ret = sem_wait(sem);
|
||||||
|
} while (ret != 0 && errno == EINTR);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef TAOS_OS_FUNC_SEMPHONE_PTHREAD
|
#ifndef TAOS_OS_FUNC_SEMPHONE_PTHREAD
|
||||||
|
|
||||||
bool taosCheckPthreadValid(pthread_t thread) { return thread != 0; }
|
bool taosCheckPthreadValid(pthread_t thread) { return thread != 0; }
|
||||||
|
|
|
@ -80,7 +80,7 @@ void tExprTreeTraverse(tExprNode *pExpr, SSkipList *pSkipList, SArray *result, S
|
||||||
void tExprTreeCalcTraverse(tExprNode *pExprs, int32_t numOfRows, char *pOutput, void *param, int32_t order,
|
void tExprTreeCalcTraverse(tExprNode *pExprs, int32_t numOfRows, char *pOutput, void *param, int32_t order,
|
||||||
char *(*cb)(void *, const char*, int32_t));
|
char *(*cb)(void *, const char*, int32_t));
|
||||||
|
|
||||||
uint8_t getBinaryExprOptr(SSQLToken *pToken);
|
uint8_t getBinaryExprOptr(SStrToken *pToken);
|
||||||
|
|
||||||
void tExprNodeDestroy(tExprNode *pNode, void (*fp)(void *));
|
void tExprNodeDestroy(tExprNode *pNode, void (*fp)(void *));
|
||||||
void exprTreeToBinary(SBufferWriter* bw, tExprNode* pExprTree);
|
void exprTreeToBinary(SBufferWriter* bw, tExprNode* pExprTree);
|
||||||
|
|
|
@ -33,6 +33,17 @@ struct SColumnFilterElem;
|
||||||
typedef bool (*__filter_func_t)(struct SColumnFilterElem* pFilter, char* val1, char* val2);
|
typedef bool (*__filter_func_t)(struct SColumnFilterElem* pFilter, char* val1, char* val2);
|
||||||
typedef int32_t (*__block_search_fn_t)(char* data, int32_t num, int64_t key, int32_t order);
|
typedef int32_t (*__block_search_fn_t)(char* data, int32_t num, int64_t key, int32_t order);
|
||||||
|
|
||||||
|
typedef struct SPosInfo {
|
||||||
|
int32_t pageId:20;
|
||||||
|
int32_t rowId:12;
|
||||||
|
} SPosInfo;
|
||||||
|
|
||||||
|
typedef struct SGroupResInfo {
|
||||||
|
int32_t groupId;
|
||||||
|
int32_t numOfDataPages;
|
||||||
|
SPosInfo pos;
|
||||||
|
} SGroupResInfo;
|
||||||
|
|
||||||
typedef struct SSqlGroupbyExpr {
|
typedef struct SSqlGroupbyExpr {
|
||||||
int16_t tableIndex;
|
int16_t tableIndex;
|
||||||
SArray* columnInfo; // SArray<SColIndex>, group by columns information
|
SArray* columnInfo; // SArray<SColIndex>, group by columns information
|
||||||
|
@ -41,21 +52,12 @@ typedef struct SSqlGroupbyExpr {
|
||||||
int16_t orderType; // order by type: asc/desc
|
int16_t orderType; // order by type: asc/desc
|
||||||
} SSqlGroupbyExpr;
|
} SSqlGroupbyExpr;
|
||||||
|
|
||||||
typedef struct SPosInfo {
|
|
||||||
int32_t pageId;
|
|
||||||
int32_t rowId;
|
|
||||||
} SPosInfo;
|
|
||||||
|
|
||||||
typedef struct SWindowStatus {
|
|
||||||
bool closed;
|
|
||||||
} SWindowStatus;
|
|
||||||
|
|
||||||
typedef struct SWindowResult {
|
typedef struct SWindowResult {
|
||||||
uint16_t numOfRows; // number of rows of current time window
|
|
||||||
SWindowStatus status; // this result status: closed or opened
|
|
||||||
SPosInfo pos; // Position of current result in disk-based output buffer
|
SPosInfo pos; // Position of current result in disk-based output buffer
|
||||||
|
uint16_t numOfRows; // number of rows of current time window
|
||||||
|
bool closed; // this result status: closed or opened
|
||||||
SResultInfo* resultInfo; // For each result column, there is a resultInfo
|
SResultInfo* resultInfo; // For each result column, there is a resultInfo
|
||||||
STimeWindow window; // The time window that current result covers.
|
TSKEY skey; // start key of current time window
|
||||||
} SWindowResult;
|
} SWindowResult;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -79,6 +81,7 @@ typedef struct SWindowResInfo {
|
||||||
int64_t startTime; // start time of the first time window for sliding query
|
int64_t startTime; // start time of the first time window for sliding query
|
||||||
int64_t prevSKey; // previous (not completed) sliding window start key
|
int64_t prevSKey; // previous (not completed) sliding window start key
|
||||||
int64_t threshold; // threshold to halt query and return the generated results.
|
int64_t threshold; // threshold to halt query and return the generated results.
|
||||||
|
int64_t interval; // time window interval
|
||||||
} SWindowResInfo;
|
} SWindowResInfo;
|
||||||
|
|
||||||
typedef struct SColumnFilterElem {
|
typedef struct SColumnFilterElem {
|
||||||
|
@ -98,7 +101,7 @@ typedef struct STableQueryInfo { // todo merge with the STableQueryInfo struct
|
||||||
TSKEY lastKey;
|
TSKEY lastKey;
|
||||||
int32_t groupIndex; // group id in table list
|
int32_t groupIndex; // group id in table list
|
||||||
int16_t queryRangeSet; // denote if the query range is set, only available for interval query
|
int16_t queryRangeSet; // denote if the query range is set, only available for interval query
|
||||||
int64_t tag;
|
tVariant tag;
|
||||||
STimeWindow win;
|
STimeWindow win;
|
||||||
STSCursor cur;
|
STSCursor cur;
|
||||||
void* pTable; // for retrieve the page id list
|
void* pTable; // for retrieve the page id list
|
||||||
|
@ -121,8 +124,9 @@ typedef struct SQueryCostInfo {
|
||||||
uint32_t loadBlockStatis;
|
uint32_t loadBlockStatis;
|
||||||
uint32_t discardBlocks;
|
uint32_t discardBlocks;
|
||||||
uint64_t elapsedTime;
|
uint64_t elapsedTime;
|
||||||
uint64_t computTime;
|
uint64_t firstStageMergeTime;
|
||||||
uint64_t internalSupSize;
|
uint64_t internalSupSize;
|
||||||
|
uint64_t numOfTimeWindows;
|
||||||
} SQueryCostInfo;
|
} SQueryCostInfo;
|
||||||
|
|
||||||
typedef struct SQuery {
|
typedef struct SQuery {
|
||||||
|
@ -189,21 +193,18 @@ typedef struct SQInfo {
|
||||||
int64_t owner; // if it is in execution
|
int64_t owner; // if it is in execution
|
||||||
void* tsdb;
|
void* tsdb;
|
||||||
int32_t vgId;
|
int32_t vgId;
|
||||||
STableGroupInfo tableGroupInfo; // table id list < only includes the STable list>
|
STableGroupInfo tableGroupInfo; // table <tid, last_key> list SArray<STableKeyInfo>
|
||||||
STableGroupInfo tableqinfoGroupInfo; // this is a group array list, including SArray<STableQueryInfo*> structure
|
STableGroupInfo tableqinfoGroupInfo; // this is a group array list, including SArray<STableQueryInfo*> structure
|
||||||
SQueryRuntimeEnv runtimeEnv;
|
SQueryRuntimeEnv runtimeEnv;
|
||||||
int32_t groupIndex;
|
|
||||||
int32_t offset; // offset in group result set of subgroup, todo refactor
|
|
||||||
SArray* arrTableIdInfo;
|
SArray* arrTableIdInfo;
|
||||||
|
int32_t groupIndex;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* the query is executed position on which meter of the whole list.
|
* the query is executed position on which meter of the whole list.
|
||||||
* when the index reaches the last one of the list, it means the query is completed.
|
* when the index reaches the last one of the list, it means the query is completed.
|
||||||
* We later may refactor to remove this attribution by using another flag to denote
|
|
||||||
* whether a multimeter query is completed or not.
|
|
||||||
*/
|
*/
|
||||||
int32_t tableIndex;
|
int32_t tableIndex;
|
||||||
int32_t numOfGroupResultPages;
|
SGroupResInfo groupResInfo;
|
||||||
void* pBuf; // allocated buffer for STableQueryInfo, sizeof(STableQueryInfo)*numOfTables;
|
void* pBuf; // allocated buffer for STableQueryInfo, sizeof(STableQueryInfo)*numOfTables;
|
||||||
|
|
||||||
pthread_mutex_t lock; // used to synchronize the rsp/query threads
|
pthread_mutex_t lock; // used to synchronize the rsp/query threads
|
||||||
|
|
|
@ -26,7 +26,7 @@ extern "C" {
|
||||||
#include "tstoken.h"
|
#include "tstoken.h"
|
||||||
#include "tvariant.h"
|
#include "tvariant.h"
|
||||||
|
|
||||||
#define ParseTOKENTYPE SSQLToken
|
#define ParseTOKENTYPE SStrToken
|
||||||
extern char tTokenTypeSwitcher[13];
|
extern char tTokenTypeSwitcher[13];
|
||||||
|
|
||||||
#define toTSDBType(x) \
|
#define toTSDBType(x) \
|
||||||
|
@ -71,16 +71,16 @@ typedef struct SQuerySQL {
|
||||||
struct tSQLExpr * pWhere; // where clause [optional]
|
struct tSQLExpr * pWhere; // where clause [optional]
|
||||||
tVariantList * pGroupby; // groupby clause, only for tags[optional]
|
tVariantList * pGroupby; // groupby clause, only for tags[optional]
|
||||||
tVariantList * pSortOrder; // orderby [optional]
|
tVariantList * pSortOrder; // orderby [optional]
|
||||||
SSQLToken interval; // interval [optional]
|
SStrToken interval; // interval [optional]
|
||||||
SSQLToken sliding; // sliding window [optional]
|
SStrToken sliding; // sliding window [optional]
|
||||||
SLimitVal limit; // limit offset [optional]
|
SLimitVal limit; // limit offset [optional]
|
||||||
SLimitVal slimit; // group limit offset [optional]
|
SLimitVal slimit; // group limit offset [optional]
|
||||||
tVariantList * fillType; // fill type[optional]
|
tVariantList * fillType; // fill type[optional]
|
||||||
SSQLToken selectToken; // sql string
|
SStrToken selectToken; // sql string
|
||||||
} SQuerySQL;
|
} SQuerySQL;
|
||||||
|
|
||||||
typedef struct SCreateTableSQL {
|
typedef struct SCreateTableSQL {
|
||||||
struct SSQLToken name; // meter name, create table [meterName] xxx
|
struct SStrToken name; // meter name, create table [meterName] xxx
|
||||||
bool existCheck;
|
bool existCheck;
|
||||||
|
|
||||||
int8_t type; // create normal table/from super table/ stream
|
int8_t type; // create normal table/from super table/ stream
|
||||||
|
@ -90,7 +90,7 @@ typedef struct SCreateTableSQL {
|
||||||
} colInfo;
|
} colInfo;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
SSQLToken stableName; // super table name, for using clause
|
SStrToken stableName; // super table name, for using clause
|
||||||
tVariantList *pTagVals; // create by using metric, tag value
|
tVariantList *pTagVals; // create by using metric, tag value
|
||||||
STagData tagdata;
|
STagData tagdata;
|
||||||
} usingInfo;
|
} usingInfo;
|
||||||
|
@ -99,7 +99,7 @@ typedef struct SCreateTableSQL {
|
||||||
} SCreateTableSQL;
|
} SCreateTableSQL;
|
||||||
|
|
||||||
typedef struct SAlterTableSQL {
|
typedef struct SAlterTableSQL {
|
||||||
SSQLToken name;
|
SStrToken name;
|
||||||
int16_t type;
|
int16_t type;
|
||||||
STagData tagData;
|
STagData tagData;
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ typedef struct SAlterTableSQL {
|
||||||
} SAlterTableSQL;
|
} SAlterTableSQL;
|
||||||
|
|
||||||
typedef struct SCreateDBInfo {
|
typedef struct SCreateDBInfo {
|
||||||
SSQLToken dbname;
|
SStrToken dbname;
|
||||||
int32_t replica;
|
int32_t replica;
|
||||||
int32_t cacheBlockSize;
|
int32_t cacheBlockSize;
|
||||||
int32_t maxTablesPerVnode;
|
int32_t maxTablesPerVnode;
|
||||||
|
@ -121,7 +121,7 @@ typedef struct SCreateDBInfo {
|
||||||
int32_t walLevel;
|
int32_t walLevel;
|
||||||
int32_t quorum;
|
int32_t quorum;
|
||||||
int32_t compressionLevel;
|
int32_t compressionLevel;
|
||||||
SSQLToken precision;
|
SStrToken precision;
|
||||||
bool ignoreExists;
|
bool ignoreExists;
|
||||||
|
|
||||||
tVariantList *keep;
|
tVariantList *keep;
|
||||||
|
@ -136,33 +136,33 @@ typedef struct SCreateAcctSQL {
|
||||||
int64_t maxStorage;
|
int64_t maxStorage;
|
||||||
int64_t maxQueryTime;
|
int64_t maxQueryTime;
|
||||||
int32_t maxConnections;
|
int32_t maxConnections;
|
||||||
SSQLToken stat;
|
SStrToken stat;
|
||||||
} SCreateAcctSQL;
|
} SCreateAcctSQL;
|
||||||
|
|
||||||
typedef struct SShowInfo {
|
typedef struct SShowInfo {
|
||||||
uint8_t showType;
|
uint8_t showType;
|
||||||
SSQLToken prefix;
|
SStrToken prefix;
|
||||||
SSQLToken pattern;
|
SStrToken pattern;
|
||||||
} SShowInfo;
|
} SShowInfo;
|
||||||
|
|
||||||
typedef struct SUserInfo {
|
typedef struct SUserInfo {
|
||||||
SSQLToken user;
|
SStrToken user;
|
||||||
SSQLToken passwd;
|
SStrToken passwd;
|
||||||
SSQLToken privilege;
|
SStrToken privilege;
|
||||||
int16_t type;
|
int16_t type;
|
||||||
} SUserInfo;
|
} SUserInfo;
|
||||||
|
|
||||||
typedef struct tDCLSQL {
|
typedef struct tDCLSQL {
|
||||||
int32_t nTokens; /* Number of expressions on the list */
|
int32_t nTokens; /* Number of expressions on the list */
|
||||||
int32_t nAlloc; /* Number of entries allocated below */
|
int32_t nAlloc; /* Number of entries allocated below */
|
||||||
SSQLToken *a; /* one entry for element */
|
SStrToken *a; /* one entry for element */
|
||||||
bool existsCheck;
|
bool existsCheck;
|
||||||
|
|
||||||
union {
|
union {
|
||||||
SCreateDBInfo dbOpt;
|
SCreateDBInfo dbOpt;
|
||||||
SCreateAcctSQL acctOpt;
|
SCreateAcctSQL acctOpt;
|
||||||
SShowInfo showOpt;
|
SShowInfo showOpt;
|
||||||
SSQLToken ip;
|
SStrToken ip;
|
||||||
};
|
};
|
||||||
|
|
||||||
SUserInfo user;
|
SUserInfo user;
|
||||||
|
@ -194,14 +194,14 @@ typedef struct tSQLExpr {
|
||||||
|
|
||||||
// the full sql string of function(col, param), which is actually the raw
|
// the full sql string of function(col, param), which is actually the raw
|
||||||
// field name, since the function name is kept in nSQLOptr already
|
// field name, since the function name is kept in nSQLOptr already
|
||||||
SSQLToken operand;
|
SStrToken operand;
|
||||||
SSQLToken colInfo; // field id
|
SStrToken colInfo; // field id
|
||||||
tVariant val; // value only for string, float, int
|
tVariant val; // value only for string, float, int
|
||||||
|
|
||||||
struct tSQLExpr *pLeft; // left child
|
struct tSQLExpr *pLeft; // left child
|
||||||
struct tSQLExpr *pRight; // right child
|
struct tSQLExpr *pRight; // right child
|
||||||
|
|
||||||
struct tSQLExprList *pParam; // function parameters
|
struct tSQLExprList *pParam; // function parameters
|
||||||
|
SStrToken token; // original sql expr string
|
||||||
} tSQLExpr;
|
} tSQLExpr;
|
||||||
|
|
||||||
// used in select clause. select <tSQLExprList> from xxx
|
// used in select clause. select <tSQLExprList> from xxx
|
||||||
|
@ -210,6 +210,7 @@ typedef struct tSQLExprItem {
|
||||||
char * aliasName; // alias name, null-terminated string
|
char * aliasName; // alias name, null-terminated string
|
||||||
} tSQLExprItem;
|
} tSQLExprItem;
|
||||||
|
|
||||||
|
// todo refactor by using SArray
|
||||||
typedef struct tSQLExprList {
|
typedef struct tSQLExprList {
|
||||||
int32_t nExpr; /* Number of expressions on the list */
|
int32_t nExpr; /* Number of expressions on the list */
|
||||||
int32_t nAlloc; /* Number of entries allocated below */
|
int32_t nAlloc; /* Number of entries allocated below */
|
||||||
|
@ -242,7 +243,7 @@ tVariantList *tVariantListAppend(tVariantList *pList, tVariant *pVar, uint8_t so
|
||||||
|
|
||||||
tVariantList *tVariantListInsert(tVariantList *pList, tVariant *pVar, uint8_t sortOrder, int32_t index);
|
tVariantList *tVariantListInsert(tVariantList *pList, tVariant *pVar, uint8_t sortOrder, int32_t index);
|
||||||
|
|
||||||
tVariantList *tVariantListAppendToken(tVariantList *pList, SSQLToken *pAliasToken, uint8_t sortOrder);
|
tVariantList *tVariantListAppendToken(tVariantList *pList, SStrToken *pAliasToken, uint8_t sortOrder);
|
||||||
void tVariantListDestroy(tVariantList *pList);
|
void tVariantListDestroy(tVariantList *pList);
|
||||||
|
|
||||||
tFieldList *tFieldListAppend(tFieldList *pList, TAOS_FIELD *pField);
|
tFieldList *tFieldListAppend(tFieldList *pList, TAOS_FIELD *pField);
|
||||||
|
@ -253,61 +254,61 @@ tSQLExpr *tSQLExprCreate(tSQLExpr *pLeft, tSQLExpr *pRight, int32_t optType);
|
||||||
|
|
||||||
void tSQLExprDestroy(tSQLExpr *);
|
void tSQLExprDestroy(tSQLExpr *);
|
||||||
|
|
||||||
tSQLExprList *tSQLExprListAppend(tSQLExprList *pList, tSQLExpr *pNode, SSQLToken *pToken);
|
tSQLExprList *tSQLExprListAppend(tSQLExprList *pList, tSQLExpr *pNode, SStrToken *pToken);
|
||||||
|
|
||||||
void tSQLExprListDestroy(tSQLExprList *pList);
|
void tSQLExprListDestroy(tSQLExprList *pList);
|
||||||
|
|
||||||
SQuerySQL *tSetQuerySQLElems(SSQLToken *pSelectToken, tSQLExprList *pSelection, tVariantList *pFrom, tSQLExpr *pWhere,
|
SQuerySQL *tSetQuerySQLElems(SStrToken *pSelectToken, tSQLExprList *pSelection, tVariantList *pFrom, tSQLExpr *pWhere,
|
||||||
tVariantList *pGroupby, tVariantList *pSortOrder, SSQLToken *pInterval,
|
tVariantList *pGroupby, tVariantList *pSortOrder, SStrToken *pInterval,
|
||||||
SSQLToken *pSliding, tVariantList *pFill, SLimitVal *pLimit, SLimitVal *pGLimit);
|
SStrToken *pSliding, tVariantList *pFill, SLimitVal *pLimit, SLimitVal *pGLimit);
|
||||||
|
|
||||||
SCreateTableSQL *tSetCreateSQLElems(tFieldList *pCols, tFieldList *pTags, SSQLToken *pMetricName,
|
SCreateTableSQL *tSetCreateSQLElems(tFieldList *pCols, tFieldList *pTags, SStrToken *pMetricName,
|
||||||
tVariantList *pTagVals, SQuerySQL *pSelect, int32_t type);
|
tVariantList *pTagVals, SQuerySQL *pSelect, int32_t type);
|
||||||
|
|
||||||
void tSQLExprNodeDestroy(tSQLExpr *pExpr);
|
void tSQLExprNodeDestroy(tSQLExpr *pExpr);
|
||||||
tSQLExpr *tSQLExprNodeClone(tSQLExpr *pExpr);
|
tSQLExpr *tSQLExprNodeClone(tSQLExpr *pExpr);
|
||||||
|
|
||||||
SAlterTableSQL *tAlterTableSQLElems(SSQLToken *pMeterName, tFieldList *pCols, tVariantList *pVals, int32_t type);
|
SAlterTableSQL *tAlterTableSQLElems(SStrToken *pMeterName, tFieldList *pCols, tVariantList *pVals, int32_t type);
|
||||||
|
|
||||||
tSQLExprListList *tSQLListListAppend(tSQLExprListList *pList, tSQLExprList *pExprList);
|
tSQLExprListList *tSQLListListAppend(tSQLExprListList *pList, tSQLExprList *pExprList);
|
||||||
|
|
||||||
void destroyAllSelectClause(SSubclauseInfo *pSql);
|
void destroyAllSelectClause(SSubclauseInfo *pSql);
|
||||||
void doDestroyQuerySql(SQuerySQL *pSql);
|
void doDestroyQuerySql(SQuerySQL *pSql);
|
||||||
|
|
||||||
SSqlInfo * setSQLInfo(SSqlInfo *pInfo, void *pSqlExprInfo, SSQLToken *pMeterName, int32_t type);
|
SSqlInfo * setSQLInfo(SSqlInfo *pInfo, void *pSqlExprInfo, SStrToken *pMeterName, int32_t type);
|
||||||
SSubclauseInfo *setSubclause(SSubclauseInfo *pClause, void *pSqlExprInfo);
|
SSubclauseInfo *setSubclause(SSubclauseInfo *pClause, void *pSqlExprInfo);
|
||||||
|
|
||||||
SSubclauseInfo *appendSelectClause(SSubclauseInfo *pInfo, void *pSubclause);
|
SSubclauseInfo *appendSelectClause(SSubclauseInfo *pInfo, void *pSubclause);
|
||||||
|
|
||||||
void setCreatedTableName(SSqlInfo *pInfo, SSQLToken *pMeterName, SSQLToken *pIfNotExists);
|
void setCreatedTableName(SSqlInfo *pInfo, SStrToken *pMeterName, SStrToken *pIfNotExists);
|
||||||
|
|
||||||
void SQLInfoDestroy(SSqlInfo *pInfo);
|
void SQLInfoDestroy(SSqlInfo *pInfo);
|
||||||
|
|
||||||
void setDCLSQLElems(SSqlInfo *pInfo, int32_t type, int32_t nParams, ...);
|
void setDCLSQLElems(SSqlInfo *pInfo, int32_t type, int32_t nParams, ...);
|
||||||
void setDropDBTableInfo(SSqlInfo *pInfo, int32_t type, SSQLToken* pToken, SSQLToken* existsCheck);
|
void setDropDBTableInfo(SSqlInfo *pInfo, int32_t type, SStrToken* pToken, SStrToken* existsCheck);
|
||||||
void setShowOptions(SSqlInfo *pInfo, int32_t type, SSQLToken* prefix, SSQLToken* pPatterns);
|
void setShowOptions(SSqlInfo *pInfo, int32_t type, SStrToken* prefix, SStrToken* pPatterns);
|
||||||
|
|
||||||
tDCLSQL *tTokenListAppend(tDCLSQL *pTokenList, SSQLToken *pToken);
|
tDCLSQL *tTokenListAppend(tDCLSQL *pTokenList, SStrToken *pToken);
|
||||||
|
|
||||||
void setCreateDBSQL(SSqlInfo *pInfo, int32_t type, SSQLToken *pToken, SCreateDBInfo *pDB, SSQLToken *pIgExists);
|
void setCreateDBSQL(SSqlInfo *pInfo, int32_t type, SStrToken *pToken, SCreateDBInfo *pDB, SStrToken *pIgExists);
|
||||||
|
|
||||||
void setCreateAcctSQL(SSqlInfo *pInfo, int32_t type, SSQLToken *pName, SSQLToken *pPwd, SCreateAcctSQL *pAcctInfo);
|
void setCreateAcctSQL(SSqlInfo *pInfo, int32_t type, SStrToken *pName, SStrToken *pPwd, SCreateAcctSQL *pAcctInfo);
|
||||||
void setCreateUserSQL(SSqlInfo *pInfo, SSQLToken *pName, SSQLToken *pPasswd);
|
void setCreateUserSQL(SSqlInfo *pInfo, SStrToken *pName, SStrToken *pPasswd);
|
||||||
void setKillSQL(SSqlInfo *pInfo, int32_t type, SSQLToken *ip);
|
void setKillSQL(SSqlInfo *pInfo, int32_t type, SStrToken *ip);
|
||||||
void setAlterUserSQL(SSqlInfo *pInfo, int16_t type, SSQLToken *pName, SSQLToken* pPwd, SSQLToken *pPrivilege);
|
void setAlterUserSQL(SSqlInfo *pInfo, int16_t type, SStrToken *pName, SStrToken* pPwd, SStrToken *pPrivilege);
|
||||||
|
|
||||||
void setDefaultCreateDbOption(SCreateDBInfo *pDBInfo);
|
void setDefaultCreateDbOption(SCreateDBInfo *pDBInfo);
|
||||||
|
|
||||||
// prefix show db.tables;
|
// prefix show db.tables;
|
||||||
void setDBName(SSQLToken *pCpxName, SSQLToken *pDB);
|
void setDBName(SStrToken *pCpxName, SStrToken *pDB);
|
||||||
|
|
||||||
tSQLExpr *tSQLExprIdValueCreate(SSQLToken *pToken, int32_t optType);
|
tSQLExpr *tSQLExprIdValueCreate(SStrToken *pToken, int32_t optType);
|
||||||
|
|
||||||
tSQLExpr *tSQLExprCreateFunction(tSQLExprList *pList, SSQLToken *pFuncToken, SSQLToken *endToken, int32_t optType);
|
tSQLExpr *tSQLExprCreateFunction(tSQLExprList *pList, SStrToken *pFuncToken, SStrToken *endToken, int32_t optType);
|
||||||
|
|
||||||
void tSQLSetColumnInfo(TAOS_FIELD *pField, SSQLToken *pName, TAOS_FIELD *pType);
|
void tSQLSetColumnInfo(TAOS_FIELD *pField, SStrToken *pName, TAOS_FIELD *pType);
|
||||||
|
|
||||||
void tSQLSetColumnType(TAOS_FIELD *pField, SSQLToken *pToken);
|
void tSQLSetColumnType(TAOS_FIELD *pField, SStrToken *pToken);
|
||||||
|
|
||||||
void *ParseAlloc(void *(*mallocProc)(size_t));
|
void *ParseAlloc(void *(*mallocProc)(size_t));
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ extern "C" {
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "taosdef.h"
|
#include "taosdef.h"
|
||||||
|
#include "tvariant.h"
|
||||||
|
|
||||||
#define MEM_BUF_SIZE (1 << 20)
|
#define MEM_BUF_SIZE (1 << 20)
|
||||||
#define TS_COMP_FILE_MAGIC 0x87F5EC4C
|
#define TS_COMP_FILE_MAGIC 0x87F5EC4C
|
||||||
|
@ -43,7 +44,7 @@ typedef struct STSRawBlock {
|
||||||
|
|
||||||
typedef struct STSElem {
|
typedef struct STSElem {
|
||||||
TSKEY ts;
|
TSKEY ts;
|
||||||
int64_t tag;
|
tVariant tag;
|
||||||
int32_t vnode;
|
int32_t vnode;
|
||||||
} STSElem;
|
} STSElem;
|
||||||
|
|
||||||
|
@ -55,7 +56,7 @@ typedef struct STSCursor {
|
||||||
} STSCursor;
|
} STSCursor;
|
||||||
|
|
||||||
typedef struct STSBlock {
|
typedef struct STSBlock {
|
||||||
int64_t tag; // tag value
|
tVariant tag; // tag value
|
||||||
int32_t numOfElem; // number of elements
|
int32_t numOfElem; // number of elements
|
||||||
int32_t compLen; // size after compressed
|
int32_t compLen; // size after compressed
|
||||||
int32_t padding; // 0xFFFFFFFF by default, after the payload
|
int32_t padding; // 0xFFFFFFFF by default, after the payload
|
||||||
|
@ -84,8 +85,8 @@ typedef struct STSBuf {
|
||||||
uint32_t fileSize;
|
uint32_t fileSize;
|
||||||
|
|
||||||
STSVnodeBlockInfoEx* pData;
|
STSVnodeBlockInfoEx* pData;
|
||||||
int32_t numOfAlloc;
|
uint32_t numOfAlloc;
|
||||||
int32_t numOfVnodes;
|
uint32_t numOfVnodes;
|
||||||
|
|
||||||
char* assistBuf;
|
char* assistBuf;
|
||||||
int32_t bufSize;
|
int32_t bufSize;
|
||||||
|
@ -109,7 +110,7 @@ STSBuf* tsBufCreateFromCompBlocks(const char* pData, int32_t numOfBlocks, int32_
|
||||||
|
|
||||||
void* tsBufDestroy(STSBuf* pTSBuf);
|
void* tsBufDestroy(STSBuf* pTSBuf);
|
||||||
|
|
||||||
void tsBufAppend(STSBuf* pTSBuf, int32_t vnodeId, int64_t tag, const char* pData, int32_t len);
|
void tsBufAppend(STSBuf* pTSBuf, int32_t vnodeId, tVariant* tag, const char* pData, int32_t len);
|
||||||
int32_t tsBufMerge(STSBuf* pDestBuf, const STSBuf* pSrcBuf, int32_t vnodeIdx);
|
int32_t tsBufMerge(STSBuf* pDestBuf, const STSBuf* pSrcBuf, int32_t vnodeIdx);
|
||||||
|
|
||||||
STSBuf* tsBufClone(STSBuf* pTSBuf);
|
STSBuf* tsBufClone(STSBuf* pTSBuf);
|
||||||
|
@ -122,7 +123,7 @@ void tsBufResetPos(STSBuf* pTSBuf);
|
||||||
STSElem tsBufGetElem(STSBuf* pTSBuf);
|
STSElem tsBufGetElem(STSBuf* pTSBuf);
|
||||||
bool tsBufNextPos(STSBuf* pTSBuf);
|
bool tsBufNextPos(STSBuf* pTSBuf);
|
||||||
|
|
||||||
STSElem tsBufGetElemStartPos(STSBuf* pTSBuf, int32_t vnodeId, int64_t tag);
|
STSElem tsBufGetElemStartPos(STSBuf* pTSBuf, int32_t vnodeId, tVariant* tag);
|
||||||
|
|
||||||
STSCursor tsBufGetCursor(STSBuf* pTSBuf);
|
STSCursor tsBufGetCursor(STSBuf* pTSBuf);
|
||||||
void tsBufSetTraverseOrder(STSBuf* pTSBuf, int32_t order);
|
void tsBufSetTraverseOrder(STSBuf* pTSBuf, int32_t order);
|
||||||
|
|
|
@ -38,7 +38,8 @@ static FORCE_INLINE SWindowResult *getWindowResult(SWindowResInfo *pWindowResInf
|
||||||
return &pWindowResInfo->pResult[slot];
|
return &pWindowResInfo->pResult[slot];
|
||||||
}
|
}
|
||||||
|
|
||||||
#define curTimeWindow(_winres) ((_winres)->curIndex)
|
#define curTimeWindowIndex(_winres) ((_winres)->curIndex)
|
||||||
|
#define GET_TIMEWINDOW(_winresInfo, _win) (STimeWindow) {(_win)->skey, ((_win)->skey + (_winresInfo)->interval - 1)}
|
||||||
#define GET_ROW_PARAM_FOR_MULTIOUTPUT(_q, tbq, sq) (((tbq) && (!sq))? (_q)->pSelectExpr[1].base.arg->argValue.i64:1)
|
#define GET_ROW_PARAM_FOR_MULTIOUTPUT(_q, tbq, sq) (((tbq) && (!sq))? (_q)->pSelectExpr[1].base.arg->argValue.i64:1)
|
||||||
|
|
||||||
bool isWindowResClosed(SWindowResInfo *pWindowResInfo, int32_t slot);
|
bool isWindowResClosed(SWindowResInfo *pWindowResInfo, int32_t slot);
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
//usage: lemon sql.y
|
//usage: lemon sql.y
|
||||||
%token_prefix TK_
|
%token_prefix TK_
|
||||||
|
|
||||||
%token_type {SSQLToken}
|
%token_type {SStrToken}
|
||||||
%default_type {SSQLToken}
|
%default_type {SStrToken}
|
||||||
%extra_argument {SSqlInfo* pInfo}
|
%extra_argument {SSqlInfo* pInfo}
|
||||||
|
|
||||||
%fallback ID BOOL TINYINT SMALLINT INTEGER BIGINT FLOAT DOUBLE STRING TIMESTAMP BINARY NCHAR.
|
%fallback ID BOOL TINYINT SMALLINT INTEGER BIGINT FLOAT DOUBLE STRING TIMESTAMP BINARY NCHAR.
|
||||||
|
@ -73,18 +73,18 @@ cmd ::= SHOW MODULES. { setShowOptions(pInfo, TSDB_MGMT_TABLE_MODULE, 0, 0);
|
||||||
cmd ::= SHOW QUERIES. { setShowOptions(pInfo, TSDB_MGMT_TABLE_QUERIES, 0, 0); }
|
cmd ::= SHOW QUERIES. { setShowOptions(pInfo, TSDB_MGMT_TABLE_QUERIES, 0, 0); }
|
||||||
cmd ::= SHOW CONNECTIONS.{ setShowOptions(pInfo, TSDB_MGMT_TABLE_CONNS, 0, 0);}
|
cmd ::= SHOW CONNECTIONS.{ setShowOptions(pInfo, TSDB_MGMT_TABLE_CONNS, 0, 0);}
|
||||||
cmd ::= SHOW STREAMS. { setShowOptions(pInfo, TSDB_MGMT_TABLE_STREAMS, 0, 0); }
|
cmd ::= SHOW STREAMS. { setShowOptions(pInfo, TSDB_MGMT_TABLE_STREAMS, 0, 0); }
|
||||||
cmd ::= SHOW CONFIGS. { setShowOptions(pInfo, TSDB_MGMT_TABLE_CONFIGS, 0, 0); }
|
cmd ::= SHOW VARIABLES. { setShowOptions(pInfo, TSDB_MGMT_TABLE_VARIABLES, 0, 0); }
|
||||||
cmd ::= SHOW SCORES. { setShowOptions(pInfo, TSDB_MGMT_TABLE_SCORES, 0, 0); }
|
cmd ::= SHOW SCORES. { setShowOptions(pInfo, TSDB_MGMT_TABLE_SCORES, 0, 0); }
|
||||||
cmd ::= SHOW GRANTS. { setShowOptions(pInfo, TSDB_MGMT_TABLE_GRANTS, 0, 0); }
|
cmd ::= SHOW GRANTS. { setShowOptions(pInfo, TSDB_MGMT_TABLE_GRANTS, 0, 0); }
|
||||||
|
|
||||||
cmd ::= SHOW VNODES. { setShowOptions(pInfo, TSDB_MGMT_TABLE_VNODES, 0, 0); }
|
cmd ::= SHOW VNODES. { setShowOptions(pInfo, TSDB_MGMT_TABLE_VNODES, 0, 0); }
|
||||||
cmd ::= SHOW VNODES IPTOKEN(X). { setShowOptions(pInfo, TSDB_MGMT_TABLE_VNODES, &X, 0); }
|
cmd ::= SHOW VNODES IPTOKEN(X). { setShowOptions(pInfo, TSDB_MGMT_TABLE_VNODES, &X, 0); }
|
||||||
|
|
||||||
%type dbPrefix {SSQLToken}
|
%type dbPrefix {SStrToken}
|
||||||
dbPrefix(A) ::=. {A.n = 0; A.type = 0;}
|
dbPrefix(A) ::=. {A.n = 0; A.type = 0;}
|
||||||
dbPrefix(A) ::= ids(X) DOT. {A = X; }
|
dbPrefix(A) ::= ids(X) DOT. {A = X; }
|
||||||
|
|
||||||
%type cpxName {SSQLToken}
|
%type cpxName {SStrToken}
|
||||||
cpxName(A) ::= . {A.n = 0; }
|
cpxName(A) ::= . {A.n = 0; }
|
||||||
cpxName(A) ::= DOT ids(Y). {A = Y; A.n += 1; }
|
cpxName(A) ::= DOT ids(Y). {A = Y; A.n += 1; }
|
||||||
|
|
||||||
|
@ -101,19 +101,19 @@ cmd ::= SHOW dbPrefix(X) STABLES. {
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd ::= SHOW dbPrefix(X) STABLES LIKE ids(Y). {
|
cmd ::= SHOW dbPrefix(X) STABLES LIKE ids(Y). {
|
||||||
SSQLToken token;
|
SStrToken token;
|
||||||
setDBName(&token, &X);
|
setDBName(&token, &X);
|
||||||
setShowOptions(pInfo, TSDB_MGMT_TABLE_METRIC, &token, &Y);
|
setShowOptions(pInfo, TSDB_MGMT_TABLE_METRIC, &token, &Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd ::= SHOW dbPrefix(X) VGROUPS. {
|
cmd ::= SHOW dbPrefix(X) VGROUPS. {
|
||||||
SSQLToken token;
|
SStrToken token;
|
||||||
setDBName(&token, &X);
|
setDBName(&token, &X);
|
||||||
setShowOptions(pInfo, TSDB_MGMT_TABLE_VGROUP, &token, 0);
|
setShowOptions(pInfo, TSDB_MGMT_TABLE_VGROUP, &token, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd ::= SHOW dbPrefix(X) VGROUPS ids(Y). {
|
cmd ::= SHOW dbPrefix(X) VGROUPS ids(Y). {
|
||||||
SSQLToken token;
|
SStrToken token;
|
||||||
setDBName(&token, &X);
|
setDBName(&token, &X);
|
||||||
setShowOptions(pInfo, TSDB_MGMT_TABLE_VGROUP, &token, &Y);
|
setShowOptions(pInfo, TSDB_MGMT_TABLE_VGROUP, &token, &Y);
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ cmd ::= ALTER DNODE ids(X) ids(Y). { setDCLSQLElems(pInfo, TSDB_SQL
|
||||||
cmd ::= ALTER DNODE ids(X) ids(Y) ids(Z). { setDCLSQLElems(pInfo, TSDB_SQL_CFG_DNODE, 3, &X, &Y, &Z); }
|
cmd ::= ALTER DNODE ids(X) ids(Y) ids(Z). { setDCLSQLElems(pInfo, TSDB_SQL_CFG_DNODE, 3, &X, &Y, &Z); }
|
||||||
cmd ::= ALTER LOCAL ids(X). { setDCLSQLElems(pInfo, TSDB_SQL_CFG_LOCAL, 1, &X); }
|
cmd ::= ALTER LOCAL ids(X). { setDCLSQLElems(pInfo, TSDB_SQL_CFG_LOCAL, 1, &X); }
|
||||||
cmd ::= ALTER LOCAL ids(X) ids(Y). { setDCLSQLElems(pInfo, TSDB_SQL_CFG_LOCAL, 2, &X, &Y); }
|
cmd ::= ALTER LOCAL ids(X) ids(Y). { setDCLSQLElems(pInfo, TSDB_SQL_CFG_LOCAL, 2, &X, &Y); }
|
||||||
cmd ::= ALTER DATABASE ids(X) alter_db_optr(Y). { SSQLToken t = {0}; setCreateDBSQL(pInfo, TSDB_SQL_ALTER_DB, &X, &Y, &t);}
|
cmd ::= ALTER DATABASE ids(X) alter_db_optr(Y). { SStrToken t = {0}; setCreateDBSQL(pInfo, TSDB_SQL_ALTER_DB, &X, &Y, &t);}
|
||||||
|
|
||||||
cmd ::= ALTER ACCOUNT ids(X) acct_optr(Z). { setCreateAcctSQL(pInfo, TSDB_SQL_ALTER_ACCT, &X, NULL, &Z);}
|
cmd ::= ALTER ACCOUNT ids(X) acct_optr(Z). { setCreateAcctSQL(pInfo, TSDB_SQL_ALTER_ACCT, &X, NULL, &Z);}
|
||||||
cmd ::= ALTER ACCOUNT ids(X) PASS ids(Y) acct_optr(Z). { setCreateAcctSQL(pInfo, TSDB_SQL_ALTER_ACCT, &X, &Y, &Z);}
|
cmd ::= ALTER ACCOUNT ids(X) PASS ids(Y) acct_optr(Z). { setCreateAcctSQL(pInfo, TSDB_SQL_ALTER_ACCT, &X, &Y, &Z);}
|
||||||
|
@ -153,15 +153,15 @@ cmd ::= ALTER ACCOUNT ids(X) PASS ids(Y) acct_optr(Z). { setCreateAcctSQL(p
|
||||||
// An IDENTIFIER can be a generic identifier, or one of several keywords.
|
// An IDENTIFIER can be a generic identifier, or one of several keywords.
|
||||||
// Any non-standard keyword can also be an identifier.
|
// Any non-standard keyword can also be an identifier.
|
||||||
// And "ids" is an identifer-or-string.
|
// And "ids" is an identifer-or-string.
|
||||||
%type ids {SSQLToken}
|
%type ids {SStrToken}
|
||||||
ids(A) ::= ID(X). {A = X; }
|
ids(A) ::= ID(X). {A = X; }
|
||||||
ids(A) ::= STRING(X). {A = X; }
|
ids(A) ::= STRING(X). {A = X; }
|
||||||
|
|
||||||
%type ifexists {SSQLToken}
|
%type ifexists {SStrToken}
|
||||||
ifexists(X) ::= IF EXISTS. {X.n = 1;}
|
ifexists(X) ::= IF EXISTS. {X.n = 1;}
|
||||||
ifexists(X) ::= . {X.n = 0;}
|
ifexists(X) ::= . {X.n = 0;}
|
||||||
|
|
||||||
%type ifnotexists {SSQLToken}
|
%type ifnotexists {SStrToken}
|
||||||
ifnotexists(X) ::= IF NOT EXISTS. {X.n = 1;}
|
ifnotexists(X) ::= IF NOT EXISTS. {X.n = 1;}
|
||||||
ifnotexists(X) ::= . {X.n = 0;}
|
ifnotexists(X) ::= . {X.n = 0;}
|
||||||
|
|
||||||
|
@ -416,7 +416,7 @@ selcollist(A) ::= sclp(P) STAR. {
|
||||||
// An option "AS <id>" phrase that can follow one of the expressions that
|
// An option "AS <id>" phrase that can follow one of the expressions that
|
||||||
// define the result set, or one of the tables in the FROM clause.
|
// define the result set, or one of the tables in the FROM clause.
|
||||||
//
|
//
|
||||||
%type as {SSQLToken}
|
%type as {SStrToken}
|
||||||
as(X) ::= AS ids(Y). { X = Y; }
|
as(X) ::= AS ids(Y). { X = Y; }
|
||||||
as(X) ::= ids(Y). { X = Y; }
|
as(X) ::= ids(Y). { X = Y; }
|
||||||
as(X) ::= . { X.n = 0; }
|
as(X) ::= . { X.n = 0; }
|
||||||
|
@ -458,10 +458,10 @@ tablelist(A) ::= tablelist(Y) COMMA ids(X) cpxName(Z) ids(F). {
|
||||||
}
|
}
|
||||||
|
|
||||||
// The value of interval should be the form of "number+[a,s,m,h,d,n,y]" or "now"
|
// The value of interval should be the form of "number+[a,s,m,h,d,n,y]" or "now"
|
||||||
%type tmvar {SSQLToken}
|
%type tmvar {SStrToken}
|
||||||
tmvar(A) ::= VARIABLE(X). {A = X;}
|
tmvar(A) ::= VARIABLE(X). {A = X;}
|
||||||
|
|
||||||
%type interval_opt {SSQLToken}
|
%type interval_opt {SStrToken}
|
||||||
interval_opt(N) ::= INTERVAL LP tmvar(E) RP. {N = E; }
|
interval_opt(N) ::= INTERVAL LP tmvar(E) RP. {N = E; }
|
||||||
interval_opt(N) ::= . {N.n = 0; N.z = NULL; N.type = 0; }
|
interval_opt(N) ::= . {N.n = 0; N.z = NULL; N.type = 0; }
|
||||||
|
|
||||||
|
@ -482,7 +482,7 @@ fill_opt(N) ::= FILL LP ID(Y) RP. {
|
||||||
N = tVariantListAppendToken(NULL, &Y, -1);
|
N = tVariantListAppendToken(NULL, &Y, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
%type sliding_opt {SSQLToken}
|
%type sliding_opt {SStrToken}
|
||||||
sliding_opt(K) ::= SLIDING LP tmvar(E) RP. {K = E; }
|
sliding_opt(K) ::= SLIDING LP tmvar(E) RP. {K = E; }
|
||||||
sliding_opt(K) ::= . {K.n = 0; K.z = NULL; K.type = 0; }
|
sliding_opt(K) ::= . {K.n = 0; K.z = NULL; K.type = 0; }
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ extern "C" {
|
||||||
|
|
||||||
#define GET_FORWARD_DIRECTION_FACTOR(ord) (((ord) == TSDB_ORDER_ASC) ? QUERY_ASC_FORWARD_STEP : QUERY_DESC_FORWARD_STEP)
|
#define GET_FORWARD_DIRECTION_FACTOR(ord) (((ord) == TSDB_ORDER_ASC) ? QUERY_ASC_FORWARD_STEP : QUERY_DESC_FORWARD_STEP)
|
||||||
|
|
||||||
#define MAX_RETRIEVE_ROWS_IN_INTERVAL_QUERY 10000000
|
#define MAX_INTERVAL_TIME_WINDOW 10000000
|
||||||
#define TOP_BOTTOM_QUERY_LIMIT 100
|
#define TOP_BOTTOM_QUERY_LIMIT 100
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
@ -141,8 +141,8 @@ typedef struct SResultInfo {
|
||||||
bool initialized; // output buffer has been initialized
|
bool initialized; // output buffer has been initialized
|
||||||
bool complete; // query has completed
|
bool complete; // query has completed
|
||||||
bool superTableQ; // is super table query
|
bool superTableQ; // is super table query
|
||||||
int32_t numOfRes; // num of output result in current buffer
|
uint32_t bufLen; // buffer size
|
||||||
int32_t bufLen; // buffer size
|
uint64_t numOfRes; // num of output result in current buffer
|
||||||
void* interResultBuf; // output result buffer
|
void* interResultBuf; // output result buffer
|
||||||
} SResultInfo;
|
} SResultInfo;
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
* ver 0.3, pipeline filter in the form of: (a+2)/9 > 14
|
* ver 0.3, pipeline filter in the form of: (a+2)/9 > 14
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static tExprNode *tExprNodeCreate(SSchema *pSchema, int32_t numOfCols, SSQLToken *pToken);
|
static tExprNode *tExprNodeCreate(SSchema *pSchema, int32_t numOfCols, SStrToken *pToken);
|
||||||
|
|
||||||
static tExprNode *createSyntaxTree(SSchema *pSchema, int32_t numOfCols, char *str, int32_t *i);
|
static tExprNode *createSyntaxTree(SSchema *pSchema, int32_t numOfCols, char *str, int32_t *i);
|
||||||
static void destroySyntaxTree(tExprNode *);
|
static void destroySyntaxTree(tExprNode *);
|
||||||
|
@ -103,7 +103,7 @@ static void reviseBinaryExprIfNecessary(tExprNode **pLeft, tExprNode **pRight, u
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static tExprNode *tExprNodeCreate(SSchema *pSchema, int32_t numOfCols, SSQLToken *pToken) {
|
static tExprNode *tExprNodeCreate(SSchema *pSchema, int32_t numOfCols, SStrToken *pToken) {
|
||||||
/* if the token is not a value, return false */
|
/* if the token is not a value, return false */
|
||||||
if (pToken->type == TK_RP || (pToken->type != TK_INTEGER && pToken->type != TK_FLOAT && pToken->type != TK_ID &&
|
if (pToken->type == TK_RP || (pToken->type != TK_INTEGER && pToken->type != TK_FLOAT && pToken->type != TK_ID &&
|
||||||
pToken->type != TK_TBNAME && pToken->type != TK_STRING && pToken->type != TK_BOOL)) {
|
pToken->type != TK_TBNAME && pToken->type != TK_STRING && pToken->type != TK_BOOL)) {
|
||||||
|
@ -117,7 +117,7 @@ static tExprNode *tExprNodeCreate(SSchema *pSchema, int32_t numOfCols, SSQLToken
|
||||||
int32_t i = 0;
|
int32_t i = 0;
|
||||||
if (pToken->type == TK_ID) {
|
if (pToken->type == TK_ID) {
|
||||||
do {
|
do {
|
||||||
SSQLToken tableToken = {0};
|
SStrToken tableToken = {0};
|
||||||
extractTableNameFromToken(pToken, &tableToken);
|
extractTableNameFromToken(pToken, &tableToken);
|
||||||
|
|
||||||
size_t len = strlen(pSchema[i].name);
|
size_t len = strlen(pSchema[i].name);
|
||||||
|
@ -157,7 +157,7 @@ static tExprNode *tExprNodeCreate(SSchema *pSchema, int32_t numOfCols, SSQLToken
|
||||||
return pNode;
|
return pNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t getBinaryExprOptr(SSQLToken *pToken) {
|
uint8_t getBinaryExprOptr(SStrToken *pToken) {
|
||||||
switch (pToken->type) {
|
switch (pToken->type) {
|
||||||
case TK_LT:
|
case TK_LT:
|
||||||
return TSDB_RELATION_LESS;
|
return TSDB_RELATION_LESS;
|
||||||
|
@ -234,7 +234,7 @@ uint8_t isQueryOnPrimaryKey(const char *primaryColumnName, const tExprNode *pLef
|
||||||
}
|
}
|
||||||
|
|
||||||
static tExprNode *createSyntaxTree(SSchema *pSchema, int32_t numOfCols, char *str, int32_t *i) {
|
static tExprNode *createSyntaxTree(SSchema *pSchema, int32_t numOfCols, char *str, int32_t *i) {
|
||||||
SSQLToken t0 = tStrGetToken(str, i, false, 0, NULL);
|
SStrToken t0 = tStrGetToken(str, i, false, 0, NULL);
|
||||||
if (t0.n == 0) {
|
if (t0.n == 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -33,7 +33,7 @@ SSqlInfo qSQLParse(const char *pStr) {
|
||||||
|
|
||||||
int32_t i = 0;
|
int32_t i = 0;
|
||||||
while (1) {
|
while (1) {
|
||||||
SSQLToken t0 = {0};
|
SStrToken t0 = {0};
|
||||||
|
|
||||||
if (pStr[i] == 0) {
|
if (pStr[i] == 0) {
|
||||||
Parse(pParser, 0, t0, &sqlInfo);
|
Parse(pParser, 0, t0, &sqlInfo);
|
||||||
|
@ -73,12 +73,12 @@ abort_parse:
|
||||||
return sqlInfo;
|
return sqlInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
tSQLExprList *tSQLExprListAppend(tSQLExprList *pList, tSQLExpr *pNode, SSQLToken *pToken) {
|
tSQLExprList *tSQLExprListAppend(tSQLExprList *pList, tSQLExpr *pNode, SStrToken *pToken) {
|
||||||
if (pList == NULL) {
|
if (pList == NULL) {
|
||||||
pList = calloc(1, sizeof(tSQLExprList));
|
pList = calloc(1, sizeof(tSQLExprList));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pList->nAlloc <= pList->nExpr) { //
|
if (pList->nAlloc <= pList->nExpr) {
|
||||||
pList->nAlloc = (pList->nAlloc << 1) + 4;
|
pList->nAlloc = (pList->nAlloc << 1) + 4;
|
||||||
pList->a = realloc(pList->a, pList->nAlloc * sizeof(pList->a[0]));
|
pList->a = realloc(pList->a, pList->nAlloc * sizeof(pList->a[0]));
|
||||||
if (pList->a == 0) {
|
if (pList->a == 0) {
|
||||||
|
@ -117,41 +117,45 @@ void tSQLExprListDestroy(tSQLExprList *pList) {
|
||||||
free(pList);
|
free(pList);
|
||||||
}
|
}
|
||||||
|
|
||||||
tSQLExpr *tSQLExprIdValueCreate(SSQLToken *pAliasToken, int32_t optrType) {
|
tSQLExpr *tSQLExprIdValueCreate(SStrToken *pToken, int32_t optrType) {
|
||||||
tSQLExpr *nodePtr = calloc(1, sizeof(tSQLExpr));
|
tSQLExpr *pSQLExpr = calloc(1, sizeof(tSQLExpr));
|
||||||
|
|
||||||
|
if (pToken != NULL) {
|
||||||
|
pSQLExpr->token = *pToken;
|
||||||
|
}
|
||||||
|
|
||||||
if (optrType == TK_INTEGER || optrType == TK_STRING || optrType == TK_FLOAT || optrType == TK_BOOL) {
|
if (optrType == TK_INTEGER || optrType == TK_STRING || optrType == TK_FLOAT || optrType == TK_BOOL) {
|
||||||
toTSDBType(pAliasToken->type);
|
toTSDBType(pToken->type);
|
||||||
|
|
||||||
tVariantCreate(&nodePtr->val, pAliasToken);
|
tVariantCreate(&pSQLExpr->val, pToken);
|
||||||
nodePtr->nSQLOptr = optrType;
|
pSQLExpr->nSQLOptr = optrType;
|
||||||
} else if (optrType == TK_NOW) {
|
} else if (optrType == TK_NOW) {
|
||||||
// default use microsecond
|
// default use microsecond
|
||||||
nodePtr->val.i64Key = taosGetTimestamp(TSDB_TIME_PRECISION_MICRO);
|
pSQLExpr->val.i64Key = taosGetTimestamp(TSDB_TIME_PRECISION_MICRO);
|
||||||
nodePtr->val.nType = TSDB_DATA_TYPE_BIGINT;
|
pSQLExpr->val.nType = TSDB_DATA_TYPE_BIGINT;
|
||||||
nodePtr->nSQLOptr = TK_TIMESTAMP; // TK_TIMESTAMP used to denote the time value is in microsecond
|
pSQLExpr->nSQLOptr = TK_TIMESTAMP; // TK_TIMESTAMP used to denote the time value is in microsecond
|
||||||
} else if (optrType == TK_VARIABLE) {
|
} else if (optrType == TK_VARIABLE) {
|
||||||
int32_t ret = getTimestampInUsFromStr(pAliasToken->z, pAliasToken->n, &nodePtr->val.i64Key);
|
int32_t ret = getTimestampInUsFromStr(pToken->z, pToken->n, &pSQLExpr->val.i64Key);
|
||||||
UNUSED(ret);
|
UNUSED(ret);
|
||||||
|
|
||||||
nodePtr->val.nType = TSDB_DATA_TYPE_BIGINT;
|
pSQLExpr->val.nType = TSDB_DATA_TYPE_BIGINT;
|
||||||
nodePtr->nSQLOptr = TK_TIMESTAMP;
|
pSQLExpr->nSQLOptr = TK_TIMESTAMP;
|
||||||
} else { // it must be the column name (tk_id) if it is not the number
|
} else { // it must be the column name (tk_id) if it is not the number
|
||||||
assert(optrType == TK_ID || optrType == TK_ALL);
|
assert(optrType == TK_ID || optrType == TK_ALL);
|
||||||
if (pAliasToken != NULL) {
|
if (pToken != NULL) {
|
||||||
nodePtr->colInfo = *pAliasToken;
|
pSQLExpr->colInfo = *pToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
nodePtr->nSQLOptr = optrType;
|
pSQLExpr->nSQLOptr = optrType;
|
||||||
}
|
}
|
||||||
return nodePtr;
|
return pSQLExpr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* pList is the parameters for function with id(optType)
|
* pList is the parameters for function with id(optType)
|
||||||
* function name is denoted by pFunctionToken
|
* function name is denoted by pFunctionToken
|
||||||
*/
|
*/
|
||||||
tSQLExpr *tSQLExprCreateFunction(tSQLExprList *pList, SSQLToken *pFuncToken, SSQLToken *endToken, int32_t optType) {
|
tSQLExpr *tSQLExprCreateFunction(tSQLExprList *pList, SStrToken *pFuncToken, SStrToken *endToken, int32_t optType) {
|
||||||
if (pFuncToken == NULL) return NULL;
|
if (pFuncToken == NULL) return NULL;
|
||||||
|
|
||||||
tSQLExpr *pExpr = calloc(1, sizeof(tSQLExpr));
|
tSQLExpr *pExpr = calloc(1, sizeof(tSQLExpr));
|
||||||
|
@ -163,6 +167,8 @@ tSQLExpr *tSQLExprCreateFunction(tSQLExprList *pList, SSQLToken *pFuncToken, SSQ
|
||||||
|
|
||||||
pExpr->operand.n = len; // raw field name
|
pExpr->operand.n = len; // raw field name
|
||||||
pExpr->operand.type = pFuncToken->type;
|
pExpr->operand.type = pFuncToken->type;
|
||||||
|
|
||||||
|
pExpr->token = pExpr->operand;
|
||||||
return pExpr;
|
return pExpr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,8 +179,14 @@ tSQLExpr *tSQLExprCreateFunction(tSQLExprList *pList, SSQLToken *pFuncToken, SSQ
|
||||||
tSQLExpr *tSQLExprCreate(tSQLExpr *pLeft, tSQLExpr *pRight, int32_t optrType) {
|
tSQLExpr *tSQLExprCreate(tSQLExpr *pLeft, tSQLExpr *pRight, int32_t optrType) {
|
||||||
tSQLExpr *pExpr = calloc(1, sizeof(tSQLExpr));
|
tSQLExpr *pExpr = calloc(1, sizeof(tSQLExpr));
|
||||||
|
|
||||||
if (optrType == TK_PLUS || optrType == TK_MINUS || optrType == TK_STAR || optrType == TK_DIVIDE ||
|
if (pRight != NULL && pLeft != NULL) {
|
||||||
optrType == TK_REM) {
|
char* endPos = pRight->token.z + pRight->token.n;
|
||||||
|
pExpr->token.z = pLeft->token.z;
|
||||||
|
pExpr->token.n = (uint32_t)(endPos - pExpr->token.z);
|
||||||
|
pExpr->token.type = pLeft->token.type;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (optrType == TK_PLUS || optrType == TK_MINUS || optrType == TK_STAR || optrType == TK_DIVIDE || optrType == TK_REM) {
|
||||||
/*
|
/*
|
||||||
* if a token is noted as the TK_TIMESTAMP, the time precision is microsecond
|
* if a token is noted as the TK_TIMESTAMP, the time precision is microsecond
|
||||||
* Otherwise, the time precision is adaptive, determined by the time precision from databases.
|
* Otherwise, the time precision is adaptive, determined by the time precision from databases.
|
||||||
|
@ -373,7 +385,7 @@ void tVariantListDestroy(tVariantList *pList) {
|
||||||
free(pList);
|
free(pList);
|
||||||
}
|
}
|
||||||
|
|
||||||
tVariantList *tVariantListAppendToken(tVariantList *pList, SSQLToken *pAliasToken, uint8_t sortOrder) {
|
tVariantList *tVariantListAppendToken(tVariantList *pList, SStrToken *pToken, uint8_t sortOrder) {
|
||||||
if (pList == NULL) {
|
if (pList == NULL) {
|
||||||
pList = calloc(1, sizeof(tVariantList));
|
pList = calloc(1, sizeof(tVariantList));
|
||||||
}
|
}
|
||||||
|
@ -382,9 +394,9 @@ tVariantList *tVariantListAppendToken(tVariantList *pList, SSQLToken *pAliasToke
|
||||||
return pList;
|
return pList;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pAliasToken) {
|
if (pToken) {
|
||||||
tVariant t = {0};
|
tVariant t = {0};
|
||||||
tVariantCreate(&t, pAliasToken);
|
tVariantCreate(&t, pToken);
|
||||||
|
|
||||||
tVariantListItem *pItem = &pList->a[pList->nExpr++];
|
tVariantListItem *pItem = &pList->a[pList->nExpr++];
|
||||||
memcpy(pItem, &t, sizeof(tVariant));
|
memcpy(pItem, &t, sizeof(tVariant));
|
||||||
|
@ -420,7 +432,7 @@ void tFieldListDestroy(tFieldList *pList) {
|
||||||
free(pList);
|
free(pList);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDBName(SSQLToken *pCpxName, SSQLToken *pDB) {
|
void setDBName(SStrToken *pCpxName, SStrToken *pDB) {
|
||||||
pCpxName->type = pDB->type;
|
pCpxName->type = pDB->type;
|
||||||
pCpxName->z = pDB->z;
|
pCpxName->z = pDB->z;
|
||||||
pCpxName->n = pDB->n;
|
pCpxName->n = pDB->n;
|
||||||
|
@ -464,7 +476,7 @@ int32_t getTimestampInUsFromStrImpl(int64_t val, char unit, int64_t *result) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tSQLSetColumnInfo(TAOS_FIELD *pField, SSQLToken *pName, TAOS_FIELD *pType) {
|
void tSQLSetColumnInfo(TAOS_FIELD *pField, SStrToken *pName, TAOS_FIELD *pType) {
|
||||||
int32_t maxLen = sizeof(pField->name) / sizeof(pField->name[0]);
|
int32_t maxLen = sizeof(pField->name) / sizeof(pField->name[0]);
|
||||||
|
|
||||||
// truncate the column name
|
// truncate the column name
|
||||||
|
@ -479,7 +491,7 @@ void tSQLSetColumnInfo(TAOS_FIELD *pField, SSQLToken *pName, TAOS_FIELD *pType)
|
||||||
pField->bytes = pType->bytes;
|
pField->bytes = pType->bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tSQLSetColumnType(TAOS_FIELD *pField, SSQLToken *type) {
|
void tSQLSetColumnType(TAOS_FIELD *pField, SStrToken *type) {
|
||||||
pField->type = -1;
|
pField->type = -1;
|
||||||
|
|
||||||
int32_t LENGTH_SIZE_OF_STR = 2; // in case of nchar and binary, there two bytes to keep the length of binary|nchar.
|
int32_t LENGTH_SIZE_OF_STR = 2; // in case of nchar and binary, there two bytes to keep the length of binary|nchar.
|
||||||
|
@ -517,9 +529,9 @@ void tSQLSetColumnType(TAOS_FIELD *pField, SSQLToken *type) {
|
||||||
/*
|
/*
|
||||||
* extract the select info out of sql string
|
* extract the select info out of sql string
|
||||||
*/
|
*/
|
||||||
SQuerySQL *tSetQuerySQLElems(SSQLToken *pSelectToken, tSQLExprList *pSelection, tVariantList *pFrom, tSQLExpr *pWhere,
|
SQuerySQL *tSetQuerySQLElems(SStrToken *pSelectToken, tSQLExprList *pSelection, tVariantList *pFrom, tSQLExpr *pWhere,
|
||||||
tVariantList *pGroupby, tVariantList *pSortOrder, SSQLToken *pInterval,
|
tVariantList *pGroupby, tVariantList *pSortOrder, SStrToken *pInterval,
|
||||||
SSQLToken *pSliding, tVariantList *pFill, SLimitVal *pLimit, SLimitVal *pGLimit) {
|
SStrToken *pSliding, tVariantList *pFill, SLimitVal *pLimit, SLimitVal *pGLimit) {
|
||||||
assert(pSelection != NULL);
|
assert(pSelection != NULL);
|
||||||
|
|
||||||
SQuerySQL *pQuery = calloc(1, sizeof(SQuerySQL));
|
SQuerySQL *pQuery = calloc(1, sizeof(SQuerySQL));
|
||||||
|
@ -611,7 +623,7 @@ void destroyAllSelectClause(SSubclauseInfo *pClause) {
|
||||||
taosTFree(pClause->pClause);
|
taosTFree(pClause->pClause);
|
||||||
}
|
}
|
||||||
|
|
||||||
SCreateTableSQL *tSetCreateSQLElems(tFieldList *pCols, tFieldList *pTags, SSQLToken *pStableName,
|
SCreateTableSQL *tSetCreateSQLElems(tFieldList *pCols, tFieldList *pTags, SStrToken *pStableName,
|
||||||
tVariantList *pTagVals, SQuerySQL *pSelect, int32_t type) {
|
tVariantList *pTagVals, SQuerySQL *pSelect, int32_t type) {
|
||||||
SCreateTableSQL *pCreate = calloc(1, sizeof(SCreateTableSQL));
|
SCreateTableSQL *pCreate = calloc(1, sizeof(SCreateTableSQL));
|
||||||
|
|
||||||
|
@ -644,7 +656,7 @@ SCreateTableSQL *tSetCreateSQLElems(tFieldList *pCols, tFieldList *pTags, SSQLTo
|
||||||
return pCreate;
|
return pCreate;
|
||||||
}
|
}
|
||||||
|
|
||||||
SAlterTableSQL *tAlterTableSQLElems(SSQLToken *pMeterName, tFieldList *pCols, tVariantList *pVals, int32_t type) {
|
SAlterTableSQL *tAlterTableSQLElems(SStrToken *pMeterName, tFieldList *pCols, tVariantList *pVals, int32_t type) {
|
||||||
SAlterTableSQL *pAlterTable = calloc(1, sizeof(SAlterTableSQL));
|
SAlterTableSQL *pAlterTable = calloc(1, sizeof(SAlterTableSQL));
|
||||||
|
|
||||||
pAlterTable->name = *pMeterName;
|
pAlterTable->name = *pMeterName;
|
||||||
|
@ -716,7 +728,7 @@ SSubclauseInfo* setSubclause(SSubclauseInfo* pSubclause, void *pSqlExprInfo) {
|
||||||
return pSubclause;
|
return pSubclause;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSqlInfo* setSQLInfo(SSqlInfo *pInfo, void *pSqlExprInfo, SSQLToken *pMeterName, int32_t type) {
|
SSqlInfo* setSQLInfo(SSqlInfo *pInfo, void *pSqlExprInfo, SStrToken *pMeterName, int32_t type) {
|
||||||
pInfo->type = type;
|
pInfo->type = type;
|
||||||
|
|
||||||
if (type == TSDB_SQL_SELECT) {
|
if (type == TSDB_SQL_SELECT) {
|
||||||
|
@ -745,7 +757,7 @@ SSubclauseInfo* appendSelectClause(SSubclauseInfo *pQueryInfo, void *pSubclause)
|
||||||
return pQueryInfo;
|
return pQueryInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCreatedTableName(SSqlInfo *pInfo, SSQLToken *pMeterName, SSQLToken *pIfNotExists) {
|
void setCreatedTableName(SSqlInfo *pInfo, SStrToken *pMeterName, SStrToken *pIfNotExists) {
|
||||||
pInfo->pCreateTableInfo->name = *pMeterName;
|
pInfo->pCreateTableInfo->name = *pMeterName;
|
||||||
pInfo->pCreateTableInfo->existCheck = (pIfNotExists->n != 0);
|
pInfo->pCreateTableInfo->existCheck = (pIfNotExists->n != 0);
|
||||||
}
|
}
|
||||||
|
@ -760,7 +772,7 @@ void tTokenListBuyMoreSpace(tDCLSQL *pTokenList) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tDCLSQL *tTokenListAppend(tDCLSQL *pTokenList, SSQLToken *pToken) {
|
tDCLSQL *tTokenListAppend(tDCLSQL *pTokenList, SStrToken *pToken) {
|
||||||
if (pToken == NULL) return NULL;
|
if (pToken == NULL) return NULL;
|
||||||
|
|
||||||
if (pTokenList == NULL) pTokenList = calloc(1, sizeof(tDCLSQL));
|
if (pTokenList == NULL) pTokenList = calloc(1, sizeof(tDCLSQL));
|
||||||
|
@ -781,19 +793,19 @@ void setDCLSQLElems(SSqlInfo *pInfo, int32_t type, int32_t nParam, ...) {
|
||||||
va_start(va, nParam);
|
va_start(va, nParam);
|
||||||
|
|
||||||
while (nParam-- > 0) {
|
while (nParam-- > 0) {
|
||||||
SSQLToken *pToken = va_arg(va, SSQLToken *);
|
SStrToken *pToken = va_arg(va, SStrToken *);
|
||||||
pInfo->pDCLInfo = tTokenListAppend(pInfo->pDCLInfo, pToken);
|
pInfo->pDCLInfo = tTokenListAppend(pInfo->pDCLInfo, pToken);
|
||||||
}
|
}
|
||||||
va_end(va);
|
va_end(va);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDropDBTableInfo(SSqlInfo *pInfo, int32_t type, SSQLToken* pToken, SSQLToken* existsCheck) {
|
void setDropDBTableInfo(SSqlInfo *pInfo, int32_t type, SStrToken* pToken, SStrToken* existsCheck) {
|
||||||
pInfo->type = type;
|
pInfo->type = type;
|
||||||
pInfo->pDCLInfo = tTokenListAppend(pInfo->pDCLInfo, pToken);
|
pInfo->pDCLInfo = tTokenListAppend(pInfo->pDCLInfo, pToken);
|
||||||
pInfo->pDCLInfo->existsCheck = (existsCheck->n == 1);
|
pInfo->pDCLInfo->existsCheck = (existsCheck->n == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setShowOptions(SSqlInfo *pInfo, int32_t type, SSQLToken* prefix, SSQLToken* pPatterns) {
|
void setShowOptions(SSqlInfo *pInfo, int32_t type, SStrToken* prefix, SStrToken* pPatterns) {
|
||||||
if (pInfo->pDCLInfo == NULL) {
|
if (pInfo->pDCLInfo == NULL) {
|
||||||
pInfo->pDCLInfo = calloc(1, sizeof(tDCLSQL));
|
pInfo->pDCLInfo = calloc(1, sizeof(tDCLSQL));
|
||||||
}
|
}
|
||||||
|
@ -816,7 +828,7 @@ void setShowOptions(SSqlInfo *pInfo, int32_t type, SSQLToken* prefix, SSQLToken*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCreateDBSQL(SSqlInfo *pInfo, int32_t type, SSQLToken *pToken, SCreateDBInfo *pDB, SSQLToken *pIgExists) {
|
void setCreateDBSQL(SSqlInfo *pInfo, int32_t type, SStrToken *pToken, SCreateDBInfo *pDB, SStrToken *pIgExists) {
|
||||||
pInfo->type = type;
|
pInfo->type = type;
|
||||||
if (pInfo->pDCLInfo == NULL) {
|
if (pInfo->pDCLInfo == NULL) {
|
||||||
pInfo->pDCLInfo = calloc(1, sizeof(tDCLSQL));
|
pInfo->pDCLInfo = calloc(1, sizeof(tDCLSQL));
|
||||||
|
@ -827,7 +839,7 @@ void setCreateDBSQL(SSqlInfo *pInfo, int32_t type, SSQLToken *pToken, SCreateDBI
|
||||||
pInfo->pDCLInfo->dbOpt.ignoreExists = pIgExists->n; // sql.y has: ifnotexists(X) ::= IF NOT EXISTS. {X.n = 1;}
|
pInfo->pDCLInfo->dbOpt.ignoreExists = pIgExists->n; // sql.y has: ifnotexists(X) ::= IF NOT EXISTS. {X.n = 1;}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCreateAcctSQL(SSqlInfo *pInfo, int32_t type, SSQLToken *pName, SSQLToken *pPwd, SCreateAcctSQL *pAcctInfo) {
|
void setCreateAcctSQL(SSqlInfo *pInfo, int32_t type, SStrToken *pName, SStrToken *pPwd, SCreateAcctSQL *pAcctInfo) {
|
||||||
pInfo->type = type;
|
pInfo->type = type;
|
||||||
if (pInfo->pDCLInfo == NULL) {
|
if (pInfo->pDCLInfo == NULL) {
|
||||||
pInfo->pDCLInfo = calloc(1, sizeof(tDCLSQL));
|
pInfo->pDCLInfo = calloc(1, sizeof(tDCLSQL));
|
||||||
|
@ -843,7 +855,7 @@ void setCreateAcctSQL(SSqlInfo *pInfo, int32_t type, SSQLToken *pName, SSQLToken
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCreateUserSQL(SSqlInfo *pInfo, SSQLToken *pName, SSQLToken *pPasswd) {
|
void setCreateUserSQL(SSqlInfo *pInfo, SStrToken *pName, SStrToken *pPasswd) {
|
||||||
pInfo->type = TSDB_SQL_CREATE_USER;
|
pInfo->type = TSDB_SQL_CREATE_USER;
|
||||||
if (pInfo->pDCLInfo == NULL) {
|
if (pInfo->pDCLInfo == NULL) {
|
||||||
pInfo->pDCLInfo = calloc(1, sizeof(tDCLSQL));
|
pInfo->pDCLInfo = calloc(1, sizeof(tDCLSQL));
|
||||||
|
@ -855,7 +867,7 @@ void setCreateUserSQL(SSqlInfo *pInfo, SSQLToken *pName, SSQLToken *pPasswd) {
|
||||||
pInfo->pDCLInfo->user.passwd = *pPasswd;
|
pInfo->pDCLInfo->user.passwd = *pPasswd;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setAlterUserSQL(SSqlInfo *pInfo, int16_t type, SSQLToken *pName, SSQLToken* pPwd, SSQLToken *pPrivilege) {
|
void setAlterUserSQL(SSqlInfo *pInfo, int16_t type, SStrToken *pName, SStrToken* pPwd, SStrToken *pPrivilege) {
|
||||||
pInfo->type = TSDB_SQL_ALTER_USER;
|
pInfo->type = TSDB_SQL_ALTER_USER;
|
||||||
if (pInfo->pDCLInfo == NULL) {
|
if (pInfo->pDCLInfo == NULL) {
|
||||||
pInfo->pDCLInfo = calloc(1, sizeof(tDCLSQL));
|
pInfo->pDCLInfo = calloc(1, sizeof(tDCLSQL));
|
||||||
|
@ -880,7 +892,7 @@ void setAlterUserSQL(SSqlInfo *pInfo, int16_t type, SSQLToken *pName, SSQLToken*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setKillSQL(SSqlInfo *pInfo, int32_t type, SSQLToken *ip) {
|
void setKillSQL(SSqlInfo *pInfo, int32_t type, SStrToken *ip) {
|
||||||
pInfo->type = type;
|
pInfo->type = type;
|
||||||
if (pInfo->pDCLInfo == NULL) {
|
if (pInfo->pDCLInfo == NULL) {
|
||||||
pInfo->pDCLInfo = calloc(1, sizeof(tDCLSQL));
|
pInfo->pDCLInfo = calloc(1, sizeof(tDCLSQL));
|
||||||
|
@ -909,5 +921,5 @@ void setDefaultCreateDbOption(SCreateDBInfo *pDBInfo) {
|
||||||
pDBInfo->quorum = -1;
|
pDBInfo->quorum = -1;
|
||||||
pDBInfo->keep = NULL;
|
pDBInfo->keep = NULL;
|
||||||
|
|
||||||
memset(&pDBInfo->precision, 0, sizeof(SSQLToken));
|
memset(&pDBInfo->precision, 0, sizeof(SStrToken));
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,8 +137,15 @@ static char* doFlushPageToDisk(SDiskbasedResultBuf* pResultBuf, SPageInfo* pg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//3. write to disk.
|
//3. write to disk.
|
||||||
fseek(pResultBuf->file, pg->info.offset, SEEK_SET);
|
int32_t ret = fseek(pResultBuf->file, pg->info.offset, SEEK_SET);
|
||||||
fwrite(t, size, 1, pResultBuf->file);
|
if (ret != 0) { // todo handle the error case
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = (int32_t)fwrite(t, size, 1, pResultBuf->file);
|
||||||
|
if (ret != size) { // todo handle the error case
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (pResultBuf->fileSize < pg->info.offset + pg->info.length) {
|
if (pResultBuf->fileSize < pg->info.offset + pg->info.length) {
|
||||||
pResultBuf->fileSize = pg->info.offset + pg->info.length;
|
pResultBuf->fileSize = pg->info.offset + pg->info.length;
|
||||||
|
|
|
@ -85,7 +85,7 @@ static SKeyword keywordTable[] = {
|
||||||
{"QUERIES", TK_QUERIES},
|
{"QUERIES", TK_QUERIES},
|
||||||
{"CONNECTIONS", TK_CONNECTIONS},
|
{"CONNECTIONS", TK_CONNECTIONS},
|
||||||
{"STREAMS", TK_STREAMS},
|
{"STREAMS", TK_STREAMS},
|
||||||
{"CONFIGS", TK_CONFIGS},
|
{"VARIABLES", TK_VARIABLES},
|
||||||
{"SCORES", TK_SCORES},
|
{"SCORES", TK_SCORES},
|
||||||
{"GRANTS", TK_GRANTS},
|
{"GRANTS", TK_GRANTS},
|
||||||
{"DOT", TK_DOT},
|
{"DOT", TK_DOT},
|
||||||
|
@ -580,8 +580,8 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSQLToken tStrGetToken(char* str, int32_t* i, bool isPrevOptr, uint32_t numOfIgnoreToken, uint32_t* ignoreTokenTypes) {
|
SStrToken tStrGetToken(char* str, int32_t* i, bool isPrevOptr, uint32_t numOfIgnoreToken, uint32_t* ignoreTokenTypes) {
|
||||||
SSQLToken t0 = {0};
|
SStrToken t0 = {0};
|
||||||
|
|
||||||
// here we reach the end of sql string, null-terminated string
|
// here we reach the end of sql string, null-terminated string
|
||||||
if (str[*i] == 0) {
|
if (str[*i] == 0) {
|
||||||
|
|
|
@ -8,7 +8,6 @@ static void TSBufUpdateVnodeInfo(STSBuf* pTSBuf, int32_t index, STSVnodeBlockInf
|
||||||
static STSBuf* allocResForTSBuf(STSBuf* pTSBuf);
|
static STSBuf* allocResForTSBuf(STSBuf* pTSBuf);
|
||||||
static int32_t STSBufUpdateHeader(STSBuf* pTSBuf, STSBufFileHeader* pHeader);
|
static int32_t STSBufUpdateHeader(STSBuf* pTSBuf, STSBufFileHeader* pHeader);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* todo error handling
|
* todo error handling
|
||||||
* support auto closeable tmp file
|
* support auto closeable tmp file
|
||||||
|
@ -76,7 +75,7 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((int32_t)header.numOfVnode > pTSBuf->numOfAlloc) {
|
if (header.numOfVnode > pTSBuf->numOfAlloc) {
|
||||||
pTSBuf->numOfAlloc = header.numOfVnode;
|
pTSBuf->numOfAlloc = header.numOfVnode;
|
||||||
STSVnodeBlockInfoEx* tmp = realloc(pTSBuf->pData, sizeof(STSVnodeBlockInfoEx) * pTSBuf->numOfAlloc);
|
STSVnodeBlockInfoEx* tmp = realloc(pTSBuf->pData, sizeof(STSVnodeBlockInfoEx) * pTSBuf->numOfAlloc);
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL) {
|
||||||
|
@ -225,14 +224,15 @@ static void writeDataToDisk(STSBuf* pTSBuf) {
|
||||||
}
|
}
|
||||||
|
|
||||||
STSBlock* pBlock = &pTSBuf->block;
|
STSBlock* pBlock = &pTSBuf->block;
|
||||||
|
STSList* pTsData = &pTSBuf->tsData;
|
||||||
|
|
||||||
pBlock->numOfElem = pTSBuf->tsData.len / TSDB_KEYSIZE;
|
pBlock->numOfElem = pTsData->len / TSDB_KEYSIZE;
|
||||||
pBlock->compLen =
|
pBlock->compLen =
|
||||||
tsCompressTimestamp(pTSBuf->tsData.rawBuf, pTSBuf->tsData.len, pTSBuf->tsData.len / TSDB_KEYSIZE, pBlock->payload,
|
tsCompressTimestamp(pTsData->rawBuf, pTsData->len, pTsData->len/TSDB_KEYSIZE, pBlock->payload, pTsData->allocSize,
|
||||||
pTSBuf->tsData.allocSize, TWO_STAGE_COMP, pTSBuf->assistBuf, pTSBuf->bufSize);
|
TWO_STAGE_COMP, pTSBuf->assistBuf, pTSBuf->bufSize);
|
||||||
|
|
||||||
int64_t r = fseek(pTSBuf->f, pTSBuf->fileSize, SEEK_SET);
|
int64_t r = fseek(pTSBuf->f, pTSBuf->fileSize, SEEK_SET);
|
||||||
UNUSED(r);
|
assert(r == 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* format for output data:
|
* format for output data:
|
||||||
|
@ -241,16 +241,22 @@ static void writeDataToDisk(STSBuf* pTSBuf) {
|
||||||
*
|
*
|
||||||
* both side has the compressed length is used to support load data forwards/backwords.
|
* both side has the compressed length is used to support load data forwards/backwords.
|
||||||
*/
|
*/
|
||||||
fwrite(&pBlock->tag, sizeof(pBlock->tag), 1, pTSBuf->f);
|
int32_t metaLen = 0;
|
||||||
|
metaLen += (int32_t)fwrite(&pBlock->tag.nType, 1, sizeof(pBlock->tag.nType), pTSBuf->f);
|
||||||
|
metaLen += (int32_t)fwrite(&pBlock->tag.nLen, 1, sizeof(pBlock->tag.nLen), pTSBuf->f);
|
||||||
|
|
||||||
|
if (pBlock->tag.nType == TSDB_DATA_TYPE_BINARY || pBlock->tag.nType == TSDB_DATA_TYPE_NCHAR) {
|
||||||
|
metaLen += (int32_t)fwrite(pBlock->tag.pz, 1, (size_t)pBlock->tag.nLen, pTSBuf->f);
|
||||||
|
} else if (pBlock->tag.nType != TSDB_DATA_TYPE_NULL) {
|
||||||
|
metaLen += (int32_t)fwrite(&pBlock->tag.i64Key, 1, sizeof(int64_t), pTSBuf->f);
|
||||||
|
}
|
||||||
|
|
||||||
fwrite(&pBlock->numOfElem, sizeof(pBlock->numOfElem), 1, pTSBuf->f);
|
fwrite(&pBlock->numOfElem, sizeof(pBlock->numOfElem), 1, pTSBuf->f);
|
||||||
|
|
||||||
fwrite(&pBlock->compLen, sizeof(pBlock->compLen), 1, pTSBuf->f);
|
fwrite(&pBlock->compLen, sizeof(pBlock->compLen), 1, pTSBuf->f);
|
||||||
|
|
||||||
fwrite(pBlock->payload, (size_t)pBlock->compLen, 1, pTSBuf->f);
|
fwrite(pBlock->payload, (size_t)pBlock->compLen, 1, pTSBuf->f);
|
||||||
|
|
||||||
fwrite(&pBlock->compLen, sizeof(pBlock->compLen), 1, pTSBuf->f);
|
fwrite(&pBlock->compLen, sizeof(pBlock->compLen), 1, pTSBuf->f);
|
||||||
|
|
||||||
int32_t blockSize = sizeof(pBlock->tag) + sizeof(pBlock->numOfElem) + sizeof(pBlock->compLen) * 2 + pBlock->compLen;
|
int32_t blockSize = metaLen + sizeof(pBlock->numOfElem) + sizeof(pBlock->compLen) * 2 + pBlock->compLen;
|
||||||
pTSBuf->fileSize += blockSize;
|
pTSBuf->fileSize += blockSize;
|
||||||
|
|
||||||
pTSBuf->tsData.len = 0;
|
pTSBuf->tsData.len = 0;
|
||||||
|
@ -299,8 +305,23 @@ STSBlock* readDataFromDisk(STSBuf* pTSBuf, int32_t order, bool decomp) {
|
||||||
UNUSED(ret);
|
UNUSED(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t sz = fread(&pBlock->tag, sizeof(pBlock->tag), 1, pTSBuf->f);
|
fread(&pBlock->tag.nType, sizeof(pBlock->tag.nType), 1, pTSBuf->f);
|
||||||
UNUSED(sz);
|
fread(&pBlock->tag.nLen, sizeof(pBlock->tag.nLen), 1, pTSBuf->f);
|
||||||
|
|
||||||
|
// NOTE: mix types tags are not supported
|
||||||
|
size_t sz = 0;
|
||||||
|
if (pBlock->tag.nType == TSDB_DATA_TYPE_BINARY || pBlock->tag.nType == TSDB_DATA_TYPE_NCHAR) {
|
||||||
|
char* tp = realloc(pBlock->tag.pz, pBlock->tag.nLen + 1);
|
||||||
|
assert(tp != NULL);
|
||||||
|
|
||||||
|
memset(tp, 0, pBlock->tag.nLen + 1);
|
||||||
|
pBlock->tag.pz = tp;
|
||||||
|
|
||||||
|
sz = fread(pBlock->tag.pz, (size_t)pBlock->tag.nLen, 1, pTSBuf->f);
|
||||||
|
} else if (pBlock->tag.nType != TSDB_DATA_TYPE_NULL) {
|
||||||
|
sz = fread(&pBlock->tag.i64Key, sizeof(int64_t), 1, pTSBuf->f);
|
||||||
|
}
|
||||||
|
|
||||||
sz = fread(&pBlock->numOfElem, sizeof(pBlock->numOfElem), 1, pTSBuf->f);
|
sz = fread(&pBlock->numOfElem, sizeof(pBlock->numOfElem), 1, pTSBuf->f);
|
||||||
UNUSED(sz);
|
UNUSED(sz);
|
||||||
sz = fread(&pBlock->compLen, sizeof(pBlock->compLen), 1, pTSBuf->f);
|
sz = fread(&pBlock->compLen, sizeof(pBlock->compLen), 1, pTSBuf->f);
|
||||||
|
@ -361,7 +382,7 @@ static int32_t setCheckTSOrder(STSBuf* pTSBuf, const char* pData, int32_t len) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tsBufAppend(STSBuf* pTSBuf, int32_t vnodeId, int64_t tag, const char* pData, int32_t len) {
|
void tsBufAppend(STSBuf* pTSBuf, int32_t vnodeId, tVariant* tag, const char* pData, int32_t len) {
|
||||||
STSVnodeBlockInfoEx* pBlockInfo = NULL;
|
STSVnodeBlockInfoEx* pBlockInfo = NULL;
|
||||||
STSList* ptsData = &pTSBuf->tsData;
|
STSList* ptsData = &pTSBuf->tsData;
|
||||||
|
|
||||||
|
@ -376,14 +397,14 @@ void tsBufAppend(STSBuf* pTSBuf, int32_t vnodeId, int64_t tag, const char* pData
|
||||||
|
|
||||||
assert(pBlockInfo->info.vnode == vnodeId);
|
assert(pBlockInfo->info.vnode == vnodeId);
|
||||||
|
|
||||||
if (pTSBuf->block.tag != tag && ptsData->len > 0) {
|
if ((tVariantCompare(&pTSBuf->block.tag, tag) != 0) && ptsData->len > 0) {
|
||||||
// new arrived data with different tags value, save current value into disk first
|
// new arrived data with different tags value, save current value into disk first
|
||||||
writeDataToDisk(pTSBuf);
|
writeDataToDisk(pTSBuf);
|
||||||
} else {
|
} else {
|
||||||
expandBuffer(ptsData, len);
|
expandBuffer(ptsData, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
pTSBuf->block.tag = tag;
|
tVariantAssign(&pTSBuf->block.tag, tag);
|
||||||
memcpy(ptsData->rawBuf + ptsData->len, pData, (size_t)len);
|
memcpy(ptsData->rawBuf + ptsData->len, pData, (size_t)len);
|
||||||
|
|
||||||
// todo check return value
|
// todo check return value
|
||||||
|
@ -465,7 +486,7 @@ static int32_t tsBufFindBlock(STSBuf* pTSBuf, STSVnodeBlockInfo* pBlockInfo, int
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t tsBufFindBlockByTag(STSBuf* pTSBuf, STSVnodeBlockInfo* pBlockInfo, int64_t tag) {
|
static int32_t tsBufFindBlockByTag(STSBuf* pTSBuf, STSVnodeBlockInfo* pBlockInfo, tVariant* tag) {
|
||||||
bool decomp = false;
|
bool decomp = false;
|
||||||
|
|
||||||
int64_t offset = 0;
|
int64_t offset = 0;
|
||||||
|
@ -484,7 +505,7 @@ static int32_t tsBufFindBlockByTag(STSBuf* pTSBuf, STSVnodeBlockInfo* pBlockInfo
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pTSBuf->block.tag == tag) {
|
if (tVariantCompare(&pTSBuf->block.tag, tag) == 0) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -669,7 +690,7 @@ STSElem tsBufGetElem(STSBuf* pTSBuf) {
|
||||||
|
|
||||||
elem1.vnode = pTSBuf->pData[pCur->vgroupIndex].info.vnode;
|
elem1.vnode = pTSBuf->pData[pCur->vgroupIndex].info.vnode;
|
||||||
elem1.ts = *(TSKEY*)(pTSBuf->tsData.rawBuf + pCur->tsIndex * TSDB_KEYSIZE);
|
elem1.ts = *(TSKEY*)(pTSBuf->tsData.rawBuf + pCur->tsIndex * TSDB_KEYSIZE);
|
||||||
elem1.tag = pBlock->tag;
|
tVariantAssign(&elem1.tag, &pBlock->tag);
|
||||||
|
|
||||||
return elem1;
|
return elem1;
|
||||||
}
|
}
|
||||||
|
@ -800,7 +821,7 @@ STSBuf* tsBufCreateFromCompBlocks(const char* pData, int32_t numOfBlocks, int32_
|
||||||
return pTSBuf;
|
return pTSBuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
STSElem tsBufGetElemStartPos(STSBuf* pTSBuf, int32_t vnodeId, int64_t tag) {
|
STSElem tsBufGetElemStartPos(STSBuf* pTSBuf, int32_t vnodeId, tVariant* tag) {
|
||||||
STSElem elem = {.vnode = -1};
|
STSElem elem = {.vnode = -1};
|
||||||
|
|
||||||
if (pTSBuf == NULL) {
|
if (pTSBuf == NULL) {
|
||||||
|
@ -881,7 +902,9 @@ void tsBufDisplay(STSBuf* pTSBuf) {
|
||||||
|
|
||||||
while (tsBufNextPos(pTSBuf)) {
|
while (tsBufNextPos(pTSBuf)) {
|
||||||
STSElem elem = tsBufGetElem(pTSBuf);
|
STSElem elem = tsBufGetElem(pTSBuf);
|
||||||
printf("%d-%" PRId64 "-%" PRId64 "\n", elem.vnode, elem.tag, elem.ts);
|
if (elem.tag.nType == TSDB_DATA_TYPE_BIGINT) {
|
||||||
|
printf("%d-%" PRId64 "-%" PRId64 "\n", elem.vnode, elem.tag.i64Key, elem.ts);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pTSBuf->cur.order = old;
|
pTSBuf->cur.order = old;
|
||||||
|
|
|
@ -46,7 +46,7 @@ int32_t initWindowResInfo(SWindowResInfo *pWindowResInfo, SQueryRuntimeEnv *pRun
|
||||||
pWindowResInfo->size = 0;
|
pWindowResInfo->size = 0;
|
||||||
pWindowResInfo->prevSKey = TSKEY_INITIAL_VAL;
|
pWindowResInfo->prevSKey = TSKEY_INITIAL_VAL;
|
||||||
|
|
||||||
pRuntimeEnv->summary.internalSupSize += sizeof(SWindowResult) * threshold;
|
SQueryCostInfo* pSummary = &pRuntimeEnv->summary;
|
||||||
|
|
||||||
// use the pointer arraylist
|
// use the pointer arraylist
|
||||||
pWindowResInfo->pResult = calloc(threshold, sizeof(SWindowResult));
|
pWindowResInfo->pResult = calloc(threshold, sizeof(SWindowResult));
|
||||||
|
@ -54,8 +54,11 @@ int32_t initWindowResInfo(SWindowResInfo *pWindowResInfo, SQueryRuntimeEnv *pRun
|
||||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
pRuntimeEnv->summary.internalSupSize += sizeof(SWindowResult) * threshold;
|
pWindowResInfo->interval = pRuntimeEnv->pQuery->intervalTime;
|
||||||
pRuntimeEnv->summary.internalSupSize += (pRuntimeEnv->pQuery->numOfOutput * sizeof(SResultInfo) + pRuntimeEnv->interBufSize) * pWindowResInfo->capacity;
|
|
||||||
|
pSummary->internalSupSize += sizeof(SWindowResult) * threshold;
|
||||||
|
pSummary->internalSupSize += (pRuntimeEnv->pQuery->numOfOutput * sizeof(SResultInfo) + pRuntimeEnv->interBufSize) * pWindowResInfo->capacity;
|
||||||
|
pSummary->numOfTimeWindows = threshold;
|
||||||
|
|
||||||
for (int32_t i = 0; i < pWindowResInfo->capacity; ++i) {
|
for (int32_t i = 0; i < pWindowResInfo->capacity; ++i) {
|
||||||
int32_t code = createQueryResultInfo(pRuntimeEnv->pQuery, &pWindowResInfo->pResult[i], pRuntimeEnv->stableQuery, pRuntimeEnv->interBufSize);
|
int32_t code = createQueryResultInfo(pRuntimeEnv->pQuery, &pWindowResInfo->pResult[i], pRuntimeEnv->stableQuery, pRuntimeEnv->interBufSize);
|
||||||
|
@ -126,8 +129,8 @@ void clearFirstNTimeWindow(SQueryRuntimeEnv *pRuntimeEnv, int32_t num) {
|
||||||
|
|
||||||
for (int32_t i = 0; i < num; ++i) {
|
for (int32_t i = 0; i < num; ++i) {
|
||||||
SWindowResult *pResult = &pWindowResInfo->pResult[i];
|
SWindowResult *pResult = &pWindowResInfo->pResult[i];
|
||||||
if (pResult->status.closed) { // remove the window slot from hash table
|
if (pResult->closed) { // remove the window slot from hash table
|
||||||
taosHashRemove(pWindowResInfo->hashList, (const char *)&pResult->window.skey, pWindowResInfo->type);
|
taosHashRemove(pWindowResInfo->hashList, (const char *)&pResult->skey, pWindowResInfo->type);
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -149,12 +152,12 @@ void clearFirstNTimeWindow(SQueryRuntimeEnv *pRuntimeEnv, int32_t num) {
|
||||||
pWindowResInfo->size = remain;
|
pWindowResInfo->size = remain;
|
||||||
for (int32_t k = 0; k < pWindowResInfo->size; ++k) {
|
for (int32_t k = 0; k < pWindowResInfo->size; ++k) {
|
||||||
SWindowResult *pResult = &pWindowResInfo->pResult[k];
|
SWindowResult *pResult = &pWindowResInfo->pResult[k];
|
||||||
int32_t *p = (int32_t *)taosHashGet(pWindowResInfo->hashList, (const char *)&pResult->window.skey,
|
int32_t *p = (int32_t *)taosHashGet(pWindowResInfo->hashList, (const char *)&pResult->skey,
|
||||||
tDataTypeDesc[pWindowResInfo->type].nSize);
|
tDataTypeDesc[pWindowResInfo->type].nSize);
|
||||||
assert(p != NULL);
|
assert(p != NULL);
|
||||||
int32_t v = (*p - num);
|
int32_t v = (*p - num);
|
||||||
assert(v >= 0 && v <= pWindowResInfo->size);
|
assert(v >= 0 && v <= pWindowResInfo->size);
|
||||||
taosHashPut(pWindowResInfo->hashList, (char *)&pResult->window.skey, tDataTypeDesc[pWindowResInfo->type].nSize,
|
taosHashPut(pWindowResInfo->hashList, (char *)&pResult->skey, tDataTypeDesc[pWindowResInfo->type].nSize,
|
||||||
(char *)&v, sizeof(int32_t));
|
(char *)&v, sizeof(int32_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +176,7 @@ void clearClosedTimeWindow(SQueryRuntimeEnv *pRuntimeEnv) {
|
||||||
|
|
||||||
int32_t numOfClosedTimeWindow(SWindowResInfo *pWindowResInfo) {
|
int32_t numOfClosedTimeWindow(SWindowResInfo *pWindowResInfo) {
|
||||||
int32_t i = 0;
|
int32_t i = 0;
|
||||||
while (i < pWindowResInfo->size && pWindowResInfo->pResult[i].status.closed) {
|
while (i < pWindowResInfo->size && pWindowResInfo->pResult[i].closed) {
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,11 +187,11 @@ void closeAllTimeWindow(SWindowResInfo *pWindowResInfo) {
|
||||||
assert(pWindowResInfo->size >= 0 && pWindowResInfo->capacity >= pWindowResInfo->size);
|
assert(pWindowResInfo->size >= 0 && pWindowResInfo->capacity >= pWindowResInfo->size);
|
||||||
|
|
||||||
for (int32_t i = 0; i < pWindowResInfo->size; ++i) {
|
for (int32_t i = 0; i < pWindowResInfo->size; ++i) {
|
||||||
if (pWindowResInfo->pResult[i].status.closed) {
|
if (pWindowResInfo->pResult[i].closed) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
pWindowResInfo->pResult[i].status.closed = true;
|
pWindowResInfo->pResult[i].closed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,7 +207,7 @@ void removeRedundantWindow(SWindowResInfo *pWindowResInfo, TSKEY lastKey, int32_
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the result order
|
// get the result order
|
||||||
int32_t resultOrder = (pWindowResInfo->pResult[0].window.skey < pWindowResInfo->pResult[1].window.skey)? 1:-1;
|
int32_t resultOrder = (pWindowResInfo->pResult[0].skey < pWindowResInfo->pResult[1].skey)? 1:-1;
|
||||||
|
|
||||||
if (order != resultOrder) {
|
if (order != resultOrder) {
|
||||||
return;
|
return;
|
||||||
|
@ -212,11 +215,12 @@ void removeRedundantWindow(SWindowResInfo *pWindowResInfo, TSKEY lastKey, int32_
|
||||||
|
|
||||||
int32_t i = 0;
|
int32_t i = 0;
|
||||||
if (order == QUERY_ASC_FORWARD_STEP) {
|
if (order == QUERY_ASC_FORWARD_STEP) {
|
||||||
while (i < pWindowResInfo->size && (pWindowResInfo->pResult[i].window.ekey < lastKey)) {
|
TSKEY ekey = pWindowResInfo->pResult[i].skey + pWindowResInfo->interval;
|
||||||
|
while (i < pWindowResInfo->size && (ekey < lastKey)) {
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
} else if (order == QUERY_DESC_FORWARD_STEP) {
|
} else if (order == QUERY_DESC_FORWARD_STEP) {
|
||||||
while (i < pWindowResInfo->size && (pWindowResInfo->pResult[i].window.skey > lastKey)) {
|
while (i < pWindowResInfo->size && (pWindowResInfo->pResult[i].skey > lastKey)) {
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -227,11 +231,11 @@ void removeRedundantWindow(SWindowResInfo *pWindowResInfo, TSKEY lastKey, int32_
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isWindowResClosed(SWindowResInfo *pWindowResInfo, int32_t slot) {
|
bool isWindowResClosed(SWindowResInfo *pWindowResInfo, int32_t slot) {
|
||||||
return (getWindowResult(pWindowResInfo, slot)->status.closed == true);
|
return (getWindowResult(pWindowResInfo, slot)->closed == true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void closeTimeWindow(SWindowResInfo *pWindowResInfo, int32_t slot) {
|
void closeTimeWindow(SWindowResInfo *pWindowResInfo, int32_t slot) {
|
||||||
getWindowResult(pWindowResInfo, slot)->status.closed = true;
|
getWindowResult(pWindowResInfo, slot)->closed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearTimeWindowResBuf(SQueryRuntimeEnv *pRuntimeEnv, SWindowResult *pWindowRes) {
|
void clearTimeWindowResBuf(SQueryRuntimeEnv *pRuntimeEnv, SWindowResult *pWindowRes) {
|
||||||
|
@ -253,8 +257,8 @@ void clearTimeWindowResBuf(SQueryRuntimeEnv *pRuntimeEnv, SWindowResult *pWindow
|
||||||
|
|
||||||
pWindowRes->numOfRows = 0;
|
pWindowRes->numOfRows = 0;
|
||||||
pWindowRes->pos = (SPosInfo){-1, -1};
|
pWindowRes->pos = (SPosInfo){-1, -1};
|
||||||
pWindowRes->status.closed = false;
|
pWindowRes->closed = false;
|
||||||
pWindowRes->window = TSWINDOW_INITIALIZER;
|
pWindowRes->skey = TSKEY_INITIAL_VAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -264,8 +268,8 @@ void clearTimeWindowResBuf(SQueryRuntimeEnv *pRuntimeEnv, SWindowResult *pWindow
|
||||||
*/
|
*/
|
||||||
void copyTimeWindowResBuf(SQueryRuntimeEnv *pRuntimeEnv, SWindowResult *dst, const SWindowResult *src) {
|
void copyTimeWindowResBuf(SQueryRuntimeEnv *pRuntimeEnv, SWindowResult *dst, const SWindowResult *src) {
|
||||||
dst->numOfRows = src->numOfRows;
|
dst->numOfRows = src->numOfRows;
|
||||||
dst->window = src->window;
|
dst->skey = src->skey;
|
||||||
dst->status = src->status;
|
dst->closed = src->closed;
|
||||||
|
|
||||||
int32_t nOutputCols = pRuntimeEnv->pQuery->numOfOutput;
|
int32_t nOutputCols = pRuntimeEnv->pQuery->numOfOutput;
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@
|
||||||
#define YYCODETYPE unsigned short int
|
#define YYCODETYPE unsigned short int
|
||||||
#define YYNOCODE 274
|
#define YYNOCODE 274
|
||||||
#define YYACTIONTYPE unsigned short int
|
#define YYACTIONTYPE unsigned short int
|
||||||
#define ParseTOKENTYPE SSQLToken
|
#define ParseTOKENTYPE SStrToken
|
||||||
typedef union {
|
typedef union {
|
||||||
int yyinit;
|
int yyinit;
|
||||||
ParseTOKENTYPE yy0;
|
ParseTOKENTYPE yy0;
|
||||||
|
@ -488,7 +488,7 @@ static const YYCODETYPE yyFallback[] = {
|
||||||
0, /* QUERIES => nothing */
|
0, /* QUERIES => nothing */
|
||||||
0, /* CONNECTIONS => nothing */
|
0, /* CONNECTIONS => nothing */
|
||||||
0, /* STREAMS => nothing */
|
0, /* STREAMS => nothing */
|
||||||
0, /* CONFIGS => nothing */
|
0, /* VARIABLES => nothing */
|
||||||
0, /* SCORES => nothing */
|
0, /* SCORES => nothing */
|
||||||
0, /* GRANTS => nothing */
|
0, /* GRANTS => nothing */
|
||||||
0, /* VNODES => nothing */
|
0, /* VNODES => nothing */
|
||||||
|
@ -781,7 +781,7 @@ static const char *const yyTokenName[] = {
|
||||||
/* 51 */ "QUERIES",
|
/* 51 */ "QUERIES",
|
||||||
/* 52 */ "CONNECTIONS",
|
/* 52 */ "CONNECTIONS",
|
||||||
/* 53 */ "STREAMS",
|
/* 53 */ "STREAMS",
|
||||||
/* 54 */ "CONFIGS",
|
/* 54 */ "VARIABLES",
|
||||||
/* 55 */ "SCORES",
|
/* 55 */ "SCORES",
|
||||||
/* 56 */ "GRANTS",
|
/* 56 */ "GRANTS",
|
||||||
/* 57 */ "VNODES",
|
/* 57 */ "VNODES",
|
||||||
|
@ -1017,7 +1017,7 @@ static const char *const yyRuleName[] = {
|
||||||
/* 7 */ "cmd ::= SHOW QUERIES",
|
/* 7 */ "cmd ::= SHOW QUERIES",
|
||||||
/* 8 */ "cmd ::= SHOW CONNECTIONS",
|
/* 8 */ "cmd ::= SHOW CONNECTIONS",
|
||||||
/* 9 */ "cmd ::= SHOW STREAMS",
|
/* 9 */ "cmd ::= SHOW STREAMS",
|
||||||
/* 10 */ "cmd ::= SHOW CONFIGS",
|
/* 10 */ "cmd ::= SHOW VARIABLES",
|
||||||
/* 11 */ "cmd ::= SHOW SCORES",
|
/* 11 */ "cmd ::= SHOW SCORES",
|
||||||
/* 12 */ "cmd ::= SHOW GRANTS",
|
/* 12 */ "cmd ::= SHOW GRANTS",
|
||||||
/* 13 */ "cmd ::= SHOW VNODES",
|
/* 13 */ "cmd ::= SHOW VNODES",
|
||||||
|
@ -1702,7 +1702,7 @@ static const struct {
|
||||||
{ 209, -2 }, /* (7) cmd ::= SHOW QUERIES */
|
{ 209, -2 }, /* (7) cmd ::= SHOW QUERIES */
|
||||||
{ 209, -2 }, /* (8) cmd ::= SHOW CONNECTIONS */
|
{ 209, -2 }, /* (8) cmd ::= SHOW CONNECTIONS */
|
||||||
{ 209, -2 }, /* (9) cmd ::= SHOW STREAMS */
|
{ 209, -2 }, /* (9) cmd ::= SHOW STREAMS */
|
||||||
{ 209, -2 }, /* (10) cmd ::= SHOW CONFIGS */
|
{ 209, -2 }, /* (10) cmd ::= SHOW VARIABLES */
|
||||||
{ 209, -2 }, /* (11) cmd ::= SHOW SCORES */
|
{ 209, -2 }, /* (11) cmd ::= SHOW SCORES */
|
||||||
{ 209, -2 }, /* (12) cmd ::= SHOW GRANTS */
|
{ 209, -2 }, /* (12) cmd ::= SHOW GRANTS */
|
||||||
{ 209, -2 }, /* (13) cmd ::= SHOW VNODES */
|
{ 209, -2 }, /* (13) cmd ::= SHOW VNODES */
|
||||||
|
@ -2029,8 +2029,8 @@ static void yy_reduce(
|
||||||
case 9: /* cmd ::= SHOW STREAMS */
|
case 9: /* cmd ::= SHOW STREAMS */
|
||||||
{ setShowOptions(pInfo, TSDB_MGMT_TABLE_STREAMS, 0, 0); }
|
{ setShowOptions(pInfo, TSDB_MGMT_TABLE_STREAMS, 0, 0); }
|
||||||
break;
|
break;
|
||||||
case 10: /* cmd ::= SHOW CONFIGS */
|
case 10: /* cmd ::= SHOW VARIABLES */
|
||||||
{ setShowOptions(pInfo, TSDB_MGMT_TABLE_CONFIGS, 0, 0); }
|
{ setShowOptions(pInfo, TSDB_MGMT_TABLE_VARIABLES, 0, 0); }
|
||||||
break;
|
break;
|
||||||
case 11: /* cmd ::= SHOW SCORES */
|
case 11: /* cmd ::= SHOW SCORES */
|
||||||
{ setShowOptions(pInfo, TSDB_MGMT_TABLE_SCORES, 0, 0); }
|
{ setShowOptions(pInfo, TSDB_MGMT_TABLE_SCORES, 0, 0); }
|
||||||
|
@ -2074,21 +2074,21 @@ static void yy_reduce(
|
||||||
break;
|
break;
|
||||||
case 22: /* cmd ::= SHOW dbPrefix STABLES LIKE ids */
|
case 22: /* cmd ::= SHOW dbPrefix STABLES LIKE ids */
|
||||||
{
|
{
|
||||||
SSQLToken token;
|
SStrToken token;
|
||||||
setDBName(&token, &yymsp[-3].minor.yy0);
|
setDBName(&token, &yymsp[-3].minor.yy0);
|
||||||
setShowOptions(pInfo, TSDB_MGMT_TABLE_METRIC, &token, &yymsp[0].minor.yy0);
|
setShowOptions(pInfo, TSDB_MGMT_TABLE_METRIC, &token, &yymsp[0].minor.yy0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 23: /* cmd ::= SHOW dbPrefix VGROUPS */
|
case 23: /* cmd ::= SHOW dbPrefix VGROUPS */
|
||||||
{
|
{
|
||||||
SSQLToken token;
|
SStrToken token;
|
||||||
setDBName(&token, &yymsp[-1].minor.yy0);
|
setDBName(&token, &yymsp[-1].minor.yy0);
|
||||||
setShowOptions(pInfo, TSDB_MGMT_TABLE_VGROUP, &token, 0);
|
setShowOptions(pInfo, TSDB_MGMT_TABLE_VGROUP, &token, 0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 24: /* cmd ::= SHOW dbPrefix VGROUPS ids */
|
case 24: /* cmd ::= SHOW dbPrefix VGROUPS ids */
|
||||||
{
|
{
|
||||||
SSQLToken token;
|
SStrToken token;
|
||||||
setDBName(&token, &yymsp[-2].minor.yy0);
|
setDBName(&token, &yymsp[-2].minor.yy0);
|
||||||
setShowOptions(pInfo, TSDB_MGMT_TABLE_VGROUP, &token, &yymsp[0].minor.yy0);
|
setShowOptions(pInfo, TSDB_MGMT_TABLE_VGROUP, &token, &yymsp[0].minor.yy0);
|
||||||
}
|
}
|
||||||
|
@ -2139,7 +2139,7 @@ static void yy_reduce(
|
||||||
{ setDCLSQLElems(pInfo, TSDB_SQL_CFG_LOCAL, 2, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); }
|
{ setDCLSQLElems(pInfo, TSDB_SQL_CFG_LOCAL, 2, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); }
|
||||||
break;
|
break;
|
||||||
case 38: /* cmd ::= ALTER DATABASE ids alter_db_optr */
|
case 38: /* cmd ::= ALTER DATABASE ids alter_db_optr */
|
||||||
{ SSQLToken t = {0}; setCreateDBSQL(pInfo, TSDB_SQL_ALTER_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy268, &t);}
|
{ SStrToken t = {0}; setCreateDBSQL(pInfo, TSDB_SQL_ALTER_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy268, &t);}
|
||||||
break;
|
break;
|
||||||
case 39: /* cmd ::= ALTER ACCOUNT ids acct_optr */
|
case 39: /* cmd ::= ALTER ACCOUNT ids acct_optr */
|
||||||
{ setCreateAcctSQL(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-1].minor.yy0, NULL, &yymsp[0].minor.yy149);}
|
{ setCreateAcctSQL(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-1].minor.yy0, NULL, &yymsp[0].minor.yy149);}
|
||||||
|
@ -2277,6 +2277,7 @@ static void yy_reduce(
|
||||||
yymsp[-1].minor.yy268 = yylhsminor.yy268;
|
yymsp[-1].minor.yy268 = yylhsminor.yy268;
|
||||||
break;
|
break;
|
||||||
case 95: /* db_optr ::= db_optr fsync */
|
case 95: /* db_optr ::= db_optr fsync */
|
||||||
|
case 107: /* alter_db_optr ::= alter_db_optr fsync */ yytestcase(yyruleno==107);
|
||||||
{ yylhsminor.yy268 = yymsp[-1].minor.yy268; yylhsminor.yy268.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
|
{ yylhsminor.yy268 = yymsp[-1].minor.yy268; yylhsminor.yy268.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
|
||||||
yymsp[-1].minor.yy268 = yylhsminor.yy268;
|
yymsp[-1].minor.yy268 = yylhsminor.yy268;
|
||||||
break;
|
break;
|
||||||
|
@ -2297,10 +2298,6 @@ static void yy_reduce(
|
||||||
case 99: /* alter_db_optr ::= */
|
case 99: /* alter_db_optr ::= */
|
||||||
{ setDefaultCreateDbOption(&yymsp[1].minor.yy268);}
|
{ setDefaultCreateDbOption(&yymsp[1].minor.yy268);}
|
||||||
break;
|
break;
|
||||||
case 107: /* alter_db_optr ::= alter_db_optr fsync */
|
|
||||||
{ yylhsminor.yy268 = yymsp[-1].minor.yy268; yylhsminor.yy268.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
|
|
||||||
yymsp[-1].minor.yy268 = yylhsminor.yy268;
|
|
||||||
break;
|
|
||||||
case 108: /* typename ::= ids */
|
case 108: /* typename ::= ids */
|
||||||
{
|
{
|
||||||
yymsp[0].minor.yy0.type = 0;
|
yymsp[0].minor.yy0.type = 0;
|
||||||
|
|
|
@ -32,14 +32,16 @@ void simpleTest() {
|
||||||
|
|
||||||
// write 10 ts points
|
// write 10 ts points
|
||||||
int32_t num = 10;
|
int32_t num = 10;
|
||||||
int64_t tag = 1;
|
tVariant t = {0};
|
||||||
|
t.nType = TSDB_DATA_TYPE_BIGINT;
|
||||||
|
t.i64Key = 1;
|
||||||
|
|
||||||
int64_t* list = createTsList(10, 10000000, 30);
|
int64_t* list = createTsList(10, 10000000, 30);
|
||||||
tsBufAppend(pTSBuf, 0, tag, (const char*)list, num * sizeof(int64_t));
|
tsBufAppend(pTSBuf, 0, &t, (const char*)list, num * sizeof(int64_t));
|
||||||
EXPECT_EQ(pTSBuf->tsOrder, TSDB_ORDER_ASC);
|
EXPECT_EQ(pTSBuf->tsOrder, TSDB_ORDER_ASC);
|
||||||
|
|
||||||
EXPECT_EQ(pTSBuf->tsData.len, sizeof(int64_t) * num);
|
EXPECT_EQ(pTSBuf->tsData.len, sizeof(int64_t) * num);
|
||||||
EXPECT_EQ(pTSBuf->block.tag, tag);
|
EXPECT_EQ(tVariantCompare(&pTSBuf->block.tag, &t), 0);
|
||||||
EXPECT_EQ(pTSBuf->numOfVnodes, 1);
|
EXPECT_EQ(pTSBuf->numOfVnodes, 1);
|
||||||
|
|
||||||
tsBufFlush(pTSBuf);
|
tsBufFlush(pTSBuf);
|
||||||
|
@ -57,14 +59,16 @@ void largeTSTest() {
|
||||||
|
|
||||||
// write 10 ts points
|
// write 10 ts points
|
||||||
int32_t num = 1000000;
|
int32_t num = 1000000;
|
||||||
int64_t tag = 1;
|
tVariant t = {0};
|
||||||
|
t.nType = TSDB_DATA_TYPE_BIGINT;
|
||||||
|
t.i64Key = 1;
|
||||||
|
|
||||||
int64_t* list = createTsList(num, 10000000, 30);
|
int64_t* list = createTsList(num, 10000000, 30);
|
||||||
tsBufAppend(pTSBuf, 0, tag, (const char*)list, num * sizeof(int64_t));
|
tsBufAppend(pTSBuf, 0, &t, (const char*)list, num * sizeof(int64_t));
|
||||||
|
|
||||||
// the data has been flush to disk, no data in cache
|
// the data has been flush to disk, no data in cache
|
||||||
EXPECT_EQ(pTSBuf->tsData.len, 0);
|
EXPECT_EQ(pTSBuf->tsData.len, 0);
|
||||||
EXPECT_EQ(pTSBuf->block.tag, tag);
|
EXPECT_EQ(tVariantCompare(&pTSBuf->block.tag, &t), 0);
|
||||||
EXPECT_EQ(pTSBuf->numOfVnodes, 1);
|
EXPECT_EQ(pTSBuf->numOfVnodes, 1);
|
||||||
EXPECT_EQ(pTSBuf->tsOrder, TSDB_ORDER_ASC);
|
EXPECT_EQ(pTSBuf->tsOrder, TSDB_ORDER_ASC);
|
||||||
|
|
||||||
|
@ -80,14 +84,18 @@ void multiTagsTest() {
|
||||||
STSBuf* pTSBuf = tsBufCreate(true, TSDB_ORDER_ASC);
|
STSBuf* pTSBuf = tsBufCreate(true, TSDB_ORDER_ASC);
|
||||||
|
|
||||||
int32_t num = 10000;
|
int32_t num = 10000;
|
||||||
int64_t tag = 1;
|
tVariant t = {0};
|
||||||
|
t.nType = TSDB_DATA_TYPE_BIGINT;
|
||||||
|
|
||||||
int64_t start = 10000000;
|
int64_t start = 10000000;
|
||||||
int32_t numOfTags = 50;
|
int32_t numOfTags = 50;
|
||||||
int32_t step = 30;
|
int32_t step = 30;
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfTags; ++i) {
|
for (int32_t i = 0; i < numOfTags; ++i) {
|
||||||
int64_t* list = createTsList(num, start, step);
|
int64_t* list = createTsList(num, start, step);
|
||||||
tsBufAppend(pTSBuf, 0, i, (const char*)list, num * sizeof(int64_t));
|
t.i64Key = i;
|
||||||
|
|
||||||
|
tsBufAppend(pTSBuf, 0, &t, (const char*)list, num * sizeof(int64_t));
|
||||||
free(list);
|
free(list);
|
||||||
|
|
||||||
start += step * num;
|
start += step * num;
|
||||||
|
@ -96,7 +104,7 @@ void multiTagsTest() {
|
||||||
EXPECT_EQ(pTSBuf->tsOrder, TSDB_ORDER_ASC);
|
EXPECT_EQ(pTSBuf->tsOrder, TSDB_ORDER_ASC);
|
||||||
EXPECT_EQ(pTSBuf->tsData.len, num * sizeof(int64_t));
|
EXPECT_EQ(pTSBuf->tsData.len, num * sizeof(int64_t));
|
||||||
|
|
||||||
EXPECT_EQ(pTSBuf->block.tag, numOfTags - 1);
|
EXPECT_EQ(pTSBuf->block.tag.i64Key, numOfTags - 1);
|
||||||
EXPECT_EQ(pTSBuf->numOfVnodes, 1);
|
EXPECT_EQ(pTSBuf->numOfVnodes, 1);
|
||||||
|
|
||||||
tsBufFlush(pTSBuf);
|
tsBufFlush(pTSBuf);
|
||||||
|
@ -118,9 +126,14 @@ void multiVnodeTagsTest() {
|
||||||
for (int32_t j = 0; j < 20; ++j) {
|
for (int32_t j = 0; j < 20; ++j) {
|
||||||
// vnodeId:0
|
// vnodeId:0
|
||||||
start = 10000000;
|
start = 10000000;
|
||||||
|
tVariant t = {0};
|
||||||
|
t.nType = TSDB_DATA_TYPE_BIGINT;
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfTags; ++i) {
|
for (int32_t i = 0; i < numOfTags; ++i) {
|
||||||
int64_t* list = createTsList(num, start, step);
|
int64_t* list = createTsList(num, start, step);
|
||||||
tsBufAppend(pTSBuf, j, i, (const char*)list, num * sizeof(int64_t));
|
t.i64Key = i;
|
||||||
|
|
||||||
|
tsBufAppend(pTSBuf, j, &t, (const char*)list, num * sizeof(int64_t));
|
||||||
free(list);
|
free(list);
|
||||||
|
|
||||||
start += step * num;
|
start += step * num;
|
||||||
|
@ -131,11 +144,11 @@ void multiVnodeTagsTest() {
|
||||||
|
|
||||||
EXPECT_EQ(pTSBuf->tsOrder, TSDB_ORDER_ASC);
|
EXPECT_EQ(pTSBuf->tsOrder, TSDB_ORDER_ASC);
|
||||||
EXPECT_EQ(pTSBuf->tsData.len, num * sizeof(int64_t));
|
EXPECT_EQ(pTSBuf->tsData.len, num * sizeof(int64_t));
|
||||||
EXPECT_EQ(pTSBuf->block.tag, numOfTags - 1);
|
EXPECT_EQ(pTSBuf->block.tag.i64Key, numOfTags - 1);
|
||||||
|
|
||||||
EXPECT_EQ(pTSBuf->tsData.len, num * sizeof(int64_t));
|
EXPECT_EQ(pTSBuf->tsData.len, num * sizeof(int64_t));
|
||||||
|
|
||||||
EXPECT_EQ(pTSBuf->block.tag, numOfTags - 1);
|
EXPECT_EQ(pTSBuf->block.tag.i64Key, numOfTags - 1);
|
||||||
|
|
||||||
tsBufFlush(pTSBuf);
|
tsBufFlush(pTSBuf);
|
||||||
EXPECT_EQ(pTSBuf->tsData.len, 0);
|
EXPECT_EQ(pTSBuf->tsData.len, 0);
|
||||||
|
@ -157,9 +170,14 @@ void loadDataTest() {
|
||||||
for (int32_t j = 0; j < numOfVnode; ++j) {
|
for (int32_t j = 0; j < numOfVnode; ++j) {
|
||||||
// vnodeId:0
|
// vnodeId:0
|
||||||
int64_t start = 10000000;
|
int64_t start = 10000000;
|
||||||
|
tVariant t = {0};
|
||||||
|
t.nType = TSDB_DATA_TYPE_BIGINT;
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfTags; ++i) {
|
for (int32_t i = 0; i < numOfTags; ++i) {
|
||||||
int64_t* list = createTsList(num, start, step);
|
int64_t* list = createTsList(num, start, step);
|
||||||
tsBufAppend(pTSBuf, j, i, (const char*)list, num * sizeof(int64_t));
|
t.i64Key = i;
|
||||||
|
|
||||||
|
tsBufAppend(pTSBuf, j, &t, (const char*)list, num * sizeof(int64_t));
|
||||||
printf("%d - %" PRIu64 "\n", i, list[0]);
|
printf("%d - %" PRIu64 "\n", i, list[0]);
|
||||||
|
|
||||||
free(list);
|
free(list);
|
||||||
|
@ -172,11 +190,11 @@ void loadDataTest() {
|
||||||
EXPECT_EQ(pTSBuf->tsOrder, TSDB_ORDER_ASC);
|
EXPECT_EQ(pTSBuf->tsOrder, TSDB_ORDER_ASC);
|
||||||
|
|
||||||
EXPECT_EQ(pTSBuf->tsData.len, num * sizeof(int64_t));
|
EXPECT_EQ(pTSBuf->tsData.len, num * sizeof(int64_t));
|
||||||
EXPECT_EQ(pTSBuf->block.tag, numOfTags - 1);
|
EXPECT_EQ(pTSBuf->block.tag.i64Key, numOfTags - 1);
|
||||||
|
|
||||||
EXPECT_EQ(pTSBuf->tsData.len, num * sizeof(int64_t));
|
EXPECT_EQ(pTSBuf->tsData.len, num * sizeof(int64_t));
|
||||||
|
|
||||||
EXPECT_EQ(pTSBuf->block.tag, numOfTags - 1);
|
EXPECT_EQ(pTSBuf->block.tag.i64Key, numOfTags - 1);
|
||||||
|
|
||||||
tsBufFlush(pTSBuf);
|
tsBufFlush(pTSBuf);
|
||||||
EXPECT_EQ(pTSBuf->tsData.len, 0);
|
EXPECT_EQ(pTSBuf->tsData.len, 0);
|
||||||
|
@ -230,16 +248,21 @@ void TSTraverse() {
|
||||||
for (int32_t j = 0; j < numOfVnode; ++j) {
|
for (int32_t j = 0; j < numOfVnode; ++j) {
|
||||||
// vnodeId:0
|
// vnodeId:0
|
||||||
int64_t start = 10000000;
|
int64_t start = 10000000;
|
||||||
|
tVariant t = {0};
|
||||||
|
t.nType = TSDB_DATA_TYPE_BIGINT;
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfTags; ++i) {
|
for (int32_t i = 0; i < numOfTags; ++i) {
|
||||||
int64_t* list = createTsList(num, start, step);
|
int64_t* list = createTsList(num, start, step);
|
||||||
tsBufAppend(pTSBuf, j, i, (const char*)list, num * sizeof(int64_t));
|
t.i64Key = i;
|
||||||
|
|
||||||
|
tsBufAppend(pTSBuf, j, &t, (const char*)list, num * sizeof(int64_t));
|
||||||
printf("%d - %d - %" PRIu64 ", %" PRIu64 "\n", j, i, list[0], list[num - 1]);
|
printf("%d - %d - %" PRIu64 ", %" PRIu64 "\n", j, i, list[0], list[num - 1]);
|
||||||
|
|
||||||
free(list);
|
free(list);
|
||||||
start += step * num;
|
start += step * num;
|
||||||
|
|
||||||
list = createTsList(num, start, step);
|
list = createTsList(num, start, step);
|
||||||
tsBufAppend(pTSBuf, j, i, (const char*)list, num * sizeof(int64_t));
|
tsBufAppend(pTSBuf, j, &t, (const char*)list, num * sizeof(int64_t));
|
||||||
printf("%d - %d - %" PRIu64 ", %" PRIu64 "\n", j, i, list[0], list[num - 1]);
|
printf("%d - %d - %" PRIu64 ", %" PRIu64 "\n", j, i, list[0], list[num - 1]);
|
||||||
free(list);
|
free(list);
|
||||||
|
|
||||||
|
@ -272,12 +295,16 @@ void TSTraverse() {
|
||||||
int32_t startVnode = 1;
|
int32_t startVnode = 1;
|
||||||
int32_t startTag = 2;
|
int32_t startTag = 2;
|
||||||
|
|
||||||
tsBufGetElemStartPos(pTSBuf, startVnode, startTag);
|
tVariant t = {0};
|
||||||
|
t.nType = TSDB_DATA_TYPE_BIGINT;
|
||||||
|
t.i64Key = startTag;
|
||||||
|
|
||||||
|
tsBufGetElemStartPos(pTSBuf, startVnode, &t);
|
||||||
|
|
||||||
int32_t totalOutput = 10;
|
int32_t totalOutput = 10;
|
||||||
while (1) {
|
while (1) {
|
||||||
STSElem elem = tsBufGetElem(pTSBuf);
|
STSElem elem = tsBufGetElem(pTSBuf);
|
||||||
printf("%d-%" PRIu64 "-%" PRIu64 "\n", elem.vnode, elem.tag, elem.ts);
|
printf("%d-%" PRIu64 "-%" PRIu64 "\n", elem.vnode, elem.tag.i64Key, elem.ts);
|
||||||
|
|
||||||
if (!tsBufNextPos(pTSBuf)) {
|
if (!tsBufNextPos(pTSBuf)) {
|
||||||
break;
|
break;
|
||||||
|
@ -286,7 +313,9 @@ void TSTraverse() {
|
||||||
if (--totalOutput <= 0) {
|
if (--totalOutput <= 0) {
|
||||||
totalOutput = 10;
|
totalOutput = 10;
|
||||||
|
|
||||||
tsBufGetElemStartPos(pTSBuf, startVnode, --startTag);
|
startTag -= 1;
|
||||||
|
t.i64Key = startTag;
|
||||||
|
tsBufGetElemStartPos(pTSBuf, startVnode, &t);
|
||||||
|
|
||||||
if (startTag == 0) {
|
if (startTag == 0) {
|
||||||
startVnode -= 1;
|
startVnode -= 1;
|
||||||
|
@ -316,13 +345,14 @@ void TSTraverse() {
|
||||||
|
|
||||||
startVnode = 1;
|
startVnode = 1;
|
||||||
startTag = 2;
|
startTag = 2;
|
||||||
|
t.i64Key = startTag;
|
||||||
|
|
||||||
tsBufGetElemStartPos(pTSBuf, startVnode, startTag);
|
tsBufGetElemStartPos(pTSBuf, startVnode, &t);
|
||||||
|
|
||||||
totalOutput = 10;
|
totalOutput = 10;
|
||||||
while (1) {
|
while (1) {
|
||||||
STSElem elem = tsBufGetElem(pTSBuf);
|
STSElem elem = tsBufGetElem(pTSBuf);
|
||||||
printf("%d-%" PRIu64 "-%" PRIu64 "\n", elem.vnode, elem.tag, elem.ts);
|
printf("%d-%" PRIu64 "-%" PRIu64 "\n", elem.vnode, elem.tag.i64Key, elem.ts);
|
||||||
|
|
||||||
if (!tsBufNextPos(pTSBuf)) {
|
if (!tsBufNextPos(pTSBuf)) {
|
||||||
break;
|
break;
|
||||||
|
@ -331,7 +361,9 @@ void TSTraverse() {
|
||||||
if (--totalOutput <= 0) {
|
if (--totalOutput <= 0) {
|
||||||
totalOutput = 10;
|
totalOutput = 10;
|
||||||
|
|
||||||
tsBufGetElemStartPos(pTSBuf, startVnode, --startTag);
|
startTag -= 1;
|
||||||
|
t.i64Key = startTag;
|
||||||
|
tsBufGetElemStartPos(pTSBuf, startVnode, &t);
|
||||||
|
|
||||||
if (startTag < 0) {
|
if (startTag < 0) {
|
||||||
startVnode -= 1;
|
startVnode -= 1;
|
||||||
|
@ -375,12 +407,17 @@ void mergeDiffVnodeBufferTest() {
|
||||||
int32_t num = 1000;
|
int32_t num = 1000;
|
||||||
int32_t numOfTags = 10;
|
int32_t numOfTags = 10;
|
||||||
|
|
||||||
|
tVariant t = {0};
|
||||||
|
t.nType = TSDB_DATA_TYPE_BIGINT;
|
||||||
|
|
||||||
// vnodeId:0
|
// vnodeId:0
|
||||||
int64_t start = 10000000;
|
int64_t start = 10000000;
|
||||||
for (int32_t i = 0; i < numOfTags; ++i) {
|
for (int32_t i = 0; i < numOfTags; ++i) {
|
||||||
int64_t* list = createTsList(num, start, step);
|
int64_t* list = createTsList(num, start, step);
|
||||||
tsBufAppend(pTSBuf1, 0, i, (const char*)list, num * sizeof(int64_t));
|
t.i64Key = i;
|
||||||
tsBufAppend(pTSBuf2, 0, i, (const char*)list, num * sizeof(int64_t));
|
|
||||||
|
tsBufAppend(pTSBuf1, 0, &t, (const char*)list, num * sizeof(int64_t));
|
||||||
|
tsBufAppend(pTSBuf2, 0, &t, (const char*)list, num * sizeof(int64_t));
|
||||||
|
|
||||||
free(list);
|
free(list);
|
||||||
|
|
||||||
|
@ -403,6 +440,9 @@ void mergeIdenticalVnodeBufferTest() {
|
||||||
STSBuf* pTSBuf1 = tsBufCreate(true, TSDB_ORDER_ASC);
|
STSBuf* pTSBuf1 = tsBufCreate(true, TSDB_ORDER_ASC);
|
||||||
STSBuf* pTSBuf2 = tsBufCreate(true, TSDB_ORDER_ASC);
|
STSBuf* pTSBuf2 = tsBufCreate(true, TSDB_ORDER_ASC);
|
||||||
|
|
||||||
|
tVariant t = {0};
|
||||||
|
t.nType = TSDB_DATA_TYPE_BIGINT;
|
||||||
|
|
||||||
int32_t step = 30;
|
int32_t step = 30;
|
||||||
int32_t num = 1000;
|
int32_t num = 1000;
|
||||||
int32_t numOfTags = 10;
|
int32_t numOfTags = 10;
|
||||||
|
@ -411,17 +451,21 @@ void mergeIdenticalVnodeBufferTest() {
|
||||||
int64_t start = 10000000;
|
int64_t start = 10000000;
|
||||||
for (int32_t i = 0; i < numOfTags; ++i) {
|
for (int32_t i = 0; i < numOfTags; ++i) {
|
||||||
int64_t* list = createTsList(num, start, step);
|
int64_t* list = createTsList(num, start, step);
|
||||||
|
t.i64Key = i;
|
||||||
|
|
||||||
tsBufAppend(pTSBuf1, 12, i, (const char*)list, num * sizeof(int64_t));
|
tsBufAppend(pTSBuf1, 12, &t, (const char*)list, num * sizeof(int64_t));
|
||||||
free(list);
|
free(list);
|
||||||
|
|
||||||
start += step * num;
|
start += step * num;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (int32_t i = numOfTags; i < numOfTags * 2; ++i) {
|
for (int32_t i = numOfTags; i < numOfTags * 2; ++i) {
|
||||||
int64_t* list = createTsList(num, start, step);
|
int64_t* list = createTsList(num, start, step);
|
||||||
|
|
||||||
tsBufAppend(pTSBuf2, 77, i, (const char*)list, num * sizeof(int64_t));
|
t.i64Key = i;
|
||||||
|
tsBufAppend(pTSBuf2, 77, &t, (const char*)list, num * sizeof(int64_t));
|
||||||
free(list);
|
free(list);
|
||||||
|
|
||||||
start += step * num;
|
start += step * num;
|
||||||
|
@ -438,7 +482,7 @@ void mergeIdenticalVnodeBufferTest() {
|
||||||
STSElem elem = tsBufGetElem(pTSBuf1);
|
STSElem elem = tsBufGetElem(pTSBuf1);
|
||||||
EXPECT_EQ(elem.vnode, 12);
|
EXPECT_EQ(elem.vnode, 12);
|
||||||
|
|
||||||
printf("%d-%" PRIu64 "-%" PRIu64 "\n", elem.vnode, elem.tag, elem.ts);
|
printf("%d-%" PRIu64 "-%" PRIu64 "\n", elem.vnode, elem.tag.i64Key, elem.ts);
|
||||||
}
|
}
|
||||||
|
|
||||||
tsBufDestroy(pTSBuf1);
|
tsBufDestroy(pTSBuf1);
|
||||||
|
@ -446,6 +490,8 @@ void mergeIdenticalVnodeBufferTest() {
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|
||||||
|
//TODO add binary tag value test case
|
||||||
TEST(testCase, tsBufTest) {
|
TEST(testCase, tsBufTest) {
|
||||||
simpleTest();
|
simpleTest();
|
||||||
largeTSTest();
|
largeTSTest();
|
||||||
|
@ -453,7 +499,7 @@ TEST(testCase, tsBufTest) {
|
||||||
multiVnodeTagsTest();
|
multiVnodeTagsTest();
|
||||||
loadDataTest();
|
loadDataTest();
|
||||||
invalidFileTest();
|
invalidFileTest();
|
||||||
// randomIncTsTest();
|
// randomIncTsTest();
|
||||||
TSTraverse();
|
TSTraverse();
|
||||||
mergeDiffVnodeBufferTest();
|
mergeDiffVnodeBufferTest();
|
||||||
mergeIdenticalVnodeBufferTest();
|
mergeIdenticalVnodeBufferTest();
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
int32_t testValidateName(char* name) {
|
int32_t testValidateName(char* name) {
|
||||||
SSQLToken token = {0};
|
SStrToken token = {0};
|
||||||
token.z = name;
|
token.z = name;
|
||||||
token.n = strlen(name);
|
token.n = strlen(name);
|
||||||
token.type = 0;
|
token.type = 0;
|
||||||
|
@ -720,8 +720,8 @@ TEST(testCase, tGetToken_Test) {
|
||||||
EXPECT_FALSE(type == TK_HEX);
|
EXPECT_FALSE(type == TK_HEX);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SSQLToken createStrToken(char* s) {
|
static SStrToken createStrToken(char* s) {
|
||||||
SSQLToken t = {0};//.type = TK_STRING, .z = s, .n = strlen(s)};
|
SStrToken t = {0};//.type = TK_STRING, .z = s, .n = strlen(s)};
|
||||||
t.type = TK_STRING;
|
t.type = TK_STRING;
|
||||||
t.z = s;
|
t.z = s;
|
||||||
t.n = strlen(s);
|
t.n = strlen(s);
|
||||||
|
@ -730,7 +730,7 @@ static SSQLToken createStrToken(char* s) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(testCase, isValidNumber_test) {
|
TEST(testCase, isValidNumber_test) {
|
||||||
SSQLToken t1 = createStrToken("123abc");
|
SStrToken t1 = createStrToken("123abc");
|
||||||
|
|
||||||
EXPECT_EQ(isValidNumber(&t1), TK_ILLEGAL);
|
EXPECT_EQ(isValidNumber(&t1), TK_ILLEGAL);
|
||||||
|
|
||||||
|
|
|
@ -99,9 +99,7 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
sInfo("TAOS arbitrator: %s:%d is running", tsNodeFqdn, tsArbitratorPort);
|
sInfo("TAOS arbitrator: %s:%d is running", tsNodeFqdn, tsArbitratorPort);
|
||||||
|
|
||||||
for (int res = tsem_wait(&tsArbSem); res != 0; res = tsem_wait(&tsArbSem)) {
|
tsem_wait(&tsArbSem);
|
||||||
if (res != EINTR) break;
|
|
||||||
}
|
|
||||||
|
|
||||||
taosCloseTcpThreadPool(tsArbTcpPool);
|
taosCloseTcpThreadPool(tsArbTcpPool);
|
||||||
sInfo("TAOS arbitrator is shut down\n");
|
sInfo("TAOS arbitrator is shut down\n");
|
||||||
|
|
|
@ -28,6 +28,14 @@
|
||||||
#define ASCENDING_TRAVERSE(o) (o == TSDB_ORDER_ASC)
|
#define ASCENDING_TRAVERSE(o) (o == TSDB_ORDER_ASC)
|
||||||
#define QH_GET_NUM_OF_COLS(handle) ((size_t)(taosArrayGetSize((handle)->pColumns)))
|
#define QH_GET_NUM_OF_COLS(handle) ((size_t)(taosArrayGetSize((handle)->pColumns)))
|
||||||
|
|
||||||
|
#define GET_FILE_DATA_BLOCK_INFO(_checkInfo, _block) \
|
||||||
|
((SDataBlockInfo){.window = {.skey = (_block)->keyFirst, .ekey = (_block)->keyLast}, \
|
||||||
|
.numOfCols = (_block)->numOfCols, \
|
||||||
|
.rows = (_block)->numOfRows, \
|
||||||
|
.tid = (_checkInfo)->tableId.tid, \
|
||||||
|
.uid = (_checkInfo)->tableId.uid})
|
||||||
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
TSDB_QUERY_TYPE_ALL = 1,
|
TSDB_QUERY_TYPE_ALL = 1,
|
||||||
TSDB_QUERY_TYPE_LAST = 2,
|
TSDB_QUERY_TYPE_LAST = 2,
|
||||||
|
@ -119,7 +127,14 @@ typedef struct STsdbQueryHandle {
|
||||||
SIOCostSummary cost;
|
SIOCostSummary cost;
|
||||||
} STsdbQueryHandle;
|
} STsdbQueryHandle;
|
||||||
|
|
||||||
static void changeQueryHandleForLastrowQuery(TsdbQueryHandleT pqHandle);
|
typedef struct STableGroupSupporter {
|
||||||
|
int32_t numOfCols;
|
||||||
|
SColIndex* pCols;
|
||||||
|
STSchema* pTagSchema;
|
||||||
|
} STableGroupSupporter;
|
||||||
|
|
||||||
|
static STimeWindow changeTableGroupByLastrow(STableGroupInfo *groupList);
|
||||||
|
|
||||||
static void changeQueryHandleForInterpQuery(TsdbQueryHandleT pHandle);
|
static void changeQueryHandleForInterpQuery(TsdbQueryHandleT pHandle);
|
||||||
static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo* pCheckInfo, SCompBlock* pBlock);
|
static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo* pCheckInfo, SCompBlock* pBlock);
|
||||||
static int32_t binarySearchForKey(char* pValue, int num, TSKEY key, int order);
|
static int32_t binarySearchForKey(char* pValue, int num, TSKEY key, int order);
|
||||||
|
@ -242,10 +257,7 @@ TsdbQueryHandleT* tsdbQueryTables(TSDB_REPO_T* tsdb, STsdbQueryCond* pCond, STab
|
||||||
for (int32_t j = 0; j < gsize; ++j) {
|
for (int32_t j = 0; j < gsize; ++j) {
|
||||||
STableKeyInfo* pKeyInfo = (STableKeyInfo*) taosArrayGet(group, j);
|
STableKeyInfo* pKeyInfo = (STableKeyInfo*) taosArrayGet(group, j);
|
||||||
|
|
||||||
STableCheckInfo info = {
|
STableCheckInfo info = { .lastKey = pKeyInfo->lastKey, .pTableObj = pKeyInfo->pTable };
|
||||||
.lastKey = pKeyInfo->lastKey,
|
|
||||||
.pTableObj = pKeyInfo->pTable,
|
|
||||||
};
|
|
||||||
info.tableId = ((STable*)(pKeyInfo->pTable))->tableId;
|
info.tableId = ((STable*)(pKeyInfo->pTable))->tableId;
|
||||||
|
|
||||||
assert(info.pTableObj != NULL && (info.pTableObj->type == TSDB_NORMAL_TABLE ||
|
assert(info.pTableObj != NULL && (info.pTableObj->type == TSDB_NORMAL_TABLE ||
|
||||||
|
@ -283,12 +295,9 @@ out_of_memory:
|
||||||
}
|
}
|
||||||
|
|
||||||
TsdbQueryHandleT tsdbQueryLastRow(TSDB_REPO_T *tsdb, STsdbQueryCond *pCond, STableGroupInfo *groupList, void* qinfo) {
|
TsdbQueryHandleT tsdbQueryLastRow(TSDB_REPO_T *tsdb, STsdbQueryCond *pCond, STableGroupInfo *groupList, void* qinfo) {
|
||||||
|
pCond->order = TSDB_ORDER_ASC;
|
||||||
|
pCond->twindow = changeTableGroupByLastrow(groupList);
|
||||||
STsdbQueryHandle *pQueryHandle = (STsdbQueryHandle*) tsdbQueryTables(tsdb, pCond, groupList, qinfo);
|
STsdbQueryHandle *pQueryHandle = (STsdbQueryHandle*) tsdbQueryTables(tsdb, pCond, groupList, qinfo);
|
||||||
if (pQueryHandle != NULL) {
|
|
||||||
pQueryHandle->type = TSDB_QUERY_TYPE_LAST;
|
|
||||||
pQueryHandle->order = TSDB_ORDER_DESC;
|
|
||||||
changeQueryHandleForLastrowQuery(pQueryHandle);
|
|
||||||
}
|
|
||||||
return pQueryHandle;
|
return pQueryHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -393,7 +402,7 @@ static bool initTableMemIterator(STsdbQueryHandle* pHandle, STableCheckInfo* pCh
|
||||||
|
|
||||||
SDataRow row = *(SDataRow *)SL_GET_NODE_DATA(node);
|
SDataRow row = *(SDataRow *)SL_GET_NODE_DATA(node);
|
||||||
TSKEY key = dataRowKey(row); // first timestamp in buffer
|
TSKEY key = dataRowKey(row); // first timestamp in buffer
|
||||||
tsdbDebug("%p uid:%" PRId64 ", tid:%d check data in mem from skey:%" PRId64 ", order:%d, ts range in buf:%" PRId64
|
tsdbDebug("%p uid:%" PRId64 ", tid:%d check data in imem from skey:%" PRId64 ", order:%d, ts range in buf:%" PRId64
|
||||||
"-%" PRId64 ", lastKey:%" PRId64 ", %p",
|
"-%" PRId64 ", lastKey:%" PRId64 ", %p",
|
||||||
pHandle, pCheckInfo->tableId.uid, pCheckInfo->tableId.tid, key, order, pIMem->keyFirst, pIMem->keyLast,
|
pHandle, pCheckInfo->tableId.uid, pCheckInfo->tableId.tid, key, order, pIMem->keyFirst, pIMem->keyLast,
|
||||||
pCheckInfo->lastKey, pHandle->qinfo);
|
pCheckInfo->lastKey, pHandle->qinfo);
|
||||||
|
@ -416,7 +425,7 @@ static void destroyTableMemIterator(STableCheckInfo* pCheckInfo) {
|
||||||
tSkipListDestroyIter(pCheckInfo->iiter);
|
tSkipListDestroyIter(pCheckInfo->iiter);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDataRow getSDataRowInTableMem(STableCheckInfo* pCheckInfo, int32_t order) {
|
static SDataRow getSDataRowInTableMem(STableCheckInfo* pCheckInfo, int32_t order) {
|
||||||
SDataRow rmem = NULL, rimem = NULL;
|
SDataRow rmem = NULL, rimem = NULL;
|
||||||
if (pCheckInfo->iter) {
|
if (pCheckInfo->iter) {
|
||||||
SSkipListNode* node = tSkipListIterGet(pCheckInfo->iter);
|
SSkipListNode* node = tSkipListIterGet(pCheckInfo->iter);
|
||||||
|
@ -432,7 +441,20 @@ SDataRow getSDataRowInTableMem(STableCheckInfo* pCheckInfo, int32_t order) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rmem != NULL && rimem != NULL) {
|
if (rmem == NULL && rimem == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rmem != NULL && rimem == NULL) {
|
||||||
|
pCheckInfo->chosen = 0;
|
||||||
|
return rmem;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rmem == NULL && rimem != NULL) {
|
||||||
|
pCheckInfo->chosen = 1;
|
||||||
|
return rimem;
|
||||||
|
}
|
||||||
|
|
||||||
TSKEY r1 = dataRowKey(rmem);
|
TSKEY r1 = dataRowKey(rmem);
|
||||||
TSKEY r2 = dataRowKey(rimem);
|
TSKEY r2 = dataRowKey(rimem);
|
||||||
|
|
||||||
|
@ -459,20 +481,6 @@ SDataRow getSDataRowInTableMem(STableCheckInfo* pCheckInfo, int32_t order) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// at least one (rmem or rimem) is absent here
|
|
||||||
if (rmem != NULL) {
|
|
||||||
pCheckInfo->chosen = 0;
|
|
||||||
return rmem;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rimem != NULL) {
|
|
||||||
pCheckInfo->chosen = 1;
|
|
||||||
return rimem;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool moveToNextRowInMem(STableCheckInfo* pCheckInfo) {
|
static bool moveToNextRowInMem(STableCheckInfo* pCheckInfo) {
|
||||||
|
@ -672,14 +680,6 @@ static int32_t getFileCompInfo(STsdbQueryHandle* pQueryHandle, int32_t* numOfBlo
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define GET_FILE_DATA_BLOCK_INFO(_checkInfo, _block) \
|
|
||||||
((SDataBlockInfo){.window = {.skey = (_block)->keyFirst, .ekey = (_block)->keyLast}, \
|
|
||||||
.numOfCols = (_block)->numOfCols, \
|
|
||||||
.rows = (_block)->numOfRows, \
|
|
||||||
.tid = (_checkInfo)->tableId.tid, \
|
|
||||||
.uid = (_checkInfo)->tableId.uid})
|
|
||||||
|
|
||||||
|
|
||||||
static int32_t doLoadFileDataBlock(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlock, STableCheckInfo* pCheckInfo, int32_t slotIndex) {
|
static int32_t doLoadFileDataBlock(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlock, STableCheckInfo* pCheckInfo, int32_t slotIndex) {
|
||||||
STsdbRepo *pRepo = pQueryHandle->pTsdb;
|
STsdbRepo *pRepo = pQueryHandle->pTsdb;
|
||||||
int64_t st = taosGetTimestampUs();
|
int64_t st = taosGetTimestampUs();
|
||||||
|
@ -736,6 +736,8 @@ static int32_t handleDataMergeIfNeeded(STsdbQueryHandle* pQueryHandle, SCompBloc
|
||||||
SDataRow row = getSDataRowInTableMem(pCheckInfo, pQueryHandle->order);
|
SDataRow row = getSDataRowInTableMem(pCheckInfo, pQueryHandle->order);
|
||||||
|
|
||||||
TSKEY key = (row != NULL)? dataRowKey(row):TSKEY_INITIAL_VAL;
|
TSKEY key = (row != NULL)? dataRowKey(row):TSKEY_INITIAL_VAL;
|
||||||
|
tsdbDebug("%p key in mem:%"PRId64", %p", pQueryHandle, key, pQueryHandle->qinfo);
|
||||||
|
|
||||||
cur->pos = ASCENDING_TRAVERSE(pQueryHandle->order)? 0:(binfo.rows-1);
|
cur->pos = ASCENDING_TRAVERSE(pQueryHandle->order)? 0:(binfo.rows-1);
|
||||||
|
|
||||||
if ((ASCENDING_TRAVERSE(pQueryHandle->order) && (key != TSKEY_INITIAL_VAL && key <= binfo.window.ekey)) ||
|
if ((ASCENDING_TRAVERSE(pQueryHandle->order) && (key != TSKEY_INITIAL_VAL && key <= binfo.window.ekey)) ||
|
||||||
|
@ -747,7 +749,8 @@ static int32_t handleDataMergeIfNeeded(STsdbQueryHandle* pQueryHandle, SCompBloc
|
||||||
// do not load file block into buffer
|
// do not load file block into buffer
|
||||||
int32_t step = ASCENDING_TRAVERSE(pQueryHandle->order) ? 1 : -1;
|
int32_t step = ASCENDING_TRAVERSE(pQueryHandle->order) ? 1 : -1;
|
||||||
|
|
||||||
cur->rows = tsdbReadRowsFromCache(pCheckInfo, binfo.window.skey - step, pQueryHandle->outputCapacity, &cur->win, pQueryHandle);
|
TSKEY maxKey = ASCENDING_TRAVERSE(pQueryHandle->order)? (binfo.window.skey - step):(binfo.window.ekey - step);
|
||||||
|
cur->rows = tsdbReadRowsFromCache(pCheckInfo, maxKey, pQueryHandle->outputCapacity, &cur->win, pQueryHandle);
|
||||||
pQueryHandle->realNumOfRows = cur->rows;
|
pQueryHandle->realNumOfRows = cur->rows;
|
||||||
|
|
||||||
// update the last key value
|
// update the last key value
|
||||||
|
@ -1072,8 +1075,8 @@ static void moveDataToFront(STsdbQueryHandle* pQueryHandle, int32_t numOfRows, i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void getQualifiedRowsPos(STsdbQueryHandle* pQueryHandle, int32_t startPos, int32_t endPos,
|
static void getQualifiedRowsPos(STsdbQueryHandle* pQueryHandle, int32_t startPos, int32_t endPos, int32_t numOfExisted,
|
||||||
int32_t numOfExisted, int32_t *start, int32_t *end) {
|
int32_t* start, int32_t* end) {
|
||||||
*start = -1;
|
*start = -1;
|
||||||
|
|
||||||
if (ASCENDING_TRAVERSE(pQueryHandle->order)) {
|
if (ASCENDING_TRAVERSE(pQueryHandle->order)) {
|
||||||
|
@ -1162,6 +1165,11 @@ static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo*
|
||||||
cur->mixBlock = true;
|
cur->mixBlock = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tsdbDebug("%p uid:%" PRIu64",tid:%d start merge data block, file block range:%"PRIu64"-%"PRIu64" rows:%d, start:%d,"
|
||||||
|
"end:%d, %p",
|
||||||
|
pQueryHandle, pCheckInfo->tableId.uid, pCheckInfo->tableId.tid, blockInfo.window.skey, blockInfo.window.ekey,
|
||||||
|
blockInfo.rows, cur->pos, endPos, pQueryHandle->qinfo);
|
||||||
|
|
||||||
// compared with the data from in-memory buffer, to generate the correct timestamp array list
|
// compared with the data from in-memory buffer, to generate the correct timestamp array list
|
||||||
int32_t numOfRows = 0;
|
int32_t numOfRows = 0;
|
||||||
int32_t pos = cur->pos;
|
int32_t pos = cur->pos;
|
||||||
|
@ -1191,6 +1199,10 @@ static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo*
|
||||||
moveDataToFront(pQueryHandle, numOfRows, numOfCols);
|
moveDataToFront(pQueryHandle, numOfRows, numOfCols);
|
||||||
updateInfoAfterMerge(pQueryHandle, pCheckInfo, numOfRows, pos);
|
updateInfoAfterMerge(pQueryHandle, pCheckInfo, numOfRows, pos);
|
||||||
doCheckGeneratedBlockRange(pQueryHandle);
|
doCheckGeneratedBlockRange(pQueryHandle);
|
||||||
|
|
||||||
|
tsdbDebug("%p uid:%" PRIu64",tid:%d data block created, mixblock:%d, brange:%"PRIu64"-%"PRIu64" rows:%d, %p",
|
||||||
|
pQueryHandle, pCheckInfo->tableId.uid, pCheckInfo->tableId.tid, cur->mixBlock, cur->win.skey,
|
||||||
|
cur->win.ekey, cur->rows, pQueryHandle->qinfo);
|
||||||
return;
|
return;
|
||||||
} else if (pCheckInfo->iter != NULL || pCheckInfo->iiter != NULL) {
|
} else if (pCheckInfo->iter != NULL || pCheckInfo->iiter != NULL) {
|
||||||
SSkipListNode* node = NULL;
|
SSkipListNode* node = NULL;
|
||||||
|
@ -1233,6 +1245,8 @@ static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo*
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t end = doBinarySearchKey(pCols->cols[0].pData, pCols->numOfRows, key, order);
|
int32_t end = doBinarySearchKey(pCols->cols[0].pData, pCols->numOfRows, key, order);
|
||||||
|
assert(end != -1);
|
||||||
|
|
||||||
if (tsArray[end] == key) { // the value of key in cache equals to the end timestamp value, ignore it
|
if (tsArray[end] == key) { // the value of key in cache equals to the end timestamp value, ignore it
|
||||||
moveToNextRowInMem(pCheckInfo);
|
moveToNextRowInMem(pCheckInfo);
|
||||||
}
|
}
|
||||||
|
@ -1269,6 +1283,7 @@ static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo*
|
||||||
|
|
||||||
cur->win.ekey = ASCENDING_TRAVERSE(pQueryHandle->order)? tsArray[end]:tsArray[start];
|
cur->win.ekey = ASCENDING_TRAVERSE(pQueryHandle->order)? tsArray[end]:tsArray[start];
|
||||||
cur->lastKey = cur->win.ekey + step;
|
cur->lastKey = cur->win.ekey + step;
|
||||||
|
cur->mixBlock = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1285,7 +1300,8 @@ static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo*
|
||||||
updateInfoAfterMerge(pQueryHandle, pCheckInfo, numOfRows, pos);
|
updateInfoAfterMerge(pQueryHandle, pCheckInfo, numOfRows, pos);
|
||||||
doCheckGeneratedBlockRange(pQueryHandle);
|
doCheckGeneratedBlockRange(pQueryHandle);
|
||||||
|
|
||||||
tsdbDebug("%p uid:%" PRIu64",tid:%d data block created, brange:%"PRIu64"-%"PRIu64" rows:%d, %p", pQueryHandle, pCheckInfo->tableId.uid, pCheckInfo->tableId.tid, cur->win.skey,
|
tsdbDebug("%p uid:%" PRIu64",tid:%d data block created, mixblock:%d, brange:%"PRIu64"-%"PRIu64" rows:%d, %p",
|
||||||
|
pQueryHandle, pCheckInfo->tableId.uid, pCheckInfo->tableId.tid, cur->mixBlock, cur->win.skey,
|
||||||
cur->win.ekey, cur->rows, pQueryHandle->qinfo);
|
cur->win.ekey, cur->rows, pQueryHandle->qinfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1658,223 +1674,6 @@ static bool doHasDataInBuffer(STsdbQueryHandle* pQueryHandle) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle data in cache situation
|
|
||||||
bool tsdbNextDataBlock(TsdbQueryHandleT* pHandle) {
|
|
||||||
STsdbQueryHandle* pQueryHandle = (STsdbQueryHandle*) pHandle;
|
|
||||||
|
|
||||||
int64_t stime = taosGetTimestampUs();
|
|
||||||
int64_t elapsedTime = stime;
|
|
||||||
|
|
||||||
size_t numOfTables = taosArrayGetSize(pQueryHandle->pTableCheckInfo);
|
|
||||||
assert(numOfTables > 0);
|
|
||||||
|
|
||||||
SDataBlockInfo blockInfo = {{0}, 0};
|
|
||||||
if (pQueryHandle->type == TSDB_QUERY_TYPE_EXTERNAL) {
|
|
||||||
pQueryHandle->type = TSDB_QUERY_TYPE_ALL;
|
|
||||||
pQueryHandle->order = TSDB_ORDER_DESC;
|
|
||||||
|
|
||||||
if (!tsdbNextDataBlock(pHandle)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
tsdbRetrieveDataBlockInfo(pHandle, &blockInfo);
|
|
||||||
/*SArray *pDataBlock = */tsdbRetrieveDataBlock(pHandle, pQueryHandle->defaultLoadColumn);
|
|
||||||
if (terrno != TSDB_CODE_SUCCESS) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pQueryHandle->cur.win.ekey == pQueryHandle->window.skey) {
|
|
||||||
// data already retrieve, discard other data rows and return
|
|
||||||
int32_t numOfCols = (int32_t)(QH_GET_NUM_OF_COLS(pQueryHandle));
|
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
|
||||||
SColumnInfoData* pCol = taosArrayGet(pQueryHandle->pColumns, i);
|
|
||||||
memcpy((char*)pCol->pData, (char*)pCol->pData + pCol->info.bytes * (pQueryHandle->cur.rows - 1), pCol->info.bytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
pQueryHandle->cur.win = (STimeWindow){pQueryHandle->window.skey, pQueryHandle->window.skey};
|
|
||||||
pQueryHandle->window = pQueryHandle->cur.win;
|
|
||||||
pQueryHandle->cur.rows = 1;
|
|
||||||
pQueryHandle->type = TSDB_QUERY_TYPE_ALL;
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
STsdbQueryHandle* pSecQueryHandle = calloc(1, sizeof(STsdbQueryHandle));
|
|
||||||
pSecQueryHandle->order = TSDB_ORDER_ASC;
|
|
||||||
pSecQueryHandle->window = (STimeWindow) {pQueryHandle->window.skey, INT64_MAX};
|
|
||||||
pSecQueryHandle->pTsdb = pQueryHandle->pTsdb;
|
|
||||||
pSecQueryHandle->type = TSDB_QUERY_TYPE_ALL;
|
|
||||||
pSecQueryHandle->cur.fid = -1;
|
|
||||||
pSecQueryHandle->cur.win = TSWINDOW_INITIALIZER;
|
|
||||||
pSecQueryHandle->checkFiles = true;
|
|
||||||
pSecQueryHandle->activeIndex = 0;
|
|
||||||
pSecQueryHandle->outputCapacity = ((STsdbRepo*)pSecQueryHandle->pTsdb)->config.maxRowsPerFileBlock;
|
|
||||||
|
|
||||||
if (tsdbInitReadHelper(&pSecQueryHandle->rhelper, (STsdbRepo*) pSecQueryHandle->pTsdb) != 0) {
|
|
||||||
free(pSecQueryHandle);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
tsdbTakeMemSnapshot(pSecQueryHandle->pTsdb, &pSecQueryHandle->mem, &pSecQueryHandle->imem);
|
|
||||||
|
|
||||||
// allocate buffer in order to load data blocks from file
|
|
||||||
int32_t numOfCols = (int32_t)(QH_GET_NUM_OF_COLS(pQueryHandle));
|
|
||||||
|
|
||||||
pSecQueryHandle->statis = calloc(numOfCols, sizeof(SDataStatis));
|
|
||||||
pSecQueryHandle->pColumns = taosArrayInit(numOfCols, sizeof(SColumnInfoData));
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
|
||||||
SColumnInfoData colInfo = {{0}, 0};
|
|
||||||
SColumnInfoData* pCol = taosArrayGet(pQueryHandle->pColumns, i);
|
|
||||||
|
|
||||||
colInfo.info = pCol->info;
|
|
||||||
colInfo.pData = calloc(1, EXTRA_BYTES + pQueryHandle->outputCapacity * pCol->info.bytes);
|
|
||||||
taosArrayPush(pSecQueryHandle->pColumns, &colInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t si = taosArrayGetSize(pQueryHandle->pTableCheckInfo);
|
|
||||||
pSecQueryHandle->pTableCheckInfo = taosArrayInit(si, sizeof(STableCheckInfo));
|
|
||||||
STsdbMeta* pMeta = tsdbGetMeta(pQueryHandle->pTsdb);
|
|
||||||
assert(pMeta != NULL);
|
|
||||||
|
|
||||||
for (int32_t j = 0; j < si; ++j) {
|
|
||||||
STableCheckInfo* pCheckInfo = (STableCheckInfo*) taosArrayGet(pQueryHandle->pTableCheckInfo, j);
|
|
||||||
STableCheckInfo info = {
|
|
||||||
.lastKey = pSecQueryHandle->window.skey,
|
|
||||||
.pTableObj = pCheckInfo->pTableObj,
|
|
||||||
};
|
|
||||||
|
|
||||||
info.tableId = pCheckInfo->tableId;
|
|
||||||
|
|
||||||
taosArrayPush(pSecQueryHandle->pTableCheckInfo, &info);
|
|
||||||
}
|
|
||||||
|
|
||||||
tsdbInitDataBlockLoadInfo(&pSecQueryHandle->dataBlockLoadInfo);
|
|
||||||
tsdbInitCompBlockLoadInfo(&pSecQueryHandle->compBlockLoadInfo);
|
|
||||||
pSecQueryHandle->defaultLoadColumn = taosArrayClone(pQueryHandle->defaultLoadColumn);
|
|
||||||
|
|
||||||
if (!tsdbNextDataBlock((void*) pSecQueryHandle)) {
|
|
||||||
tsdbCleanupQueryHandle(pSecQueryHandle);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
tsdbRetrieveDataBlockInfo((void*) pSecQueryHandle, &blockInfo);
|
|
||||||
tsdbRetrieveDataBlock((void*) pSecQueryHandle, pSecQueryHandle->defaultLoadColumn);
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
|
||||||
SColumnInfoData* pCol = taosArrayGet(pQueryHandle->pColumns, i);
|
|
||||||
memcpy((char*)pCol->pData, (char*)pCol->pData + pCol->info.bytes * (pQueryHandle->cur.rows - 1), pCol->info.bytes);
|
|
||||||
|
|
||||||
SColumnInfoData* pCol1 = taosArrayGet(pSecQueryHandle->pColumns, i);
|
|
||||||
assert(pCol->info.colId == pCol1->info.colId);
|
|
||||||
|
|
||||||
memcpy((char*)pCol->pData + pCol->info.bytes, pCol1->pData, pCol1->info.bytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
SColumnInfoData* pTSCol = taosArrayGet(pQueryHandle->pColumns, 0);
|
|
||||||
|
|
||||||
// it is ascending order
|
|
||||||
pQueryHandle->cur.win = (STimeWindow){((TSKEY*)pTSCol->pData)[0], ((TSKEY*)pTSCol->pData)[1]};
|
|
||||||
pQueryHandle->window = pQueryHandle->cur.win;
|
|
||||||
pQueryHandle->cur.rows = 2;
|
|
||||||
pQueryHandle->cur.mixBlock = true;
|
|
||||||
pQueryHandle->order = TSDB_ORDER_DESC;
|
|
||||||
|
|
||||||
int32_t step = -1;// one step for ascending order traverse
|
|
||||||
for (int32_t j = 0; j < si; ++j) {
|
|
||||||
STableCheckInfo* pCheckInfo = (STableCheckInfo*) taosArrayGet(pQueryHandle->pTableCheckInfo, j);
|
|
||||||
pCheckInfo->lastKey = pQueryHandle->cur.win.ekey + step;
|
|
||||||
}
|
|
||||||
|
|
||||||
tsdbCleanupQueryHandle(pSecQueryHandle);
|
|
||||||
}
|
|
||||||
|
|
||||||
//disable it after retrieve data
|
|
||||||
pQueryHandle->type = TSDB_QUERY_TYPE_EXTERNAL;
|
|
||||||
pQueryHandle->checkFiles = false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pQueryHandle->checkFiles) {
|
|
||||||
bool exists = true;
|
|
||||||
|
|
||||||
int32_t code = getDataBlocksInFiles(pQueryHandle, &exists);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
pQueryHandle->activeIndex = 0;
|
|
||||||
pQueryHandle->checkFiles = false;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (exists) {
|
|
||||||
pQueryHandle->cost.checkForNextTime += (taosGetTimestampUs() - stime);
|
|
||||||
return exists;
|
|
||||||
}
|
|
||||||
|
|
||||||
pQueryHandle->activeIndex = 0;
|
|
||||||
pQueryHandle->checkFiles = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: opt by consider the scan order
|
|
||||||
bool ret = doHasDataInBuffer(pQueryHandle);
|
|
||||||
terrno = TSDB_CODE_SUCCESS;
|
|
||||||
|
|
||||||
elapsedTime = taosGetTimestampUs() - stime;
|
|
||||||
pQueryHandle->cost.checkForNextTime += elapsedTime;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
void changeQueryHandleForLastrowQuery(TsdbQueryHandleT pqHandle) {
|
|
||||||
STsdbQueryHandle* pQueryHandle = (STsdbQueryHandle*) pqHandle;
|
|
||||||
assert(!ASCENDING_TRAVERSE(pQueryHandle->order));
|
|
||||||
|
|
||||||
// starts from the buffer in case of descending timestamp order check data blocks
|
|
||||||
|
|
||||||
// todo consider the query time window, current last_row does not apply the query time window
|
|
||||||
size_t numOfTables = taosArrayGetSize(pQueryHandle->pTableCheckInfo);
|
|
||||||
|
|
||||||
TSKEY key = TSKEY_INITIAL_VAL;
|
|
||||||
int32_t index = -1;
|
|
||||||
|
|
||||||
for(int32_t i = 0; i < numOfTables; ++i) {
|
|
||||||
STableCheckInfo* pCheckInfo = taosArrayGet(pQueryHandle->pTableCheckInfo, i);
|
|
||||||
if (pCheckInfo->pTableObj->lastKey > key) {
|
|
||||||
key = pCheckInfo->pTableObj->lastKey;
|
|
||||||
index = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (index == -1) {
|
|
||||||
// todo add failure test cases
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// erase all other elements in array list
|
|
||||||
size_t size = taosArrayGetSize(pQueryHandle->pTableCheckInfo);
|
|
||||||
for (int32_t i = 0; i < size; ++i) {
|
|
||||||
if (i == index) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
STableCheckInfo* pTableCheckInfo = taosArrayGet(pQueryHandle->pTableCheckInfo, i);
|
|
||||||
tSkipListDestroyIter(pTableCheckInfo->iter);
|
|
||||||
|
|
||||||
if (pTableCheckInfo->pDataCols != NULL) {
|
|
||||||
taosTFree(pTableCheckInfo->pDataCols->buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
taosTFree(pTableCheckInfo->pDataCols);
|
|
||||||
taosTFree(pTableCheckInfo->pCompInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
STableCheckInfo info = *(STableCheckInfo*) taosArrayGet(pQueryHandle->pTableCheckInfo, index);
|
|
||||||
taosArrayClear(pQueryHandle->pTableCheckInfo);
|
|
||||||
|
|
||||||
info.lastKey = key;
|
|
||||||
taosArrayPush(pQueryHandle->pTableCheckInfo, &info);
|
|
||||||
|
|
||||||
// update the query time window according to the chosen last timestamp
|
|
||||||
pQueryHandle->window = (STimeWindow) {key, key};
|
|
||||||
}
|
|
||||||
|
|
||||||
static void changeQueryHandleForInterpQuery(TsdbQueryHandleT pHandle) {
|
static void changeQueryHandleForInterpQuery(TsdbQueryHandleT pHandle) {
|
||||||
// filter the queried time stamp in the first place
|
// filter the queried time stamp in the first place
|
||||||
STsdbQueryHandle* pQueryHandle = (STsdbQueryHandle*) pHandle;
|
STsdbQueryHandle* pQueryHandle = (STsdbQueryHandle*) pHandle;
|
||||||
|
@ -1968,6 +1767,261 @@ static int tsdbReadRowsFromCache(STableCheckInfo* pCheckInfo, TSKEY maxKey, int
|
||||||
return numOfRows;
|
return numOfRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t getAllTableList(STable* pSuperTable, SArray* list) {
|
||||||
|
SSkipListIterator* iter = tSkipListCreateIter(pSuperTable->pIndex);
|
||||||
|
while (tSkipListIterNext(iter)) {
|
||||||
|
SSkipListNode* pNode = tSkipListIterGet(iter);
|
||||||
|
|
||||||
|
STable** pTable = (STable**) SL_GET_NODE_DATA((SSkipListNode*) pNode);
|
||||||
|
|
||||||
|
STableKeyInfo info = {.pTable = *pTable, .lastKey = TSKEY_INITIAL_VAL};
|
||||||
|
taosArrayPush(list, &info);
|
||||||
|
}
|
||||||
|
|
||||||
|
tSkipListDestroyIter(iter);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void destroyHelper(void* param) {
|
||||||
|
if (param == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
tQueryInfo* pInfo = (tQueryInfo*)param;
|
||||||
|
if (pInfo->optr != TSDB_RELATION_IN) {
|
||||||
|
taosTFree(pInfo->q);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(param);
|
||||||
|
}
|
||||||
|
|
||||||
|
// handle data in cache situation
|
||||||
|
bool tsdbNextDataBlock(TsdbQueryHandleT* pHandle) {
|
||||||
|
STsdbQueryHandle* pQueryHandle = (STsdbQueryHandle*) pHandle;
|
||||||
|
|
||||||
|
int64_t stime = taosGetTimestampUs();
|
||||||
|
int64_t elapsedTime = stime;
|
||||||
|
|
||||||
|
size_t numOfTables = taosArrayGetSize(pQueryHandle->pTableCheckInfo);
|
||||||
|
assert(numOfTables > 0);
|
||||||
|
|
||||||
|
SDataBlockInfo blockInfo = {{0}, 0};
|
||||||
|
if (pQueryHandle->type == TSDB_QUERY_TYPE_EXTERNAL) {
|
||||||
|
pQueryHandle->type = TSDB_QUERY_TYPE_ALL;
|
||||||
|
pQueryHandle->order = TSDB_ORDER_DESC;
|
||||||
|
|
||||||
|
if (!tsdbNextDataBlock(pHandle)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
tsdbRetrieveDataBlockInfo(pHandle, &blockInfo);
|
||||||
|
/*SArray *pDataBlock = */tsdbRetrieveDataBlock(pHandle, pQueryHandle->defaultLoadColumn);
|
||||||
|
if (terrno != TSDB_CODE_SUCCESS) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pQueryHandle->cur.win.ekey == pQueryHandle->window.skey) {
|
||||||
|
// data already retrieve, discard other data rows and return
|
||||||
|
int32_t numOfCols = (int32_t)(QH_GET_NUM_OF_COLS(pQueryHandle));
|
||||||
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
|
SColumnInfoData* pCol = taosArrayGet(pQueryHandle->pColumns, i);
|
||||||
|
memcpy((char*)pCol->pData, (char*)pCol->pData + pCol->info.bytes * (pQueryHandle->cur.rows - 1), pCol->info.bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
pQueryHandle->cur.win = (STimeWindow){pQueryHandle->window.skey, pQueryHandle->window.skey};
|
||||||
|
pQueryHandle->window = pQueryHandle->cur.win;
|
||||||
|
pQueryHandle->cur.rows = 1;
|
||||||
|
pQueryHandle->type = TSDB_QUERY_TYPE_ALL;
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
STsdbQueryHandle* pSecQueryHandle = calloc(1, sizeof(STsdbQueryHandle));
|
||||||
|
if (pSecQueryHandle == NULL) {
|
||||||
|
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
pSecQueryHandle->order = TSDB_ORDER_ASC;
|
||||||
|
pSecQueryHandle->window = (STimeWindow) {pQueryHandle->window.skey, INT64_MAX};
|
||||||
|
pSecQueryHandle->pTsdb = pQueryHandle->pTsdb;
|
||||||
|
pSecQueryHandle->type = TSDB_QUERY_TYPE_ALL;
|
||||||
|
pSecQueryHandle->cur.fid = -1;
|
||||||
|
pSecQueryHandle->cur.win = TSWINDOW_INITIALIZER;
|
||||||
|
pSecQueryHandle->checkFiles = true;
|
||||||
|
pSecQueryHandle->activeIndex = 0;
|
||||||
|
pSecQueryHandle->outputCapacity = ((STsdbRepo*)pSecQueryHandle->pTsdb)->config.maxRowsPerFileBlock;
|
||||||
|
|
||||||
|
if (tsdbInitReadHelper(&pSecQueryHandle->rhelper, (STsdbRepo*) pSecQueryHandle->pTsdb) != 0) {
|
||||||
|
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
|
||||||
|
free(pSecQueryHandle);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
tsdbTakeMemSnapshot(pSecQueryHandle->pTsdb, &pSecQueryHandle->mem, &pSecQueryHandle->imem);
|
||||||
|
|
||||||
|
// allocate buffer in order to load data blocks from file
|
||||||
|
int32_t numOfCols = (int32_t)(QH_GET_NUM_OF_COLS(pQueryHandle));
|
||||||
|
|
||||||
|
pSecQueryHandle->statis = calloc(numOfCols, sizeof(SDataStatis));
|
||||||
|
pSecQueryHandle->pColumns = taosArrayInit(numOfCols, sizeof(SColumnInfoData));
|
||||||
|
if (pSecQueryHandle->statis == NULL || pSecQueryHandle->pColumns == NULL) {
|
||||||
|
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
|
||||||
|
tsdbCleanupQueryHandle(pSecQueryHandle);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
|
SColumnInfoData colInfo = {{0}, 0};
|
||||||
|
SColumnInfoData* pCol = taosArrayGet(pQueryHandle->pColumns, i);
|
||||||
|
|
||||||
|
colInfo.info = pCol->info;
|
||||||
|
colInfo.pData = calloc(1, EXTRA_BYTES + pQueryHandle->outputCapacity * pCol->info.bytes);
|
||||||
|
if (colInfo.pData == NULL) {
|
||||||
|
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
|
||||||
|
tsdbCleanupQueryHandle(pSecQueryHandle);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
taosArrayPush(pSecQueryHandle->pColumns, &colInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t si = taosArrayGetSize(pQueryHandle->pTableCheckInfo);
|
||||||
|
pSecQueryHandle->pTableCheckInfo = taosArrayInit(si, sizeof(STableCheckInfo));
|
||||||
|
STsdbMeta* pMeta = tsdbGetMeta(pQueryHandle->pTsdb);
|
||||||
|
assert(pMeta != NULL);
|
||||||
|
|
||||||
|
for (int32_t j = 0; j < si; ++j) {
|
||||||
|
STableCheckInfo* pCheckInfo = (STableCheckInfo*) taosArrayGet(pQueryHandle->pTableCheckInfo, j);
|
||||||
|
STableCheckInfo info = {
|
||||||
|
.lastKey = pSecQueryHandle->window.skey,
|
||||||
|
.pTableObj = pCheckInfo->pTableObj,
|
||||||
|
};
|
||||||
|
|
||||||
|
info.tableId = pCheckInfo->tableId;
|
||||||
|
|
||||||
|
taosArrayPush(pSecQueryHandle->pTableCheckInfo, &info);
|
||||||
|
}
|
||||||
|
|
||||||
|
tsdbInitDataBlockLoadInfo(&pSecQueryHandle->dataBlockLoadInfo);
|
||||||
|
tsdbInitCompBlockLoadInfo(&pSecQueryHandle->compBlockLoadInfo);
|
||||||
|
pSecQueryHandle->defaultLoadColumn = taosArrayClone(pQueryHandle->defaultLoadColumn);
|
||||||
|
|
||||||
|
if (!tsdbNextDataBlock((void*) pSecQueryHandle)) {
|
||||||
|
tsdbCleanupQueryHandle(pSecQueryHandle);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
tsdbRetrieveDataBlockInfo((void*) pSecQueryHandle, &blockInfo);
|
||||||
|
tsdbRetrieveDataBlock((void*) pSecQueryHandle, pSecQueryHandle->defaultLoadColumn);
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
|
SColumnInfoData* pCol = taosArrayGet(pQueryHandle->pColumns, i);
|
||||||
|
memcpy((char*)pCol->pData, (char*)pCol->pData + pCol->info.bytes * (pQueryHandle->cur.rows - 1), pCol->info.bytes);
|
||||||
|
|
||||||
|
SColumnInfoData* pCol1 = taosArrayGet(pSecQueryHandle->pColumns, i);
|
||||||
|
assert(pCol->info.colId == pCol1->info.colId);
|
||||||
|
|
||||||
|
memcpy((char*)pCol->pData + pCol->info.bytes, pCol1->pData, pCol1->info.bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
SColumnInfoData* pTSCol = taosArrayGet(pQueryHandle->pColumns, 0);
|
||||||
|
|
||||||
|
// it is ascending order
|
||||||
|
pQueryHandle->cur.win = (STimeWindow){((TSKEY*)pTSCol->pData)[0], ((TSKEY*)pTSCol->pData)[1]};
|
||||||
|
pQueryHandle->window = pQueryHandle->cur.win;
|
||||||
|
pQueryHandle->cur.rows = 2;
|
||||||
|
pQueryHandle->cur.mixBlock = true;
|
||||||
|
pQueryHandle->order = TSDB_ORDER_DESC;
|
||||||
|
|
||||||
|
int32_t step = -1;// one step for ascending order traverse
|
||||||
|
for (int32_t j = 0; j < si; ++j) {
|
||||||
|
STableCheckInfo* pCheckInfo = (STableCheckInfo*) taosArrayGet(pQueryHandle->pTableCheckInfo, j);
|
||||||
|
pCheckInfo->lastKey = pQueryHandle->cur.win.ekey + step;
|
||||||
|
}
|
||||||
|
|
||||||
|
tsdbCleanupQueryHandle(pSecQueryHandle);
|
||||||
|
}
|
||||||
|
|
||||||
|
//disable it after retrieve data
|
||||||
|
pQueryHandle->type = TSDB_QUERY_TYPE_EXTERNAL;
|
||||||
|
pQueryHandle->checkFiles = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pQueryHandle->checkFiles) {
|
||||||
|
// check if the query range overlaps with the file data block
|
||||||
|
bool exists = true;
|
||||||
|
|
||||||
|
int32_t code = getDataBlocksInFiles(pQueryHandle, &exists);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
pQueryHandle->activeIndex = 0;
|
||||||
|
pQueryHandle->checkFiles = false;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (exists) {
|
||||||
|
pQueryHandle->cost.checkForNextTime += (taosGetTimestampUs() - stime);
|
||||||
|
return exists;
|
||||||
|
}
|
||||||
|
|
||||||
|
pQueryHandle->activeIndex = 0;
|
||||||
|
pQueryHandle->checkFiles = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: opt by consider the scan order
|
||||||
|
bool ret = doHasDataInBuffer(pQueryHandle);
|
||||||
|
terrno = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
|
elapsedTime = taosGetTimestampUs() - stime;
|
||||||
|
pQueryHandle->cost.checkForNextTime += elapsedTime;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
STimeWindow changeTableGroupByLastrow(STableGroupInfo *groupList) {
|
||||||
|
STimeWindow window = {INT64_MAX, INT64_MIN};
|
||||||
|
|
||||||
|
// NOTE: starts from the buffer in case of descending timestamp order check data blocks
|
||||||
|
// todo consider the query time window, current last_row does not apply the query time window
|
||||||
|
size_t numOfGroups = taosArrayGetSize(groupList->pGroupList);
|
||||||
|
for(int32_t j = 0; j < numOfGroups; ++j) {
|
||||||
|
SArray* pGroup = taosArrayGetP(groupList->pGroupList, j);
|
||||||
|
TSKEY key = TSKEY_INITIAL_VAL;
|
||||||
|
|
||||||
|
STableKeyInfo keyInfo = {0};
|
||||||
|
|
||||||
|
size_t numOfTables = taosArrayGetSize(pGroup);
|
||||||
|
for(int32_t i = 0; i < numOfTables; ++i) {
|
||||||
|
STableKeyInfo* pKeyInfo = (STableKeyInfo*) taosArrayGet(pGroup, i);
|
||||||
|
TSKEY lastKey = ((STable*)(pKeyInfo->pTable))->lastKey;
|
||||||
|
|
||||||
|
if (key < lastKey) {
|
||||||
|
key = lastKey;
|
||||||
|
|
||||||
|
keyInfo.pTable = pKeyInfo->pTable;
|
||||||
|
keyInfo.lastKey = key;
|
||||||
|
pKeyInfo->lastKey = key;
|
||||||
|
|
||||||
|
if (key < window.skey) {
|
||||||
|
window.skey = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (key > window.ekey) {
|
||||||
|
window.ekey = key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// more than one table in each group, only one table left for each group
|
||||||
|
if (numOfTables > 1) {
|
||||||
|
taosArrayClear(pGroup);
|
||||||
|
taosArrayPush(pGroup, &keyInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return window;
|
||||||
|
}
|
||||||
|
|
||||||
void tsdbRetrieveDataBlockInfo(TsdbQueryHandleT* pQueryHandle, SDataBlockInfo* pDataBlockInfo) {
|
void tsdbRetrieveDataBlockInfo(TsdbQueryHandleT* pQueryHandle, SDataBlockInfo* pDataBlockInfo) {
|
||||||
STsdbQueryHandle* pHandle = (STsdbQueryHandle*)pQueryHandle;
|
STsdbQueryHandle* pHandle = (STsdbQueryHandle*)pQueryHandle;
|
||||||
SQueryFilePos* cur = &pHandle->cur;
|
SQueryFilePos* cur = &pHandle->cur;
|
||||||
|
@ -2102,36 +2156,6 @@ SArray* tsdbRetrieveDataBlock(TsdbQueryHandleT* pQueryHandle, SArray* pIdList) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t getAllTableList(STable* pSuperTable, SArray* list) {
|
|
||||||
SSkipListIterator* iter = tSkipListCreateIter(pSuperTable->pIndex);
|
|
||||||
while (tSkipListIterNext(iter)) {
|
|
||||||
SSkipListNode* pNode = tSkipListIterGet(iter);
|
|
||||||
|
|
||||||
STable** pTable = (STable**) SL_GET_NODE_DATA((SSkipListNode*) pNode);
|
|
||||||
|
|
||||||
STableKeyInfo info = {.pTable = *pTable, .lastKey = TSKEY_INITIAL_VAL};
|
|
||||||
taosArrayPush(list, &info);
|
|
||||||
}
|
|
||||||
|
|
||||||
tSkipListDestroyIter(iter);
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void destroyHelper(void* param) {
|
|
||||||
if (param == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
tQueryInfo* pInfo = (tQueryInfo*)param;
|
|
||||||
if (pInfo->optr != TSDB_RELATION_IN) {
|
|
||||||
taosTFree(pInfo->q);
|
|
||||||
}
|
|
||||||
|
|
||||||
// tVariantDestroy(&(pInfo->q));
|
|
||||||
free(param);
|
|
||||||
}
|
|
||||||
|
|
||||||
void filterPrepare(void* expr, void* param) {
|
void filterPrepare(void* expr, void* param) {
|
||||||
tExprNode* pExpr = (tExprNode*)expr;
|
tExprNode* pExpr = (tExprNode*)expr;
|
||||||
if (pExpr->_node.info != NULL) {
|
if (pExpr->_node.info != NULL) {
|
||||||
|
@ -2158,13 +2182,7 @@ void filterPrepare(void* expr, void* param) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct STableGroupSupporter {
|
static int32_t tableGroupComparFn(const void *p1, const void *p2, const void *param) {
|
||||||
int32_t numOfCols;
|
|
||||||
SColIndex* pCols;
|
|
||||||
STSchema* pTagSchema;
|
|
||||||
} STableGroupSupporter;
|
|
||||||
|
|
||||||
int32_t tableGroupComparFn(const void *p1, const void *p2, const void *param) {
|
|
||||||
STableGroupSupporter* pTableGroupSupp = (STableGroupSupporter*) param;
|
STableGroupSupporter* pTableGroupSupp = (STableGroupSupporter*) param;
|
||||||
STable* pTable1 = ((STableKeyInfo*) p1)->pTable;
|
STable* pTable1 = ((STableKeyInfo*) p1)->pTable;
|
||||||
STable* pTable2 = ((STableKeyInfo*) p2)->pTable;
|
STable* pTable2 = ((STableKeyInfo*) p2)->pTable;
|
||||||
|
@ -2217,8 +2235,19 @@ int32_t tableGroupComparFn(const void *p1, const void *p2, const void *param) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void createTableGroupImpl(SArray* pGroups, SArray* pTableList, size_t numOfTables, TSKEY skey, STableGroupSupporter* pSupp,
|
static int tsdbCheckInfoCompar(const void* key1, const void* key2) {
|
||||||
__ext_compar_fn_t compareFn) {
|
if (((STableCheckInfo*)key1)->tableId.tid < ((STableCheckInfo*)key2)->tableId.tid) {
|
||||||
|
return -1;
|
||||||
|
} else if (((STableCheckInfo*)key1)->tableId.tid > ((STableCheckInfo*)key2)->tableId.tid) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
ASSERT(false);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void createTableGroupImpl(SArray* pGroups, SArray* pTableList, size_t numOfTables, TSKEY skey,
|
||||||
|
STableGroupSupporter* pSupp, __ext_compar_fn_t compareFn) {
|
||||||
STable* pTable = taosArrayGetP(pTableList, 0);
|
STable* pTable = taosArrayGetP(pTableList, 0);
|
||||||
|
|
||||||
SArray* g = taosArrayInit(16, sizeof(STableKeyInfo));
|
SArray* g = taosArrayInit(16, sizeof(STableKeyInfo));
|
||||||
|
@ -2264,6 +2293,10 @@ SArray* createTableGroup(SArray* pTableList, STSchema* pTagSchema, SColIndex* pC
|
||||||
|
|
||||||
if (numOfOrderCols == 0 || size == 1) { // no group by tags clause or only one table
|
if (numOfOrderCols == 0 || size == 1) { // no group by tags clause or only one table
|
||||||
SArray* sa = taosArrayInit(size, sizeof(STableKeyInfo));
|
SArray* sa = taosArrayInit(size, sizeof(STableKeyInfo));
|
||||||
|
if (sa == NULL) {
|
||||||
|
taosArrayDestroy(pTableGroup);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
for(int32_t i = 0; i < size; ++i) {
|
for(int32_t i = 0; i < size; ++i) {
|
||||||
STableKeyInfo *pKeyInfo = taosArrayGet(pTableList, i);
|
STableKeyInfo *pKeyInfo = taosArrayGet(pTableList, i);
|
||||||
|
@ -2278,20 +2311,19 @@ SArray* createTableGroup(SArray* pTableList, STSchema* pTagSchema, SColIndex* pC
|
||||||
taosArrayPush(pTableGroup, &sa);
|
taosArrayPush(pTableGroup, &sa);
|
||||||
tsdbDebug("all %" PRIzu " tables belong to one group", size);
|
tsdbDebug("all %" PRIzu " tables belong to one group", size);
|
||||||
} else {
|
} else {
|
||||||
STableGroupSupporter *pSupp = (STableGroupSupporter *) calloc(1, sizeof(STableGroupSupporter));
|
STableGroupSupporter sup = {0};
|
||||||
pSupp->numOfCols = numOfOrderCols;
|
sup.numOfCols = numOfOrderCols;
|
||||||
pSupp->pTagSchema = pTagSchema;
|
sup.pTagSchema = pTagSchema;
|
||||||
pSupp->pCols = pCols;
|
sup.pCols = pCols;
|
||||||
|
|
||||||
taosqsort(pTableList->pData, size, sizeof(STableKeyInfo), pSupp, tableGroupComparFn);
|
taosqsort(pTableList->pData, size, sizeof(STableKeyInfo), &sup, tableGroupComparFn);
|
||||||
createTableGroupImpl(pTableGroup, pTableList, size, skey, pSupp, tableGroupComparFn);
|
createTableGroupImpl(pTableGroup, pTableList, size, skey, &sup, tableGroupComparFn);
|
||||||
taosTFree(pSupp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return pTableGroup;
|
return pTableGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool indexedNodeFilterFp(const void* pNode, void* param) {
|
static bool indexedNodeFilterFp(const void* pNode, void* param) {
|
||||||
tQueryInfo* pInfo = (tQueryInfo*) param;
|
tQueryInfo* pInfo = (tQueryInfo*) param;
|
||||||
|
|
||||||
STable* pTable = *(STable**)(SL_GET_NODE_DATA((SSkipListNode*)pNode));
|
STable* pTable = *(STable**)(SL_GET_NODE_DATA((SSkipListNode*)pNode));
|
||||||
|
@ -2562,7 +2594,7 @@ void tsdbCleanupQueryHandle(TsdbQueryHandleT queryHandle) {
|
||||||
tsdbDestroyHelper(&pQueryHandle->rhelper);
|
tsdbDestroyHelper(&pQueryHandle->rhelper);
|
||||||
|
|
||||||
SIOCostSummary* pCost = &pQueryHandle->cost;
|
SIOCostSummary* pCost = &pQueryHandle->cost;
|
||||||
tsdbDebug("%p :io-cost summary: statis-info:%"PRId64"us, datablock:%" PRId64"us, check data:%"PRId64"us, %p",
|
tsdbDebug("%p :io-cost summary: statis-info:%"PRId64" us, datablock:%" PRId64" us, check data:%"PRId64" us, %p",
|
||||||
pQueryHandle, pCost->statisInfoLoadTime, pCost->blockLoadTime, pCost->checkForNextTime, pQueryHandle->qinfo);
|
pQueryHandle, pCost->statisInfoLoadTime, pCost->blockLoadTime, pCost->checkForNextTime, pQueryHandle->qinfo);
|
||||||
|
|
||||||
taosTFree(pQueryHandle);
|
taosTFree(pQueryHandle);
|
||||||
|
@ -2589,14 +2621,3 @@ void tsdbDestroyTableGroup(STableGroupInfo *pGroupList) {
|
||||||
|
|
||||||
taosArrayDestroy(pGroupList->pGroupList);
|
taosArrayDestroy(pGroupList->pGroupList);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tsdbCheckInfoCompar(const void* key1, const void* key2) {
|
|
||||||
if (((STableCheckInfo*)key1)->tableId.tid < ((STableCheckInfo*)key2)->tableId.tid) {
|
|
||||||
return -1;
|
|
||||||
} else if (((STableCheckInfo*)key1)->tableId.tid > ((STableCheckInfo*)key2)->tableId.tid) {
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
ASSERT(false);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -103,7 +103,7 @@ SCacheObj *taosCacheInit(int32_t keyType, int64_t refreshTimeInSeconds, bool ext
|
||||||
* @param keepTime survival time in second
|
* @param keepTime survival time in second
|
||||||
* @return cached element
|
* @return cached element
|
||||||
*/
|
*/
|
||||||
void *taosCachePut(SCacheObj *pCacheObj, const void *key, size_t keyLen, const void *pData, size_t dataSize, int keepTimeInSeconds);
|
void *taosCachePut(SCacheObj *pCacheObj, const void *key, size_t keyLen, const void *pData, size_t dataSize, int durationMS);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get data from cache
|
* get data from cache
|
||||||
|
@ -113,16 +113,6 @@ void *taosCachePut(SCacheObj *pCacheObj, const void *key, size_t keyLen, const v
|
||||||
*/
|
*/
|
||||||
void *taosCacheAcquireByKey(SCacheObj *pCacheObj, const void *key, size_t keyLen);
|
void *taosCacheAcquireByKey(SCacheObj *pCacheObj, const void *key, size_t keyLen);
|
||||||
|
|
||||||
/**
|
|
||||||
* update the expire time of data in cache
|
|
||||||
* @param pCacheObj cache object
|
|
||||||
* @param key key
|
|
||||||
* @param keyLen keyLen
|
|
||||||
* @param expireTime new expire time of data
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
//void* taosCacheUpdateExpireTimeByName(SCacheObj *pCacheObj, void *key, size_t keyLen, uint64_t expireTime);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add one reference count for the exist data, and assign this data for a new owner.
|
* Add one reference count for the exist data, and assign this data for a new owner.
|
||||||
* The new owner needs to invoke the taosCacheRelease when it does not need this data anymore.
|
* The new owner needs to invoke the taosCacheRelease when it does not need this data anymore.
|
||||||
|
|
|
@ -36,6 +36,14 @@ typedef void (*_ref_fn_t)(const void* pObj);
|
||||||
_ref_fn_t end; \
|
_ref_fn_t end; \
|
||||||
} _ref_func = {.begin = (s), .end = (e)};
|
} _ref_func = {.begin = (s), .end = (e)};
|
||||||
|
|
||||||
|
// set the initial reference count value
|
||||||
|
#define T_REF_INIT_VAL(x, _v) \
|
||||||
|
do { \
|
||||||
|
assert(_v >= 0); \
|
||||||
|
atomic_store_32(&((x)->_ref.val), (_v)); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
// increase the reference count by 1
|
||||||
#define T_REF_INC(x) (atomic_add_fetch_32(&((x)->_ref.val), 1))
|
#define T_REF_INC(x) (atomic_add_fetch_32(&((x)->_ref.val), 1))
|
||||||
|
|
||||||
#define T_REF_INC_WITH_CB(x, p) \
|
#define T_REF_INC_WITH_CB(x, p) \
|
||||||
|
|
|
@ -28,11 +28,11 @@ extern "C" {
|
||||||
#define TSQL_TBNAME_L "tbname"
|
#define TSQL_TBNAME_L "tbname"
|
||||||
|
|
||||||
// used to denote the minimum unite in sql parsing
|
// used to denote the minimum unite in sql parsing
|
||||||
typedef struct SSQLToken {
|
typedef struct SStrToken {
|
||||||
uint32_t n;
|
uint32_t n;
|
||||||
uint32_t type;
|
uint32_t type;
|
||||||
char * z;
|
char * z;
|
||||||
} SSQLToken;
|
} SStrToken;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* tokenizer for sql string
|
* tokenizer for sql string
|
||||||
|
@ -52,7 +52,7 @@ uint32_t tSQLGetToken(char *z, uint32_t *tokenType);
|
||||||
* @param ignoreTokenTypes
|
* @param ignoreTokenTypes
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
SSQLToken tStrGetToken(char *str, int32_t *i, bool isPrevOptr, uint32_t numOfIgnoreToken, uint32_t *ignoreTokenTypes);
|
SStrToken tStrGetToken(char *str, int32_t *i, bool isPrevOptr, uint32_t numOfIgnoreToken, uint32_t *ignoreTokenTypes);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* check if it is a keyword or not
|
* check if it is a keyword or not
|
||||||
|
@ -76,7 +76,7 @@ bool isKeyWord(const char *z, int32_t len);
|
||||||
* @param pToken
|
* @param pToken
|
||||||
* @return token type, if it is not a number, TK_ILLEGAL will return
|
* @return token type, if it is not a number, TK_ILLEGAL will return
|
||||||
*/
|
*/
|
||||||
static FORCE_INLINE int32_t isValidNumber(const SSQLToken* pToken) {
|
static FORCE_INLINE int32_t isValidNumber(const SStrToken* pToken) {
|
||||||
const char* z = pToken->z;
|
const char* z = pToken->z;
|
||||||
int32_t type = TK_ILLEGAL;
|
int32_t type = TK_ILLEGAL;
|
||||||
|
|
||||||
|
|
|
@ -657,7 +657,7 @@ void taosHashTableResize(SHashObj *pHashObj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t st = taosGetTimestampUs();
|
int64_t st = taosGetTimestampUs();
|
||||||
void *pNewEntryList = realloc(pHashObj->hashList, sizeof(void*) * newSize);
|
void *pNewEntryList = realloc(pHashObj->hashList, sizeof(void *) * newSize);
|
||||||
if (pNewEntryList == NULL) { // todo handle error
|
if (pNewEntryList == NULL) { // todo handle error
|
||||||
// uDebug("cache resize failed due to out of memory, capacity remain:%d", pHashObj->capacity);
|
// uDebug("cache resize failed due to out of memory, capacity remain:%d", pHashObj->capacity);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -189,12 +189,12 @@ SCacheObj *taosCacheInit(int32_t keyType, int64_t refreshTimeInSeconds, bool ext
|
||||||
return pCacheObj;
|
return pCacheObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *taosCachePut(SCacheObj *pCacheObj, const void *key, size_t keyLen, const void *pData, size_t dataSize, int duration) {
|
void *taosCachePut(SCacheObj *pCacheObj, const void *key, size_t keyLen, const void *pData, size_t dataSize, int durationMS) {
|
||||||
if (pCacheObj == NULL || pCacheObj->pHashTable == NULL || pCacheObj->deleting == 1) {
|
if (pCacheObj == NULL || pCacheObj->pHashTable == NULL || pCacheObj->deleting == 1) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SCacheDataNode *pNode1 = taosCreateCacheNode(key, keyLen, pData, dataSize, duration);
|
SCacheDataNode *pNode1 = taosCreateCacheNode(key, keyLen, pData, dataSize, durationMS);
|
||||||
if (pNode1 == NULL) {
|
if (pNode1 == NULL) {
|
||||||
uError("cache:%s, key:%p, failed to added into cache, out of memory", pCacheObj->name, key);
|
uError("cache:%s, key:%p, failed to added into cache, out of memory", pCacheObj->name, key);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -221,7 +221,13 @@ static int32_t compareStrPatternComp(const void* pLeft, const void* pRight) {
|
||||||
memcpy(pattern, varDataVal(pRight), varDataLen(pRight));
|
memcpy(pattern, varDataVal(pRight), varDataLen(pRight));
|
||||||
assert(varDataLen(pRight) < 128);
|
assert(varDataLen(pRight) < 128);
|
||||||
|
|
||||||
int32_t ret = patternMatch(pattern, varDataVal(pLeft), varDataLen(pLeft), &pInfo);
|
size_t sz = varDataLen(pLeft);
|
||||||
|
char *buf = malloc(sz + 1);
|
||||||
|
memcpy(buf, varDataVal(pLeft), sz);
|
||||||
|
buf[sz] = 0;
|
||||||
|
|
||||||
|
int32_t ret = patternMatch(pattern, buf, sz, &pInfo);
|
||||||
|
free(buf);
|
||||||
return (ret == TSDB_PATTERN_MATCH) ? 0 : 1;
|
return (ret == TSDB_PATTERN_MATCH) ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -123,11 +123,6 @@ void *taosProcessSchedQueue(void *param) {
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (tsem_wait(&pSched->fullSem) != 0) {
|
if (tsem_wait(&pSched->fullSem) != 0) {
|
||||||
if (errno == EINTR) {
|
|
||||||
/* sem_wait is interrupted by interrupt, ignore and continue */
|
|
||||||
uDebug("wait %s fullSem was interrupted", pSched->label);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
uError("wait %s fullSem failed(%s)", pSched->label, strerror(errno));
|
uError("wait %s fullSem failed(%s)", pSched->label, strerror(errno));
|
||||||
}
|
}
|
||||||
if (pSched->stop) {
|
if (pSched->stop) {
|
||||||
|
@ -163,12 +158,8 @@ int taosScheduleTask(void *qhandle, SSchedMsg *pMsg) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (tsem_wait(&pSched->emptySem) != 0) {
|
if (tsem_wait(&pSched->emptySem) != 0) {
|
||||||
if (errno != EINTR) {
|
|
||||||
uError("wait %s emptySem failed(%s)", pSched->label, strerror(errno));
|
uError("wait %s emptySem failed(%s)", pSched->label, strerror(errno));
|
||||||
break;
|
|
||||||
}
|
|
||||||
uDebug("wait %s emptySem was interrupted", pSched->label);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_mutex_lock(&pSched->queueMutex) != 0)
|
if (pthread_mutex_lock(&pSched->queueMutex) != 0)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
char version[12] = "${TD_VER_1}.${TD_VER_2}.${TD_VER_3}.${TD_VER_4}";
|
char version[12] = "${TD_VER_NUMBER}";
|
||||||
char compatible_version[12] = "${TD_VER_COMPATIBLE}";
|
char compatible_version[12] = "${TD_VER_COMPATIBLE}";
|
||||||
char gitinfo[48] = "${TD_VER_GIT}";
|
char gitinfo[48] = "${TD_VER_GIT}";
|
||||||
char gitinfoOfInternal[48] = "${TD_VER_GIT_INTERNAL}";
|
char gitinfoOfInternal[48] = "${TD_VER_GIT_INTERNAL}";
|
||||||
char buildinfo[64] = "Built at ${TD_VER_DATE}";
|
char buildinfo[64] = "Built at ${TD_VER_DATE}";
|
||||||
|
|
||||||
void libtaos_${TD_VER_1}_${TD_VER_2}_${TD_VER_3}_${TD_VER_4}_${TD_VER_OSTYPE}_${TD_VER_CPUTYPE}_${TD_VER_VERTYPE}() {};
|
void libtaos_${TD_LIB_VER_NUMBER}_${TD_VER_OSTYPE}_${TD_VER_CPUTYPE}_${TD_VER_VERTYPE}() {};
|
||||||
|
|
|
@ -297,6 +297,11 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pVnode->qMgmt = qOpenQueryMgmt(pVnode->vgId);
|
pVnode->qMgmt = qOpenQueryMgmt(pVnode->vgId);
|
||||||
|
if (pVnode->qMgmt == NULL) {
|
||||||
|
vnodeCleanUp(pVnode);
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
|
||||||
pVnode->events = NULL;
|
pVnode->events = NULL;
|
||||||
pVnode->status = TAOS_VN_STATUS_READY;
|
pVnode->status = TAOS_VN_STATUS_READY;
|
||||||
vDebug("vgId:%d, vnode is opened in %s, pVnode:%p", pVnode->vgId, rootDir, pVnode);
|
vDebug("vgId:%d, vnode is opened in %s, pVnode:%p", pVnode->vgId, rootDir, pVnode);
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
system sh/stop_dnodes.sh
|
|
||||||
|
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
|
||||||
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
|
||||||
|
|
||||||
system sh/cfg.sh -n dnode1 -c dDebugFlag -v 135
|
|
||||||
system sh/cfg.sh -n dnode1 -c mDebugFlag -v 135
|
|
||||||
system sh/cfg.sh -n dnode1 -c sdbDebugFlag -v 135
|
|
||||||
system sh/cfg.sh -n dnode1 -c rpcDebugFlag -v 135
|
|
||||||
system sh/cfg.sh -n dnode1 -c cDebugFlag -v 135
|
|
||||||
system sh/cfg.sh -n dnode1 -c monitorDebugflag -v 135
|
|
||||||
system sh/cfg.sh -n dnode1 -c httpDebugFlag -v 135
|
|
||||||
system sh/cfg.sh -n dnode1 -c uDebugFlag -v 135
|
|
||||||
|
|
||||||
system sh/cfg.sh -n dnode1 -c httpCacheSessions -v 10
|
|
||||||
system sh/cfg.sh -n dnode1 -c httpMaxThreads -v 10
|
|
||||||
system sh/cfg.sh -n dnode1 -c httpEnableCompress -v 0
|
|
||||||
|
|
||||||
system sh/cfg.sh -n dnode1 -c maxVnodeConnections -v 30000
|
|
||||||
system sh/cfg.sh -n dnode1 -c maxMgmtConnections -v 30000
|
|
||||||
system sh/cfg.sh -n dnode1 -c maxMeterConnections -v 30000
|
|
||||||
system sh/cfg.sh -n dnode1 -c maxShellConns -v 30000
|
|
||||||
|
|
||||||
system sh/exec.sh -n dnode1 -s start
|
|
||||||
sql connect
|
|
||||||
|
|
||||||
sql create database db;
|
|
||||||
sql use db;
|
|
||||||
sql create table t (ts timestamp, i int);
|
|
||||||
sql create table st1 (ts timestamp, f1 int) tags(t1 int);
|
|
||||||
sql create table st2 (ts timestamp, f2 int) tags(t2 int);
|
|
||||||
|
|
||||||
sql create table t1 using st1 tags(1);
|
|
||||||
sql create table t2 using st2 tags(1);
|
|
||||||
|
|
||||||
sql insert into t1 values(1575880055000, 1);
|
|
||||||
sql insert into t2 values(1575880055000, 2);
|
|
||||||
|
|
||||||
sql select st1.ts, st1.f1, st2.f2 from db.st1, db.st2 where st1.t1=st2.t2 and st1.ts=st2.ts
|
|
||||||
|
|
||||||
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'select st1.ts, st1.f1, st2.f2 from db.st1, db.st2 where st1.t1=st2.t2 and st1.ts=st2.ts' 127.0.0.1:7111/restful/sql
|
|
||||||
|
|
||||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
|
@ -0,0 +1,354 @@
|
||||||
|
system sh/stop_dnodes.sh
|
||||||
|
|
||||||
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
|
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||||
|
|
||||||
|
system sh/cfg.sh -n dnode1 -c dDebugFlag -v 135
|
||||||
|
system sh/cfg.sh -n dnode1 -c mDebugFlag -v 135
|
||||||
|
system sh/cfg.sh -n dnode1 -c sdbDebugFlag -v 135
|
||||||
|
system sh/cfg.sh -n dnode1 -c rpcDebugFlag -v 135
|
||||||
|
system sh/cfg.sh -n dnode1 -c cDebugFlag -v 135
|
||||||
|
system sh/cfg.sh -n dnode1 -c monitorDebugflag -v 135
|
||||||
|
system sh/cfg.sh -n dnode1 -c httpDebugFlag -v 135
|
||||||
|
system sh/cfg.sh -n dnode1 -c uDebugFlag -v 135
|
||||||
|
|
||||||
|
system sh/cfg.sh -n dnode1 -c httpCacheSessions -v 10
|
||||||
|
system sh/cfg.sh -n dnode1 -c httpMaxThreads -v 10
|
||||||
|
system sh/cfg.sh -n dnode1 -c httpEnableCompress -v 0
|
||||||
|
|
||||||
|
system sh/cfg.sh -n dnode1 -c maxVnodeConnections -v 30000
|
||||||
|
system sh/cfg.sh -n dnode1 -c maxMgmtConnections -v 30000
|
||||||
|
system sh/cfg.sh -n dnode1 -c maxMeterConnections -v 30000
|
||||||
|
system sh/cfg.sh -n dnode1 -c maxShellConns -v 30000
|
||||||
|
|
||||||
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
sql connect
|
||||||
|
|
||||||
|
sql create database db;
|
||||||
|
sql use db;
|
||||||
|
sql create table t (ts timestamp, i int);
|
||||||
|
sql create table st1 (ts timestamp, f1 int) tags(t1 int);
|
||||||
|
sql create table st2 (ts timestamp, f2 int) tags(t2 int);
|
||||||
|
|
||||||
|
sql create table t1 using st1 tags(1);
|
||||||
|
sql create table t2 using st2 tags(1);
|
||||||
|
|
||||||
|
sql insert into t1 values(1575880055000, 1);
|
||||||
|
sql insert into t1 values(1575880059000, 1);
|
||||||
|
sql insert into t1 values(1575880069000, 1);
|
||||||
|
|
||||||
|
sql insert into t2 values(1575880055000, 2);
|
||||||
|
|
||||||
|
sql select st1.ts, st1.f1, st2.f2 from db.st1, db.st2 where st1.t1=st2.t2 and st1.ts=st2.ts
|
||||||
|
|
||||||
|
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'select st1.ts, st1.f1, st2.f2 from db.st1, db.st2 where st1.t1=st2.t2 and st1.ts=st2.ts' 127.0.0.1:7111/restful/sql
|
||||||
|
|
||||||
|
print ==============select with user-defined columns
|
||||||
|
sql select 'abc' as f, ts,f1 from t1
|
||||||
|
if $rows != 3 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data00 != @abc@ then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data01 != @19-12-09 16:27:35.000@ then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data02 != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select 'abc', ts, f1 from t1
|
||||||
|
if $rows != 3 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data01 != @19-12-09 16:27:35.000@ then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data02 != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data10 != @abc@ then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select 'abc' from t1
|
||||||
|
if $rows != 3 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data00 != @abc@ then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select 'abc' as f1 from t1
|
||||||
|
if $rows != 3 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data00 != @abc@ then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select 1 from t1
|
||||||
|
if $rows != 3 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data00 != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data10 != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data20 != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select 1 as f1 from t1
|
||||||
|
if $rows != 3 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data00 != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select 1 as f, f1 from t1
|
||||||
|
if $rows != 3 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data00 != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data01 != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select 1.123 as f, f1 from t1
|
||||||
|
if $rows != 3 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data00 != 1.123000000 then
|
||||||
|
print expect 1.123000000 , actual:$data00
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data10 != 1.123000000 then
|
||||||
|
print expect 1.123000000 , actual:$data10
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select 1, f1 from t1
|
||||||
|
if $rows != 3 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data00 != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data01 != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data10 != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select 1.2391, f1 from t1
|
||||||
|
if $rows != 3 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data00 != 1.239100000 then
|
||||||
|
print expect 1.239100000 actual: $data00
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data10 != 1.239100000 then
|
||||||
|
print expect 1.239100000 actual: $data00
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data01 != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print ===================== user-defined columns with agg functions
|
||||||
|
sql select 1 as t, count(*) from t1
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data00 != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data01 != 3 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select 1, sum(f1) from t1
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data00 != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data01 != 3 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select 1,2,3, sum(f1)*99, 4,5,6,7,8,9,10 from t1
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data00 != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data01 != 2 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data02 != 3 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data03 != 297.000000000 then
|
||||||
|
print expect 297.000000000, actual:$data03
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select sum(f1)*avg(f1)+12, 1,2,3,4,5,6,7,8,9,10 from t1
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data00 != 15.000000000 then
|
||||||
|
print expect 15.000000000 actual:$data00
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data01 != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data02 != 2 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select 1.2987, f1, 'k' from t1 where f1=1
|
||||||
|
if $rows != 3 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data00 != 1.298700000 then
|
||||||
|
print expect 1.298700000 actual:$data00
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data01 != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data02 != @k@ then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print ====================user-defined columns with union
|
||||||
|
sql select f1, 'f1' from t1 union all select f1, 'f1' from t1;
|
||||||
|
if $rows != 6 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data00 != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data01 != @f1@ then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data10 != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data11 != @f1@ then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print =====================udc with join
|
||||||
|
sql select st1.ts, st1.f1, st2.f2, 'abc', 1.9827 from db.st1, db.st2 where st1.t1=st2.t2 and st1.ts=st2.ts
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data00 != @19-12-09 16:27:35.000@ then
|
||||||
|
print expect @19-12-09 16:27:35.000@ actual:$data00
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data01 != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data02 != 2 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data03 != @abc@ then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data04 != 1.982700000 then
|
||||||
|
print expect 1.982700000 actual:$data04
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print ======================udc with interval
|
||||||
|
sql select count(*), 'uuu' from t1 interval(1s) order by ts desc;
|
||||||
|
if $rows != 3 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print ======================udc with tags
|
||||||
|
sql select t1,'abc',tbname from st1
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data01 != @abc@ then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data02 != @t1@ then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print ======================udc with arithmetic
|
||||||
|
sql select 1+1 from t1
|
||||||
|
if $rows != 3 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql_error select from t1
|
||||||
|
sql_error select abc from t1
|
||||||
|
sql_error select abc as tu from t1
|
||||||
|
|
||||||
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
@ -133,12 +133,18 @@ endi
|
||||||
if $data74 != -4.000000000 then
|
if $data74 != -4.000000000 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
## fill(value) + group by
|
## fill(value) + group by
|
||||||
sql select max(c1), max(c2), max(c3), max(c4), max(c5) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, -1, -2, -3, -4, -5, -6, -7, -8) group by t1
|
sql select max(c1), max(c2), max(c3), max(c4), max(c5) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, -1, -2, -3, -4, -5, -6, -7, -8) group by t1
|
||||||
$val = $rowNum * 2
|
$val = $rowNum * 2
|
||||||
|
print $rowNum, $val
|
||||||
|
|
||||||
$val = $val - 1
|
$val = $val - 1
|
||||||
$val = $val * $tbNum
|
$val = $val * $tbNum
|
||||||
if $rows != $val then
|
print ==================== $val
|
||||||
|
|
||||||
|
if $rows != 190 then
|
||||||
|
print expect 190, actual:$rows
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
if $data06 != 0 then
|
if $data06 != 0 then
|
||||||
|
|
|
@ -330,7 +330,10 @@ sql_error select join_tb1.* from $tb1 , $tb2 where join_tb1.ts != join_tb0.ts an
|
||||||
sql_error select join_tb1.* from $tb1 , $tb1 where join_tb1.ts = join_tb1.ts and join_tb1.ts >= 100000;
|
sql_error select join_tb1.* from $tb1 , $tb1 where join_tb1.ts = join_tb1.ts and join_tb1.ts >= 100000;
|
||||||
sql_error select join_tb1.* from $tb1 , $tb1 where join_tb1.ts = join_tb1.ts order by ts;
|
sql_error select join_tb1.* from $tb1 , $tb1 where join_tb1.ts = join_tb1.ts order by ts;
|
||||||
sql_error select join_tb1.* from $tb1 , $tb1 where join_tb1.ts = join_tb1.ts order by join_tb1.c7;
|
sql_error select join_tb1.* from $tb1 , $tb1 where join_tb1.ts = join_tb1.ts order by join_tb1.c7;
|
||||||
|
sql_error select * from join_tb0, join_tb1
|
||||||
|
sql_error select last_row(*) from join_tb0, join_tb1
|
||||||
|
sql_error select last_row(*) from $tb1, $tb2 where join_tb1.ts < now
|
||||||
|
sql_error select last_row(*) from $tb1, $tb2 where join_tb1.ts = join_tb2.ts
|
||||||
|
|
||||||
print ==================================super table join ==============================
|
print ==================================super table join ==============================
|
||||||
# select duplicate columns
|
# select duplicate columns
|
||||||
|
|
|
@ -128,3 +128,27 @@ if $rows != 86399 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
sql select t1,t1,count(*),t1,t1 from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' interval(1h) fill(NULL) group by t1 order by ts DESC limit 30
|
||||||
|
if $rows != 48 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select t1,t1,count(*),t1,t1 from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' interval(1h) fill(NULL) group by t1 order by ts DESC limit 2
|
||||||
|
if $rows != 4 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select t1,t1,count(*),tbname,t1,t1,tbname from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' interval(1s) fill(NULL) group by tbname, t1 order by ts desc slimit 1 soffset 1 limit 250000 offset 1
|
||||||
|
if $rows != 86399 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select t1,t1,count(*),t1,t1 from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' interval(1h) fill(NULL) group by t1 order by ts desc limit 1
|
||||||
|
if $rows != 2 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select t1,t1,count(*),t1,t1 from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' interval(1h) fill(NULL) group by t1 order by ts desc limit 25 offset 1
|
||||||
|
if $rows != 46 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
|
@ -223,6 +223,7 @@ if $rows != 2 then
|
||||||
endi
|
endi
|
||||||
print data00 = $data00
|
print data00 = $data00
|
||||||
if $data00 != 5 then
|
if $data00 != 5 then
|
||||||
|
print expect 5, actual: $data00
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
if $data10 != 5 then
|
if $data10 != 5 then
|
||||||
|
|
|
@ -97,7 +97,7 @@ run general/parser/topbot.sim
|
||||||
sleep 2000
|
sleep 2000
|
||||||
run general/parser/union.sim
|
run general/parser/union.sim
|
||||||
sleep 2000
|
sleep 2000
|
||||||
run general/parser/bug.sim
|
run general/parser/constCol.sim
|
||||||
sleep 2000
|
sleep 2000
|
||||||
run general/parser/sliding.sim
|
run general/parser/sliding.sim
|
||||||
|
|
||||||
|
|
|
@ -147,7 +147,6 @@ cd ../../../debug; make
|
||||||
./test.sh -f general/parser/join.sim
|
./test.sh -f general/parser/join.sim
|
||||||
./test.sh -f general/parser/join_multivnode.sim
|
./test.sh -f general/parser/join_multivnode.sim
|
||||||
./test.sh -f general/parser/binary_escapeCharacter.sim
|
./test.sh -f general/parser/binary_escapeCharacter.sim
|
||||||
./test.sh -f general/parser/bug.sim
|
|
||||||
./test.sh -f general/parser/repeatAlter.sim
|
./test.sh -f general/parser/repeatAlter.sim
|
||||||
./test.sh -f general/parser/union.sim
|
./test.sh -f general/parser/union.sim
|
||||||
./test.sh -f general/parser/topbot.sim
|
./test.sh -f general/parser/topbot.sim
|
||||||
|
|
|
@ -6,8 +6,8 @@ echo Start TDengine Testing Case ...
|
||||||
set "SCRIPT_DIR=%~dp0"
|
set "SCRIPT_DIR=%~dp0"
|
||||||
echo SCRIPT_DIR: %SCRIPT_DIR%
|
echo SCRIPT_DIR: %SCRIPT_DIR%
|
||||||
|
|
||||||
set "BUILD_DIR=%~dp0..\..\debug\build\bin"
|
set "BUILD_DIR=%~dp0..\..\debug\32\build\bin"
|
||||||
set "TSIM=%~dp0..\..\debug\build\bin\tsim"
|
set "TSIM=%~dp0..\..\debug\32\build\bin\tsim"
|
||||||
echo BUILD_DIR: %BUILD_DIR%
|
echo BUILD_DIR: %BUILD_DIR%
|
||||||
|
|
||||||
set "SIM_DIR=%~dp0..\..\sim"
|
set "SIM_DIR=%~dp0..\..\sim"
|
||||||
|
@ -47,7 +47,7 @@ echo qdebugFlag 143 >> %TAOS_CFG%
|
||||||
echo udebugFlag 143 >> %TAOS_CFG%
|
echo udebugFlag 143 >> %TAOS_CFG%
|
||||||
|
|
||||||
set "FILE_NAME=windows\testSuite.sim"
|
set "FILE_NAME=windows\testSuite.sim"
|
||||||
set "FIRSTEP=localhost"
|
set "FIRSTEP=192.168.1.182"
|
||||||
if "%1" == "-f" set "FILE_NAME=%2"
|
if "%1" == "-f" set "FILE_NAME=%2"
|
||||||
if "%1" == "-h" set "FIRSTEP=%2"
|
if "%1" == "-h" set "FIRSTEP=%2"
|
||||||
if "%3" == "-f" set "FILE_NAME=%4"
|
if "%3" == "-f" set "FILE_NAME=%4"
|
||||||
|
|
Loading…
Reference in New Issue