diff --git a/.gitmodules b/.gitmodules
index 0e65b02221..346f5c0069 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -10,3 +10,6 @@
[submodule "tests/examples/rust"]
path = tests/examples/rust
url = https://github.com/songtianyi/tdengine-rust-bindings.git
+[submodule "deps/jemalloc"]
+ path = deps/jemalloc
+ url = https://github.com/jemalloc/jemalloc
diff --git a/cmake/define.inc b/cmake/define.inc
index 57351e5478..cc8bd0fc35 100755
--- a/cmake/define.inc
+++ b/cmake/define.inc
@@ -59,6 +59,11 @@ IF (TD_LINUX_64)
MESSAGE(STATUS "linux64 is defined")
SET(COMMON_FLAGS "-std=gnu99 -Wall -Werror -fPIC -gdwarf-2 -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
ADD_DEFINITIONS(-DUSE_LIBICONV)
+
+ IF (JEMALLOC_ENABLED)
+ ADD_DEFINITIONS(-DTD_JEMALLOC_ENABLED -I${CMAKE_BINARY_DIR}/build/include -L${CMAKE_BINARY_DIR}/build/lib -Wl,-rpath,${CMAKE_BINARY_DIR}/build/lib -ljemalloc)
+ ENDIF ()
+
ENDIF ()
IF (TD_LINUX_32)
diff --git a/cmake/input.inc b/cmake/input.inc
index 00e0e1bc0f..543114ad09 100755
--- a/cmake/input.inc
+++ b/cmake/input.inc
@@ -72,3 +72,8 @@ IF (${RANDOM_NETWORK_FAIL} MATCHES "true")
SET(TD_RANDOM_NETWORK_FAIL TRUE)
MESSAGE(STATUS "build with random-network-fail enabled")
ENDIF ()
+
+IF (${JEMALLOC_ENABLED} MATCHES "true")
+ SET(TD_JEMALLOC_ENABLED TRUE)
+ MESSAGE(STATUS "build with jemalloc enabled")
+ENDIF ()
diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt
index cfc17442f5..99152c6ce3 100644
--- a/deps/CMakeLists.txt
+++ b/deps/CMakeLists.txt
@@ -18,3 +18,16 @@ ENDIF ()
IF (TD_DARWIN AND TD_MQTT)
ADD_SUBDIRECTORY(MQTT-C)
ENDIF ()
+
+IF (TD_LINUX_64 AND JEMALLOC_ENABLED)
+ MESSAGE("setup dpes/jemalloc, current source dir:" ${CMAKE_CURRENT_SOURCE_DIR})
+ MESSAGE("binary dir:" ${CMAKE_BINARY_DIR})
+ include(ExternalProject)
+ ExternalProject_Add(jemalloc
+ PREFIX "jemalloc"
+ SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/jemalloc
+ BUILD_IN_SOURCE 1
+ CONFIGURE_COMMAND ./autogen.sh COMMAND ./configure --prefix=${CMAKE_BINARY_DIR}/build/
+ BUILD_COMMAND ${MAKE}
+ )
+ENDIF ()
diff --git a/deps/jemalloc b/deps/jemalloc
new file mode 160000
index 0000000000..ea6b3e973b
--- /dev/null
+++ b/deps/jemalloc
@@ -0,0 +1 @@
+Subproject commit ea6b3e973b477b8061e0076bb257dbd7f3faa756
diff --git a/documentation20/cn/03.architecture/02.replica/docs.md b/documentation20/cn/03.architecture/02.replica/docs.md
index 8e1b1e3ab1..59192ee0cc 100644
--- a/documentation20/cn/03.architecture/02.replica/docs.md
+++ b/documentation20/cn/03.architecture/02.replica/docs.md
@@ -107,9 +107,9 @@ TDengine采取的是Master-Slave模式进行同步,与流行的RAFT一致性

-1. 应用对写请求做基本的合法性检查,通过,则给改请求包打上一个版本号(version, 单调递增)
+1. 应用对写请求做基本的合法性检查,通过,则给该请求包打上一个版本号(version, 单调递增)
2. 应用将打上版本号的写请求封装一个WAL Head, 写入WAL(Write Ahead Log)
-3. 应用调用API syncForwardToPeer,如多vnode B是slave状态,sync模块将包含WAL Head的数据包通过Forward消息发送给vnode B,否则就不转发。
+3. 应用调用API syncForwardToPeer,如果vnode B是slave状态,sync模块将包含WAL Head的数据包通过Forward消息发送给vnode B,否则就不转发。
4. vnode B收到Forward消息后,调用回调函数writeToCache, 交给应用处理
5. vnode B应用在写入成功后,都需要调用syncAckForward通知sync模块已经写入成功。
6. 如果quorum大于1,vnode B需要等待应用的回复确认,收到确认后,vnode B发送Forward Response消息给node A。
@@ -219,7 +219,7 @@ Arbitrator的程序tarbitrator.c在复制模块的同一目录, 编译整个系
不同之处:
-- 选举流程不一样:Raft里任何一个节点是candidate时,主动向其他节点发出vote request, 如果超过半数回答Yes, 这个candidate就成为Leader,开始一个新的term. 而TDengine的实现里,节点上线、离线或角色改变都会触发状态消息在节点组类传播,等节点组里状态稳定一致之后才触发选举流程,因为状态稳定一致,基于同样的状态信息,每个节点做出的决定会是一致的,一旦某个节点符合成为master的条件,无需其他节点认可,它会自动将自己设为master。TDengine里,任何一个节点检测到其他节点或自己的角色发生改变,就会给节点组内其他节点进行广播的。Raft里不存在这样的机制,因此需要投票来解决。
+- 选举流程不一样:Raft里任何一个节点是candidate时,主动向其他节点发出vote request,如果超过半数回答Yes,这个candidate就成为Leader,开始一个新的term。而TDengine的实现里,节点上线、离线或角色改变都会触发状态消息在节点组内传播,等节点组里状态稳定一致之后才触发选举流程,因为状态稳定一致,基于同样的状态信息,每个节点做出的决定会是一致的,一旦某个节点符合成为master的条件,无需其他节点认可,它会自动将自己设为master。TDengine里,任何一个节点检测到其他节点或自己的角色发生改变,就会向节点组内其他节点进行广播。Raft里不存在这样的机制,因此需要投票来解决。
- 对WAL的一条记录,Raft用term + index来做唯一标识。但TDengine只用version(类似index),在TDengine实现里,仅仅用version是完全可行的, 因为TDengine的选举机制,没有term的概念。
如果整个虚拟节点组全部宕机,重启,但不是所有虚拟节点都上线,这个时候TDengine是不会选出master的,因为未上线的节点有可能有最高version的数据。而RAFT协议,只要超过半数上线,就会选出Leader。
diff --git a/documentation20/cn/03.architecture/docs.md b/documentation20/cn/03.architecture/docs.md
index 3d6e5e4f21..2668967102 100644
--- a/documentation20/cn/03.architecture/docs.md
+++ b/documentation20/cn/03.architecture/docs.md
@@ -343,7 +343,7 @@ TDengine采用数据驱动的方式让缓存中的数据写入硬盘进行持久
对于采集的数据,一般有保留时长,这个时长由系统配置参数keep决定。超过这个设置天数的数据文件,将被系统自动删除,释放存储空间。
-给定days与keep两个参数,一个vnode总的数据文件数为:keep/days。总的数据文件个数不宜过大,也不宜过小。10到100以内合适。基于这个原则,可以设置合理的days。 目前的版本,参数keep可以修改,但对于参数days,一但设置后,不可修改。
+给定days与keep两个参数,一个典型工作状态的vnode中总的数据文件数为:`向上取整(keep/days)+1`个。总的数据文件个数不宜过大,也不宜过小。10到100以内合适。基于这个原则,可以设置合理的days。 目前的版本,参数keep可以修改,但对于参数days,一但设置后,不可修改。
在每个数据文件里,一张表的数据是一块一块存储的。一张表可以有一到多个数据文件块。在一个文件块里,数据是列式存储的,占用的是一片连续的存储空间,这样大大提高读取速度。文件块的大小由系统参数maxRows(每块最大记录条数)决定,缺省值为4096。这个值不宜过大,也不宜过小。过大,定位具体时间段的数据的搜索时间会变长,影响读取速度;过小,数据块的索引太大,压缩效率偏低,也影响读取速度。
diff --git a/documentation20/cn/08.connector/docs.md b/documentation20/cn/08.connector/docs.md
index 9edeb78c68..9484917993 100644
--- a/documentation20/cn/08.connector/docs.md
+++ b/documentation20/cn/08.connector/docs.md
@@ -516,7 +516,7 @@ conn.close()
- _TDengineCursor_ 类
参考python中help(taos.TDengineCursor)。
- 这个类对应客户端进行的写入、查询操作。在客户端多线程的场景下,这个游标实例必须保持线程独享,不能夸线程共享使用,否则会导致返回结果出现错误。
+ 这个类对应客户端进行的写入、查询操作。在客户端多线程的场景下,这个游标实例必须保持线程独享,不能跨线程共享使用,否则会导致返回结果出现错误。
- _connect_ 方法
diff --git a/documentation20/cn/12.taos-sql/docs.md b/documentation20/cn/12.taos-sql/docs.md
index af78074eb2..6bd007ff21 100644
--- a/documentation20/cn/12.taos-sql/docs.md
+++ b/documentation20/cn/12.taos-sql/docs.md
@@ -37,7 +37,7 @@ taos> DESCRIBE meters;
- Epoch Time:时间戳也可以是一个长整数,表示从 1970-01-01 08:00:00.000 开始的毫秒数
- 时间可以加减,比如 now-2h,表明查询时刻向前推 2 个小时(最近 2 小时)。数字后面的时间单位可以是 u(微秒)、a(毫秒)、s(秒)、m(分)、h(小时)、d(天)、w(周)。 比如 `select * from t1 where ts > now-2w and ts <= now-1w`,表示查询两周前整整一周的数据。在指定降频操作(down sampling)的时间窗口(interval)时,时间单位还可以使用 n(自然月) 和 y(自然年)。
-TDengine 缺省的时间戳是毫秒精度,但通过修改配置参数 enableMicrosecond 就可以支持微秒。
+TDengine 缺省的时间戳是毫秒精度,但通过在 CREATE DATABASE 时传递的 PRECISION 参数就可以支持微秒。
在TDengine中,普通表的数据模型中可使用以下 10 种数据类型。
@@ -400,6 +400,7 @@ TDengine 缺省的时间戳是毫秒精度,但通过修改配置参数 enableM
tb2_name (tb2_field1_name, ...) [USING stb2_name TAGS (tag_value2, ...)] VALUES (field1_value1, ...) (field1_value2, ...) ...;
```
以自动建表的方式,同时向表tb1_name和tb2_name中按列分别插入多条记录。
+ 说明:`(tb1_field1_name, ...)`的部分可以省略掉,这样就是使用全列模式写入——也即在 VALUES 部分提供的数据,必须为数据表的每个列都显式地提供数据。全列写入速度会远快于指定列,因此建议尽可能采用全列写入方式,此时空列可以填入NULL。
从 2.0.20.5 版本开始,子表的列名可以不跟在子表名称后面,而是可以放在 TAGS 和 VALUES 之间,例如像下面这样写:
```mysql
INSERT INTO tb1_name [USING stb1_name TAGS (tag_value1, ...)] (tb1_field1_name, ...) VALUES (field1_value1, ...) (field1_value2, ...) ...;
@@ -423,9 +424,9 @@ Query OK, 1 row(s) in set (0.001029s)
taos> SHOW TABLES;
Query OK, 0 row(s) in set (0.000946s)
-taos> INSERT INTO d1001 USING meters TAGS('Beijing.Chaoyang', 2);
+taos> INSERT INTO d1001 USING meters TAGS('Beijing.Chaoyang', 2) VALUES('a');
-DB error: invalid SQL: keyword VALUES or FILE required
+DB error: invalid SQL: 'a' (invalid timestamp) (0.039494s)
taos> SHOW TABLES;
table_name | created_time | columns | stable_name |
diff --git a/packaging/deb/makedeb.sh b/packaging/deb/makedeb.sh
index 28be037e6c..e6ddb6d742 100755
--- a/packaging/deb/makedeb.sh
+++ b/packaging/deb/makedeb.sh
@@ -24,14 +24,14 @@ echo "compile_dir: ${compile_dir}"
echo "pkg_dir: ${pkg_dir}"
if [ -d ${pkg_dir} ]; then
- rm -rf ${pkg_dir}
+ rm -rf ${pkg_dir}
fi
mkdir -p ${pkg_dir}
cd ${pkg_dir}
libfile="libtaos.so.${tdengine_ver}"
-# create install dir
+# create install dir
install_home_path="/usr/local/taos"
mkdir -p ${pkg_dir}${install_home_path}
mkdir -p ${pkg_dir}${install_home_path}/bin
@@ -42,7 +42,7 @@ mkdir -p ${pkg_dir}${install_home_path}/examples
mkdir -p ${pkg_dir}${install_home_path}/include
mkdir -p ${pkg_dir}${install_home_path}/init.d
mkdir -p ${pkg_dir}${install_home_path}/script
-
+
cp ${compile_dir}/../packaging/cfg/taos.cfg ${pkg_dir}${install_home_path}/cfg
cp ${compile_dir}/../packaging/deb/taosd ${pkg_dir}${install_home_path}/init.d
cp ${compile_dir}/../packaging/tools/post.sh ${pkg_dir}${install_home_path}/script
@@ -54,7 +54,7 @@ cp ${compile_dir}/build/bin/taosdemo ${pkg_dir}${install_home_pat
cp ${compile_dir}/build/bin/taosdump ${pkg_dir}${install_home_path}/bin
cp ${compile_dir}/build/bin/taosd ${pkg_dir}${install_home_path}/bin
cp ${compile_dir}/build/bin/taos ${pkg_dir}${install_home_path}/bin
-cp ${compile_dir}/build/lib/${libfile} ${pkg_dir}${install_home_path}/driver
+cp ${compile_dir}/build/lib/${libfile} ${pkg_dir}${install_home_path}/driver
cp ${compile_dir}/../src/inc/taos.h ${pkg_dir}${install_home_path}/include
cp ${compile_dir}/../src/inc/taoserror.h ${pkg_dir}${install_home_path}/include
cp -r ${top_dir}/tests/examples/* ${pkg_dir}${install_home_path}/examples
@@ -67,7 +67,41 @@ fi
cp -r ${top_dir}/src/connector/python ${pkg_dir}${install_home_path}/connector
cp -r ${top_dir}/src/connector/go ${pkg_dir}${install_home_path}/connector
cp -r ${top_dir}/src/connector/nodejs ${pkg_dir}${install_home_path}/connector
-cp ${compile_dir}/build/lib/taos-jdbcdriver*dist.* ${pkg_dir}${install_home_path}/connector ||:
+cp ${compile_dir}/build/lib/taos-jdbcdriver*.* ${pkg_dir}${install_home_path}/connector ||:
+
+if [ -f ${compile_dir}/build/bin/jemalloc-config ]; then
+ install_user_local_path="/usr/local"
+ mkdir -p ${pkg_dir}${install_user_local_path}/{bin,lib,lib/pkgconfig,include/jemalloc,share/doc/jemalloc,share/man/man3}
+ cp ${compile_dir}/build/bin/jemalloc-config ${pkg_dir}${install_user_local_path}/bin/
+ if [ -f ${compile_dir}/build/bin/jemalloc.sh ]; then
+ cp ${compile_dir}/build/bin/jemalloc.sh ${pkg_dir}${install_user_local_path}/bin/
+ fi
+ if [ -f ${compile_dir}/build/bin/jeprof ]; then
+ cp ${compile_dir}/build/bin/jeprof ${pkg_dir}${install_user_local_path}/bin/
+ fi
+ if [ -f ${compile_dir}/build/include/jemalloc/jemalloc.h ]; then
+ cp ${compile_dir}/build/include/jemalloc/jemalloc.h ${pkg_dir}${install_user_local_path}/include/jemalloc/
+ fi
+ if [ -f ${compile_dir}/build/lib/libjemalloc.so.2 ]; then
+ cp ${compile_dir}/build/lib/libjemalloc.so.2 ${pkg_dir}${install_user_local_path}/lib/
+ ln -sf libjemalloc.so.2 ${pkg_dir}${install_user_local_path}/lib/libjemalloc.so
+ fi
+ if [ -f ${compile_dir}/build/lib/libjemalloc.a ]; then
+ cp ${compile_dir}/build/lib/libjemalloc.a ${pkg_dir}${install_user_local_path}/lib/
+ fi
+ if [ -f ${compile_dir}/build/lib/libjemalloc_pic.a ]; then
+ cp ${compile_dir}/build/lib/libjemalloc_pic.a ${pkg_dir}${install_user_local_path}/lib/
+ fi
+ if [ -f ${compile_dir}/build/lib/pkgconfig/jemalloc.pc ]; then
+ cp ${compile_dir}/build/lib/pkgconfig/jemalloc.pc ${pkg_dir}${install_user_local_path}/lib/pkgconfig/
+ fi
+ if [ -f ${compile_dir}/build/share/doc/jemalloc/jemalloc.html ]; then
+ cp ${compile_dir}/build/share/doc/jemalloc/jemalloc.html ${pkg_dir}${install_user_local_path}/share/doc/jemalloc/
+ fi
+ if [ -f ${compile_dir}/build/share/man/man3/jemalloc.3 ]; then
+ cp ${compile_dir}/build/share/man/man3/jemalloc.3 ${pkg_dir}${install_user_local_path}/share/man/man3/
+ fi
+fi
cp -r ${compile_dir}/../packaging/deb/DEBIAN ${pkg_dir}/
chmod 755 ${pkg_dir}/DEBIAN/*
@@ -75,7 +109,7 @@ chmod 755 ${pkg_dir}/DEBIAN/*
# modify version of control
debver="Version: "$tdengine_ver
sed -i "2c$debver" ${pkg_dir}/DEBIAN/control
-
+
#get taos version, then set deb name
@@ -90,7 +124,7 @@ fi
if [ "$verType" == "beta" ]; then
debname=${debname}-${verType}".deb"
-elif [ "$verType" == "stable" ]; then
+elif [ "$verType" == "stable" ]; then
debname=${debname}".deb"
else
echo "unknow verType, nor stabel or beta"
@@ -101,7 +135,7 @@ fi
dpkg -b ${pkg_dir} $debname
echo "make deb package success!"
-cp ${pkg_dir}/*.deb ${output_dir}
+cp ${pkg_dir}/*.deb ${output_dir}
# clean tmep dir
rm -rf ${pkg_dir}
diff --git a/packaging/release.sh b/packaging/release.sh
index 1e54bc2872..1d81f818a9 100755
--- a/packaging/release.sh
+++ b/packaging/release.sh
@@ -6,7 +6,7 @@ set -e
#set -x
# release.sh -v [cluster | edge]
-# -c [aarch32 | aarch64 | x64 | x86 | mips64 ...]
+# -c [aarch32 | aarch64 | x64 | x86 | mips64 ...]
# -o [Linux | Kylin | Alpine | Raspberrypi | Darwin | Windows | Ningsi60 | Ningsi80 |...]
# -V [stable | beta]
# -l [full | lite]
@@ -22,11 +22,12 @@ cpuType=x64 # [aarch32 | aarch64 | x64 | x86 | mips64 ...]
osType=Linux # [Linux | Kylin | Alpine | Raspberrypi | Darwin | Windows | Ningsi60 | Ningsi80 |...]
pagMode=full # [full | lite]
soMode=dynamic # [static | dynamic]
+allocator=glibc # [glibc | jemalloc]
dbName=taos # [taos | power]
verNumber=""
verNumberComp="2.0.0.0"
-while getopts "hv:V:c:o:l:s:d:n:m:" arg
+while getopts "hv:V:c:o:l:s:d:a:n:m:" arg
do
case $arg in
v)
@@ -53,6 +54,10 @@ do
#echo "dbName=$OPTARG"
dbName=$(echo $OPTARG)
;;
+ a)
+ #echo "allocator=$OPTARG"
+ allocator=$(echo $OPTARG)
+ ;;
n)
#echo "verNumber=$OPTARG"
verNumber=$(echo $OPTARG)
@@ -71,20 +76,21 @@ do
echo " -o [Linux | Kylin | Alpine | Raspberrypi | Darwin | Windows | Ningsi60 | Ningsi80 |...] "
echo " -V [stable | beta] "
echo " -l [full | lite] "
+ echo " -a [glibc | jemalloc] "
echo " -s [static | dynamic] "
echo " -d [taos | power] "
echo " -n [version number] "
echo " -m [compatible version number] "
exit 0
;;
- ?) #unknow option
+ ?) #unknow option
echo "unkonw argument"
exit 1
;;
esac
done
-echo "verMode=${verMode} verType=${verType} cpuType=${cpuType} osType=${osType} pagMode=${pagMode} soMode=${soMode} dbName=${dbName} verNumber=${verNumber} verNumberComp=${verNumberComp}"
+echo "verMode=${verMode} verType=${verType} cpuType=${cpuType} osType=${osType} pagMode=${pagMode} soMode=${soMode} dbName=${dbName} allocator=${allocator} verNumber=${verNumber} verNumberComp=${verNumberComp}"
curr_dir=$(pwd)
@@ -118,7 +124,7 @@ function vercomp () {
echo 0
exit 0
fi
-
+
local IFS=.
local i ver1=($1) ver2=($2)
@@ -164,7 +170,7 @@ if [[ "$verMode" == "cluster" ]]; then
else
gitinfoOfInternal=NULL
fi
-
+
cd ${curr_dir}
# 2. cmake executable file
@@ -180,12 +186,18 @@ else
fi
cd ${compile_dir}
+if [[ "$allocator" == "jemalloc" ]]; then
+ allocator_macro="-DJEMALLOC_ENABLED=true"
+else
+ allocator_macro=""
+fi
+
# check support cpu type
if [[ "$cpuType" == "x64" ]] || [[ "$cpuType" == "aarch64" ]] || [[ "$cpuType" == "aarch32" ]] || [[ "$cpuType" == "mips64" ]] ; then
if [ "$verMode" != "cluster" ]; then
- cmake ../ -DCPUTYPE=${cpuType} -DOSTYPE=${osType} -DSOMODE=${soMode} -DDBNAME=${dbName} -DVERTYPE=${verType} -DVERDATE="${build_time}" -DGITINFO=${gitinfo} -DGITINFOI=${gitinfoOfInternal} -DVERNUMBER=${verNumber} -DVERCOMPATIBLE=${verNumberComp} -DPAGMODE=${pagMode}
+ cmake ../ -DCPUTYPE=${cpuType} -DOSTYPE=${osType} -DSOMODE=${soMode} -DDBNAME=${dbName} -DVERTYPE=${verType} -DVERDATE="${build_time}" -DGITINFO=${gitinfo} -DGITINFOI=${gitinfoOfInternal} -DVERNUMBER=${verNumber} -DVERCOMPATIBLE=${verNumberComp} -DPAGMODE=${pagMode} ${allocator_macro}
else
- cmake ../../ -DCPUTYPE=${cpuType} -DOSTYPE=${osType} -DSOMODE=${soMode} -DDBNAME=${dbName} -DVERTYPE=${verType} -DVERDATE="${build_time}" -DGITINFO=${gitinfo} -DGITINFOI=${gitinfoOfInternal} -DVERNUMBER=${verNumber} -DVERCOMPATIBLE=${verNumberComp}
+ cmake ../../ -DCPUTYPE=${cpuType} -DOSTYPE=${osType} -DSOMODE=${soMode} -DDBNAME=${dbName} -DVERTYPE=${verType} -DVERDATE="${build_time}" -DGITINFO=${gitinfo} -DGITINFOI=${gitinfoOfInternal} -DVERNUMBER=${verNumber} -DVERCOMPATIBLE=${verNumberComp} ${allocator_macro}
fi
else
echo "input cpuType=${cpuType} error!!!"
@@ -199,9 +211,9 @@ cd ${curr_dir}
# 3. Call the corresponding script for packaging
if [ "$osType" != "Darwin" ]; then
if [[ "$verMode" != "cluster" ]] && [[ "$cpuType" == "x64" ]] && [[ "$dbName" == "taos" ]]; then
- ret='0'
+ ret='0'
command -v dpkg >/dev/null 2>&1 || { ret='1'; }
- if [ "$ret" -eq 0 ]; then
+ if [ "$ret" -eq 0 ]; then
echo "====do deb package for the ubuntu system===="
output_dir="${top_dir}/debs"
if [ -d ${output_dir} ]; then
@@ -214,9 +226,9 @@ if [ "$osType" != "Darwin" ]; then
echo "==========dpkg command not exist, so not release deb package!!!"
fi
- ret='0'
+ ret='0'
command -v rpmbuild >/dev/null 2>&1 || { ret='1'; }
- if [ "$ret" -eq 0 ]; then
+ if [ "$ret" -eq 0 ]; then
echo "====do rpm package for the centos system===="
output_dir="${top_dir}/rpms"
if [ -d ${output_dir} ]; then
@@ -229,11 +241,11 @@ if [ "$osType" != "Darwin" ]; then
echo "==========rpmbuild command not exist, so not release rpm package!!!"
fi
fi
-
+
echo "====do tar.gz package for all systems===="
cd ${script_dir}/tools
-
- if [[ "$dbName" == "taos" ]]; then
+
+ if [[ "$dbName" == "taos" ]]; then
${csudo} ./makepkg.sh ${compile_dir} ${verNumber} "${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} ${verNumber} "${build_time}" ${cpuType} ${osType} ${verMode} ${verType} ${pagMode}
diff --git a/packaging/rpm/makerpm.sh b/packaging/rpm/makerpm.sh
index 678e75c500..7c3272f8d0 100755
--- a/packaging/rpm/makerpm.sh
+++ b/packaging/rpm/makerpm.sh
@@ -1,6 +1,6 @@
#!/bin/bash
#
-# Generate rpm package for centos
+# Generate rpm package for centos
set -e
# set -x
@@ -60,7 +60,7 @@ ${csudo} rpmbuild --define="_version ${tdengine_ver}" --define="_topdir ${pkg_di
# copy rpm package to output_dir, and modify package name, then clean temp dir
#${csudo} cp -rf RPMS/* ${output_dir}
-cp_rpm_package ${pkg_dir}/RPMS
+cp_rpm_package ${pkg_dir}/RPMS
if [ "$verMode" == "cluster" ]; then
@@ -74,7 +74,7 @@ fi
if [ "$verType" == "beta" ]; then
rpmname=${rpmname}-${verType}".rpm"
-elif [ "$verType" == "stable" ]; then
+elif [ "$verType" == "stable" ]; then
rpmname=${rpmname}".rpm"
else
echo "unknow verType, nor stabel or beta"
diff --git a/packaging/rpm/tdengine.spec b/packaging/rpm/tdengine.spec
index 9910e20bfe..8a870286ab 100644
--- a/packaging/rpm/tdengine.spec
+++ b/packaging/rpm/tdengine.spec
@@ -1,4 +1,5 @@
%define homepath /usr/local/taos
+%define userlocalpath /usr/local
%define cfg_install_dir /etc/taos
%define __strip /bin/true
@@ -12,22 +13,22 @@ URL: www.taosdata.com
AutoReqProv: no
#BuildRoot: %_topdir/BUILDROOT
-BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
#Prefix: /usr/local/taos
-#BuildRequires:
-#Requires:
+#BuildRequires:
+#Requires:
%description
Big Data Platform Designed and Optimized for IoT
-#"prep" Nothing needs to be done
+#"prep" Nothing needs to be done
#%prep
#%setup -q
-#%setup -T
+#%setup -T
-#"build" Nothing needs to be done
+#"build" Nothing needs to be done
#%build
#%configure
#make %{?_smp_mflags}
@@ -75,9 +76,53 @@ fi
cp -r %{_compiledir}/../src/connector/python %{buildroot}%{homepath}/connector
cp -r %{_compiledir}/../src/connector/go %{buildroot}%{homepath}/connector
cp -r %{_compiledir}/../src/connector/nodejs %{buildroot}%{homepath}/connector
-cp %{_compiledir}/build/lib/taos-jdbcdriver*dist.* %{buildroot}%{homepath}/connector ||:
+cp %{_compiledir}/build/lib/taos-jdbcdriver*.* %{buildroot}%{homepath}/connector ||:
cp -r %{_compiledir}/../tests/examples/* %{buildroot}%{homepath}/examples
+
+if [ -f %{_compiledir}/build/bin/jemalloc-config ]; then
+ mkdir -p %{buildroot}%{userlocalpath}/bin
+ mkdir -p %{buildroot}%{userlocalpath}/lib
+ mkdir -p %{buildroot}%{userlocalpath}/lib/pkgconfig
+ mkdir -p %{buildroot}%{userlocalpath}/include
+ mkdir -p %{buildroot}%{userlocalpath}/include/jemalloc
+ mkdir -p %{buildroot}%{userlocalpath}/share
+ mkdir -p %{buildroot}%{userlocalpath}/share/doc
+ mkdir -p %{buildroot}%{userlocalpath}/share/doc/jemalloc
+ mkdir -p %{buildroot}%{userlocalpath}/share/man
+ mkdir -p %{buildroot}%{userlocalpath}/share/man/man3
+
+ cp %{_compiledir}/build/bin/jemalloc-config %{buildroot}%{userlocalpath}/bin/
+ if [ -f %{_compiledir}/build/bin/jemalloc.sh ]; then
+ cp %{_compiledir}/build/bin/jemalloc.sh %{buildroot}%{userlocalpath}/bin/
+ fi
+ if [ -f %{_compiledir}/build/bin/jeprof ]; then
+ cp %{_compiledir}/build/bin/jeprof %{buildroot}%{userlocalpath}/bin/
+ fi
+ if [ -f %{_compiledir}/build/include/jemalloc/jemalloc.h ]; then
+ cp %{_compiledir}/build/include/jemalloc/jemalloc.h %{buildroot}%{userlocalpath}/include/jemalloc/
+ fi
+ if [ -f %{_compiledir}/build/lib/libjemalloc.so.2 ]; then
+ cp %{_compiledir}/build/lib/libjemalloc.so.2 %{buildroot}%{userlocalpath}/lib/
+ ln -sf libjemalloc.so.2 %{buildroot}%{userlocalpath}/lib/libjemalloc.so
+ fi
+ if [ -f %{_compiledir}/build/lib/libjemalloc.a ]; then
+ cp %{_compiledir}/build/lib/libjemalloc.a %{buildroot}%{userlocalpath}/lib/
+ fi
+ if [ -f %{_compiledir}/build/lib/libjemalloc_pic.a ]; then
+ cp %{_compiledir}/build/lib/libjemalloc_pic.a %{buildroot}%{userlocalpath}/lib/
+ fi
+ if [ -f %{_compiledir}/build/lib/pkgconfig/jemalloc.pc ]; then
+ cp %{_compiledir}/build/lib/pkgconfig/jemalloc.pc %{buildroot}%{userlocalpath}/lib/pkgconfig/
+ fi
+ if [ -f %{_compiledir}/build/share/doc/jemalloc/jemalloc.html ]; then
+ cp %{_compiledir}/build/share/doc/jemalloc/jemalloc.html %{buildroot}%{userlocalpath}/share/doc/jemalloc/
+ fi
+ if [ -f %{_compiledir}/build/share/man/man3/jemalloc.3 ]; then
+ cp %{_compiledir}/build/share/man/man3/jemalloc.3 %{buildroot}%{userlocalpath}/share/man/man3/
+ fi
+fi
+
#Scripts executed before installation
%pre
csudo=""
@@ -103,7 +148,7 @@ fi
# if taos.cfg already softlink, remove it
if [ -f %{cfg_install_dir}/taos.cfg ]; then
${csudo} rm -f %{homepath}/cfg/taos.cfg || :
-fi
+fi
# there can not libtaos.so*, otherwise ln -s error
${csudo} rm -f %{homepath}/driver/libtaos* || :
@@ -116,18 +161,18 @@ if command -v sudo > /dev/null; then
fi
cd %{homepath}/script
${csudo} ./post.sh
-
+
# Scripts executed before uninstall
%preun
csudo=""
if command -v sudo > /dev/null; then
csudo="sudo"
fi
-# only remove package to call preun.sh, not but update(2)
+# only remove package to call preun.sh, not but update(2)
if [ $1 -eq 0 ];then
#cd %{homepath}/script
#${csudo} ./preun.sh
-
+
if [ -f %{homepath}/script/preun.sh ]; then
cd %{homepath}/script
${csudo} ./preun.sh
@@ -135,7 +180,7 @@ if [ $1 -eq 0 ];then
bin_link_dir="/usr/bin"
lib_link_dir="/usr/lib"
inc_link_dir="/usr/include"
-
+
data_link_dir="/usr/local/taos/data"
log_link_dir="/usr/local/taos/log"
cfg_link_dir="/usr/local/taos/cfg"
@@ -149,20 +194,20 @@ if [ $1 -eq 0 ];then
${csudo} rm -f ${inc_link_dir}/taos.h || :
${csudo} rm -f ${inc_link_dir}/taoserror.h || :
${csudo} rm -f ${lib_link_dir}/libtaos.* || :
-
+
${csudo} rm -f ${log_link_dir} || :
${csudo} rm -f ${data_link_dir} || :
-
+
pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}')
if [ -n "$pid" ]; then
${csudo} kill -9 $pid || :
- fi
- fi
+ fi
+ fi
fi
-
+
# Scripts executed after uninstall
%postun
-
+
# clean build dir
%clean
csudo=""
diff --git a/packaging/tools/install.sh b/packaging/tools/install.sh
index 178a248cfe..325ac81053 100755
--- a/packaging/tools/install.sh
+++ b/packaging/tools/install.sh
@@ -59,11 +59,11 @@ initd_mod=0
service_mod=2
if pidof systemd &> /dev/null; then
service_mod=0
-elif $(which service &> /dev/null); then
+elif $(which service &> /dev/null); then
service_mod=1
- service_config_dir="/etc/init.d"
+ service_config_dir="/etc/init.d"
if $(which chkconfig &> /dev/null); then
- initd_mod=1
+ initd_mod=1
elif $(which insserv &> /dev/null); then
initd_mod=2
elif $(which update-rc.d &> /dev/null); then
@@ -71,7 +71,7 @@ elif $(which service &> /dev/null); then
else
service_mod=2
fi
-else
+else
service_mod=2
fi
@@ -103,7 +103,7 @@ elif echo $osinfo | grep -qwi "fedora" ; then
os_type=2
else
echo " osinfo: ${osinfo}"
- echo " This is an officially unverified linux system,"
+ echo " This is an officially unverified linux system,"
echo " if there are any problems with the installation and operation, "
echo " please feel free to contact taosdata.com for support."
os_type=1
@@ -138,7 +138,7 @@ do
echo "Usage: `basename $0` -v [server | client] -e [yes | no]"
exit 0
;;
- ?) #unknow option
+ ?) #unknow option
echo "unkonw argument"
exit 1
;;
@@ -157,9 +157,9 @@ function kill_process() {
function install_main_path() {
#create install main dir and all sub dir
${csudo} rm -rf ${install_main_dir} || :
- ${csudo} mkdir -p ${install_main_dir}
+ ${csudo} mkdir -p ${install_main_dir}
${csudo} mkdir -p ${install_main_dir}/cfg
- ${csudo} mkdir -p ${install_main_dir}/bin
+ ${csudo} mkdir -p ${install_main_dir}/bin
${csudo} mkdir -p ${install_main_dir}/connector
${csudo} mkdir -p ${install_main_dir}/driver
${csudo} mkdir -p ${install_main_dir}/examples
@@ -168,10 +168,10 @@ function install_main_path() {
if [ "$verMode" == "cluster" ]; then
${csudo} mkdir -p ${nginx_dir}
fi
-
+
if [[ -e ${script_dir}/email ]]; then
- ${csudo} cp ${script_dir}/email ${install_main_dir}/ ||:
- fi
+ ${csudo} cp ${script_dir}/email ${install_main_dir}/ ||:
+ fi
}
function install_bin() {
@@ -207,29 +207,75 @@ function install_lib() {
${csudo} rm -f ${lib_link_dir}/libtaos.* || :
${csudo} rm -f ${lib64_link_dir}/libtaos.* || :
#${csudo} rm -rf ${v15_java_app_dir} || :
- ${csudo} cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/*
-
+ ${csudo} cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/*
+
${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1
${csudo} ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so
-
+
if [[ -d ${lib64_link_dir} && ! -e ${lib64_link_dir}/libtaos.so ]]; then
${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 || :
${csudo} ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || :
fi
-
- #if [ "$verMode" == "cluster" ]; then
+
+ #if [ "$verMode" == "cluster" ]; then
# # Compatible with version 1.5
# ${csudo} mkdir -p ${v15_java_app_dir}
# ${csudo} ln -s ${install_main_dir}/connector/taos-jdbcdriver-1.0.2-dist.jar ${v15_java_app_dir}/JDBCDriver-1.0.2-dist.jar
# ${csudo} chmod 777 ${v15_java_app_dir} || :
#fi
-
+
${csudo} ldconfig
}
+function install_jemalloc() {
+ jemalloc_dir=${script_dir}/jemalloc
+
+ if [ -d ${jemalloc_dir} ]; then
+ ${csudo} /usr/bin/install -c -d /usr/local/bin
+
+ if [ -f ${jemalloc_dir}/bin/jemalloc-config ]; then
+ ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc-config /usr/local/bin
+ fi
+ if [ -f ${jemalloc_dir}/bin/jemalloc.sh ]; then
+ ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc.sh /usr/local/bin
+ fi
+ if [ -f ${jemalloc_dir}/bin/jeprof ]; then
+ ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jeprof /usr/local/bin
+ fi
+ if [ -f ${jemalloc_dir}/include/jemalloc/jemalloc.h ]; then
+ ${csudo} /usr/bin/install -c -d /usr/local/include/jemalloc
+ ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/include/jemalloc/jemalloc.h /usr/local/include/jemalloc
+ fi
+ if [ -f ${jemalloc_dir}/lib/libjemalloc.so.2 ]; then
+ ${csudo} /usr/bin/install -c -d /usr/local/lib
+ ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.so.2 /usr/local/lib
+ ${csudo} ln -sf libjemalloc.so.2 /usr/local/lib/libjemalloc.so
+ ${csudo} /usr/bin/install -c -d /usr/local/lib
+ if [ -f ${jemalloc_dir}/lib/libjemalloc.a ]; then
+ ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.a /usr/local/lib
+ fi
+ if [ -f ${jemalloc_dir}/lib/libjemalloc_pic.a ]; then
+ ${csudo} /usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc_pic.a /usr/local/lib
+ fi
+ if [ -f ${jemalloc_dir}/lib/libjemalloc_pic.a ]; then
+ ${csudo} /usr/bin/install -c -d /usr/local/lib/pkgconfig
+ ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/lib/pkgconfig/jemalloc.pc /usr/local/lib/pkgconfig
+ fi
+ fi
+ if [ -f ${jemalloc_dir}/share/doc/jemalloc/jemalloc.html ]; then
+ ${csudo} /usr/bin/install -c -d /usr/local/share/doc/jemalloc
+ ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/share/doc/jemalloc/jemalloc.html /usr/local/share/doc/jemalloc
+ fi
+ if [ -f ${jemalloc_dir}/share/man/man3/jemalloc.3 ]; then
+ ${csudo} /usr/bin/install -c -d /usr/local/share/man/man3
+ ${csudo} /usr/bin/install -c -m 644 ${jemalloc_dir}/share/man/man3/jemalloc.3 /usr/local/share/man/man3
+ fi
+ fi
+}
+
function install_header() {
${csudo} rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taoserror.h || :
- ${csudo} cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo} chmod 644 ${install_main_dir}/include/*
+ ${csudo} cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo} chmod 644 ${install_main_dir}/include/*
${csudo} ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h
${csudo} ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h
}
@@ -246,13 +292,13 @@ function add_newHostname_to_hosts() {
if [[ "$s" == "$localIp" ]]; then
return
fi
- done
+ done
${csudo} echo "127.0.0.1 $1" >> /etc/hosts ||:
}
function set_hostname() {
echo -e -n "${GREEN}Please enter one hostname(must not be 'localhost')${NC}:"
- read newHostname
+ read newHostname
while true; do
if [[ ! -z "$newHostname" && "$newHostname" != "localhost" ]]; then
break
@@ -266,25 +312,25 @@ function set_hostname() {
if [[ $retval != 0 ]]; then
echo
echo "set hostname fail!"
- return
+ return
fi
#echo -e -n "$(hostnamectl status --static)"
#echo -e -n "$(hostnamectl status --transient)"
#echo -e -n "$(hostnamectl status --pretty)"
-
+
#ubuntu/centos /etc/hostname
if [[ -e /etc/hostname ]]; then
${csudo} echo $newHostname > /etc/hostname ||:
fi
-
+
#debian: #HOSTNAME=yourname
if [[ -e /etc/sysconfig/network ]]; then
${csudo} sed -i -r "s/#*\s*(HOSTNAME=\s*).*/\1$newHostname/" /etc/sysconfig/network ||:
fi
${csudo} sed -i -r "s/#*\s*(fqdn\s*).*/\1$newHostname/" ${cfg_install_dir}/taos.cfg
- serverFqdn=$newHostname
-
+ serverFqdn=$newHostname
+
if [[ -e /etc/hosts ]]; then
add_newHostname_to_hosts $newHostname
fi
@@ -302,7 +348,7 @@ function is_correct_ipaddr() {
return 0
fi
done
-
+
return 1
}
@@ -316,13 +362,13 @@ function set_ipAsFqdn() {
echo
echo -e -n "${GREEN}Unable to get local ip, use 127.0.0.1${NC}"
localFqdn="127.0.0.1"
- # Write the local FQDN to configuration file
- ${csudo} sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/taos.cfg
+ # Write the local FQDN to configuration file
+ ${csudo} sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/taos.cfg
serverFqdn=$localFqdn
echo
return
- fi
-
+ fi
+
echo -e -n "${GREEN}Please choose an IP from local IP list${NC}:"
echo
echo -e -n "${GREEN}$iplist${NC}"
@@ -331,15 +377,15 @@ function set_ipAsFqdn() {
echo -e -n "${GREEN}Notes: if IP is used as the node name, data can NOT be migrated to other machine directly${NC}:"
read localFqdn
while true; do
- if [ ! -z "$localFqdn" ]; then
+ if [ ! -z "$localFqdn" ]; then
# Check if correct ip address
is_correct_ipaddr $localFqdn
retval=`echo $?`
if [[ $retval != 0 ]]; then
read -p "Please choose an IP from local IP list:" localFqdn
else
- # Write the local FQDN to configuration file
- ${csudo} sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/taos.cfg
+ # Write the local FQDN to configuration file
+ ${csudo} sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/taos.cfg
serverFqdn=$localFqdn
break
fi
@@ -354,59 +400,59 @@ function local_fqdn_check() {
echo
echo -e -n "System hostname is: ${GREEN}$serverFqdn${NC}"
echo
- if [[ "$serverFqdn" == "" ]] || [[ "$serverFqdn" == "localhost" ]]; then
+ if [[ "$serverFqdn" == "" ]] || [[ "$serverFqdn" == "localhost" ]]; then
echo -e -n "${GREEN}It is strongly recommended to configure a hostname for this machine ${NC}"
echo
-
+
while true
do
- read -r -p "Set hostname now? [Y/n] " input
- if [ ! -n "$input" ]; then
- set_hostname
- break
- else
- case $input in
- [yY][eE][sS]|[yY])
- set_hostname
- break
- ;;
-
- [nN][oO]|[nN])
- set_ipAsFqdn
- break
- ;;
-
- *)
- echo "Invalid input..."
- ;;
- esac
- fi
+ read -r -p "Set hostname now? [Y/n] " input
+ if [ ! -n "$input" ]; then
+ set_hostname
+ break
+ else
+ case $input in
+ [yY][eE][sS]|[yY])
+ set_hostname
+ break
+ ;;
+
+ [nN][oO]|[nN])
+ set_ipAsFqdn
+ break
+ ;;
+
+ *)
+ echo "Invalid input..."
+ ;;
+ esac
+ fi
done
fi
}
function install_config() {
#${csudo} rm -f ${install_main_dir}/cfg/taos.cfg || :
-
+
if [ ! -f ${cfg_install_dir}/taos.cfg ]; then
${csudo} mkdir -p ${cfg_install_dir}
[ -f ${script_dir}/cfg/taos.cfg ] && ${csudo} cp ${script_dir}/cfg/taos.cfg ${cfg_install_dir}
${csudo} chmod 644 ${cfg_install_dir}/*
- fi
-
+ fi
+
${csudo} cp -f ${script_dir}/cfg/taos.cfg ${install_main_dir}/cfg/taos.cfg.org
${csudo} ln -s ${cfg_install_dir}/taos.cfg ${install_main_dir}/cfg
[ ! -z $1 ] && return 0 || : # only install client
-
+
if ((${update_flag}==1)); then
return 0
fi
-
+
if [ "$interactiveFqdn" == "no" ]; then
return 0
- fi
-
+ fi
+
local_fqdn_check
#FQDN_FORMAT="(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"
@@ -424,8 +470,8 @@ function install_config() {
if [ ! -z "$firstEp" ]; then
# check the format of the firstEp
#if [[ $firstEp == $FQDN_PATTERN ]]; then
- # Write the first FQDN to configuration file
- ${csudo} sed -i -r "s/#*\s*(firstEp\s*).*/\1$firstEp/" ${cfg_install_dir}/taos.cfg
+ # Write the first FQDN to configuration file
+ ${csudo} sed -i -r "s/#*\s*(firstEp\s*).*/\1$firstEp/" ${cfg_install_dir}/taos.cfg
break
#else
# read -p "Please enter the correct FQDN:port: " firstEp
@@ -433,9 +479,9 @@ function install_config() {
else
break
fi
- done
+ done
- # user email
+ # user email
#EMAIL_PATTERN='^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$'
#EMAIL_PATTERN='^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$'
#EMAIL_PATTERN="^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$"
@@ -446,31 +492,31 @@ function install_config() {
if [ ! -z "$emailAddr" ]; then
# check the format of the emailAddr
#if [[ "$emailAddr" =~ $EMAIL_PATTERN ]]; then
- # Write the email address to temp file
- email_file="${install_main_dir}/email"
+ # Write the email address to temp file
+ email_file="${install_main_dir}/email"
${csudo} bash -c "echo $emailAddr > ${email_file}"
- break
+ break
#else
- # read -p "Please enter the correct email address: " emailAddr
+ # read -p "Please enter the correct email address: " emailAddr
#fi
else
break
fi
- done
+ done
}
function install_log() {
${csudo} rm -rf ${log_dir} || :
${csudo} mkdir -p ${log_dir} && ${csudo} chmod 777 ${log_dir}
-
+
${csudo} ln -s ${log_dir} ${install_main_dir}/log
}
function install_data() {
${csudo} mkdir -p ${data_dir}
-
- ${csudo} ln -s ${data_dir} ${install_main_dir}/data
+
+ ${csudo} ln -s ${data_dir} ${install_main_dir}/data
}
function install_connector() {
@@ -485,26 +531,26 @@ function install_examples() {
function clean_service_on_sysvinit() {
#restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start"
- #${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || :
-
+ #${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || :
+
if pidof taosd &> /dev/null; then
${csudo} service taosd stop || :
fi
-
+
if pidof tarbitrator &> /dev/null; then
${csudo} service tarbitratord stop || :
fi
if ((${initd_mod}==1)); then
- if [ -e ${service_config_dir}/taosd ]; then
+ if [ -e ${service_config_dir}/taosd ]; then
${csudo} chkconfig --del taosd || :
fi
- if [ -e ${service_config_dir}/tarbitratord ]; then
+ if [ -e ${service_config_dir}/tarbitratord ]; then
${csudo} chkconfig --del tarbitratord || :
fi
elif ((${initd_mod}==2)); then
- if [ -e ${service_config_dir}/taosd ]; then
+ if [ -e ${service_config_dir}/taosd ]; then
${csudo} insserv -r taosd || :
fi
if [ -e ${service_config_dir}/tarbitratord ]; then
@@ -518,10 +564,10 @@ function clean_service_on_sysvinit() {
${csudo} update-rc.d -f tarbitratord remove || :
fi
fi
-
+
${csudo} rm -f ${service_config_dir}/taosd || :
${csudo} rm -f ${service_config_dir}/tarbitratord || :
-
+
if $(which init &> /dev/null); then
${csudo} init q || :
fi
@@ -544,10 +590,10 @@ function install_service_on_sysvinit() {
${csudo} cp -f ${script_dir}/init.d/tarbitratord.rpm ${install_main_dir}/init.d/tarbitratord
${csudo} cp ${script_dir}/init.d/tarbitratord.rpm ${service_config_dir}/tarbitratord && ${csudo} chmod a+x ${service_config_dir}/tarbitratord
fi
-
+
#restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start"
#${csudo} grep -q -F "$restart_config_str" /etc/inittab || ${csudo} bash -c "echo '${restart_config_str}' >> /etc/inittab"
-
+
if ((${initd_mod}==1)); then
${csudo} chkconfig --add taosd || :
${csudo} chkconfig --level 2345 taosd on || :
@@ -572,7 +618,7 @@ function clean_service_on_systemd() {
fi
${csudo} systemctl disable taosd &> /dev/null || echo &> /dev/null
${csudo} rm -f ${taosd_service_config}
-
+
tarbitratord_service_config="${service_config_dir}/tarbitratord.service"
if systemctl is-active --quiet tarbitratord; then
echo "tarbitrator is running, stopping it..."
@@ -580,7 +626,7 @@ function clean_service_on_systemd() {
fi
${csudo} systemctl disable tarbitratord &> /dev/null || echo &> /dev/null
${csudo} rm -f ${tarbitratord_service_config}
-
+
if [ "$verMode" == "cluster" ]; then
nginx_service_config="${service_config_dir}/nginxd.service"
if systemctl is-active --quiet nginxd; then
@@ -588,8 +634,8 @@ function clean_service_on_systemd() {
${csudo} systemctl stop nginxd &> /dev/null || echo &> /dev/null
fi
${csudo} systemctl disable nginxd &> /dev/null || echo &> /dev/null
- ${csudo} rm -f ${nginx_service_config}
- fi
+ ${csudo} rm -f ${nginx_service_config}
+ fi
}
# taos:2345:respawn:/etc/init.d/taosd start
@@ -621,7 +667,7 @@ function install_service_on_systemd() {
${csudo} bash -c "echo '[Install]' >> ${taosd_service_config}"
${csudo} bash -c "echo 'WantedBy=multi-user.target' >> ${taosd_service_config}"
${csudo} systemctl enable taosd
-
+
tarbitratord_service_config="${service_config_dir}/tarbitratord.service"
${csudo} bash -c "echo '[Unit]' >> ${tarbitratord_service_config}"
${csudo} bash -c "echo 'Description=TDengine arbitrator service' >> ${tarbitratord_service_config}"
@@ -643,9 +689,9 @@ function install_service_on_systemd() {
${csudo} bash -c "echo >> ${tarbitratord_service_config}"
${csudo} bash -c "echo '[Install]' >> ${tarbitratord_service_config}"
${csudo} bash -c "echo 'WantedBy=multi-user.target' >> ${tarbitratord_service_config}"
- #${csudo} systemctl enable tarbitratord
-
- if [ "$verMode" == "cluster" ]; then
+ #${csudo} systemctl enable tarbitratord
+
+ if [ "$verMode" == "cluster" ]; then
nginx_service_config="${service_config_dir}/nginxd.service"
${csudo} bash -c "echo '[Unit]' >> ${nginx_service_config}"
${csudo} bash -c "echo 'Description=Nginx For TDengine Service' >> ${nginx_service_config}"
@@ -674,7 +720,7 @@ function install_service_on_systemd() {
${csudo} systemctl enable nginxd
fi
${csudo} systemctl start nginxd
- fi
+ fi
}
function install_service() {
@@ -757,7 +803,7 @@ function update_TDengine() {
fi
sleep 1
fi
-
+
if [ "$verMode" == "cluster" ]; then
if pidof nginx &> /dev/null; then
if ((${service_mod}==0)); then
@@ -770,12 +816,13 @@ function update_TDengine() {
sleep 1
fi
fi
-
+
install_main_path
install_log
install_header
install_lib
+ install_jemalloc
if [ "$pagMode" != "lite" ]; then
install_connector
fi
@@ -783,10 +830,10 @@ function update_TDengine() {
if [ -z $1 ]; then
install_bin
install_service
- install_config
-
+ install_config
+
openresty_work=false
- if [ "$verMode" == "cluster" ]; then
+ if [ "$verMode" == "cluster" ]; then
# Check if openresty is installed
# Check if nginx is installed successfully
if type curl &> /dev/null; then
@@ -797,7 +844,7 @@ function update_TDengine() {
echo -e "\033[44;31;5mNginx for TDengine does not work! Please try again!\033[0m"
fi
fi
- fi
+ fi
#echo
#echo -e "\033[44;32;1mTDengine is updated successfully!${NC}"
@@ -816,7 +863,7 @@ function update_TDengine() {
else
echo -e "${GREEN_DARK}To access TDengine ${NC}: use ${GREEN_UNDERLINE}taos -h $serverFqdn${NC} in shell${NC}"
fi
-
+
echo
echo -e "\033[44;32;1mTDengine is updated successfully!${NC}"
else
@@ -839,14 +886,14 @@ function install_TDengine() {
tar -zxf taos.tar.gz
echo -e "${GREEN}Start to install TDengine...${NC}"
-
- install_main_path
-
+
+ install_main_path
+
if [ -z $1 ]; then
install_data
- fi
-
- install_log
+ fi
+
+ install_log
install_header
install_lib
if [ "$pagMode" != "lite" ]; then
@@ -871,8 +918,8 @@ function install_TDengine() {
fi
fi
fi
-
- install_config
+
+ install_config
# Ask if to start the service
#echo
@@ -885,36 +932,36 @@ function install_TDengine() {
echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo} service taosd start${NC}"
else
echo -e "${GREEN_DARK}To start TDengine ${NC}: taosd${NC}"
- fi
+ fi
#if [ ${openresty_work} = 'true' ]; then
# echo -e "${GREEN_DARK}To access TDengine ${NC}: use ${GREEN_UNDERLINE}taos${NC} in shell OR from ${GREEN_UNDERLINE}http://127.0.0.1:${nginx_port}${NC}"
#else
# echo -e "${GREEN_DARK}To access TDengine ${NC}: use ${GREEN_UNDERLINE}taos${NC} in shell${NC}"
#fi
-
+
if [ ! -z "$firstEp" ]; then
- tmpFqdn=${firstEp%%:*}
- substr=":"
- if [[ $firstEp =~ $substr ]];then
- tmpPort=${firstEp#*:}
- else
- tmpPort=""
- fi
- if [[ "$tmpPort" != "" ]];then
- echo -e "${GREEN_DARK}To access TDengine ${NC}: taos -h $tmpFqdn -P $tmpPort${GREEN_DARK} to login into cluster, then${NC}"
- else
- echo -e "${GREEN_DARK}To access TDengine ${NC}: taos -h $tmpFqdn${GREEN_DARK} to login into cluster, then${NC}"
- fi
- echo -e "${GREEN_DARK}execute ${NC}: create dnode 'newDnodeFQDN:port'; ${GREEN_DARK}to add this new node${NC}"
- echo
+ tmpFqdn=${firstEp%%:*}
+ substr=":"
+ if [[ $firstEp =~ $substr ]];then
+ tmpPort=${firstEp#*:}
+ else
+ tmpPort=""
+ fi
+ if [[ "$tmpPort" != "" ]];then
+ echo -e "${GREEN_DARK}To access TDengine ${NC}: taos -h $tmpFqdn -P $tmpPort${GREEN_DARK} to login into cluster, then${NC}"
+ else
+ echo -e "${GREEN_DARK}To access TDengine ${NC}: taos -h $tmpFqdn${GREEN_DARK} to login into cluster, then${NC}"
+ fi
+ echo -e "${GREEN_DARK}execute ${NC}: create dnode 'newDnodeFQDN:port'; ${GREEN_DARK}to add this new node${NC}"
+ echo
elif [ ! -z "$serverFqdn" ]; then
- echo -e "${GREEN_DARK}To access TDengine ${NC}: taos -h $serverFqdn${GREEN_DARK} to login into TDengine server${NC}"
- echo
+ echo -e "${GREEN_DARK}To access TDengine ${NC}: taos -h $serverFqdn${GREEN_DARK} to login into TDengine server${NC}"
+ echo
fi
-
+
echo -e "\033[44;32;1mTDengine is installed successfully!${NC}"
- echo
+ echo
else # Only install client
install_bin
install_config
@@ -945,6 +992,6 @@ elif [ "$verType" == "client" ]; then
else
install_TDengine client
fi
-else
- echo "please input correct verType"
+else
+ echo "please input correct verType"
fi
diff --git a/packaging/tools/make_install.sh b/packaging/tools/make_install.sh
index d6ace0a063..0c755d9f72 100755
--- a/packaging/tools/make_install.sh
+++ b/packaging/tools/make_install.sh
@@ -1,12 +1,12 @@
#!/bin/bash
#
-# This file is used to install TAOS time-series database on linux systems. The operating system
+# This file is used to install TAOS time-series database on linux systems. The operating system
# is required to use systemd to manage services at boot
set -e
# set -x
-# -----------------------Variables definition---------------------
+# -----------------------Variables definition
source_dir=$1
binary_dir=$2
osType=$3
@@ -71,9 +71,9 @@ if [ "$osType" != "Darwin" ]; then
service_mod=0
elif $(which service &> /dev/null); then
service_mod=1
- service_config_dir="/etc/init.d"
+ service_config_dir="/etc/init.d"
if $(which chkconfig &> /dev/null); then
- initd_mod=1
+ initd_mod=1
elif $(which insserv &> /dev/null); then
initd_mod=2
elif $(which update-rc.d &> /dev/null); then
@@ -123,9 +123,9 @@ function kill_taosd() {
function install_main_path() {
#create install main dir and all sub dir
${csudo} rm -rf ${install_main_dir} || :
- ${csudo} mkdir -p ${install_main_dir}
+ ${csudo} mkdir -p ${install_main_dir}
${csudo} mkdir -p ${install_main_dir}/cfg
- ${csudo} mkdir -p ${install_main_dir}/bin
+ ${csudo} mkdir -p ${install_main_dir}/bin
${csudo} mkdir -p ${install_main_dir}/connector
${csudo} mkdir -p ${install_main_dir}/driver
${csudo} mkdir -p ${install_main_dir}/examples
@@ -176,6 +176,49 @@ function install_bin() {
[ -x ${install_main_dir}/bin/remove_client.sh ] && ${csudo} ln -s ${install_main_dir}/bin/remove_client.sh ${bin_link_dir}/rmtaos || :
fi
}
+function install_jemalloc() {
+ if [ "$osType" != "Darwin" ]; then
+ /usr/bin/install -c -d /usr/local/bin
+
+ if [ -f ${binary_dir}/build/bin/jemalloc-config ]; then
+ /usr/bin/install -c -m 755 ${binary_dir}/build/bin/jemalloc-config /usr/local/bin
+ fi
+ if [ -f ${binary_dir}/build/bin/jemalloc.sh ]; then
+ /usr/bin/install -c -m 755 ${binary_dir}/build/bin/jemalloc.sh /usr/local/bin
+ fi
+ if [ -f ${binary_dir}/build/bin/jeprof ]; then
+ /usr/bin/install -c -m 755 ${binary_dir}/build/bin/jeprof /usr/local/bin
+ fi
+ if [ -f ${binary_dir}/build/include/jemalloc/jemalloc.h ]; then
+ /usr/bin/install -c -d /usr/local/include/jemalloc
+ /usr/bin/install -c -m 644 ${binary_dir}/build/include/jemalloc/jemalloc.h /usr/local/include/jemalloc
+ fi
+ if [ -f ${binary_dir}/build/lib/libjemalloc.so.2 ]; then
+ /usr/bin/install -c -d /usr/local/lib
+ /usr/bin/install -c -m 755 ${binary_dir}/build/lib/libjemalloc.so.2 /usr/local/lib
+ ln -sf libjemalloc.so.2 /usr/local/lib/libjemalloc.so
+ /usr/bin/install -c -d /usr/local/lib
+ if [ -f ${binary_dir}/build/lib/libjemalloc.a ]; then
+ /usr/bin/install -c -m 755 ${binary_dir}/build/lib/libjemalloc.a /usr/local/lib
+ fi
+ if [ -f ${binary_dir}/build/lib/libjemalloc_pic.a ]; then
+ /usr/bin/install -c -m 755 ${binary_dir}/build/lib/libjemalloc_pic.a /usr/local/lib
+ fi
+ if [ -f ${binary_dir}/build/lib/pkgconfig/jemalloc.pc ]; then
+ /usr/bin/install -c -d /usr/local/lib/pkgconfig
+ /usr/bin/install -c -m 644 ${binary_dir}/build/lib/pkgconfig/jemalloc.pc /usr/local/lib/pkgconfig
+ fi
+ fi
+ if [ -f ${binary_dir}/build/share/doc/jemalloc/jemalloc.html ]; then
+ /usr/bin/install -c -d /usr/local/share/doc/jemalloc
+ /usr/bin/install -c -m 644 ${binary_dir}/build/share/doc/jemalloc/jemalloc.html /usr/local/share/doc/jemalloc
+ fi
+ if [ -f ${binary_dir}/build/share/man/man3/jemalloc.3 ]; then
+ /usr/bin/install -c -d /usr/local/share/man/man3
+ /usr/bin/install -c -m 644 ${binary_dir}/build/share/man/man3/jemalloc.3 /usr/local/share/man/man3
+ fi
+ fi
+}
function install_lib() {
# Remove links
@@ -183,12 +226,12 @@ function install_lib() {
if [ "$osType" != "Darwin" ]; then
${csudo} rm -f ${lib64_link_dir}/libtaos.* || :
fi
-
+
if [ "$osType" != "Darwin" ]; then
${csudo} cp ${binary_dir}/build/lib/libtaos.so.${verNumber} ${install_main_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/*
${csudo} ln -sf ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1
${csudo} ln -sf ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so
-
+
if [ -d "${lib64_link_dir}" ]; then
${csudo} ln -sf ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1
${csudo} ln -sf ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so
@@ -198,7 +241,9 @@ function install_lib() {
${csudo} ln -sf ${install_main_dir}/driver/libtaos.1.dylib ${lib_link_dir}/libtaos.1.dylib
${csudo} ln -sf ${lib_link_dir}/libtaos.1.dylib ${lib_link_dir}/libtaos.dylib
fi
-
+
+ install_jemalloc
+
if [ "$osType" != "Darwin" ]; then
${csudo} ldconfig
fi
@@ -206,26 +251,26 @@ function install_lib() {
function install_header() {
- ${csudo} rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taoserror.h || :
- ${csudo} cp -f ${source_dir}/src/inc/taos.h ${source_dir}/src/inc/taoserror.h ${install_main_dir}/include && ${csudo} chmod 644 ${install_main_dir}/include/*
+ ${csudo} rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taoserror.h || :
+ ${csudo} cp -f ${source_dir}/src/inc/taos.h ${source_dir}/src/inc/taoserror.h ${install_main_dir}/include && ${csudo} chmod 644 ${install_main_dir}/include/*
${csudo} ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h
${csudo} ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h
}
function install_config() {
#${csudo} rm -f ${install_main_dir}/cfg/taos.cfg || :
-
- if [ ! -f ${cfg_install_dir}/taos.cfg ]; then
+
+ if [ ! -f ${cfg_install_dir}/taos.cfg ]; then
${csudo} mkdir -p ${cfg_install_dir}
[ -f ${script_dir}/../cfg/taos.cfg ] && ${csudo} cp ${script_dir}/../cfg/taos.cfg ${cfg_install_dir}
${csudo} chmod 644 ${cfg_install_dir}/*
- fi
-
+ fi
+
${csudo} cp -f ${script_dir}/../cfg/taos.cfg ${install_main_dir}/cfg/taos.cfg.org
- ${csudo} ln -s ${cfg_install_dir}/taos.cfg ${install_main_dir}/cfg
+ ${csudo} ln -s ${cfg_install_dir}/taos.cfg ${install_main_dir}/cfg
}
-function install_log() {
+function install_log() {
${csudo} rm -rf ${log_dir} || :
if [ "$osType" != "Darwin" ]; then
@@ -239,7 +284,7 @@ function install_log() {
function install_data() {
${csudo} mkdir -p ${data_dir}
- ${csudo} ln -s ${data_dir} ${install_main_dir}/data
+ ${csudo} ln -s ${data_dir} ${install_main_dir}/data
}
function install_connector() {
@@ -254,8 +299,8 @@ function install_connector() {
echo "WARNING: go connector not found, please check if want to use it!"
fi
${csudo} cp -rf ${source_dir}/src/connector/python ${install_main_dir}/connector
-
- ${csudo} cp ${binary_dir}/build/lib/*.jar ${install_main_dir}/connector &> /dev/null && ${csudo} chmod 777 ${install_main_dir}/connector/*.jar || echo &> /dev/null
+
+ ${csudo} cp ${binary_dir}/build/lib/*.jar ${install_main_dir}/connector &> /dev/null && ${csudo} chmod 777 ${install_main_dir}/connector/*.jar || echo &> /dev/null
}
function install_examples() {
@@ -264,8 +309,8 @@ function install_examples() {
function clean_service_on_sysvinit() {
#restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start"
- #${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || :
-
+ #${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || :
+
if pidof taosd &> /dev/null; then
${csudo} service taosd stop || :
fi
@@ -277,9 +322,9 @@ function clean_service_on_sysvinit() {
elif ((${initd_mod}==3)); then
${csudo} update-rc.d -f taosd remove || :
fi
-
+
${csudo} rm -f ${service_config_dir}/taosd || :
-
+
if $(which init &> /dev/null); then
${csudo} init q || :
fi
@@ -298,10 +343,10 @@ function install_service_on_sysvinit() {
${csudo} cp -f ${script_dir}/../rpm/taosd ${install_main_dir}/init.d
${csudo} cp ${script_dir}/../rpm/taosd ${service_config_dir} && ${csudo} chmod a+x ${service_config_dir}/taosd
fi
-
+
#restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start"
#${csudo} grep -q -F "$restart_config_str" /etc/inittab || ${csudo} bash -c "echo '${restart_config_str}' >> /etc/inittab"
-
+
if ((${initd_mod}==1)); then
${csudo} chkconfig --add taosd || :
${csudo} chkconfig --level 2345 taosd on || :
@@ -323,7 +368,7 @@ function clean_service_on_systemd() {
${csudo} systemctl disable taosd &> /dev/null || echo &> /dev/null
${csudo} rm -f ${taosd_service_config}
-}
+}
# taos:2345:respawn:/etc/init.d/taosd start
@@ -383,7 +428,7 @@ function update_TDengine() {
sleep 1
fi
fi
-
+
install_main_path
install_log
@@ -431,16 +476,16 @@ function install_TDengine() {
# Start to install
if [ "$osType" != "Darwin" ]; then
echo -e "${GREEN}Start to install TDEngine...${NC}"
- else
- echo -e "${GREEN}Start to install TDEngine Client ...${NC}"
+ else
+ echo -e "${GREEN}Start to install TDEngine Client ...${NC}"
fi
- install_main_path
+ install_main_path
- if [ "$osType" != "Darwin" ]; then
+ if [ "$osType" != "Darwin" ]; then
install_data
fi
- install_log
+ install_log
install_header
install_lib
install_connector
@@ -452,7 +497,7 @@ function install_TDengine() {
install_service
fi
- install_config
+ install_config
if [ "$osType" != "Darwin" ]; then
# Ask if to start the service
diff --git a/packaging/tools/makepkg.sh b/packaging/tools/makepkg.sh
index e4d2d71b01..624f72278a 100755
--- a/packaging/tools/makepkg.sh
+++ b/packaging/tools/makepkg.sh
@@ -30,12 +30,12 @@ else
install_dir="${release_dir}/TDengine-server-${version}"
fi
-# Directories and files.
+# Directories and files
if [ "$pagMode" == "lite" ]; then
- strip ${build_dir}/bin/taosd
+ strip ${build_dir}/bin/taosd
strip ${build_dir}/bin/taos
bin_files="${build_dir}/bin/taosd ${build_dir}/bin/taos ${script_dir}/remove.sh"
-else
+else
bin_files="${build_dir}/bin/taosd ${build_dir}/bin/taos ${build_dir}/bin/taosdump ${build_dir}/bin/taosdemo ${build_dir}/bin/tarbitrator\
${script_dir}/remove.sh ${script_dir}/set_core.sh ${script_dir}/startPre.sh ${script_dir}/taosd-dump-cfg.gdb"
fi
@@ -73,10 +73,43 @@ mkdir -p ${install_dir}/init.d && cp ${init_file_rpm} ${install_dir}/init.d/taos
mkdir -p ${install_dir}/init.d && cp ${init_file_tarbitrator_deb} ${install_dir}/init.d/tarbitratord.deb || :
mkdir -p ${install_dir}/init.d && cp ${init_file_tarbitrator_rpm} ${install_dir}/init.d/tarbitratord.rpm || :
+if [ -f ${build_dir}/bin/jemalloc-config ]; then
+ mkdir -p ${install_dir}/jemalloc/{bin,lib,lib/pkgconfig,include/jemalloc,share/doc/jemalloc,share/man/man3}
+ cp ${build_dir}/bin/jemalloc-config ${install_dir}/jemalloc/bin
+ if [ -f ${build_dir}/bin/jemalloc.sh ]; then
+ cp ${build_dir}/bin/jemalloc.sh ${install_dir}/jemalloc/bin
+ fi
+ if [ -f ${build_dir}/bin/jeprof ]; then
+ cp ${build_dir}/bin/jeprof ${install_dir}/jemalloc/bin
+ fi
+ if [ -f ${build_dir}/include/jemalloc/jemalloc.h ]; then
+ cp ${build_dir}/include/jemalloc/jemalloc.h ${install_dir}/jemalloc/include/jemalloc
+ fi
+ if [ -f ${build_dir}/lib/libjemalloc.so.2 ]; then
+ cp ${build_dir}/lib/libjemalloc.so.2 ${install_dir}/jemalloc/lib
+ ln -sf libjemalloc.so.2 ${install_dir}/jemalloc/lib/libjemalloc.so
+ fi
+ if [ -f ${build_dir}/lib/libjemalloc.a ]; then
+ cp ${build_dir}/lib/libjemalloc.a ${install_dir}/jemalloc/lib
+ fi
+ if [ -f ${build_dir}/lib/libjemalloc_pic.a ]; then
+ cp ${build_dir}/lib/libjemalloc_pic.a ${install_dir}/jemalloc/lib
+ fi
+ if [ -f ${build_dir}/lib/pkgconfig/jemalloc.pc ]; then
+ cp ${build_dir}/lib/pkgconfig/jemalloc.pc ${install_dir}/jemalloc/lib/pkgconfig
+ fi
+ if [ -f ${build_dir}/share/doc/jemalloc/jemalloc.html ]; then
+ cp ${build_dir}/share/doc/jemalloc/jemalloc.html ${install_dir}/jemalloc/share/doc/jemalloc
+ fi
+ if [ -f ${build_dir}/share/man/man3/jemalloc.3 ]; then
+ cp ${build_dir}/share/man/man3/jemalloc.3 ${install_dir}/jemalloc/share/man/man3
+ fi
+fi
+
if [ "$verMode" == "cluster" ]; then
sed 's/verMode=edge/verMode=cluster/g' ${install_dir}/bin/remove.sh >> remove_temp.sh
mv remove_temp.sh ${install_dir}/bin/remove.sh
-
+
mkdir -p ${install_dir}/nginxd && cp -r ${nginx_dir}/* ${install_dir}/nginxd
cp ${nginx_dir}/png/taos.png ${install_dir}/nginxd/admin/images/taos.png
rm -rf ${install_dir}/nginxd/png
@@ -132,7 +165,7 @@ if [[ "$pagMode" != "lite" ]] && [[ "$cpuType" != "aarch32" ]]; then
if [ -d ${examples_dir}/JDBC/taosdemo/target ]; then
rm -rf ${examples_dir}/JDBC/taosdemo/target
fi
-
+
cp -r ${examples_dir}/JDBC ${install_dir}/examples
cp -r ${examples_dir}/matlab ${install_dir}/examples
cp -r ${examples_dir}/python ${install_dir}/examples
@@ -142,7 +175,7 @@ if [[ "$pagMode" != "lite" ]] && [[ "$cpuType" != "aarch32" ]]; then
cp -r ${examples_dir}/C# ${install_dir}/examples
fi
# Copy driver
-mkdir -p ${install_dir}/driver
+mkdir -p ${install_dir}/driver
cp ${lib_files} ${install_dir}/driver
# Copy connector
@@ -168,7 +201,7 @@ fi
# exit 1
-cd ${release_dir}
+cd ${release_dir}
if [ "$verMode" == "cluster" ]; then
pkg_name=${install_dir}-${osType}-${cpuType}
@@ -185,8 +218,8 @@ fi
if [ "$verType" == "beta" ]; then
pkg_name=${pkg_name}-${verType}
-elif [ "$verType" == "stable" ]; then
- pkg_name=${pkg_name}
+elif [ "$verType" == "stable" ]; then
+ pkg_name=${pkg_name}
else
echo "unknow verType, nor stabel or beta"
exit 1
diff --git a/src/client/inc/tscLocalMerge.h b/src/client/inc/tscGlobalmerge.h
similarity index 79%
rename from src/client/inc/tscLocalMerge.h
rename to src/client/inc/tscGlobalmerge.h
index 3c0bde0000..a462d78ff0 100644
--- a/src/client/inc/tscLocalMerge.h
+++ b/src/client/inc/tscGlobalmerge.h
@@ -13,8 +13,8 @@
* along with this program. If not, see .
*/
-#ifndef TDENGINE_TSCLOCALMERGE_H
-#define TDENGINE_TSCLOCALMERGE_H
+#ifndef TDENGINE_TSCGLOBALMERGE_H
+#define TDENGINE_TSCGLOBALMERGE_H
#ifdef __cplusplus
extern "C" {
@@ -24,7 +24,7 @@ extern "C" {
#include "qFill.h"
#include "taosmsg.h"
#include "tlosertree.h"
-#include "tsclient.h"
+#include "qExecutor.h"
#define MAX_NUM_OF_SUBQUERY_RETRY 3
@@ -38,7 +38,7 @@ typedef struct SLocalDataSource {
tFilePage filePage;
} SLocalDataSource;
-typedef struct SLocalMerger {
+typedef struct SGlobalMerger {
SLocalDataSource **pLocalDataSrc;
int32_t numOfBuffer;
int32_t numOfCompleted;
@@ -48,20 +48,22 @@ typedef struct SLocalMerger {
tOrderDescriptor *pDesc;
tExtMemBuffer **pExtMemBuffer; // disk-based buffer
char *buf; // temp buffer
-} SLocalMerger;
+} SGlobalMerger;
+
+struct SSqlObj;
typedef struct SRetrieveSupport {
tExtMemBuffer ** pExtMemBuffer; // for build loser tree
tOrderDescriptor *pOrderDescriptor;
int32_t subqueryIndex; // index of current vnode in vnode list
- SSqlObj * pParentSql;
+ struct SSqlObj *pParentSql;
tFilePage * localBuffer; // temp buffer, there is a buffer for each vnode to
uint32_t numOfRetry; // record the number of retry times
} SRetrieveSupport;
-int32_t tscLocalReducerEnvCreate(SQueryInfo* pQueryInfo, tExtMemBuffer ***pMemBuffer, int32_t numOfSub, tOrderDescriptor **pDesc, uint32_t nBufferSize, int64_t id);
+int32_t tscCreateGlobalMergerEnv(SQueryInfo* pQueryInfo, tExtMemBuffer ***pMemBuffer, int32_t numOfSub, tOrderDescriptor **pDesc, uint32_t nBufferSize, int64_t id);
-void tscLocalReducerEnvDestroy(tExtMemBuffer **pMemBuffer, tOrderDescriptor *pDesc, int32_t numOfVnodes);
+void tscDestroyGlobalMergerEnv(tExtMemBuffer **pMemBuffer, tOrderDescriptor *pDesc, int32_t numOfVnodes);
int32_t saveToBuffer(tExtMemBuffer *pMemoryBuf, tOrderDescriptor *pDesc, tFilePage *pPage, void *data,
int32_t numOfRows, int32_t orderType);
@@ -71,13 +73,13 @@ int32_t tscFlushTmpBuffer(tExtMemBuffer *pMemoryBuf, tOrderDescriptor *pDesc, tF
/*
* create local reducer to launch the second-stage reduce process at client site
*/
-int32_t tscCreateLocalMerger(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrderDescriptor *pDesc,
- SQueryInfo *pQueryInfo, SLocalMerger **pMerger, int64_t id);
+int32_t tscCreateGlobalMerger(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrderDescriptor *pDesc,
+ SQueryInfo *pQueryInfo, SGlobalMerger **pMerger, int64_t id);
-void tscDestroyLocalMerger(SLocalMerger* pLocalMerger);
+void tscDestroyGlobalMerger(SGlobalMerger* pMerger);
#ifdef __cplusplus
}
#endif
-#endif // TDENGINE_TSCLOCALMERGE_H
+#endif // TDENGINE_TSCGLOBALMERGE_H
diff --git a/src/client/inc/tscUtil.h b/src/client/inc/tscUtil.h
index 34dbd9b337..f747184ce0 100644
--- a/src/client/inc/tscUtil.h
+++ b/src/client/inc/tscUtil.h
@@ -20,13 +20,13 @@
extern "C" {
#endif
-#include "tsched.h"
#include "exception.h"
#include "os.h"
#include "qExtbuffer.h"
#include "taosdef.h"
#include "tbuffer.h"
-#include "tscLocalMerge.h"
+#include "tscGlobalmerge.h"
+#include "tsched.h"
#include "tsclient.h"
#define UTIL_TABLE_IS_SUPER_TABLE(metaInfo) \
@@ -63,7 +63,7 @@ typedef struct SJoinSupporter {
SArray* exprList;
SFieldInfo fieldsInfo;
STagCond tagCond;
- SGroupbyExpr groupInfo; // group by info
+ SGroupbyExpr groupInfo; // group by info
struct STSBuf* pTSBuf; // the TSBuf struct that holds the compressed timestamp array
FILE* f; // temporary file in order to create TSBuf
char path[PATH_MAX]; // temporary file path, todo dynamic allocate memory
@@ -110,7 +110,7 @@ void* tscDestroyBlockArrayList(SArray* pDataBlockList);
void* tscDestroyBlockHashTable(SHashObj* pBlockHashTable, bool removeMeta);
int32_t tscCopyDataBlockToPayload(SSqlObj* pSql, STableDataBlocks* pDataBlock);
-int32_t tscMergeTableDataBlocks(SSqlObj* pSql, bool freeBlockMap);
+int32_t tscMergeTableDataBlocks(SInsertStatementParam *pInsertParam, bool freeBlockMap);
int32_t tscGetDataBlockFromList(SHashObj* pHashList, int64_t id, int32_t size, int32_t startOffset, int32_t rowSize, SName* pName, STableMeta* pTableMeta,
STableDataBlocks** dataBlocks, SArray* pBlockList);
@@ -123,6 +123,8 @@ int32_t tscGetDataBlockFromList(SHashObj* pHashList, int64_t id, int32_t size, i
*/
bool tscIsPointInterpQuery(SQueryInfo* pQueryInfo);
bool tscIsTWAQuery(SQueryInfo* pQueryInfo);
+bool tscIsSessionWindowQuery(SQueryInfo* pQueryInfo);
+bool tscIsSecondStageQuery(SQueryInfo* pQueryInfo);
bool tsIsArithmeticQueryOnAggResult(SQueryInfo* pQueryInfo);
bool tscGroupbyColumn(SQueryInfo* pQueryInfo);
bool tscIsTopBotQuery(SQueryInfo* pQueryInfo);
@@ -284,6 +286,7 @@ void tscSVgroupInfoCopy(SVgroupInfo* dst, const SVgroupInfo* src);
SSqlObj* createSimpleSubObj(SSqlObj* pSql, __async_cb_func_t fp, void* param, int32_t cmd);
void registerSqlObj(SSqlObj* pSql);
+void tscInitResForMerge(SSqlRes* pRes);
SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, __async_cb_func_t fp, void* param, int32_t cmd, SSqlObj* pPrevSql);
void addGroupInfoForSubquery(SSqlObj* pParentObj, SSqlObj* pSql, int32_t subClauseIndex, int32_t tableIndex);
@@ -328,12 +331,15 @@ SVgroupsInfo* tscVgroupsInfoDup(SVgroupsInfo* pVgroupsInfo);
int32_t tscCreateQueryFromQueryInfo(SQueryInfo* pQueryInfo, SQueryAttr* pQueryAttr, void* addr);
void tsCreateSQLFunctionCtx(SQueryInfo* pQueryInfo, SQLFunctionCtx* pCtx, SSchema* pSchema);
-void* createQInfoFromQueryNode(SQueryInfo* pQueryInfo, SExprInfo* pExprs, STableGroupInfo* pTableGroupInfo, SOperatorInfo* pOperator, char* sql, void* addr, int32_t stage);
+void* createQInfoFromQueryNode(SQueryInfo* pQueryInfo, STableGroupInfo* pTableGroupInfo, SOperatorInfo* pOperator, char* sql, void* addr, int32_t stage);
void* malloc_throw(size_t size);
void* calloc_throw(size_t nmemb, size_t size);
char* strdup_throw(const char* str);
+bool vgroupInfoIdentical(SNewVgroupInfo *pExisted, SVgroupMsg* src);
+SNewVgroupInfo createNewVgroupInfo(SVgroupMsg *pVgroupMsg);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/client/inc/tschemautil.h b/src/client/inc/tschemautil.h
deleted file mode 100644
index 0026a27e19..0000000000
--- a/src/client/inc/tschemautil.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (c) 2019 TAOS Data, Inc.
- *
- * This program is free software: you can use, redistribute, and/or modify
- * it under the terms of the GNU Affero General Public License, version 3
- * or later ("AGPL"), as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-#ifndef TDENGINE_TSCHEMAUTIL_H
-#define TDENGINE_TSCHEMAUTIL_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "taosmsg.h"
-#include "tsclient.h"
-#include "ttoken.h"
-
-/**
- * get the number of tags of this table
- * @param pTableMeta
- * @return
- */
-int32_t tscGetNumOfTags(const STableMeta* pTableMeta);
-
-/**
- * get the number of columns of this table
- * @param pTableMeta
- * @return
- */
-int32_t tscGetNumOfColumns(const STableMeta* pTableMeta);
-
-/**
- * get the basic info of this table
- * @param pTableMeta
- * @return
- */
-STableComInfo tscGetTableInfo(const STableMeta* pTableMeta);
-
-/**
- * get the schema
- * @param pTableMeta
- * @return
- */
-SSchema* tscGetTableSchema(const STableMeta* pTableMeta);
-
-/**
- * get the tag schema
- * @param pMeta
- * @return
- */
-SSchema *tscGetTableTagSchema(const STableMeta *pMeta);
-
-/**
- * get the column schema according to the column index
- * @param pMeta
- * @param colIndex
- * @return
- */
-SSchema *tscGetTableColumnSchema(const STableMeta *pMeta, int32_t colIndex);
-
-/**
- * get the column schema according to the column id
- * @param pTableMeta
- * @param colId
- * @return
- */
-SSchema* tscGetColumnSchemaById(STableMeta* pTableMeta, int16_t colId);
-
-/**
- * create the table meta from the msg
- * @param pTableMetaMsg
- * @param size size of the table meta
- * @return
- */
-STableMeta* tscCreateTableMetaFromMsg(STableMetaMsg* pTableMetaMsg);
-
-bool vgroupInfoIdentical(SNewVgroupInfo *pExisted, SVgroupMsg* src);
-SNewVgroupInfo createNewVgroupInfo(SVgroupMsg *pVgroupMsg);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // TDENGINE_TSCHEMAUTIL_H
diff --git a/src/client/inc/tsclient.h b/src/client/inc/tsclient.h
index c1a85b6d27..67fd34ffd7 100644
--- a/src/client/inc/tsclient.h
+++ b/src/client/inc/tsclient.h
@@ -40,17 +40,9 @@ extern "C" {
// forward declaration
struct SSqlInfo;
-struct SLocalMerger;
typedef void (*__async_cb_func_t)(void *param, TAOS_RES *tres, int32_t numOfRows);
-typedef struct STableComInfo {
- uint8_t numOfTags;
- uint8_t precision;
- int16_t numOfColumns;
- int32_t rowSize;
-} STableComInfo;
-
typedef struct SNewVgroupInfo {
int32_t vgId;
int8_t inUse;
@@ -66,34 +58,6 @@ typedef struct CChildTableMeta {
uint64_t suid; // super table id
} CChildTableMeta;
-typedef struct STableMeta {
- int32_t vgId;
- STableId id;
- uint8_t tableType;
- char sTableName[TSDB_TABLE_FNAME_LEN]; // super table name
- uint64_t suid; // super table id
- int16_t sversion;
- int16_t tversion;
- STableComInfo tableInfo;
- SSchema schema[]; // if the table is TSDB_CHILD_TABLE, schema is acquired by super table meta info
-} STableMeta;
-
-typedef struct STableMetaInfo {
- STableMeta *pTableMeta; // table meta, cached in client side and acquired by name
- uint32_t tableMetaSize;
- SVgroupsInfo *vgroupList;
- SArray *pVgroupTables; // SArray
-
- /*
- * 1. keep the vgroup index during the multi-vnode super table projection query
- * 2. keep the vgroup index for multi-vnode insertion
- */
- int32_t vgroupIndex;
- SName name;
- char aliasName[TSDB_TABLE_NAME_LEN]; // alias name of table specified in query sql
- SArray *tagColList; // SArray, involved tag columns
-} STableMetaInfo;
-
typedef struct SColumnIndex {
int16_t tableIndex;
int16_t columnIndex;
@@ -111,44 +75,6 @@ typedef struct SInternalField {
SExprInfo *pExpr;
} SInternalField;
-typedef struct SFieldInfo {
- int16_t numOfOutput; // number of column in result
- TAOS_FIELD* final;
- SArray *internalField; // SArray
-} SFieldInfo;
-
-typedef struct SCond {
- uint64_t uid;
- int32_t len; // length of tag query condition data
- char * cond;
-} SCond;
-
-typedef struct SJoinNode {
- uint64_t uid;
- int16_t tagColId;
- SArray* tsJoin;
- SArray* tagJoin;
-} SJoinNode;
-
-typedef struct SJoinInfo {
- bool hasJoin;
- SJoinNode *joinTables[TSDB_MAX_JOIN_TABLE_NUM];
-} SJoinInfo;
-
-typedef struct STagCond {
- // relation between tbname list and query condition, including : TK_AND or TK_OR
- int16_t relType;
-
- // tbname query condition, only support tbname query condition on one table
- SCond tbnameCond;
-
- // join condition, only support two tables join currently
- SJoinInfo joinInfo;
-
- // for different table, the query condition must be seperated
- SArray *pCond;
-} STagCond;
-
typedef struct SParamInfo {
int32_t idx;
uint8_t type;
@@ -191,57 +117,6 @@ typedef struct STableDataBlocks {
SParamInfo *params;
} STableDataBlocks;
-typedef struct SQueryInfo {
- int16_t command; // the command may be different for each subclause, so keep it seperately.
- uint32_t type; // query/insert type
- STimeWindow window; // the whole query time window
-
- SInterval interval; // tumble time window
- SSessionWindow sessionWindow; // session time window
-
- SGroupbyExpr groupbyExpr; // groupby tags info
- SArray * colList; // SArray
- SFieldInfo fieldsInfo;
- SArray * exprList; // SArray
- SArray * exprList1; // final exprlist in case of arithmetic expression exists
- SLimitVal limit;
- SLimitVal slimit;
- STagCond tagCond;
-
- SOrderVal order;
- int16_t fillType; // final result fill type
- int16_t numOfTables;
- STableMetaInfo **pTableMetaInfo;
- struct STSBuf *tsBuf;
- int64_t * fillVal; // default value for fill
- char * msg; // pointer to the pCmd->payload to keep error message temporarily
- 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 vgroupLimit; // table limit in case of super table projection query + global order + limit
-
- int32_t udColumnId; // current user-defined constant output field column id, monotonically decreases from TSDB_UD_COLUMN_INDEX
- int16_t resColumnId; // result column id
- bool distinctTag; // distinct tag or not
- int32_t round; // 0/1/....
- int32_t bufLen;
- char* buf;
- SQInfo* pQInfo; // global merge operator
- SQueryAttr* pQueryAttr; // query object
-
- struct SQueryInfo *sibling; // sibling
- SArray *pUpstream; // SArray
- struct SQueryInfo *pDownstream;
- int32_t havingFieldNum;
- bool stableQuery;
- bool groupbyColumn;
- bool simpleAgg;
- bool arithmeticOnAgg;
- bool projectionQuery;
- bool hasFilter;
- bool onlyTagQuery;
-} SQueryInfo;
-
typedef struct {
STableMeta *pTableMeta;
SVgroupsInfo *pVgroupInfo;
@@ -255,9 +130,13 @@ typedef struct SInsertStatementParam {
int8_t schemaAttached; // denote if submit block is built with table schema or not
STagData tagData; // NOTE: pTagData->data is used as a variant length array
+ int32_t batchSize; // for parameter ('?') binding and batch processing
+ int32_t numOfParams;
+
char msg[512]; // error message
- char *sql; // current sql statement position
uint32_t insertType; // insert data from [file|sql statement| bound statement]
+ uint64_t objectId; // sql object id
+ char *sql; // current sql statement position
} SInsertStatementParam;
// TODO extract sql parser supporter
@@ -266,13 +145,9 @@ typedef struct {
uint8_t msgType;
SInsertStatementParam insertParam;
char reserve1[3]; // fix bus error on arm32
- union {
- int32_t count;
- };
+ int32_t count; // todo remove it
- char * curSql; // current sql, resume position of sql after parsing paused
char reserve2[3]; // fix bus error on arm32
-
int16_t numOfCols;
char reserve3[2]; // fix bus error on arm32
uint32_t allocSize;
@@ -283,8 +158,6 @@ typedef struct {
SQueryInfo *pQueryInfo;
SQueryInfo *active; // current active query info
int32_t batchSize; // for parameter ('?') binding and batch processing
- int32_t numOfParams;
- STagData tagData; // NOTE: pTagData->data is used as a variant length array
int32_t resColumnId;
} SSqlCmd;
@@ -320,7 +193,7 @@ typedef struct {
TAOS_FIELD* final;
SArithmeticSupport *pArithSup; // support the arithmetic expression calculation on agg functions
- struct SLocalMerger *pLocalMerger;
+ struct SGlobalMerger *pMerger;
} SSqlRes;
typedef struct {
@@ -447,7 +320,7 @@ void tscSetResRawPtr(SSqlRes* pRes, SQueryInfo* pQueryInfo);
void tscSetResRawPtrRv(SSqlRes* pRes, SQueryInfo* pQueryInfo, SSDataBlock* pBlock);
void handleDownstreamOperator(SSqlObj** pSqlList, int32_t numOfUpstream, SQueryInfo* px, SSqlRes* pOutput);
-void destroyTableNameList(SSqlCmd* pCmd);
+void destroyTableNameList(SInsertStatementParam* pInsertParam);
void tscResetSqlCmd(SSqlCmd *pCmd, bool removeMeta);
@@ -479,7 +352,7 @@ void waitForQueryRsp(void *param, TAOS_RES *tres, int code);
void doAsyncQuery(STscObj *pObj, SSqlObj *pSql, __async_cb_func_t fp, void *param, const char *sqlstr, size_t sqlLen);
void tscImportDataFromFile(SSqlObj *pSql);
-void tscInitResObjForLocalQuery(SSqlObj *pObj, int32_t numOfRes, int32_t rowLen);
+struct SGlobalMerger* tscInitResObjForLocalQuery(int32_t numOfRes, int32_t rowLen, uint64_t id);
bool tscIsUpdateQuery(SSqlObj* pSql);
char* tscGetSqlStr(SSqlObj* pSql);
bool tscIsQueryWithLimit(SSqlObj* pSql);
@@ -489,7 +362,7 @@ void tscSetBoundColumnInfo(SParsedDataColInfo *pColInfo, SSchema *pSchema, int32
char *tscGetErrorMsgPayload(SSqlCmd *pCmd);
-int32_t tscInvalidSQLErrMsg(char *msg, const char *additionalInfo, const char *sql);
+int32_t tscInvalidOperationMsg(char *msg, const char *additionalInfo, const char *sql);
int32_t tscSQLSyntaxErrMsg(char* msg, const char* additionalInfo, const char* sql);
int32_t tscValidateSqlInfo(SSqlObj *pSql, struct SSqlInfo *pInfo);
diff --git a/src/client/src/tscAsync.c b/src/client/src/tscAsync.c
index 47798f4e33..15276a3888 100644
--- a/src/client/src/tscAsync.c
+++ b/src/client/src/tscAsync.c
@@ -22,7 +22,7 @@
#include "tscSubquery.h"
#include "tscUtil.h"
#include "tsched.h"
-#include "tschemautil.h"
+#include "qTableMeta.h"
#include "tsclient.h"
static void tscAsyncQueryRowsForNextVnode(void *param, TAOS_RES *tres, int numOfRows);
@@ -58,7 +58,6 @@ void doAsyncQuery(STscObj* pObj, SSqlObj* pSql, __async_cb_func_t fp, void* para
strntolower(pSql->sqlstr, sqlstr, (int32_t)sqlLen);
tscDebugL("0x%"PRIx64" SQL: %s", pSql->self, pSql->sqlstr);
- pCmd->curSql = pSql->sqlstr;
pCmd->resColumnId = TSDB_RES_COL_ID;
int32_t code = tsParseSql(pSql, true);
@@ -221,7 +220,7 @@ void taos_fetch_rows_a(TAOS_RES *tres, __async_cb_func_t fp, void *param) {
tscResetForNextRetrieve(pRes);
- // handle the sub queries of join query
+ // handle outer query based on the already retrieved nest query results.
SQueryInfo* pQueryInfo = tscGetQueryInfo(pCmd);
if (pQueryInfo->pUpstream != NULL && taosArrayGetSize(pQueryInfo->pUpstream) > 0) {
SSchedMsg schedMsg = {0};
diff --git a/src/client/src/tscLocalMerge.c b/src/client/src/tscGlobalmerge.c
similarity index 90%
rename from src/client/src/tscLocalMerge.c
rename to src/client/src/tscGlobalmerge.c
index 77a4c7fb46..d835b37c24 100644
--- a/src/client/src/tscLocalMerge.c
+++ b/src/client/src/tscGlobalmerge.c
@@ -13,15 +13,19 @@
* along with this program. If not, see .
*/
-#include "tscLocalMerge.h"
-#include "tscSubquery.h"
#include "os.h"
#include "texpr.h"
#include "tlosertree.h"
+
+#include "tscGlobalmerge.h"
+#include "tscSubquery.h"
#include "tscLog.h"
-#include "tsclient.h"
#include "qUtil.h"
+#define COLMODEL_GET_VAL(data, schema, rowId, colId) \
+ (data + (schema)->pFields[colId].offset * ((schema)->capacity) + (rowId) * (schema)->pFields[colId].field.bytes)
+
+
typedef struct SCompareParam {
SLocalDataSource **pLocalData;
tOrderDescriptor * pDesc;
@@ -29,9 +33,18 @@ typedef struct SCompareParam {
int32_t groupOrderType;
} SCompareParam;
-bool needToMergeRv(SSDataBlock* pBlock, SArray* columnIndex, int32_t index, char **buf);
+static bool needToMerge(SSDataBlock* pBlock, SArray* columnIndexList, int32_t index, char **buf) {
+ int32_t ret = 0;
+ size_t size = taosArrayGetSize(columnIndexList);
+ if (size > 0) {
+ ret = compare_aRv(pBlock, columnIndexList, (int32_t) size, index, buf, TSDB_ORDER_ASC);
+ }
-int32_t treeComparator(const void *pLeft, const void *pRight, void *param) {
+ // if ret == 0, means the result belongs to the same group
+ return (ret == 0);
+}
+
+static int32_t treeComparator(const void *pLeft, const void *pRight, void *param) {
int32_t pLeftIdx = *(int32_t *)pLeft;
int32_t pRightIdx = *(int32_t *)pRight;
@@ -57,16 +70,16 @@ int32_t treeComparator(const void *pLeft, const void *pRight, void *param) {
}
}
-int32_t tscCreateLocalMerger(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrderDescriptor *pDesc,
- SQueryInfo* pQueryInfo, SLocalMerger **pMerger, int64_t id) {
+int32_t tscCreateGlobalMerger(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrderDescriptor *pDesc,
+ SQueryInfo* pQueryInfo, SGlobalMerger **pMerger, int64_t id) {
if (pMemBuffer == NULL) {
- tscLocalReducerEnvDestroy(pMemBuffer, pDesc, numOfBuffer);
+ tscDestroyGlobalMergerEnv(pMemBuffer, pDesc, numOfBuffer);
tscError("0x%"PRIx64" %p pMemBuffer is NULL", id, pMemBuffer);
return TSDB_CODE_TSC_APP_ERROR;
}
if (pDesc->pColumnModel == NULL) {
- tscLocalReducerEnvDestroy(pMemBuffer, pDesc, numOfBuffer);
+ tscDestroyGlobalMergerEnv(pMemBuffer, pDesc, numOfBuffer);
tscError("0x%"PRIx64" no local buffer or intermediate result format model", id);
return TSDB_CODE_TSC_APP_ERROR;
}
@@ -83,7 +96,7 @@ int32_t tscCreateLocalMerger(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tO
}
if (numOfFlush == 0 || numOfBuffer == 0) {
- tscLocalReducerEnvDestroy(pMemBuffer, pDesc, numOfBuffer);
+ tscDestroyGlobalMergerEnv(pMemBuffer, pDesc, numOfBuffer);
tscDebug("0x%"PRIx64" no data to retrieve", id);
return TSDB_CODE_SUCCESS;
}
@@ -92,15 +105,15 @@ int32_t tscCreateLocalMerger(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tO
tscError("0x%"PRIx64" Invalid value of buffer capacity %d and page size %d ", id, pDesc->pColumnModel->capacity,
pMemBuffer[0]->pageSize);
- tscLocalReducerEnvDestroy(pMemBuffer, pDesc, numOfBuffer);
+ tscDestroyGlobalMergerEnv(pMemBuffer, pDesc, numOfBuffer);
return TSDB_CODE_TSC_APP_ERROR;
}
- *pMerger = (SLocalMerger *) calloc(1, sizeof(SLocalMerger));
+ *pMerger = (SGlobalMerger *) calloc(1, sizeof(SGlobalMerger));
if ((*pMerger) == NULL) {
tscError("0x%"PRIx64" failed to create local merge structure, out of memory", id);
- tscLocalReducerEnvDestroy(pMemBuffer, pDesc, numOfBuffer);
+ tscDestroyGlobalMergerEnv(pMemBuffer, pDesc, numOfBuffer);
return TSDB_CODE_TSC_OUT_OF_MEMORY;
}
@@ -160,7 +173,7 @@ int32_t tscCreateLocalMerger(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tO
// no data actually, no need to merge result.
if (idx == 0) {
tscDebug("0x%"PRIx64" retrieved no data", id);
- tscLocalReducerEnvDestroy(pMemBuffer, pDesc, numOfBuffer);
+ tscDestroyGlobalMergerEnv(pMemBuffer, pDesc, numOfBuffer);
return TSDB_CODE_SUCCESS;
}
@@ -198,7 +211,7 @@ int32_t tscCreateLocalMerger(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tO
}
// restore the limitation value at the last stage
- if (tscOrderedProjectionQueryOnSTable(pQueryInfo, 0)) {
+ if (pQueryInfo->orderProjectQuery) {
pQueryInfo->limit.limit = pQueryInfo->clauseLimit;
pQueryInfo->limit.offset = pQueryInfo->prjOffset;
}
@@ -297,28 +310,28 @@ int32_t saveToBuffer(tExtMemBuffer *pMemoryBuf, tOrderDescriptor *pDesc, tFilePa
return 0;
}
-void tscDestroyLocalMerger(SLocalMerger* pLocalMerger) {
- if (pLocalMerger == NULL) {
+void tscDestroyGlobalMerger(SGlobalMerger* pMerger) {
+ if (pMerger == NULL) {
return;
}
- for (int32_t i = 0; i < pLocalMerger->numOfBuffer; ++i) {
- tfree(pLocalMerger->pLocalDataSrc[i]);
+ for (int32_t i = 0; i < pMerger->numOfBuffer; ++i) {
+ tfree(pMerger->pLocalDataSrc[i]);
}
- pLocalMerger->numOfBuffer = 0;
- tscLocalReducerEnvDestroy(pLocalMerger->pExtMemBuffer, pLocalMerger->pDesc, pLocalMerger->numOfVnode);
+ pMerger->numOfBuffer = 0;
+ tscDestroyGlobalMergerEnv(pMerger->pExtMemBuffer, pMerger->pDesc, pMerger->numOfVnode);
- pLocalMerger->numOfCompleted = 0;
+ pMerger->numOfCompleted = 0;
- if (pLocalMerger->pLoserTree) {
- tfree(pLocalMerger->pLoserTree->param);
- tfree(pLocalMerger->pLoserTree);
+ if (pMerger->pLoserTree) {
+ tfree(pMerger->pLoserTree->param);
+ tfree(pMerger->pLoserTree);
}
- tfree(pLocalMerger->buf);
- tfree(pLocalMerger->pLocalDataSrc);
- free(pLocalMerger);
+ tfree(pMerger->buf);
+ tfree(pMerger->pLocalDataSrc);
+ free(pMerger);
}
static int32_t createOrderDescriptor(tOrderDescriptor **pOrderDesc, SQueryInfo* pQueryInfo, SColumnModel *pModel) {
@@ -329,7 +342,7 @@ static int32_t createOrderDescriptor(tOrderDescriptor **pOrderDesc, SQueryInfo*
}
// primary timestamp column is involved in final result
- if (pQueryInfo->interval.interval != 0 || tscOrderedProjectionQueryOnSTable(pQueryInfo, 0)) {
+ if (pQueryInfo->interval.interval != 0 || pQueryInfo->orderProjectQuery) {
numOfGroupByCols++;
}
@@ -392,7 +405,7 @@ static int32_t createOrderDescriptor(tOrderDescriptor **pOrderDesc, SQueryInfo*
}
}
-int32_t tscLocalReducerEnvCreate(SQueryInfo *pQueryInfo, tExtMemBuffer ***pMemBuffer, int32_t numOfSub,
+int32_t tscCreateGlobalMergerEnv(SQueryInfo *pQueryInfo, tExtMemBuffer ***pMemBuffer, int32_t numOfSub,
tOrderDescriptor **pOrderDesc, uint32_t nBufferSizes, int64_t id) {
SSchema *pSchema = NULL;
SColumnModel *pModel = NULL;
@@ -456,7 +469,7 @@ int32_t tscLocalReducerEnvCreate(SQueryInfo *pQueryInfo, tExtMemBuffer ***pMemBu
* @param pDesc
* @param numOfVnodes
*/
-void tscLocalReducerEnvDestroy(tExtMemBuffer **pMemBuffer, tOrderDescriptor *pDesc, int32_t numOfVnodes) {
+void tscDestroyGlobalMergerEnv(tExtMemBuffer **pMemBuffer, tOrderDescriptor *pDesc, int32_t numOfVnodes) {
tOrderDescDestroy(pDesc);
for (int32_t i = 0; i < numOfVnodes; ++i) {
pMemBuffer[i] = destoryExtMemBuffer(pMemBuffer[i]);
@@ -467,12 +480,12 @@ void tscLocalReducerEnvDestroy(tExtMemBuffer **pMemBuffer, tOrderDescriptor *pDe
/**
*
- * @param pLocalMerge
+ * @param pMerger
* @param pOneInterDataSrc
* @param treeList
* @return the number of remain input source. if ret == 0, all data has been handled
*/
-int32_t loadNewDataFromDiskFor(SLocalMerger *pLocalMerge, SLocalDataSource *pOneInterDataSrc,
+int32_t loadNewDataFromDiskFor(SGlobalMerger *pMerger, SLocalDataSource *pOneInterDataSrc,
bool *needAdjustLoserTree) {
pOneInterDataSrc->rowIdx = 0;
pOneInterDataSrc->pageId += 1;
@@ -489,17 +502,17 @@ int32_t loadNewDataFromDiskFor(SLocalMerger *pLocalMerge, SLocalDataSource *pOne
#endif
*needAdjustLoserTree = true;
} else {
- pLocalMerge->numOfCompleted += 1;
+ pMerger->numOfCompleted += 1;
pOneInterDataSrc->rowIdx = -1;
pOneInterDataSrc->pageId = -1;
*needAdjustLoserTree = true;
}
- return pLocalMerge->numOfBuffer;
+ return pMerger->numOfBuffer;
}
-void adjustLoserTreeFromNewData(SLocalMerger *pLocalMerge, SLocalDataSource *pOneInterDataSrc,
+void adjustLoserTreeFromNewData(SGlobalMerger *pMerger, SLocalDataSource *pOneInterDataSrc,
SLoserTreeInfo *pTree) {
/*
* load a new data page into memory for intermediate dataset source,
@@ -507,7 +520,7 @@ void adjustLoserTreeFromNewData(SLocalMerger *pLocalMerge, SLocalDataSource *pOn
*/
bool needToAdjust = true;
if (pOneInterDataSrc->filePage.num <= pOneInterDataSrc->rowIdx) {
- loadNewDataFromDiskFor(pLocalMerge, pOneInterDataSrc, &needToAdjust);
+ loadNewDataFromDiskFor(pMerger, pOneInterDataSrc, &needToAdjust);
}
/*
@@ -515,7 +528,7 @@ void adjustLoserTreeFromNewData(SLocalMerger *pLocalMerge, SLocalDataSource *pOn
* if the loser tree is rebuild completed, we do not need to adjust
*/
if (needToAdjust) {
- int32_t leafNodeIdx = pTree->pNode[0].index + pLocalMerge->numOfBuffer;
+ int32_t leafNodeIdx = pTree->pNode[0].index + pMerger->numOfBuffer;
#ifdef _DEBUG_VIEW
printf("before adjust:\t");
@@ -567,7 +580,7 @@ static void setTagValueForMultipleRows(SQLFunctionCtx* pCtx, int32_t numOfOutput
}
}
-static void doExecuteFinalMergeRv(SOperatorInfo* pOperator, int32_t numOfExpr, SSDataBlock* pBlock) {
+static void doExecuteFinalMerge(SOperatorInfo* pOperator, int32_t numOfExpr, SSDataBlock* pBlock) {
SMultiwayMergeInfo* pInfo = pOperator->info;
SQLFunctionCtx* pCtx = pInfo->binfo.pCtx;
@@ -579,7 +592,7 @@ static void doExecuteFinalMergeRv(SOperatorInfo* pOperator, int32_t numOfExpr, S
for(int32_t i = 0; i < pBlock->info.rows; ++i) {
if (pInfo->hasPrev) {
- if (needToMergeRv(pBlock, pInfo->orderColumnList, i, pInfo->prevRow)) {
+ if (needToMerge(pBlock, pInfo->orderColumnList, i, pInfo->prevRow)) {
for (int32_t j = 0; j < numOfExpr; ++j) {
pCtx[j].pInput = add[j] + pCtx[j].inputBytes * i;
}
@@ -654,45 +667,27 @@ static void doExecuteFinalMergeRv(SOperatorInfo* pOperator, int32_t numOfExpr, S
tfree(add);
}
-bool needToMergeRv(SSDataBlock* pBlock, SArray* columnIndexList, int32_t index, char **buf) {
- int32_t ret = 0;
- size_t size = taosArrayGetSize(columnIndexList);
- if (size > 0) {
- ret = compare_aRv(pBlock, columnIndexList, (int32_t) size, index, buf, TSDB_ORDER_ASC);
- }
-
- // if ret == 0, means the result belongs to the same group
- return (ret == 0);
+static bool isAllSourcesCompleted(SGlobalMerger *pMerger) {
+ return (pMerger->numOfBuffer == pMerger->numOfCompleted);
}
-static bool isAllSourcesCompleted(SLocalMerger *pLocalMerge) {
- return (pLocalMerge->numOfBuffer == pLocalMerge->numOfCompleted);
-}
-
-void tscInitResObjForLocalQuery(SSqlObj *pSql, int32_t numOfRes, int32_t rowLen) {
- SSqlRes *pRes = &pSql->res;
- if (pRes->pLocalMerger != NULL) {
- tscDestroyLocalMerger(pRes->pLocalMerger);
- pRes->pLocalMerger = NULL;
- tscDebug("0x%"PRIx64" free local reducer finished", pSql->self);
+SGlobalMerger* tscInitResObjForLocalQuery(int32_t numOfRes, int32_t rowLen, uint64_t id) {
+ SGlobalMerger *pMerger = calloc(1, sizeof(SGlobalMerger));
+ if (pMerger == NULL) {
+ tscDebug("0x%"PRIx64" free local reducer finished", id);
+ return NULL;
}
- pRes->qId = 1; // hack to pass the safety check in fetch_row function
- pRes->numOfRows = 0;
- pRes->row = 0;
-
- pRes->rspType = 0; // used as a flag to denote if taos_retrieved() has been called yet
- pRes->pLocalMerger = (SLocalMerger *)calloc(1, sizeof(SLocalMerger));
-
/*
* One more byte space is required, since the sprintf function needs one additional space to put '\0' at
* the end of string
*/
size_t size = numOfRes * rowLen + 1;
- pRes->pLocalMerger->buf = calloc(1, size);
- pRes->data = pRes->pLocalMerger->buf;
+ pMerger->buf = calloc(1, size);
+ return pMerger;
}
+// todo remove it
int32_t doArithmeticCalculate(SQueryInfo* pQueryInfo, tFilePage* pOutput, int32_t rowSize, int32_t finalRowSize) {
int32_t maxRowSize = MAX(rowSize, finalRowSize);
char* pbuf = calloc(1, (size_t)(pOutput->num * maxRowSize));
@@ -736,9 +731,6 @@ int32_t doArithmeticCalculate(SQueryInfo* pQueryInfo, tFilePage* pOutput, int32_
return offset;
}
-#define COLMODEL_GET_VAL(data, schema, rowId, colId) \
- (data + (schema)->pFields[colId].offset * ((schema)->capacity) + (rowId) * (schema)->pFields[colId].field.bytes)
-
static void appendOneRowToDataBlock(SSDataBlock *pBlock, char *buf, SColumnModel *pModel, int32_t rowIndex,
int32_t maxRows) {
for (int32_t i = 0; i < pBlock->info.numOfCols; ++i) {
@@ -760,7 +752,7 @@ SSDataBlock* doMultiwayMergeSort(void* param, bool* newgroup) {
SMultiwayMergeInfo *pInfo = pOperator->info;
- SLocalMerger *pMerger = pInfo->pMerge;
+ SGlobalMerger *pMerger = pInfo->pMerge;
SLoserTreeInfo *pTree = pMerger->pLoserTree;
pInfo->binfo.pRes->info.rows = 0;
@@ -844,7 +836,7 @@ SSDataBlock* doMultiwayMergeSort(void* param, bool* newgroup) {
return (pInfo->binfo.pRes->info.rows > 0)? pInfo->binfo.pRes:NULL;
}
-static bool isSameGroupRv(SArray* orderColumnList, SSDataBlock* pBlock, char** dataCols) {
+static bool isSameGroup(SArray* orderColumnList, SSDataBlock* pBlock, char** dataCols) {
int32_t numOfCols = (int32_t) taosArrayGetSize(orderColumnList);
for (int32_t i = 0; i < numOfCols; ++i) {
SColIndex *pIndex = taosArrayGet(orderColumnList, i);
@@ -892,7 +884,7 @@ SSDataBlock* doGlobalAggregate(void* param, bool* newgroup) {
}
}
- doExecuteFinalMergeRv(pOperator, pOperator->numOfOutput, pAggInfo->pExistBlock);
+ doExecuteFinalMerge(pOperator, pOperator->numOfOutput, pAggInfo->pExistBlock);
savePrevOrderColumns(pAggInfo->currentGroupColData, pAggInfo->groupColumnList, pAggInfo->pExistBlock, 0,
&pAggInfo->hasGroupColData);
@@ -913,7 +905,7 @@ SSDataBlock* doGlobalAggregate(void* param, bool* newgroup) {
}
if (pAggInfo->hasGroupColData) {
- bool sameGroup = isSameGroupRv(pAggInfo->groupColumnList, pBlock, pAggInfo->currentGroupColData);
+ bool sameGroup = isSameGroup(pAggInfo->groupColumnList, pBlock, pAggInfo->currentGroupColData);
if (!sameGroup) {
*newgroup = true;
pAggInfo->hasDataBlockForNewGroup = true;
@@ -927,7 +919,7 @@ SSDataBlock* doGlobalAggregate(void* param, bool* newgroup) {
setInputDataBlock(pOperator, pAggInfo->binfo.pCtx, pBlock, TSDB_ORDER_ASC);
updateOutputBuf(&pAggInfo->binfo, &pAggInfo->bufCapacity, pBlock->info.rows * pAggInfo->resultRowFactor);
- doExecuteFinalMergeRv(pOperator, pOperator->numOfOutput, pBlock);
+ doExecuteFinalMerge(pOperator, pOperator->numOfOutput, pBlock);
savePrevOrderColumns(pAggInfo->currentGroupColData, pAggInfo->groupColumnList, pBlock, 0, &pAggInfo->hasGroupColData);
handleData = true;
}
diff --git a/src/client/src/tscLocal.c b/src/client/src/tscLocal.c
index abac2407fb..f97f54a626 100644
--- a/src/client/src/tscLocal.c
+++ b/src/client/src/tscLocal.c
@@ -20,7 +20,7 @@
#include "tname.h"
#include "tscLog.h"
#include "tscUtil.h"
-#include "tschemautil.h"
+#include "qTableMeta.h"
#include "tsclient.h"
#include "taos.h"
#include "tscSubquery.h"
@@ -71,7 +71,9 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
numOfRows = numOfRows + tscGetNumOfTags(pMeta);
}
- tscInitResObjForLocalQuery(pSql, totalNumOfRows, rowLen);
+ pSql->res.pMerger = tscInitResObjForLocalQuery(totalNumOfRows, rowLen, pSql->self);
+ tscInitResForMerge(&pSql->res);
+
SSchema *pSchema = tscGetTableSchema(pMeta);
for (int32_t i = 0; i < numOfRows; ++i) {
@@ -433,7 +435,8 @@ static int32_t tscSCreateSetValueToResObj(SSqlObj *pSql, int32_t rowLen, const c
if (strlen(ddl) == 0) {
}
- tscInitResObjForLocalQuery(pSql, numOfRows, rowLen);
+ pSql->res.pMerger = tscInitResObjForLocalQuery(numOfRows, rowLen, pSql->self);
+ tscInitResForMerge(&pSql->res);
TAOS_FIELD *pField = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, 0);
char* dst = pRes->data + tscFieldInfoGetOffset(pQueryInfo, 0) * numOfRows;
@@ -882,7 +885,8 @@ void tscSetLocalQueryResult(SSqlObj *pSql, const char *val, const char *columnNa
TAOS_FIELD f = tscCreateField((int8_t)type, columnName, (int16_t)valueLength);
tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f);
- tscInitResObjForLocalQuery(pSql, 1, (int32_t)valueLength);
+ pSql->res.pMerger = tscInitResObjForLocalQuery(1, (int32_t)valueLength, pSql->self);
+ tscInitResForMerge(&pSql->res);
SInternalField* pInfo = tscFieldInfoGetInternalField(&pQueryInfo->fieldsInfo, 0);
pInfo->pExpr = taosArrayGetP(pQueryInfo->exprList, 0);
diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c
index cc89fd6220..cd9853df03 100644
--- a/src/client/src/tscParseInsert.c
+++ b/src/client/src/tscParseInsert.c
@@ -23,7 +23,7 @@
#include "ttype.h"
#include "hash.h"
#include "tscUtil.h"
-#include "tschemautil.h"
+#include "qTableMeta.h"
#include "tsclient.h"
#include "ttokendef.h"
#include "taosdef.h"
@@ -38,8 +38,9 @@ enum {
TSDB_USE_CLI_TS = 1,
};
-static int32_t tscAllocateMemIfNeed(STableDataBlocks *pDataBlock, int32_t rowSize, int32_t * numOfRows);
-static int32_t parseBoundColumns(SSqlCmd* pCmd, SParsedDataColInfo* pColInfo, SSchema* pSchema, char* str, char** end);
+static int32_t tscAllocateMemIfNeed(STableDataBlocks *pDataBlock, int32_t rowSize, int32_t *numOfRows);
+static int32_t parseBoundColumns(SInsertStatementParam *pInsertParam, SParsedDataColInfo *pColInfo, SSchema *pSchema,
+ char *str, char **end);
static int32_t tscToDouble(SStrToken *pToken, double *value, char **endPtr) {
errno = 0;
@@ -71,7 +72,7 @@ int tsParseTime(SStrToken *pToken, int64_t *time, char **next, char *error, int1
} else {
// strptime("2001-11-12 18:31:01", "%Y-%m-%d %H:%M:%S", &tm);
if (taosParseTime(pToken->z, time, pToken->n, timePrec, tsDaylight) != TSDB_CODE_SUCCESS) {
- return tscInvalidSQLErrMsg(error, "invalid timestamp format", pToken->z);
+ return tscInvalidOperationMsg(error, "invalid timestamp format", pToken->z);
}
return TSDB_CODE_SUCCESS;
@@ -103,7 +104,7 @@ int tsParseTime(SStrToken *pToken, int64_t *time, char **next, char *error, int1
pTokenEnd += index;
if (valueToken.n < 2) {
- return tscInvalidSQLErrMsg(error, "value expected in timestamp", sToken.z);
+ return tscInvalidOperationMsg(error, "value expected in timestamp", sToken.z);
}
if (parseAbsoluteDuration(valueToken.z, valueToken.n, &interval) != TSDB_CODE_SUCCESS) {
@@ -138,7 +139,7 @@ int32_t tsParseOneColumn(SSchema *pSchema, SStrToken *pToken, char *payload, cha
char *endptr = NULL;
if (IS_NUMERIC_TYPE(pSchema->type) && pToken->n == 0) {
- return tscInvalidSQLErrMsg(msg, "invalid numeric data", pToken->z);
+ return tscInvalidOperationMsg(msg, "invalid numeric data", pToken->z);
}
switch (pSchema->type) {
@@ -161,7 +162,7 @@ int32_t tsParseOneColumn(SSchema *pSchema, SStrToken *pToken, char *payload, cha
double dv = strtod(pToken->z, NULL);
*(uint8_t *)payload = (int8_t)((dv == 0) ? TSDB_FALSE : TSDB_TRUE);
} else {
- return tscInvalidSQLErrMsg(msg, "invalid bool data", pToken->z);
+ return tscInvalidOperationMsg(msg, "invalid bool data", pToken->z);
}
}
break;
@@ -173,9 +174,9 @@ int32_t tsParseOneColumn(SSchema *pSchema, SStrToken *pToken, char *payload, cha
} else {
ret = tStrToInteger(pToken->z, pToken->type, pToken->n, &iv, true);
if (ret != TSDB_CODE_SUCCESS) {
- return tscInvalidSQLErrMsg(msg, "invalid tinyint data", pToken->z);
+ return tscInvalidOperationMsg(msg, "invalid tinyint data", pToken->z);
} else if (!IS_VALID_TINYINT(iv)) {
- return tscInvalidSQLErrMsg(msg, "data overflow", pToken->z);
+ return tscInvalidOperationMsg(msg, "data overflow", pToken->z);
}
*((uint8_t *)payload) = (uint8_t)iv;
@@ -189,9 +190,9 @@ int32_t tsParseOneColumn(SSchema *pSchema, SStrToken *pToken, char *payload, cha
} else {
ret = tStrToInteger(pToken->z, pToken->type, pToken->n, &iv, false);
if (ret != TSDB_CODE_SUCCESS) {
- return tscInvalidSQLErrMsg(msg, "invalid unsigned tinyint data", pToken->z);
+ return tscInvalidOperationMsg(msg, "invalid unsigned tinyint data", pToken->z);
} else if (!IS_VALID_UTINYINT(iv)) {
- return tscInvalidSQLErrMsg(msg, "unsigned tinyint data overflow", pToken->z);
+ return tscInvalidOperationMsg(msg, "unsigned tinyint data overflow", pToken->z);
}
*((uint8_t *)payload) = (uint8_t)iv;
@@ -205,9 +206,9 @@ int32_t tsParseOneColumn(SSchema *pSchema, SStrToken *pToken, char *payload, cha
} else {
ret = tStrToInteger(pToken->z, pToken->type, pToken->n, &iv, true);
if (ret != TSDB_CODE_SUCCESS) {
- return tscInvalidSQLErrMsg(msg, "invalid smallint data", pToken->z);
+ return tscInvalidOperationMsg(msg, "invalid smallint data", pToken->z);
} else if (!IS_VALID_SMALLINT(iv)) {
- return tscInvalidSQLErrMsg(msg, "smallint data overflow", pToken->z);
+ return tscInvalidOperationMsg(msg, "smallint data overflow", pToken->z);
}
*((int16_t *)payload) = (int16_t)iv;
@@ -221,9 +222,9 @@ int32_t tsParseOneColumn(SSchema *pSchema, SStrToken *pToken, char *payload, cha
} else {
ret = tStrToInteger(pToken->z, pToken->type, pToken->n, &iv, false);
if (ret != TSDB_CODE_SUCCESS) {
- return tscInvalidSQLErrMsg(msg, "invalid unsigned smallint data", pToken->z);
+ return tscInvalidOperationMsg(msg, "invalid unsigned smallint data", pToken->z);
} else if (!IS_VALID_USMALLINT(iv)) {
- return tscInvalidSQLErrMsg(msg, "unsigned smallint data overflow", pToken->z);
+ return tscInvalidOperationMsg(msg, "unsigned smallint data overflow", pToken->z);
}
*((uint16_t *)payload) = (uint16_t)iv;
@@ -237,9 +238,9 @@ int32_t tsParseOneColumn(SSchema *pSchema, SStrToken *pToken, char *payload, cha
} else {
ret = tStrToInteger(pToken->z, pToken->type, pToken->n, &iv, true);
if (ret != TSDB_CODE_SUCCESS) {
- return tscInvalidSQLErrMsg(msg, "invalid int data", pToken->z);
+ return tscInvalidOperationMsg(msg, "invalid int data", pToken->z);
} else if (!IS_VALID_INT(iv)) {
- return tscInvalidSQLErrMsg(msg, "int data overflow", pToken->z);
+ return tscInvalidOperationMsg(msg, "int data overflow", pToken->z);
}
*((int32_t *)payload) = (int32_t)iv;
@@ -253,9 +254,9 @@ int32_t tsParseOneColumn(SSchema *pSchema, SStrToken *pToken, char *payload, cha
} else {
ret = tStrToInteger(pToken->z, pToken->type, pToken->n, &iv, false);
if (ret != TSDB_CODE_SUCCESS) {
- return tscInvalidSQLErrMsg(msg, "invalid unsigned int data", pToken->z);
+ return tscInvalidOperationMsg(msg, "invalid unsigned int data", pToken->z);
} else if (!IS_VALID_UINT(iv)) {
- return tscInvalidSQLErrMsg(msg, "unsigned int data overflow", pToken->z);
+ return tscInvalidOperationMsg(msg, "unsigned int data overflow", pToken->z);
}
*((uint32_t *)payload) = (uint32_t)iv;
@@ -269,9 +270,9 @@ int32_t tsParseOneColumn(SSchema *pSchema, SStrToken *pToken, char *payload, cha
} else {
ret = tStrToInteger(pToken->z, pToken->type, pToken->n, &iv, true);
if (ret != TSDB_CODE_SUCCESS) {
- return tscInvalidSQLErrMsg(msg, "invalid bigint data", pToken->z);
+ return tscInvalidOperationMsg(msg, "invalid bigint data", pToken->z);
} else if (!IS_VALID_BIGINT(iv)) {
- return tscInvalidSQLErrMsg(msg, "bigint data overflow", pToken->z);
+ return tscInvalidOperationMsg(msg, "bigint data overflow", pToken->z);
}
*((int64_t *)payload) = iv;
@@ -284,9 +285,9 @@ int32_t tsParseOneColumn(SSchema *pSchema, SStrToken *pToken, char *payload, cha
} else {
ret = tStrToInteger(pToken->z, pToken->type, pToken->n, &iv, false);
if (ret != TSDB_CODE_SUCCESS) {
- return tscInvalidSQLErrMsg(msg, "invalid unsigned bigint data", pToken->z);
+ return tscInvalidOperationMsg(msg, "invalid unsigned bigint data", pToken->z);
} else if (!IS_VALID_UBIGINT((uint64_t)iv)) {
- return tscInvalidSQLErrMsg(msg, "unsigned bigint data overflow", pToken->z);
+ return tscInvalidOperationMsg(msg, "unsigned bigint data overflow", pToken->z);
}
*((uint64_t *)payload) = iv;
@@ -299,11 +300,11 @@ int32_t tsParseOneColumn(SSchema *pSchema, SStrToken *pToken, char *payload, cha
} else {
double dv;
if (TK_ILLEGAL == tscToDouble(pToken, &dv, &endptr)) {
- return tscInvalidSQLErrMsg(msg, "illegal float data", pToken->z);
+ return tscInvalidOperationMsg(msg, "illegal float data", pToken->z);
}
if (((dv == HUGE_VAL || dv == -HUGE_VAL) && errno == ERANGE) || dv > FLT_MAX || dv < -FLT_MAX || isinf(dv) || isnan(dv)) {
- return tscInvalidSQLErrMsg(msg, "illegal float data", pToken->z);
+ return tscInvalidOperationMsg(msg, "illegal float data", pToken->z);
}
// *((float *)payload) = (float)dv;
@@ -317,11 +318,11 @@ int32_t tsParseOneColumn(SSchema *pSchema, SStrToken *pToken, char *payload, cha
} else {
double dv;
if (TK_ILLEGAL == tscToDouble(pToken, &dv, &endptr)) {
- return tscInvalidSQLErrMsg(msg, "illegal double data", pToken->z);
+ return tscInvalidOperationMsg(msg, "illegal double data", pToken->z);
}
if (((dv == HUGE_VAL || dv == -HUGE_VAL) && errno == ERANGE) || isinf(dv) || isnan(dv)) {
- return tscInvalidSQLErrMsg(msg, "illegal double data", pToken->z);
+ return tscInvalidOperationMsg(msg, "illegal double data", pToken->z);
}
*((double *)payload) = dv;
@@ -334,7 +335,7 @@ int32_t tsParseOneColumn(SSchema *pSchema, SStrToken *pToken, char *payload, cha
setVardataNull(payload, TSDB_DATA_TYPE_BINARY);
} else { // too long values will return invalid sql, not be truncated automatically
if (pToken->n + VARSTR_HEADER_SIZE > pSchema->bytes) { //todo refactor
- return tscInvalidSQLErrMsg(msg, "string data overflow", pToken->z);
+ return tscInvalidOperationMsg(msg, "string data overflow", pToken->z);
}
STR_WITH_SIZE_TO_VARSTR(payload, pToken->z, pToken->n);
@@ -351,7 +352,7 @@ int32_t tsParseOneColumn(SSchema *pSchema, SStrToken *pToken, char *payload, cha
if (!taosMbsToUcs4(pToken->z, pToken->n, varDataVal(payload), pSchema->bytes - VARSTR_HEADER_SIZE, &output)) {
char buf[512] = {0};
snprintf(buf, tListLen(buf), "%s", strerror(errno));
- return tscInvalidSQLErrMsg(msg, buf, pToken->z);
+ return tscInvalidOperationMsg(msg, buf, pToken->z);
}
varDataSetLen(payload, output);
@@ -368,7 +369,7 @@ int32_t tsParseOneColumn(SSchema *pSchema, SStrToken *pToken, char *payload, cha
} else {
int64_t temp;
if (tsParseTime(pToken, &temp, str, msg, timePrec) != TSDB_CODE_SUCCESS) {
- return tscInvalidSQLErrMsg(msg, "invalid timestamp", pToken->z);
+ return tscInvalidOperationMsg(msg, "invalid timestamp", pToken->z);
}
*((int64_t *)payload) = temp;
@@ -417,8 +418,8 @@ int32_t tsCheckTimestamp(STableDataBlocks *pDataBlocks, const char *start) {
return TSDB_CODE_SUCCESS;
}
-int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, SSqlCmd *pCmd, int16_t timePrec, int32_t *len,
- char *tmpTokenBuf) {
+int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, int16_t timePrec, int32_t *len,
+ char *tmpTokenBuf, SInsertStatementParam* pInsertParam) {
int32_t index = 0;
SStrToken sToken = {0};
char *payload = pDataBlocks->pData + pDataBlocks->size;
@@ -441,8 +442,8 @@ int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, SSqlCmd *pCmd, int1
*str += index;
if (sToken.type == TK_QUESTION) {
- if (pCmd->insertParam.insertType != TSDB_QUERY_TYPE_STMT_INSERT) {
- return tscSQLSyntaxErrMsg(pCmd->payload, "? only allowed in binding insertion", *str);
+ if (pInsertParam->insertType != TSDB_QUERY_TYPE_STMT_INSERT) {
+ return tscSQLSyntaxErrMsg(pInsertParam->msg, "? only allowed in binding insertion", *str);
}
uint32_t offset = (uint32_t)(start - pDataBlocks->pData);
@@ -450,14 +451,14 @@ int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, SSqlCmd *pCmd, int1
continue;
}
- strcpy(pCmd->payload, "client out of memory");
+ strcpy(pInsertParam->msg, "client out of memory");
return TSDB_CODE_TSC_OUT_OF_MEMORY;
}
int16_t type = sToken.type;
if ((type != TK_NOW && type != TK_INTEGER && type != TK_STRING && type != TK_FLOAT && type != TK_BOOL &&
type != TK_NULL && type != TK_HEX && type != TK_OCT && type != TK_BIN) || (sToken.n == 0) || (type == TK_RP)) {
- return tscSQLSyntaxErrMsg(pCmd->payload, "invalid data or symbol", sToken.z);
+ return tscSQLSyntaxErrMsg(pInsertParam->msg, "invalid data or symbol", sToken.z);
}
// Remove quotation marks
@@ -487,13 +488,13 @@ int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, SSqlCmd *pCmd, int1
}
bool isPrimaryKey = (colIndex == PRIMARYKEY_TIMESTAMP_COL_INDEX);
- int32_t ret = tsParseOneColumn(pSchema, &sToken, start, pCmd->payload, str, isPrimaryKey, timePrec);
+ int32_t ret = tsParseOneColumn(pSchema, &sToken, start, pInsertParam->msg, str, isPrimaryKey, timePrec);
if (ret != TSDB_CODE_SUCCESS) {
return ret;
}
if (isPrimaryKey && tsCheckTimestamp(pDataBlocks, start) != TSDB_CODE_SUCCESS) {
- tscInvalidSQLErrMsg(pCmd->payload, "client time/server time can not be mixed up", sToken.z);
+ tscInvalidOperationMsg(pInsertParam->msg, "client time/server time can not be mixed up", sToken.z);
return TSDB_CODE_TSC_INVALID_TIME_STAMP;
}
}
@@ -536,7 +537,8 @@ static int32_t rowDataCompar(const void *lhs, const void *rhs) {
}
}
-int32_t tsParseValues(char **str, STableDataBlocks *pDataBlock, int maxRows, SSqlCmd* pCmd, int32_t* numOfRows, char *tmpTokenBuf) {
+int32_t tsParseValues(char **str, STableDataBlocks *pDataBlock, int maxRows, SInsertStatementParam *pInsertParam,
+ int32_t* numOfRows, char *tmpTokenBuf) {
int32_t index = 0;
int32_t code = 0;
@@ -559,7 +561,7 @@ int32_t tsParseValues(char **str, STableDataBlocks *pDataBlock, int maxRows, SSq
int32_t tSize;
code = tscAllocateMemIfNeed(pDataBlock, tinfo.rowSize, &tSize);
if (code != TSDB_CODE_SUCCESS) { //TODO pass the correct error code to client
- strcpy(pCmd->payload, "client out of memory");
+ strcpy(pInsertParam->msg, "client out of memory");
return TSDB_CODE_TSC_OUT_OF_MEMORY;
}
@@ -568,7 +570,7 @@ int32_t tsParseValues(char **str, STableDataBlocks *pDataBlock, int maxRows, SSq
}
int32_t len = 0;
- code = tsParseOneRow(str, pDataBlock, pCmd, precision, &len, tmpTokenBuf);
+ code = tsParseOneRow(str, pDataBlock, precision, &len, tmpTokenBuf, pInsertParam);
if (code != TSDB_CODE_SUCCESS) { // error message has been set in tsParseOneRow, return directly
return TSDB_CODE_TSC_SQL_SYNTAX_ERROR;
}
@@ -578,7 +580,7 @@ int32_t tsParseValues(char **str, STableDataBlocks *pDataBlock, int maxRows, SSq
index = 0;
sToken = tStrGetToken(*str, &index, false);
if (sToken.n == 0 || sToken.type != TK_RP) {
- tscSQLSyntaxErrMsg(pCmd->payload, ") expected", *str);
+ tscSQLSyntaxErrMsg(pInsertParam->msg, ") expected", *str);
code = TSDB_CODE_TSC_SQL_SYNTAX_ERROR;
return code;
}
@@ -589,7 +591,7 @@ int32_t tsParseValues(char **str, STableDataBlocks *pDataBlock, int maxRows, SSq
}
if ((*numOfRows) <= 0) {
- strcpy(pCmd->payload, "no any data points");
+ strcpy(pInsertParam->msg, "no any data points");
return TSDB_CODE_TSC_SQL_SYNTAX_ERROR;
} else {
return TSDB_CODE_SUCCESS;
@@ -699,7 +701,7 @@ void tscSortRemoveDataBlockDupRows(STableDataBlocks *dataBuf) {
dataBuf->prevTS = INT64_MIN;
}
-static int32_t doParseInsertStatement(SSqlCmd* pCmd, char **str, STableDataBlocks* dataBuf, int32_t *totalNum) {
+static int32_t doParseInsertStatement(SInsertStatementParam *pInsertParam, char **str, STableDataBlocks* dataBuf, int32_t *totalNum) {
STableComInfo tinfo = tscGetTableInfo(dataBuf->pTableMeta);
int32_t maxNumOfRows;
@@ -712,7 +714,7 @@ static int32_t doParseInsertStatement(SSqlCmd* pCmd, char **str, STableDataBlock
char tmpTokenBuf[16*1024] = {0}; // used for deleting Escape character: \\, \', \"
int32_t numOfRows = 0;
- code = tsParseValues(str, dataBuf, maxNumOfRows, pCmd, &numOfRows, tmpTokenBuf);
+ code = tsParseValues(str, dataBuf, maxNumOfRows, pInsertParam, &numOfRows, tmpTokenBuf);
if (code != TSDB_CODE_SUCCESS) {
return code;
}
@@ -720,7 +722,7 @@ static int32_t doParseInsertStatement(SSqlCmd* pCmd, char **str, STableDataBlock
for (uint32_t i = 0; i < dataBuf->numOfParams; ++i) {
SParamInfo *param = dataBuf->params + i;
if (param->idx == -1) {
- param->idx = pCmd->numOfParams++;
+ param->idx = pInsertParam->numOfParams++;
param->offset -= sizeof(SSubmitBlk);
}
}
@@ -728,7 +730,7 @@ static int32_t doParseInsertStatement(SSqlCmd* pCmd, char **str, STableDataBlock
SSubmitBlk *pBlocks = (SSubmitBlk *)(dataBuf->pData);
code = tsSetBlockInfo(pBlocks, dataBuf->pTableMeta, numOfRows);
if (code != TSDB_CODE_SUCCESS) {
- tscInvalidSQLErrMsg(pCmd->payload, "too many rows in sql, total number of rows should be less than 32767", *str);
+ tscInvalidOperationMsg(pInsertParam->msg, "too many rows in sql, total number of rows should be less than 32767", *str);
return code;
}
@@ -748,6 +750,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
SSqlCmd * pCmd = &pSql->cmd;
SQueryInfo *pQueryInfo = tscGetQueryInfo(pCmd);
+ SInsertStatementParam* pInsertParam = &pCmd->insertParam;
char *sql = *sqlstr;
@@ -771,6 +774,10 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
index = 0;
sToken = tStrGetToken(sql, &index, false);
+ if (sToken.type == TK_ILLEGAL) {
+ return tscSQLSyntaxErrMsg(pCmd->payload, "unrecognized token", sToken.z);
+ }
+
if (sToken.type == TK_RP) {
break;
}
@@ -784,7 +791,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
}
if (numOfColList == 0 && (*boundColumn) != NULL) {
- return TSDB_CODE_TSC_INVALID_OPERATION;
+ return TSDB_CODE_TSC_SQL_SYNTAX_ERROR;
}
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, TABLE_INDEX);
@@ -805,8 +812,8 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
return code;
}
- tNameExtractFullName(&pSTableMetaInfo->name, pCmd->tagData.name);
- pCmd->tagData.dataLen = 0;
+ tNameExtractFullName(&pSTableMetaInfo->name, pInsertParam->tagData.name);
+ pInsertParam->tagData.dataLen = 0;
code = tscGetTableMeta(pSql, pSTableMetaInfo);
if (code != TSDB_CODE_SUCCESS) {
@@ -814,7 +821,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
}
if (!UTIL_TABLE_IS_SUPER_TABLE(pSTableMetaInfo)) {
- return tscInvalidSQLErrMsg(pCmd->payload, "create table only from super table is allowed", sToken.z);
+ return tscInvalidOperationMsg(pInsertParam->msg, "create table only from super table is allowed", sToken.z);
}
SSchema *pTagSchema = tscGetTableTagSchema(pSTableMetaInfo->pTableMeta);
@@ -827,7 +834,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
sToken = tStrGetToken(sql, &index, false);
if (sToken.type != TK_TAGS && sToken.type != TK_LP) {
tscDestroyBoundColumnInfo(&spd);
- return tscInvalidSQLErrMsg(pCmd->payload, "keyword TAGS expected", sToken.z);
+ return tscSQLSyntaxErrMsg(pInsertParam->msg, "keyword TAGS expected", sToken.z);
}
// parse the bound tags column
@@ -837,7 +844,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
* tags(tagVal1, tagVal2, ..., tagValn) values(v1, v2,... vn);
*/
char* end = NULL;
- code = parseBoundColumns(pCmd, &spd, pTagSchema, sql, &end);
+ code = parseBoundColumns(pInsertParam, &spd, pTagSchema, sql, &end);
if (code != TSDB_CODE_SUCCESS) {
tscDestroyBoundColumnInfo(&spd);
return code;
@@ -858,7 +865,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
if (sToken.type != TK_LP) {
tscDestroyBoundColumnInfo(&spd);
- return tscInvalidSQLErrMsg(pCmd->payload, "( is expected", sToken.z);
+ return tscSQLSyntaxErrMsg(pInsertParam->msg, "( is expected", sToken.z);
}
SKVRowBuilder kvRowBuilder = {0};
@@ -877,7 +884,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
if (TK_ILLEGAL == sToken.type) {
tdDestroyKVRowBuilder(&kvRowBuilder);
tscDestroyBoundColumnInfo(&spd);
- return TSDB_CODE_TSC_INVALID_OPERATION;
+ return TSDB_CODE_TSC_SQL_SYNTAX_ERROR;
}
if (sToken.n == 0 || sToken.type == TK_RP) {
@@ -891,7 +898,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
}
char tagVal[TSDB_MAX_TAGS_LEN];
- code = tsParseOneColumn(pSchema, &sToken, tagVal, pCmd->payload, &sql, false, tinfo.precision);
+ code = tsParseOneColumn(pSchema, &sToken, tagVal, pInsertParam->msg, &sql, false, tinfo.precision);
if (code != TSDB_CODE_SUCCESS) {
tdDestroyKVRowBuilder(&kvRowBuilder);
tscDestroyBoundColumnInfo(&spd);
@@ -906,29 +913,29 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
SKVRow row = tdGetKVRowFromBuilder(&kvRowBuilder);
tdDestroyKVRowBuilder(&kvRowBuilder);
if (row == NULL) {
- return tscInvalidSQLErrMsg(pCmd->payload, "tag value expected", NULL);
+ return tscSQLSyntaxErrMsg(pInsertParam->msg, "tag value expected", NULL);
}
tdSortKVRowByColIdx(row);
- pCmd->tagData.dataLen = kvRowLen(row);
- if (pCmd->tagData.dataLen <= 0){
- return tscInvalidSQLErrMsg(pCmd->payload, "tag value expected", NULL);
+ pInsertParam->tagData.dataLen = kvRowLen(row);
+ if (pInsertParam->tagData.dataLen <= 0){
+ return tscSQLSyntaxErrMsg(pInsertParam->msg, "tag value expected", NULL);
}
- char* pTag = realloc(pCmd->tagData.data, pCmd->tagData.dataLen);
+ char* pTag = realloc(pInsertParam->tagData.data, pInsertParam->tagData.dataLen);
if (pTag == NULL) {
return TSDB_CODE_TSC_OUT_OF_MEMORY;
}
kvRowCpy(pTag, row);
free(row);
- pCmd->tagData.data = pTag;
+ pInsertParam->tagData.data = pTag;
index = 0;
sToken = tStrGetToken(sql, &index, false);
sql += index;
if (sToken.n == 0 || sToken.type != TK_RP) {
- return tscSQLSyntaxErrMsg(pCmd->payload, ") expected", sToken.z);
+ return tscSQLSyntaxErrMsg(pInsertParam->msg, ") expected", sToken.z);
}
/* parse columns after super table tags values.
@@ -941,7 +948,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
int numOfColsAfterTags = 0;
if (sToken.type == TK_LP) {
if (*boundColumn != NULL) {
- return tscSQLSyntaxErrMsg(pCmd->payload, "bind columns again", sToken.z);
+ return tscSQLSyntaxErrMsg(pInsertParam->msg, "bind columns again", sToken.z);
} else {
*boundColumn = &sToken.z[0];
}
@@ -959,7 +966,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
}
if (numOfColsAfterTags == 0 && (*boundColumn) != NULL) {
- return TSDB_CODE_TSC_INVALID_OPERATION;
+ return TSDB_CODE_TSC_SQL_SYNTAX_ERROR;
}
sToken = tStrGetToken(sql, &index, false);
@@ -968,7 +975,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
sql = sToken.z;
if (tscValidateName(&tableToken) != TSDB_CODE_SUCCESS) {
- return tscInvalidSQLErrMsg(pCmd->payload, "invalid table name", *sqlstr);
+ return tscInvalidOperationMsg(pInsertParam->msg, "invalid table name", *sqlstr);
}
int32_t ret = tscSetTableFullName(&pTableMetaInfo->name, &tableToken, pSql);
@@ -977,7 +984,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
}
if (sql == NULL) {
- return TSDB_CODE_TSC_INVALID_OPERATION;
+ return TSDB_CODE_TSC_SQL_SYNTAX_ERROR;
}
code = tscGetTableMetaEx(pSql, pTableMetaInfo, true);
@@ -986,20 +993,18 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
}
} else {
- sql = sToken.z;
-
- if (sql == NULL) {
- return TSDB_CODE_TSC_INVALID_OPERATION;
+ if (sToken.z == NULL) {
+ return tscSQLSyntaxErrMsg(pInsertParam->msg, "", sql);
}
+ sql = sToken.z;
code = tscGetTableMetaEx(pSql, pTableMetaInfo, false);
- if (pCmd->curSql == NULL) {
+ if (pInsertParam->sql == NULL) {
assert(code == TSDB_CODE_TSC_ACTION_IN_PROGRESS);
}
}
*sqlstr = sql;
-
return code;
}
@@ -1013,21 +1018,21 @@ int validateTableName(char *tblName, int len, SStrToken* psTblToken) {
return tscValidateName(psTblToken);
}
-static int32_t validateDataSource(SSqlCmd *pCmd, int32_t type, const char *sql) {
- uint32_t *insertType = &pCmd->insertParam.insertType;
+static int32_t validateDataSource(SInsertStatementParam *pInsertParam, int32_t type, const char *sql) {
+ uint32_t *insertType = &pInsertParam->insertType;
if (*insertType == TSDB_QUERY_TYPE_STMT_INSERT && type == TSDB_QUERY_TYPE_INSERT) {
return TSDB_CODE_SUCCESS;
}
if ((*insertType) != 0 && (*insertType) != type) {
- return tscInvalidSQLErrMsg(pCmd->payload, "keyword VALUES and FILE are not allowed to mixed up", sql);
+ return tscSQLSyntaxErrMsg(pInsertParam->msg, "keyword VALUES and FILE are not allowed to mixed up", sql);
}
*insertType = type;
return TSDB_CODE_SUCCESS;
}
-static int32_t parseBoundColumns(SSqlCmd* pCmd, SParsedDataColInfo* pColInfo, SSchema* pSchema,
+static int32_t parseBoundColumns(SInsertStatementParam *pInsertParam, SParsedDataColInfo* pColInfo, SSchema* pSchema,
char* str, char **end) {
pColInfo->numOfBound = 0;
@@ -1043,7 +1048,7 @@ static int32_t parseBoundColumns(SSqlCmd* pCmd, SParsedDataColInfo* pColInfo, SS
str += index;
if (sToken.type != TK_LP) {
- code = tscInvalidSQLErrMsg(pCmd->payload, "( is expected", sToken.z);
+ code = tscSQLSyntaxErrMsg(pInsertParam->msg, "( is expected", sToken.z);
goto _clean;
}
@@ -1070,7 +1075,7 @@ static int32_t parseBoundColumns(SSqlCmd* pCmd, SParsedDataColInfo* pColInfo, SS
for (int32_t t = 0; t < pColInfo->numOfCols; ++t) {
if (strncmp(sToken.z, pSchema[t].name, sToken.n) == 0 && strlen(pSchema[t].name) == sToken.n) {
if (pColInfo->cols[t].hasVal == true) {
- code = tscInvalidSQLErrMsg(pCmd->payload, "duplicated column name", sToken.z);
+ code = tscInvalidOperationMsg(pInsertParam->msg, "duplicated column name", sToken.z);
goto _clean;
}
@@ -1083,7 +1088,7 @@ static int32_t parseBoundColumns(SSqlCmd* pCmd, SParsedDataColInfo* pColInfo, SS
}
if (!findColumnIndex) {
- code = tscInvalidSQLErrMsg(pCmd->payload, "invalid column/tag name", sToken.z);
+ code = tscInvalidOperationMsg(pInsertParam->msg, "invalid column/tag name", sToken.z);
goto _clean;
}
}
@@ -1092,10 +1097,25 @@ static int32_t parseBoundColumns(SSqlCmd* pCmd, SParsedDataColInfo* pColInfo, SS
return TSDB_CODE_SUCCESS;
_clean:
- pCmd->curSql = NULL;
+ pInsertParam->sql = NULL;
return code;
}
+static int32_t getFileFullPath(SStrToken* pToken, char* output) {
+ char path[PATH_MAX] = {0};
+ strncpy(path, pToken->z, pToken->n);
+ strdequote(path);
+
+ wordexp_t full_path;
+ if (wordexp(path, &full_path, 0) != 0) {
+ return TSDB_CODE_TSC_INVALID_OPERATION;
+ }
+
+ tstrncpy(output, full_path.we_wordv[0], PATH_MAX);
+ wordfree(&full_path);
+ return TSDB_CODE_SUCCESS;
+}
+
/**
* parse insert sql
* @param pSql
@@ -1103,7 +1123,9 @@ static int32_t parseBoundColumns(SSqlCmd* pCmd, SParsedDataColInfo* pColInfo, SS
*/
int tsParseInsertSql(SSqlObj *pSql) {
SSqlCmd *pCmd = &pSql->cmd;
- char* str = pCmd->curSql;
+
+ SInsertStatementParam* pInsertParam = &pCmd->insertParam;
+ char* str = pInsertParam->sql;
int32_t totalNum = 0;
int32_t code = TSDB_CODE_SUCCESS;
@@ -1118,21 +1140,17 @@ int tsParseInsertSql(SSqlObj *pSql) {
return code;
}
- if ((code = tscAllocPayload(pCmd, TSDB_DEFAULT_PAYLOAD_SIZE)) != TSDB_CODE_SUCCESS) {
- return code;
- }
-
- if (NULL == pCmd->insertParam.pTableBlockHashList) {
- pCmd->insertParam.pTableBlockHashList = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, false);
- if (NULL == pCmd->insertParam.pTableBlockHashList) {
+ if (NULL == pInsertParam->pTableBlockHashList) {
+ pInsertParam->pTableBlockHashList = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, false);
+ if (NULL == pInsertParam->pTableBlockHashList) {
code = TSDB_CODE_TSC_OUT_OF_MEMORY;
goto _clean;
}
} else {
- str = pCmd->curSql;
+ str = pInsertParam->sql;
}
- tscDebug("0x%"PRIx64" create data block list hashList:%p", pSql->self, pCmd->insertParam.pTableBlockHashList);
+ tscDebug("0x%"PRIx64" create data block list hashList:%p", pSql->self, pInsertParam->pTableBlockHashList);
while (1) {
int32_t index = 0;
@@ -1144,7 +1162,7 @@ int tsParseInsertSql(SSqlObj *pSql) {
* if the data is from the data file, no data has been generated yet. So, there no data to
* merge or submit, save the file path and parse the file in other routines.
*/
- if (TSDB_QUERY_HAS_TYPE(pCmd->insertParam.insertType, TSDB_QUERY_TYPE_FILE_INSERT)) {
+ if (TSDB_QUERY_HAS_TYPE(pInsertParam->insertType, TSDB_QUERY_TYPE_FILE_INSERT)) {
goto _clean;
}
@@ -1160,13 +1178,13 @@ int tsParseInsertSql(SSqlObj *pSql) {
}
}
- pCmd->curSql = sToken.z;
+ pInsertParam->sql = sToken.z;
char buf[TSDB_TABLE_FNAME_LEN];
SStrToken sTblToken;
sTblToken.z = buf;
// Check if the table name available or not
if (validateTableName(sToken.z, sToken.n, &sTblToken) != TSDB_CODE_SUCCESS) {
- code = tscInvalidSQLErrMsg(pCmd->payload, "table name invalid", sToken.z);
+ code = tscInvalidOperationMsg(pInsertParam->msg, "table name invalid", sToken.z);
goto _clean;
}
@@ -1185,12 +1203,12 @@ int tsParseInsertSql(SSqlObj *pSql) {
}
tscError("0x%"PRIx64" async insert parse error, code:%s", pSql->self, tstrerror(code));
- pCmd->curSql = NULL;
+ pInsertParam->sql = NULL;
goto _clean;
}
if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) {
- code = tscInvalidSQLErrMsg(pCmd->payload, "insert data into super table is not supported", NULL);
+ code = tscInvalidOperationMsg(pInsertParam->msg, "insert data into super table is not supported", NULL);
goto _clean;
}
@@ -1199,58 +1217,49 @@ int tsParseInsertSql(SSqlObj *pSql) {
str += index;
if (sToken.n == 0 || (sToken.type != TK_FILE && sToken.type != TK_VALUES)) {
- code = tscInvalidSQLErrMsg(pCmd->payload, "keyword VALUES or FILE required", sToken.z);
+ code = tscSQLSyntaxErrMsg(pInsertParam->msg, "keyword VALUES or FILE required", sToken.z);
goto _clean;
}
STableComInfo tinfo = tscGetTableInfo(pTableMetaInfo->pTableMeta);
if (sToken.type == TK_FILE) {
- if (validateDataSource(pCmd, TSDB_QUERY_TYPE_FILE_INSERT, sToken.z) != TSDB_CODE_SUCCESS) {
+ if (validateDataSource(pInsertParam, TSDB_QUERY_TYPE_FILE_INSERT, sToken.z) != TSDB_CODE_SUCCESS) {
goto _clean;
}
index = 0;
sToken = tStrGetToken(str, &index, false);
if (sToken.type != TK_STRING && sToken.type != TK_ID) {
- code = tscInvalidSQLErrMsg(pCmd->payload, "file path is required following keyword FILE", sToken.z);
+ code = tscSQLSyntaxErrMsg(pInsertParam->msg, "file path is required following keyword FILE", sToken.z);
goto _clean;
}
str += index;
if (sToken.n == 0) {
- code = tscInvalidSQLErrMsg(pCmd->payload, "file path is required following keyword FILE", sToken.z);
+ code = tscSQLSyntaxErrMsg(pInsertParam->msg, "file path is required following keyword FILE", sToken.z);
goto _clean;
}
- strncpy(pCmd->payload, sToken.z, sToken.n);
- strdequote(pCmd->payload);
-
- // todo refactor extract method
- wordexp_t full_path;
- if (wordexp(pCmd->payload, &full_path, 0) != 0) {
- code = tscInvalidSQLErrMsg(pCmd->payload, "invalid filename", sToken.z);
+ code = getFileFullPath(&sToken, pCmd->payload);
+ if (code != TSDB_CODE_SUCCESS) {
+ tscInvalidOperationMsg(pInsertParam->msg, "invalid filename", sToken.z);
goto _clean;
}
-
- tstrncpy(pCmd->payload, full_path.we_wordv[0], pCmd->allocSize);
- wordfree(&full_path);
-
} else {
if (bindedColumns == NULL) {
STableMeta *pTableMeta = pTableMetaInfo->pTableMeta;
-
- if (validateDataSource(pCmd, TSDB_QUERY_TYPE_INSERT, sToken.z) != TSDB_CODE_SUCCESS) {
+ if (validateDataSource(pInsertParam, TSDB_QUERY_TYPE_INSERT, sToken.z) != TSDB_CODE_SUCCESS) {
goto _clean;
}
STableDataBlocks *dataBuf = NULL;
- int32_t ret = tscGetDataBlockFromList(pCmd->insertParam.pTableBlockHashList, pTableMeta->id.uid, TSDB_DEFAULT_PAYLOAD_SIZE,
+ int32_t ret = tscGetDataBlockFromList(pInsertParam->pTableBlockHashList, pTableMeta->id.uid, TSDB_DEFAULT_PAYLOAD_SIZE,
sizeof(SSubmitBlk), tinfo.rowSize, &pTableMetaInfo->name, pTableMeta,
&dataBuf, NULL);
if (ret != TSDB_CODE_SUCCESS) {
goto _clean;
}
- code = doParseInsertStatement(pCmd, &str, dataBuf, &totalNum);
+ code = doParseInsertStatement(pInsertParam, &str, dataBuf, &totalNum);
if (code != TSDB_CODE_SUCCESS) {
goto _clean;
}
@@ -1258,12 +1267,12 @@ int tsParseInsertSql(SSqlObj *pSql) {
// insert into tablename(col1, col2,..., coln) values(v1, v2,... vn);
STableMeta *pTableMeta = tscGetTableMetaInfoFromCmd(pCmd, 0)->pTableMeta;
- if (validateDataSource(pCmd, TSDB_QUERY_TYPE_INSERT, sToken.z) != TSDB_CODE_SUCCESS) {
+ if (validateDataSource(pInsertParam, TSDB_QUERY_TYPE_INSERT, sToken.z) != TSDB_CODE_SUCCESS) {
goto _clean;
}
STableDataBlocks *dataBuf = NULL;
- int32_t ret = tscGetDataBlockFromList(pCmd->insertParam.pTableBlockHashList, pTableMeta->id.uid, TSDB_DEFAULT_PAYLOAD_SIZE,
+ int32_t ret = tscGetDataBlockFromList(pInsertParam->pTableBlockHashList, pTableMeta->id.uid, TSDB_DEFAULT_PAYLOAD_SIZE,
sizeof(SSubmitBlk), tinfo.rowSize, &pTableMetaInfo->name, pTableMeta,
&dataBuf, NULL);
if (ret != TSDB_CODE_SUCCESS) {
@@ -1271,22 +1280,22 @@ int tsParseInsertSql(SSqlObj *pSql) {
}
SSchema *pSchema = tscGetTableSchema(pTableMeta);
- code = parseBoundColumns(pCmd, &dataBuf->boundColumnInfo, pSchema, bindedColumns, NULL);
+ code = parseBoundColumns(pInsertParam, &dataBuf->boundColumnInfo, pSchema, bindedColumns, NULL);
if (code != TSDB_CODE_SUCCESS) {
goto _clean;
}
if (dataBuf->boundColumnInfo.cols[0].hasVal == false) {
- code = tscInvalidSQLErrMsg(pCmd->payload, "primary timestamp column can not be null", NULL);
+ code = tscInvalidOperationMsg(pInsertParam->msg, "primary timestamp column can not be null", NULL);
goto _clean;
}
if (sToken.type != TK_VALUES) {
- code = tscInvalidSQLErrMsg(pCmd->payload, "keyword VALUES is expected", sToken.z);
+ code = tscSQLSyntaxErrMsg(pInsertParam->msg, "keyword VALUES is expected", sToken.z);
goto _clean;
}
- code = doParseInsertStatement(pCmd, &str, dataBuf, &totalNum);
+ code = doParseInsertStatement(pInsertParam, &str, dataBuf, &totalNum);
if (code != TSDB_CODE_SUCCESS) {
goto _clean;
}
@@ -1295,13 +1304,13 @@ int tsParseInsertSql(SSqlObj *pSql) {
}
// we need to keep the data blocks if there are parameters in the sql
- if (pCmd->numOfParams > 0) {
+ if (pInsertParam->numOfParams > 0) {
goto _clean;
}
// merge according to vgId
- if (!TSDB_QUERY_HAS_TYPE(pCmd->insertParam.insertType, TSDB_QUERY_TYPE_STMT_INSERT) && taosHashGetSize(pCmd->insertParam.pTableBlockHashList) > 0) {
- if ((code = tscMergeTableDataBlocks(pSql, true)) != TSDB_CODE_SUCCESS) {
+ if (!TSDB_QUERY_HAS_TYPE(pInsertParam->insertType, TSDB_QUERY_TYPE_STMT_INSERT) && taosHashGetSize(pInsertParam->pTableBlockHashList) > 0) {
+ if ((code = tscMergeTableDataBlocks(pInsertParam, true)) != TSDB_CODE_SUCCESS) {
goto _clean;
}
}
@@ -1310,7 +1319,7 @@ int tsParseInsertSql(SSqlObj *pSql) {
goto _clean;
_clean:
- pCmd->curSql = NULL;
+ pInsertParam->sql = NULL;
return code;
}
@@ -1325,18 +1334,19 @@ int tsInsertInitialCheck(SSqlObj *pSql) {
SStrToken sToken = tStrGetToken(pSql->sqlstr, &index, false);
assert(sToken.type == TK_INSERT || sToken.type == TK_IMPORT);
- pCmd->count = 0;
+ pCmd->count = 0;
pCmd->command = TSDB_SQL_INSERT;
+ SInsertStatementParam* pInsertParam = &pCmd->insertParam;
SQueryInfo *pQueryInfo = tscGetQueryInfoS(pCmd);
TSDB_QUERY_SET_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_INSERT);
sToken = tStrGetToken(pSql->sqlstr, &index, false);
if (sToken.type != TK_INTO) {
- return tscInvalidSQLErrMsg(pCmd->payload, "keyword INTO is expected", sToken.z);
+ return tscSQLSyntaxErrMsg(pInsertParam->msg, "keyword INTO is expected", sToken.z);
}
- pCmd->curSql = sToken.z + sToken.n;
+ pInsertParam->sql = sToken.z + sToken.n;
return TSDB_CODE_SUCCESS;
}
@@ -1345,7 +1355,7 @@ int tsParseSql(SSqlObj *pSql, bool initial) {
SSqlCmd* pCmd = &pSql->cmd;
if (!initial) {
- tscDebug("0x%"PRIx64" resume to parse sql: %s", pSql->self, pCmd->curSql);
+ tscDebug("0x%"PRIx64" resume to parse sql: %s", pSql->self, pCmd->insertParam.sql);
}
ret = tscAllocPayload(pCmd, TSDB_DEFAULT_PAYLOAD_SIZE);
@@ -1355,12 +1365,11 @@ int tsParseSql(SSqlObj *pSql, bool initial) {
if (tscIsInsertData(pSql->sqlstr)) {
if (initial && ((ret = tsInsertInitialCheck(pSql)) != TSDB_CODE_SUCCESS)) {
+ strncpy(pCmd->payload, pCmd->insertParam.msg, TSDB_DEFAULT_PAYLOAD_SIZE);
return ret;
}
ret = tsParseInsertSql(pSql);
- assert(ret == TSDB_CODE_SUCCESS || ret == TSDB_CODE_TSC_ACTION_IN_PROGRESS || ret == TSDB_CODE_TSC_SQL_SYNTAX_ERROR || ret == TSDB_CODE_TSC_INVALID_OPERATION);
-
if (pSql->parseRetry < 1 && (ret == TSDB_CODE_TSC_SQL_SYNTAX_ERROR || ret == TSDB_CODE_TSC_INVALID_OPERATION)) {
tscDebug("0x%"PRIx64 " parse insert sql statement failed, code:%s, clear meta cache and retry ", pSql->self, tstrerror(ret));
@@ -1371,6 +1380,10 @@ int tsParseSql(SSqlObj *pSql, bool initial) {
ret = tsParseInsertSql(pSql);
}
}
+
+ if (ret != TSDB_CODE_SUCCESS) {
+ strncpy(pCmd->payload, pCmd->insertParam.msg, TSDB_DEFAULT_PAYLOAD_SIZE);
+ }
} else {
SSqlInfo sqlInfo = qSqlParse(pSql->sqlstr);
ret = tscValidateSqlInfo(pSql, &sqlInfo);
@@ -1395,29 +1408,25 @@ int tsParseSql(SSqlObj *pSql, bool initial) {
return ret;
}
-static int doPackSendDataBlock(SSqlObj *pSql, int32_t numOfRows, STableDataBlocks *pTableDataBlocks) {
+static int doPackSendDataBlock(SSqlObj* pSql, SInsertStatementParam *pInsertParam, STableMeta* pTableMeta, int32_t numOfRows, STableDataBlocks *pTableDataBlocks) {
int32_t code = TSDB_CODE_SUCCESS;
- SSqlCmd *pCmd = &pSql->cmd;
- pSql->res.numOfRows = 0;
-
- STableMeta *pTableMeta = tscGetTableMetaInfoFromCmd(pCmd, 0)->pTableMeta;
SSubmitBlk *pBlocks = (SSubmitBlk *)(pTableDataBlocks->pData);
code = tsSetBlockInfo(pBlocks, pTableMeta, numOfRows);
if (code != TSDB_CODE_SUCCESS) {
- return tscInvalidSQLErrMsg(pCmd->payload, "too many rows in sql, total number of rows should be less than 32767", NULL);
+ return tscInvalidOperationMsg(pInsertParam->msg, "too many rows in sql, total number of rows should be less than 32767", NULL);
}
- if ((code = tscMergeTableDataBlocks(pSql, true)) != TSDB_CODE_SUCCESS) {
+ if ((code = tscMergeTableDataBlocks(pInsertParam, true)) != TSDB_CODE_SUCCESS) {
return code;
}
- STableDataBlocks *pDataBlock = taosArrayGetP(pCmd->insertParam.pDataBlocks, 0);
+ STableDataBlocks *pDataBlock = taosArrayGetP(pInsertParam->pDataBlocks, 0);
if ((code = tscCopyDataBlockToPayload(pSql, pDataBlock)) != TSDB_CODE_SUCCESS) {
return code;
}
- return tscBuildAndSendRequest(pSql, NULL);
+ return TSDB_CODE_SUCCESS;
}
typedef struct SImportFileSupport {
@@ -1466,13 +1475,14 @@ static void parseFileSendDataBlock(void *param, TAOS_RES *tres, int32_t numOfRow
STableMeta * pTableMeta = pTableMetaInfo->pTableMeta;
STableComInfo tinfo = tscGetTableInfo(pTableMeta);
- destroyTableNameList(pCmd);
+ SInsertStatementParam* pInsertParam = &pCmd->insertParam;
+ destroyTableNameList(pInsertParam);
- pCmd->insertParam.pDataBlocks = tscDestroyBlockArrayList(pCmd->insertParam.pDataBlocks);
+ pInsertParam->pDataBlocks = tscDestroyBlockArrayList(pInsertParam->pDataBlocks);
- if (pCmd->insertParam.pTableBlockHashList == NULL) {
- pCmd->insertParam.pTableBlockHashList = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, false);
- if (pCmd->insertParam.pTableBlockHashList == NULL) {
+ if (pInsertParam->pTableBlockHashList == NULL) {
+ pInsertParam->pTableBlockHashList = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, false);
+ if (pInsertParam->pTableBlockHashList == NULL) {
code = TSDB_CODE_TSC_OUT_OF_MEMORY;
goto _error;
}
@@ -1480,7 +1490,7 @@ static void parseFileSendDataBlock(void *param, TAOS_RES *tres, int32_t numOfRow
STableDataBlocks *pTableDataBlock = NULL;
int32_t ret =
- tscGetDataBlockFromList(pCmd->insertParam.pTableBlockHashList, pTableMeta->id.uid, TSDB_PAYLOAD_SIZE, sizeof(SSubmitBlk),
+ tscGetDataBlockFromList(pInsertParam->pTableBlockHashList, pTableMeta->id.uid, TSDB_PAYLOAD_SIZE, sizeof(SSubmitBlk),
tinfo.rowSize, &pTableMetaInfo->name, pTableMeta, &pTableDataBlock, NULL);
if (ret != TSDB_CODE_SUCCESS) {
pParentSql->res.code = TSDB_CODE_TSC_OUT_OF_MEMORY;
@@ -1507,7 +1517,7 @@ static void parseFileSendDataBlock(void *param, TAOS_RES *tres, int32_t numOfRow
strtolower(line, line);
int32_t len = 0;
- code = tsParseOneRow(&lineptr, pTableDataBlock, pCmd, tinfo.precision, &len, tokenBuf);
+ code = tsParseOneRow(&lineptr, pTableDataBlock, tinfo.precision, &len, tokenBuf, pInsertParam);
if (code != TSDB_CODE_SUCCESS || pTableDataBlock->numOfParams > 0) {
pSql->res.code = code;
break;
@@ -1526,12 +1536,14 @@ static void parseFileSendDataBlock(void *param, TAOS_RES *tres, int32_t numOfRow
pParentSql->res.code = code;
if (code == TSDB_CODE_SUCCESS) {
if (count > 0) {
- code = doPackSendDataBlock(pSql, count, pTableDataBlock);
- if (code == TSDB_CODE_SUCCESS) {
- return;
- } else {
+ pSql->res.numOfRows = 0;
+ code = doPackSendDataBlock(pSql, pInsertParam, pTableMeta, count, pTableDataBlock);
+ if (code != TSDB_CODE_SUCCESS) {
goto _error;
}
+
+ tscBuildAndSendRequest(pSql, NULL);
+ return;
} else {
taos_free_result(pSql);
tfree(pSupporter);
@@ -1562,7 +1574,8 @@ void tscImportDataFromFile(SSqlObj *pSql) {
return;
}
- assert(TSDB_QUERY_HAS_TYPE(pCmd->insertParam.insertType, TSDB_QUERY_TYPE_FILE_INSERT) && strlen(pCmd->payload) != 0);
+ SInsertStatementParam* pInsertParam = &pCmd->insertParam;
+ assert(TSDB_QUERY_HAS_TYPE(pInsertParam->insertType, TSDB_QUERY_TYPE_FILE_INSERT) && strlen(pCmd->payload) != 0);
pCmd->active = pCmd->pQueryInfo;
SImportFileSupport *pSupporter = calloc(1, sizeof(SImportFileSupport));
diff --git a/src/client/src/tscPrepare.c b/src/client/src/tscPrepare.c
index b80bdabbfc..f199a57987 100644
--- a/src/client/src/tscPrepare.c
+++ b/src/client/src/tscPrepare.c
@@ -48,6 +48,7 @@ typedef struct SMultiTbStmt {
bool nameSet;
bool tagSet;
uint64_t currentUid;
+ char *sqlstr;
uint32_t tbNum;
SStrToken tbname;
SStrToken stbname;
@@ -1085,7 +1086,7 @@ static int insertStmtExecute(STscStmt* stmt) {
fillTablesColumnsNull(stmt->pSql);
- int code = tscMergeTableDataBlocks(stmt->pSql, false);
+ int code = tscMergeTableDataBlocks(&stmt->pSql->cmd.insertParam, false);
if (code != TSDB_CODE_SUCCESS) {
return code;
}
@@ -1185,7 +1186,7 @@ static int insertBatchStmtExecute(STscStmt* pStmt) {
fillTablesColumnsNull(pStmt->pSql);
- if ((code = tscMergeTableDataBlocks(pStmt->pSql, false)) != TSDB_CODE_SUCCESS) {
+ if ((code = tscMergeTableDataBlocks(&pStmt->pSql->cmd.insertParam, false)) != TSDB_CODE_SUCCESS) {
return code;
}
@@ -1203,7 +1204,6 @@ static int insertBatchStmtExecute(STscStmt* pStmt) {
return pStmt->pSql->res.code;
}
-
int stmtParseInsertTbTags(SSqlObj* pSql, STscStmt* pStmt) {
SSqlCmd *pCmd = &pSql->cmd;
int32_t ret = TSDB_CODE_SUCCESS;
@@ -1213,7 +1213,7 @@ int stmtParseInsertTbTags(SSqlObj* pSql, STscStmt* pStmt) {
}
int32_t index = 0;
- SStrToken sToken = tStrGetToken(pCmd->curSql, &index, false);
+ SStrToken sToken = tStrGetToken(pCmd->insertParam.sql, &index, false);
if (sToken.n == 0) {
return TSDB_CODE_TSC_INVALID_OPERATION;
}
@@ -1232,29 +1232,29 @@ int stmtParseInsertTbTags(SSqlObj* pSql, STscStmt* pStmt) {
pStmt->mtb.tagSet = true;
- sToken = tStrGetToken(pCmd->curSql, &index, false);
- if (sToken.n > 0 && sToken.type == TK_VALUES) {
+ sToken = tStrGetToken(pCmd->insertParam.sql, &index, false);
+ if (sToken.n > 0 && (sToken.type == TK_VALUES || sToken.type == TK_LP)) {
return TSDB_CODE_SUCCESS;
}
if (sToken.n <= 0 || sToken.type != TK_USING) {
- return TSDB_CODE_TSC_INVALID_OPERATION;
+ return tscSQLSyntaxErrMsg(pCmd->payload, "keywords USING is expected", sToken.z);
}
- sToken = tStrGetToken(pCmd->curSql, &index, false);
+ sToken = tStrGetToken(pCmd->insertParam.sql, &index, false);
if (sToken.n <= 0 || ((sToken.type != TK_ID) && (sToken.type != TK_STRING))) {
- return TSDB_CODE_TSC_INVALID_OPERATION;
+ return tscSQLSyntaxErrMsg(pCmd->payload, "invalid token", sToken.z);
}
pStmt->mtb.stbname = sToken;
- sToken = tStrGetToken(pCmd->curSql, &index, false);
+ sToken = tStrGetToken(pCmd->insertParam.sql, &index, false);
if (sToken.n <= 0 || sToken.type != TK_TAGS) {
- return TSDB_CODE_TSC_INVALID_OPERATION;
+ return tscSQLSyntaxErrMsg(pCmd->payload, "keyword TAGS expected", sToken.z);
}
- sToken = tStrGetToken(pCmd->curSql, &index, false);
+ sToken = tStrGetToken(pCmd->insertParam.sql, &index, false);
if (sToken.n <= 0 || sToken.type != TK_LP) {
- return TSDB_CODE_TSC_INVALID_OPERATION;
+ return tscSQLSyntaxErrMsg(pCmd->payload, ") expected", sToken.z);
}
pStmt->mtb.tags = taosArrayInit(4, sizeof(SStrToken));
@@ -1262,7 +1262,7 @@ int stmtParseInsertTbTags(SSqlObj* pSql, STscStmt* pStmt) {
int32_t loopCont = 1;
while (loopCont) {
- sToken = tStrGetToken(pCmd->curSql, &index, false);
+ sToken = tStrGetToken(pCmd->insertParam.sql, &index, false);
if (sToken.n <= 0) {
return TSDB_CODE_TSC_INVALID_OPERATION;
}
@@ -1285,20 +1285,18 @@ int stmtParseInsertTbTags(SSqlObj* pSql, STscStmt* pStmt) {
return TSDB_CODE_TSC_INVALID_OPERATION;
}
- sToken = tStrGetToken(pCmd->curSql, &index, false);
- if (sToken.n <= 0 || sToken.type != TK_VALUES) {
+ sToken = tStrGetToken(pCmd->insertParam.sql, &index, false);
+ if (sToken.n <= 0 || (sToken.type != TK_VALUES && sToken.type != TK_LP)) {
return TSDB_CODE_TSC_INVALID_OPERATION;
}
pStmt->mtb.values = sToken;
+
}
return TSDB_CODE_SUCCESS;
}
-
-
-
int stmtGenInsertStatement(SSqlObj* pSql, STscStmt* pStmt, const char* name, TAOS_BIND* tags) {
size_t tagNum = taosArrayGetSize(pStmt->mtb.tags);
size_t size = 1048576;
@@ -1373,14 +1371,17 @@ int stmtGenInsertStatement(SSqlObj* pSql, STscStmt* pStmt, const char* name, TAO
break;
}
- free(pSql->sqlstr);
+ if (pStmt->mtb.sqlstr == NULL) {
+ pStmt->mtb.sqlstr = pSql->sqlstr;
+ } else {
+ tfree(pSql->sqlstr);
+ }
+
pSql->sqlstr = str;
return TSDB_CODE_SUCCESS;
}
-
-
////////////////////////////////////////////////////////////////////////////////
// interface functions
@@ -1468,7 +1469,7 @@ int taos_stmt_prepare(TAOS_STMT* stmt, const char* sql, unsigned long length) {
if (tscIsInsertData(pSql->sqlstr)) {
pStmt->isInsert = true;
- pSql->cmd.numOfParams = 0;
+ pSql->cmd.insertParam.numOfParams = 0;
pSql->cmd.batchSize = 0;
registerSqlObj(pSql);
@@ -1561,11 +1562,10 @@ int taos_stmt_set_tbname_tags(TAOS_STMT* stmt, const char* name, TAOS_BIND* tags
}
pStmt->mtb.nameSet = true;
- pStmt->mtb.tagSet = true;
tscDebug("0x%"PRIx64" SQL: %s", pSql->self, pSql->sqlstr);
- pSql->cmd.numOfParams = 0;
+ pSql->cmd.insertParam.numOfParams = 0;
pSql->cmd.batchSize = 0;
if (taosHashGetSize(pCmd->insertParam.pTableBlockHashList) > 0) {
@@ -1634,6 +1634,7 @@ int taos_stmt_close(TAOS_STMT* stmt) {
taosHashCleanup(pStmt->pSql->cmd.insertParam.pTableBlockHashList);
pStmt->pSql->cmd.insertParam.pTableBlockHashList = NULL;
taosArrayDestroy(pStmt->mtb.tags);
+ tfree(pStmt->mtb.sqlstr);
}
}
@@ -1851,8 +1852,8 @@ int taos_stmt_num_params(TAOS_STMT *stmt, int *nums) {
if (pStmt->isInsert) {
SSqlObj* pSql = pStmt->pSql;
- SSqlCmd *pCmd = &pSql->cmd;
- *nums = pCmd->numOfParams;
+ SSqlCmd *pCmd = &pSql->cmd;
+ *nums = pCmd->insertParam.numOfParams;
return TSDB_CODE_SUCCESS;
} else {
SNormalStmt* normal = &pStmt->normal;
diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c
index d9be43b412..f34434e66c 100644
--- a/src/client/src/tscSQLParser.c
+++ b/src/client/src/tscSQLParser.c
@@ -28,7 +28,7 @@
#include "tname.h"
#include "tscLog.h"
#include "tscUtil.h"
-#include "tschemautil.h"
+#include "qTableMeta.h"
#include "tsclient.h"
#include "tstrbuild.h"
#include "ttoken.h"
@@ -41,11 +41,11 @@
#define TSWINDOW_IS_EQUAL(t1, t2) (((t1).skey == (t2).skey) && ((t1).ekey == (t2).ekey))
-// -1 is tbname column index, so here use the -3 as the initial value
-#define COLUMN_INDEX_INITIAL_VAL (-3)
+// -1 is tbname column index, so here use the -2 as the initial value
+#define COLUMN_INDEX_INITIAL_VAL (-2)
#define COLUMN_INDEX_INITIALIZER \
{ COLUMN_INDEX_INITIAL_VAL, COLUMN_INDEX_INITIAL_VAL }
-#define COLUMN_INDEX_VALIDE(index) (((index).tableIndex >= 0) && ((index).columnIndex >= TSDB_BLOCK_DIST_COLUMN_INDEX))
+#define COLUMN_INDEX_VALIDE(index) (((index).tableIndex >= 0) && ((index).columnIndex >= TSDB_TBNAME_COLUMN_INDEX))
#define TBNAME_LIST_SEP ","
typedef struct SColumnList { // todo refactor
@@ -90,6 +90,7 @@ static int32_t validateGroupbyNode(SQueryInfo* pQueryInfo, SArray* pList, SSqlCm
static int32_t validateIntervalNode(SSqlObj* pSql, SQueryInfo* pQueryInfo, SSqlNode* pSqlNode);
static int32_t parseIntervalOffset(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SStrToken* offsetToken);
static int32_t parseSlidingClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SStrToken* pSliding);
+static int32_t validateStateWindowNode(SSqlCmd* pSql, SQueryInfo* pQueryInfo, SSqlNode* pSqlNode, bool isStable);
static int32_t addProjectionExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExprItem* pItem);
@@ -195,7 +196,7 @@ static bool validateDebugFlag(int32_t v) {
* is not needed in the final error message.
*/
static int32_t invalidOperationMsg(char* dstBuffer, const char* errMsg) {
- return tscInvalidSQLErrMsg(dstBuffer, errMsg, NULL);
+ return tscInvalidOperationMsg(dstBuffer, errMsg, NULL);
}
static int setColumnFilterInfoForTimestamp(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tVariant* pVar) {
@@ -395,11 +396,18 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
const char* msg2 = "name too long";
SCreateDbInfo* pCreateDB = &(pInfo->pMiscInfo->dbOpt);
- if (tscValidateName(&pCreateDB->dbname) != TSDB_CODE_SUCCESS) {
+ if (pCreateDB->dbname.n >= TSDB_DB_NAME_LEN) {
+ return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2);
+ }
+
+ char buf[TSDB_DB_NAME_LEN] = {0};
+ SStrToken token = taosTokenDup(&pCreateDB->dbname, buf, tListLen(buf));
+
+ if (tscValidateName(&token) != TSDB_CODE_SUCCESS) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1);
}
- int32_t ret = tNameSetDbName(&pTableMetaInfo->name, getAccountId(pSql), &(pCreateDB->dbname));
+ int32_t ret = tNameSetDbName(&pTableMetaInfo->name, getAccountId(pSql), &token);
if (ret != TSDB_CODE_SUCCESS) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2);
}
@@ -851,6 +859,59 @@ int32_t validateIntervalNode(SSqlObj* pSql, SQueryInfo* pQueryInfo, SSqlNode* pS
// The following part is used to check for the invalid query expression.
return checkInvalidExprForTimeWindow(pCmd, pQueryInfo);
}
+static int32_t validateStateWindowNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSqlNode, bool isStable) {
+
+ const char* msg1 = "invalid column name";
+ const char* msg3 = "not support state_window with group by ";
+ const char* msg4 = "function not support for super table query";
+
+ SStrToken *col = &(pSqlNode->windowstateVal.col) ;
+ if (col->z == NULL || col->n <= 0) {
+ return TSDB_CODE_SUCCESS;
+ }
+
+ if (pQueryInfo->colList == NULL) {
+ pQueryInfo->colList = taosArrayInit(4, POINTER_BYTES);
+ }
+ if (pQueryInfo->groupbyExpr.numOfGroupCols > 0) {
+ return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3);
+ }
+ pQueryInfo->groupbyExpr.numOfGroupCols = 1;
+
+ //TODO(dengyihao): check tag column
+ if (isStable) {
+ return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg4);
+ }
+
+ SColumnIndex index = COLUMN_INDEX_INITIALIZER;
+ if (getColumnIndexByName(pCmd, col, pQueryInfo, &index) != TSDB_CODE_SUCCESS) {
+ return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1);
+ }
+
+ STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, index.tableIndex);
+ STableMeta* pTableMeta = pTableMetaInfo->pTableMeta;
+ int32_t numOfCols = tscGetNumOfColumns(pTableMeta);
+ if (index.columnIndex == TSDB_TBNAME_COLUMN_INDEX || index.columnIndex >= numOfCols) {
+ return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3);
+ }
+
+ SGroupbyExpr* pGroupExpr = &pQueryInfo->groupbyExpr;
+ if (pGroupExpr->columnInfo == NULL) {
+ pGroupExpr->columnInfo = taosArrayInit(4, sizeof(SColIndex));
+ }
+
+ SSchema* pSchema = tscGetTableColumnSchema(pTableMeta, index.columnIndex);
+ if (pSchema->type == TSDB_DATA_TYPE_TIMESTAMP || pSchema->type == TSDB_DATA_TYPE_FLOAT || pSchema->type == TSDB_DATA_TYPE_DOUBLE) {
+ return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1);
+ }
+
+ tscColumnListInsert(pQueryInfo->colList, index.columnIndex, pTableMeta->id.uid, pSchema);
+ SColIndex colIndex = { .colIndex = index.columnIndex, .flag = TSDB_COL_NORMAL, .colId = pSchema->colId };
+ taosArrayPush(pGroupExpr->columnInfo, &colIndex);
+ pQueryInfo->groupbyExpr.orderType = TSDB_ORDER_ASC;
+ pQueryInfo->stateWindow = true;
+ return TSDB_CODE_SUCCESS;
+}
int32_t validateSessionNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode * pSqlNode) {
const char* msg1 = "gap should be fixed time window";
@@ -885,11 +946,17 @@ int32_t validateSessionNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode * pS
if (pQueryInfo->sessionWindow.gap != 0 && pQueryInfo->interval.interval != 0) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2);
}
+ if (pQueryInfo->sessionWindow.gap == 0) {
+ return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg4);
+ }
SColumnIndex index = COLUMN_INDEX_INITIALIZER;
if (getColumnIndexByName(pCmd, col, pQueryInfo, &index) != TSDB_CODE_SUCCESS) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3);
}
+ if (index.columnIndex != PRIMARYKEY_TIMESTAMP_COL_INDEX) {
+ return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3);
+ }
pQueryInfo->sessionWindow.primaryColId = PRIMARYKEY_TIMESTAMP_COL_INDEX;
@@ -1873,9 +1940,6 @@ int32_t addProjectionExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, t
if (index.columnIndex == TSDB_TBNAME_COLUMN_INDEX) {
SSchema* colSchema = tGetTbnameColumnSchema();
tscAddFuncInSelectClause(pQueryInfo, startPos, TSDB_FUNC_TAGPRJ, &index, colSchema, TSDB_COL_TAG, getNewResColId(pCmd));
- } else if (index.columnIndex == TSDB_BLOCK_DIST_COLUMN_INDEX) {
- SSchema colSchema = tGetBlockDistColumnSchema();
- tscAddFuncInSelectClause(pQueryInfo, startPos, TSDB_FUNC_PRJ, &index, &colSchema, TSDB_COL_TAG, getNewResColId(pCmd));
} else {
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, index.tableIndex);
STableMeta* pTableMeta = pTableMetaInfo->pTableMeta;
@@ -2487,7 +2551,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2);
}
- SColumnIndex index = {.tableIndex = 0, .columnIndex = TSDB_BLOCK_DIST_COLUMN_INDEX,};
+ SColumnIndex index = {.tableIndex = 0, .columnIndex = 0,};
pTableMetaInfo = tscGetMetaInfo(pQueryInfo, index.tableIndex);
SSchema s = {.name = "block_dist", .type = TSDB_DATA_TYPE_BINARY};
@@ -2495,10 +2559,16 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
int16_t resType = 0;
int16_t bytes = 0;
getResultDataInfo(TSDB_DATA_TYPE_INT, 4, TSDB_FUNC_BLKINFO, 0, &resType, &bytes, &inter, 0, 0);
-
s.bytes = bytes;
s.type = (uint8_t)resType;
- SExprInfo* pExpr = tscAddFuncInSelectClause(pQueryInfo, 0, TSDB_FUNC_BLKINFO, &index, &s, TSDB_COL_TAG, getNewResColId(pCmd));
+
+ SExprInfo* pExpr = tscExprInsert(pQueryInfo, 0, TSDB_FUNC_BLKINFO, &index, resType,
+ bytes, getNewResColId(pCmd), bytes, 0);
+ tstrncpy(pExpr->base.aliasName, s.name, sizeof(pExpr->base.aliasName));
+
+ SColumnList ids = createColumnList(1, index.tableIndex, index.columnIndex);
+ insertResultField(pQueryInfo, 0, &ids, bytes, s.type, s.name, pExpr);
+
pExpr->base.numOfParams = 1;
pExpr->base.param[0].i64 = pTableMetaInfo->pTableMeta->tableInfo.rowSize;
pExpr->base.param[0].nType = TSDB_DATA_TYPE_BIGINT;
@@ -2545,14 +2615,6 @@ static bool isTablenameToken(SStrToken* token) {
return (strncasecmp(TSQL_TBNAME_L, tmpToken.z, tmpToken.n) == 0 && tmpToken.n == strlen(TSQL_TBNAME_L));
}
-static bool isTableBlockDistToken(SStrToken* token) {
- SStrToken tmpToken = *token;
- SStrToken tableToken = {0};
-
- extractTableNameFromToken(&tmpToken, &tableToken);
-
- return (strncasecmp(TSQL_BLOCK_DIST, tmpToken.z, tmpToken.n) == 0 && tmpToken.n == strlen(TSQL_BLOCK_DIST_L));
-}
static int16_t doGetColumnIndex(SQueryInfo* pQueryInfo, int32_t index, SStrToken* pToken) {
STableMeta* pTableMeta = tscGetMetaInfo(pQueryInfo, index)->pTableMeta;
@@ -2582,8 +2644,6 @@ int32_t doGetColumnIndexByName(SSqlCmd* pCmd, SStrToken* pToken, SQueryInfo* pQu
if (isTablenameToken(pToken)) {
pIndex->columnIndex = TSDB_TBNAME_COLUMN_INDEX;
- } else if (isTableBlockDistToken(pToken)) {
- pIndex->columnIndex = TSDB_BLOCK_DIST_COLUMN_INDEX;
} else if (strncasecmp(pToken->z, DEFAULT_PRIMARY_TIMESTAMP_COL_NAME, pToken->n) == 0) {
pIndex->columnIndex = PRIMARYKEY_TIMESTAMP_COL_INDEX;
} else {
@@ -2903,6 +2963,9 @@ bool hasUnsupportFunctionsForSTableQuery(SSqlCmd* pCmd, SQueryInfo* pQueryInfo)
return true;
}
}
+ } else if (tscIsSessionWindowQuery(pQueryInfo)) {
+ invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3);
+ return true;
}
return false;
@@ -6163,7 +6226,7 @@ static int32_t doTagFunctionCheck(SQueryInfo* pQueryInfo) {
int32_t doFunctionsCompatibleCheck(SSqlCmd* pCmd, SQueryInfo* pQueryInfo) {
const char* msg1 = "functions/columns not allowed in group by query";
const char* msg2 = "projection query on columns not allowed";
- const char* msg3 = "group by not allowed on projection query";
+ const char* msg3 = "group by/session/state_window not allowed on projection query";
const char* msg4 = "retrieve tags not compatible with group by or interval query";
const char* msg5 = "functions can not be mixed up";
@@ -6179,6 +6242,9 @@ int32_t doFunctionsCompatibleCheck(SSqlCmd* pCmd, SQueryInfo* pQueryInfo) {
return TSDB_CODE_SUCCESS;
}
}
+ if (tscIsProjectionQuery(pQueryInfo) && tscIsSessionWindowQuery(pQueryInfo)) {
+ return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3);
+ }
if (pQueryInfo->groupbyExpr.numOfGroupCols > 0) {
// check if all the tags prj columns belongs to the group by columns
@@ -6610,7 +6676,7 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) {
if (!findColumnIndex) {
tdDestroyKVRowBuilder(&kvRowBuilder);
- return tscInvalidSQLErrMsg(pCmd->payload, "invalid tag name", sToken->z);
+ return tscInvalidOperationMsg(pCmd->payload, "invalid tag name", sToken->z);
}
}
} else {
@@ -6748,6 +6814,7 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) {
return TSDB_CODE_TSC_INVALID_OPERATION;
}
+
if (isTimeWindowQuery(pQueryInfo) && (validateFunctionsInIntervalOrGroupbyQuery(pCmd, pQueryInfo) != TSDB_CODE_SUCCESS)) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2);
}
@@ -7422,6 +7489,7 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, SQueryInfo* pQueryInf
const char* msg1 = "point interpolation query needs timestamp";
const char* msg2 = "too many tables in from clause";
const char* msg3 = "start(end) time of query range required or time range too large";
+ const char* msg4 = "interval query not supported, since the result of sub query not include valid timestamp column";
const char* msg9 = "only tag query not compatible with normal column filter";
int32_t code = TSDB_CODE_SUCCESS;
@@ -7463,6 +7531,7 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, SQueryInfo* pQueryInf
return TSDB_CODE_TSC_INVALID_OPERATION;
}
+ // validate the query filter condition info
if (pSqlNode->pWhere != NULL) {
if (validateWhereNode(pQueryInfo, &pSqlNode->pWhere, pSql) != TSDB_CODE_SUCCESS) {
return TSDB_CODE_TSC_INVALID_OPERATION;
@@ -7474,6 +7543,30 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, SQueryInfo* pQueryInf
pQueryInfo->window.ekey = pQueryInfo->window.ekey / 1000;
}
}
+
+ // validate the interval info
+ if (validateIntervalNode(pSql, pQueryInfo, pSqlNode) != TSDB_CODE_SUCCESS) {
+ return TSDB_CODE_TSC_INVALID_OPERATION;
+ } else {
+ if (isTimeWindowQuery(pQueryInfo)) {
+ // check if the first column of the nest query result is timestamp column
+ SColumn* pCol = taosArrayGetP(pQueryInfo->colList, 0);
+ if (pCol->info.type != TSDB_DATA_TYPE_TIMESTAMP) {
+ return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg4);
+ }
+
+ if (validateFunctionsInIntervalOrGroupbyQuery(pCmd, pQueryInfo) != TSDB_CODE_SUCCESS) {
+ return TSDB_CODE_TSC_INVALID_OPERATION;
+ }
+ }
+ }
+
+ // set order by info
+ STableMeta* pTableMeta = tscGetMetaInfo(pQueryInfo, 0)->pTableMeta;
+ if (validateOrderbyNode(pCmd, pQueryInfo, pSqlNode, tscGetTableSchema(pTableMeta)) !=
+ TSDB_CODE_SUCCESS) {
+ return TSDB_CODE_TSC_INVALID_OPERATION;
+ }
} else {
pQueryInfo->command = TSDB_SQL_SELECT;
@@ -7525,7 +7618,10 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, SQueryInfo* pQueryInf
TSDB_CODE_SUCCESS) {
return TSDB_CODE_TSC_INVALID_OPERATION;
}
-
+ // parse the window_state
+ if (validateStateWindowNode(pCmd, pQueryInfo, pSqlNode, isSTable) != TSDB_CODE_SUCCESS) {
+ return TSDB_CODE_TSC_INVALID_OPERATION;
+ }
// set order by info
if (validateOrderbyNode(pCmd, pQueryInfo, pSqlNode, tscGetTableSchema(pTableMetaInfo->pTableMeta)) !=
TSDB_CODE_SUCCESS) {
@@ -7566,6 +7662,10 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, SQueryInfo* pQueryInf
* transfer sql functions that need secondary merge into another format
* in dealing with super table queries such as: count/first/last
*/
+ if (validateSessionNode(pCmd, pQueryInfo, pSqlNode) != TSDB_CODE_SUCCESS) {
+ return TSDB_CODE_TSC_INVALID_OPERATION;
+ }
+
if (isSTable) {
tscTansformFuncForSTableQuery(pQueryInfo);
if (hasUnsupportFunctionsForSTableQuery(pCmd, pQueryInfo)) {
@@ -7573,10 +7673,6 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, SQueryInfo* pQueryInf
}
}
- if (validateSessionNode(pCmd, pQueryInfo, pSqlNode) != TSDB_CODE_SUCCESS) {
- return TSDB_CODE_TSC_INVALID_OPERATION;
- }
-
// no result due to invalid query time range
if (pQueryInfo->window.skey > pQueryInfo->window.ekey) {
pQueryInfo->command = TSDB_SQL_RETRIEVE_EMPTY_RESULT;
@@ -7619,11 +7715,12 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, SQueryInfo* pQueryInf
pQueryInfo->groupbyColumn = tscGroupbyColumn(pQueryInfo);
pQueryInfo->arithmeticOnAgg = tsIsArithmeticQueryOnAggResult(pQueryInfo);
+ pQueryInfo->orderProjectQuery = tscOrderedProjectionQueryOnSTable(pQueryInfo, 0);
SExprInfo** p = NULL;
int32_t numOfExpr = 0;
+ pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
code = createProjectionExpr(pQueryInfo, pTableMetaInfo, &p, &numOfExpr);
-
if (pQueryInfo->exprList1 == NULL) {
pQueryInfo->exprList1 = taosArrayInit(4, POINTER_BYTES);
}
diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c
index a3032a342e..f997d487d1 100644
--- a/src/client/src/tscServer.c
+++ b/src/client/src/tscServer.c
@@ -15,15 +15,15 @@
#include "os.h"
#include "tcmdtype.h"
+#include "tlockfree.h"
#include "trpc.h"
-#include "tscLocalMerge.h"
+#include "tscGlobalmerge.h"
#include "tscLog.h"
#include "tscProfile.h"
#include "tscUtil.h"
-#include "tschemautil.h"
+#include "qTableMeta.h"
#include "tsclient.h"
#include "ttimer.h"
-#include "tlockfree.h"
#include "qPlan.h"
int (*tscBuildMsg[TSDB_SQL_MAX])(SSqlObj *pSql, SSqlInfo *pInfo) = {0};
@@ -477,7 +477,6 @@ int doBuildAndSendMsg(SSqlObj *pSql) {
pCmd->command == TSDB_SQL_INSERT ||
pCmd->command == TSDB_SQL_CONNECT ||
pCmd->command == TSDB_SQL_HB ||
-// pCmd->command == TSDB_SQL_META ||
pCmd->command == TSDB_SQL_STABLEVGROUP) {
pRes->code = tscBuildMsg[pCmd->command](pSql, NULL);
}
@@ -857,6 +856,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pQueryMsg->simpleAgg = query.simpleAgg;
pQueryMsg->pointInterpQuery = query.pointInterpQuery;
pQueryMsg->needReverseScan = query.needReverseScan;
+ pQueryMsg->stateWindow = query.stateWindow;
pQueryMsg->numOfTags = htonl(numOfTags);
pQueryMsg->sqlstrLen = htonl(sqlLen);
@@ -1598,7 +1598,7 @@ int tscProcessRetrieveLocalMergeRsp(SSqlObj *pSql) {
return code;
}
- if (pRes->pLocalMerger == NULL) { // no result from subquery, so abort here directly.
+ if (pRes->pMerger == NULL) { // no result from subquery, so abort here directly.
(*pSql->fp)(pSql->param, pSql, pRes->numOfRows);
return code;
}
@@ -1615,15 +1615,7 @@ int tscProcessRetrieveLocalMergeRsp(SSqlObj *pSql) {
taosArrayPush(group, &tableKeyInfo);
taosArrayPush(tableGroupInfo.pGroupList, &group);
- // todo remove it
- SExprInfo* list = calloc(tscNumOfExprs(pQueryInfo), sizeof(SExprInfo));
- for(int32_t i = 0; i < tscNumOfExprs(pQueryInfo); ++i) {
- SExprInfo* pExprInfo = tscExprGet(pQueryInfo, i);
- list[i] = *pExprInfo;
- }
-
- pQueryInfo->pQInfo = createQInfoFromQueryNode(pQueryInfo, list, &tableGroupInfo, NULL, NULL, pRes->pLocalMerger, MERGE_STAGE);
- tfree(list);
+ pQueryInfo->pQInfo = createQInfoFromQueryNode(pQueryInfo, &tableGroupInfo, NULL, NULL, pRes->pMerger, MERGE_STAGE);
}
uint64_t localQueryId = 0;
@@ -2402,8 +2394,8 @@ static int32_t getTableMetaFromMnode(SSqlObj *pSql, STableMetaInfo *pTableMetaIn
char *pMsg = (char *)pInfoMsg + sizeof(STableInfoMsg);
// tag data exists
- if (autocreate && pSql->cmd.tagData.dataLen != 0) {
- pMsg = serializeTagData(&pSql->cmd.tagData, pMsg);
+ if (autocreate && pSql->cmd.insertParam.tagData.dataLen != 0) {
+ pMsg = serializeTagData(&pSql->cmd.insertParam.tagData, pMsg);
}
pNew->cmd.payloadLen = (int32_t)(pMsg - (char*)pInfoMsg);
@@ -2477,8 +2469,8 @@ int32_t getMultiTableMetaFromMnode(SSqlObj *pSql, SArray* pNameList, SArray* pVg
pNew->fp = fp;
pNew->param = (void *)pSql->self;
- tscDebug("0x%"PRIx64" metaRid from %" PRId64 " to %" PRId64 , pSql->self, pSql->metaRid, pNew->self);
-
+ tscDebug("0x%"PRIx64" metaRid from 0x%" PRIx64 " to 0x%" PRIx64 , pSql->self, pSql->metaRid, pNew->self);
+
pSql->metaRid = pNew->self;
int32_t code = tscBuildAndSendRequest(pNew, NULL);
if (code == TSDB_CODE_SUCCESS) {
diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c
index 1ffa6416b2..554ce351eb 100644
--- a/src/client/src/tscSql.c
+++ b/src/client/src/tscSql.c
@@ -627,7 +627,7 @@ static bool hasAdditionalErrorInfo(int32_t code, SSqlCmd *pCmd) {
char *z = NULL;
if (len > 0) {
- z = strstr(pCmd->payload, "invalid SQL");
+ z = strstr(pCmd->payload, "invalid operation");
if (z == NULL) {
z = strstr(pCmd->payload, "syntax error");
}
diff --git a/src/client/src/tscStream.c b/src/client/src/tscStream.c
index 8e11fd0cfb..73a3fbafc3 100644
--- a/src/client/src/tscStream.c
+++ b/src/client/src/tscStream.c
@@ -13,7 +13,6 @@
* along with this program. If not, see .
*/
-#include
#include "os.h"
#include "taosmsg.h"
#include "tscLog.h"
diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c
index 37c60edd38..2f32e775d6 100644
--- a/src/client/src/tscSubquery.c
+++ b/src/client/src/tscSubquery.c
@@ -21,7 +21,7 @@
#include "tcompare.h"
#include "tscLog.h"
#include "tscSubquery.h"
-#include "tschemautil.h"
+#include "qTableMeta.h"
#include "tsclient.h"
#include "qUtil.h"
#include "qPlan.h"
@@ -1469,6 +1469,8 @@ static void joinRetrieveFinalResCallback(void* param, TAOS_RES* tres, int numOfR
SSqlRes* pRes1 = &pParentSql->pSubs[i]->res;
+ pParentSql->res.precision = pRes1->precision;
+
if (pRes1->row > 0 && pRes1->numOfRows > 0) {
tscDebug("0x%"PRIx64" sub:0x%"PRIx64" index:%d numOfRows:%d total:%"PRId64 " (not retrieve)", pParentSql->self,
pParentSql->pSubs[i]->self, i, pRes1->numOfRows, pRes1->numOfTotal);
@@ -2446,7 +2448,7 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
assert(pState->numOfSub > 0);
- int32_t ret = tscLocalReducerEnvCreate(pQueryInfo, &pMemoryBuf, pSql->subState.numOfSub, &pDesc, nBufferSize, pSql->self);
+ int32_t ret = tscCreateGlobalMergerEnv(pQueryInfo, &pMemoryBuf, pSql->subState.numOfSub, &pDesc, nBufferSize, pSql->self);
if (ret != 0) {
pRes->code = ret;
tscAsyncResultOnError(pSql);
@@ -2459,7 +2461,7 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
if (pSql->pSubs == NULL) {
tfree(pSql->pSubs);
pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY;
- tscLocalReducerEnvDestroy(pMemoryBuf, pDesc,pState->numOfSub);
+ tscDestroyGlobalMergerEnv(pMemoryBuf, pDesc,pState->numOfSub);
tscAsyncResultOnError(pSql);
return ret;
@@ -2526,13 +2528,13 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
tscError("0x%"PRIx64" failed to prepare subquery structure and launch subqueries", pSql->self);
pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY;
- tscLocalReducerEnvDestroy(pMemoryBuf, pDesc, pState->numOfSub);
+ tscDestroyGlobalMergerEnv(pMemoryBuf, pDesc, pState->numOfSub);
doCleanupSubqueries(pSql, i);
return pRes->code; // free all allocated resource
}
if (pRes->code == TSDB_CODE_TSC_QUERY_CANCELLED) {
- tscLocalReducerEnvDestroy(pMemoryBuf, pDesc, pState->numOfSub);
+ tscDestroyGlobalMergerEnv(pMemoryBuf, pDesc, pState->numOfSub);
doCleanupSubqueries(pSql, i);
return pRes->code;
}
@@ -2697,7 +2699,7 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO
tstrerror(pParentSql->res.code));
// release allocated resource
- tscLocalReducerEnvDestroy(trsupport->pExtMemBuffer, trsupport->pOrderDescriptor,
+ tscDestroyGlobalMergerEnv(trsupport->pExtMemBuffer, trsupport->pOrderDescriptor,
pState->numOfSub);
tscFreeRetrieveSup(pSql);
@@ -2772,7 +2774,7 @@ static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* p
SQueryInfo *pPQueryInfo = tscGetQueryInfo(&pParentSql->cmd);
tscClearInterpInfo(pPQueryInfo);
- code = tscCreateLocalMerger(trsupport->pExtMemBuffer, pState->numOfSub, pDesc, pPQueryInfo, &pParentSql->res.pLocalMerger, pParentSql->self);
+ code = tscCreateGlobalMerger(trsupport->pExtMemBuffer, pState->numOfSub, pDesc, pPQueryInfo, &pParentSql->res.pMerger, pParentSql->self);
pParentSql->res.code = code;
if (code == TSDB_CODE_SUCCESS && trsupport->pExtMemBuffer == NULL) {
@@ -3499,9 +3501,8 @@ static UNUSED_FUNC bool tscHasRemainDataInSubqueryResultSet(SSqlObj *pSql) {
return hasData;
}
-// todo remove pExprs
-void* createQInfoFromQueryNode(SQueryInfo* pQueryInfo, SExprInfo* pExprs, STableGroupInfo* pTableGroupInfo,
- SOperatorInfo* pSourceOperator, char* sql, void* merger, int32_t stage) {
+void* createQInfoFromQueryNode(SQueryInfo* pQueryInfo, STableGroupInfo* pTableGroupInfo, SOperatorInfo* pSourceOperator,
+ char* sql, void* merger, int32_t stage) {
assert(pQueryInfo != NULL);
SQInfo *pQInfo = (SQInfo *)calloc(1, sizeof(SQInfo));
if (pQInfo == NULL) {
diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c
index 4596846d4c..8042f032c8 100644
--- a/src/client/src/tscUtil.c
+++ b/src/client/src/tscUtil.c
@@ -14,18 +14,18 @@
*/
#include "tscUtil.h"
-#include "tsched.h"
#include "hash.h"
#include "os.h"
#include "taosmsg.h"
#include "texpr.h"
#include "tkey.h"
#include "tmd5.h"
-#include "tscLocalMerge.h"
+#include "tscGlobalmerge.h"
#include "tscLog.h"
#include "tscProfile.h"
#include "tscSubquery.h"
-#include "tschemautil.h"
+#include "tsched.h"
+#include "qTableMeta.h"
#include "tsclient.h"
#include "ttimer.h"
#include "ttokendef.h"
@@ -434,6 +434,9 @@ bool tscIsTWAQuery(SQueryInfo* pQueryInfo) {
return false;
}
+bool tscIsSessionWindowQuery(SQueryInfo* pQueryInfo) {
+ return pQueryInfo->sessionWindow.gap > 0;
+}
bool tscNeedReverseScan(SQueryInfo* pQueryInfo) {
size_t numOfExprs = tscNumOfExprs(pQueryInfo);
@@ -527,7 +530,7 @@ bool isSimpleAggregateRv(SQueryInfo* pQueryInfo) {
bool isBlockDistQuery(SQueryInfo* pQueryInfo) {
size_t numOfExprs = tscNumOfExprs(pQueryInfo);
SExprInfo* pExpr = tscExprGet(pQueryInfo, 0);
- return (numOfExprs == 1 && pExpr->base.colInfo.colId == TSDB_BLOCK_DIST_COLUMN_INDEX);
+ return (numOfExprs == 1 && pExpr->base.functionId == TSDB_FUNC_BLKINFO);
}
void tscClearInterpInfo(SQueryInfo* pQueryInfo) {
@@ -707,9 +710,10 @@ static SColumnInfo* extractColumnInfoFromResult(SArray* pTableCols) {
}
typedef struct SDummyInputInfo {
- SSDataBlock *block;
- SSqlObj *pSql; // refactor: remove it
- int32_t numOfFilterCols;
+ SSDataBlock *block;
+ STableQueryInfo *pTableQueryInfo;
+ SSqlObj *pSql; // refactor: remove it
+ int32_t numOfFilterCols;
SSingleColumnFilterInfo *pFilterInfo;
} SDummyInputInfo;
@@ -726,9 +730,10 @@ typedef struct SJoinOperatorInfo {
SRspResultInfo resultInfo; // todo refactor, add this info for each operator
} SJoinOperatorInfo;
-static void doSetupSDataBlock(SSqlRes* pRes, SSDataBlock* pBlock) {
+static void doSetupSDataBlock(SSqlRes* pRes, SSDataBlock* pBlock, SSingleColumnFilterInfo* pFilterInfo, int32_t numOfFilterCols) {
int32_t offset = 0;
char* pData = pRes->data;
+
for(int32_t i = 0; i < pBlock->info.numOfCols; ++i) {
SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, i);
if (pData != NULL) {
@@ -740,6 +745,26 @@ static void doSetupSDataBlock(SSqlRes* pRes, SSDataBlock* pBlock) {
offset += pColData->info.bytes;
}
+ // filter data if needed
+ if (numOfFilterCols > 0) {
+ doSetFilterColumnInfo(pFilterInfo, numOfFilterCols, pBlock);
+ int8_t* p = calloc(pBlock->info.rows, sizeof(int8_t));
+ bool all = doFilterDataBlock(pFilterInfo, numOfFilterCols, pBlock->info.rows, p);
+ if (!all) {
+ doCompactSDataBlock(pBlock, pBlock->info.rows, p);
+ }
+
+ tfree(p);
+ }
+
+ // todo refactor: extract method
+ // set the timestamp range of current result data block
+ SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, 0);
+ if (pColData->info.type == TSDB_DATA_TYPE_TIMESTAMP) {
+ pBlock->info.window.skey = ((int64_t*)pColData->pData)[0];
+ pBlock->info.window.ekey = ((int64_t*)pColData->pData)[pBlock->info.rows-1];
+ }
+
pRes->numOfRows = 0;
}
@@ -755,22 +780,13 @@ SSDataBlock* doGetDataBlock(void* param, bool* newgroup) {
SSqlRes* pRes = &pSql->res;
SSDataBlock* pBlock = pInput->block;
+ if (pOperator->pRuntimeEnv != NULL) {
+ pOperator->pRuntimeEnv->current = pInput->pTableQueryInfo;
+ }
pBlock->info.rows = pRes->numOfRows;
if (pRes->numOfRows != 0) {
- doSetupSDataBlock(pRes, pBlock);
-
- if (pInput->numOfFilterCols > 0) {
- doSetFilterColumnInfo(pInput->pFilterInfo, pInput->numOfFilterCols, pBlock);
- int8_t* p = calloc(pBlock->info.rows, sizeof(int8_t));
- bool all = doFilterDataBlock(pInput->pFilterInfo, pInput->numOfFilterCols, pBlock->info.rows, p);
- if (!all) {
- doCompactSDataBlock(pBlock, pBlock->info.rows, p);
- }
-
- tfree(p);
- }
-
+ doSetupSDataBlock(pRes, pBlock, pInput->pFilterInfo, pInput->numOfFilterCols);
*newgroup = false;
return pBlock;
}
@@ -785,11 +801,29 @@ SSDataBlock* doGetDataBlock(void* param, bool* newgroup) {
}
pBlock->info.rows = pRes->numOfRows;
- doSetupSDataBlock(pRes, pBlock);
+ doSetupSDataBlock(pRes, pBlock, pInput->pFilterInfo, pInput->numOfFilterCols);
*newgroup = false;
return pBlock;
}
+static void fetchNextBlockIfCompleted(SOperatorInfo* pOperator, bool* newgroup) {
+ SJoinOperatorInfo* pJoinInfo = pOperator->info;
+
+ for (int32_t i = 0; i < pOperator->numOfUpstream; ++i) {
+ SJoinStatus* pStatus = &pJoinInfo->status[i];
+ if (pStatus->pBlock == NULL || pStatus->index >= pStatus->pBlock->info.rows) {
+ pStatus->pBlock = pOperator->upstream[i]->exec(pOperator->upstream[i], newgroup);
+ pStatus->index = 0;
+
+ if (pStatus->pBlock == NULL) {
+ pOperator->status = OP_EXEC_DONE;
+ pJoinInfo->resultInfo.total += pJoinInfo->pRes->info.rows;
+ break;
+ }
+ }
+ }
+}
+
SSDataBlock* doDataBlockJoin(void* param, bool* newgroup) {
SOperatorInfo *pOperator = (SOperatorInfo*) param;
if (pOperator->status == OP_EXEC_DONE) {
@@ -802,19 +836,9 @@ SSDataBlock* doDataBlockJoin(void* param, bool* newgroup) {
pJoinInfo->pRes->info.rows = 0;
while(1) {
- for (int32_t i = 0; i < pOperator->numOfUpstream; ++i) {
- SJoinStatus* pStatus = &pJoinInfo->status[i];
- if (pStatus->pBlock == NULL || pStatus->index >= pStatus->pBlock->info.rows) {
- pStatus->pBlock = pOperator->upstream[i]->exec(pOperator->upstream[i], newgroup);
- pStatus->index = 0;
-
- if (pStatus->pBlock == NULL) {
- pOperator->status = OP_EXEC_DONE;
-
- pJoinInfo->resultInfo.total += pJoinInfo->pRes->info.rows;
- return pJoinInfo->pRes;
- }
- }
+ fetchNextBlockIfCompleted(pOperator, newgroup);
+ if (pOperator->status == OP_EXEC_DONE) {
+ return pJoinInfo->pRes;
}
SJoinStatus* st0 = &pJoinInfo->status[0];
@@ -833,8 +857,12 @@ SSDataBlock* doDataBlockJoin(void* param, bool* newgroup) {
if (ts[st->index] < ts0[st0->index]) { // less than the first
prefixEqual = false;
+
if ((++(st->index)) >= st->pBlock->info.rows) {
- break;
+ fetchNextBlockIfCompleted(pOperator, newgroup);
+ if (pOperator->status == OP_EXEC_DONE) {
+ return pJoinInfo->pRes;
+ }
}
} else if (ts[st->index] > ts0[st0->index]) { // greater than the first;
if (prefixEqual == true) {
@@ -842,12 +870,19 @@ SSDataBlock* doDataBlockJoin(void* param, bool* newgroup) {
for (int32_t j = 0; j < i; ++j) {
SJoinStatus* stx = &pJoinInfo->status[j];
if ((++(stx->index)) >= stx->pBlock->info.rows) {
- break;
+
+ fetchNextBlockIfCompleted(pOperator, newgroup);
+ if (pOperator->status == OP_EXEC_DONE) {
+ return pJoinInfo->pRes;
+ }
}
}
} else {
if ((++(st0->index)) >= st0->pBlock->info.rows) {
- break;
+ fetchNextBlockIfCompleted(pOperator, newgroup);
+ if (pOperator->status == OP_EXEC_DONE) {
+ return pJoinInfo->pRes;
+ }
}
}
}
@@ -942,11 +977,14 @@ static void destroyDummyInputOperator(void* param, int32_t numOfOutput) {
// todo this operator servers as the adapter for Operator tree and SqlRes result, remove it later
SOperatorInfo* createDummyInputOperator(SSqlObj* pSql, SSchema* pSchema, int32_t numOfCols, SSingleColumnFilterInfo* pFilterInfo, int32_t numOfFilterCols) {
assert(numOfCols > 0);
+ STimeWindow win = {.skey = INT64_MIN, .ekey = INT64_MAX};
+
SDummyInputInfo* pInfo = calloc(1, sizeof(SDummyInputInfo));
pInfo->pSql = pSql;
pInfo->pFilterInfo = pFilterInfo;
pInfo->numOfFilterCols = numOfFilterCols;
+ pInfo->pTableQueryInfo = createTmpTableQueryInfo(win);
pInfo->block = calloc(numOfCols, sizeof(SSDataBlock));
pInfo->block->info.numOfCols = numOfCols;
@@ -1032,20 +1070,31 @@ void convertQueryResult(SSqlRes* pRes, SQueryInfo* pQueryInfo) {
pRes->completed = (pRes->numOfRows == 0);
}
+static void createInputDataFilterInfo(SQueryInfo* px, int32_t numOfCol1, int32_t* numOfFilterCols, SSingleColumnFilterInfo** pFilterInfo) {
+ SColumnInfo* tableCols = calloc(numOfCol1, sizeof(SColumnInfo));
+ for(int32_t i = 0; i < numOfCol1; ++i) {
+ SColumn* pCol = taosArrayGetP(px->colList, i);
+ if (pCol->info.flist.numOfFilters > 0) {
+ (*numOfFilterCols) += 1;
+ }
+
+ tableCols[i] = pCol->info;
+ }
+
+ if ((*numOfFilterCols) > 0) {
+ doCreateFilterInfo(tableCols, numOfCol1, (*numOfFilterCols), pFilterInfo, 0);
+ }
+
+ tfree(tableCols);
+}
+
void handleDownstreamOperator(SSqlObj** pSqlObjList, int32_t numOfUpstream, SQueryInfo* px, SSqlRes* pOutput) {
// handle the following query process
if (px->pQInfo == NULL) {
SColumnInfo* pColumnInfo = extractColumnInfoFromResult(px->colList);
- int32_t numOfOutput = (int32_t)tscNumOfExprs(px);
- int32_t numOfCols = (int32_t)taosArrayGetSize(px->colList);
-
- SQueriedTableInfo info = {
- .colList = pColumnInfo,
- .numOfCols = numOfCols,
- };
-
- SSchema* pSchema = tscGetTableSchema(px->pTableMetaInfo[0]->pTableMeta);
+ STableMeta* pTableMeta = tscGetMetaInfo(px, 0)->pTableMeta;
+ SSchema* pSchema = tscGetTableSchema(pTableMeta);
STableGroupInfo tableGroupInfo = {
.numOfTables = 1,
@@ -1062,23 +1111,11 @@ void handleDownstreamOperator(SSqlObj** pSqlObjList, int32_t numOfUpstream, SQue
taosArrayPush(tableGroupInfo.pGroupList, &group);
// if it is a join query, create join operator here
- int32_t numOfCol1 = px->pTableMetaInfo[0]->pTableMeta->tableInfo.numOfColumns;
+ int32_t numOfCol1 = pTableMeta->tableInfo.numOfColumns;
int32_t numOfFilterCols = 0;
- SColumnInfo* tableCols = calloc(numOfCol1, sizeof(SColumnInfo));
- for(int32_t i = 0; i < numOfCol1; ++i) {
- SColumn* pCol = taosArrayGetP(px->colList, i);
- if (pCol->info.flist.numOfFilters > 0) {
- numOfFilterCols += 1;
- }
-
- tableCols[i] = pCol->info;
- }
-
SSingleColumnFilterInfo* pFilterInfo = NULL;
- if (numOfFilterCols > 0) {
- doCreateFilterInfo(tableCols, numOfCol1, numOfFilterCols, &pFilterInfo, 0);
- }
+ createInputDataFilterInfo(px, numOfCol1, &numOfFilterCols, &pFilterInfo);
SOperatorInfo* pSourceOperator = createDummyInputOperator(pSqlObjList[0], pSchema, numOfCol1, pFilterInfo, numOfFilterCols);
@@ -1094,24 +1131,14 @@ void handleDownstreamOperator(SSqlObj** pSqlObjList, int32_t numOfUpstream, SQue
int32_t offset = pSourceOperator->numOfOutput;
for(int32_t i = 1; i < px->numOfTables; ++i) {
- SSchema* pSchema1 = tscGetTableSchema(px->pTableMetaInfo[i]->pTableMeta);
- int32_t n = px->pTableMetaInfo[i]->pTableMeta->tableInfo.numOfColumns;
+ STableMeta* pTableMeta1 = tscGetMetaInfo(px, i)->pTableMeta;
+
+ SSchema* pSchema1 = tscGetTableSchema(pTableMeta1);
+ int32_t n = pTableMeta1->tableInfo.numOfColumns;
int32_t numOfFilterCols1 = 0;
- SColumnInfo* tableCols1 = calloc(numOfCol1, sizeof(SColumnInfo));
- for(int32_t j = 0; j < numOfCol1; ++j) {
- SColumn* pCol = taosArrayGetP(px->colList, j);
- if (pCol->info.flist.numOfFilters > 0) {
- numOfFilterCols += 1;
- }
-
- tableCols1[j] = pCol->info;
- }
-
SSingleColumnFilterInfo* pFilterInfo1 = NULL;
- if (numOfFilterCols1 > 0) {
- doCreateFilterInfo(tableCols1, numOfCol1, numOfFilterCols1, &pFilterInfo1, 0);
- }
+ createInputDataFilterInfo(px, numOfCol1, &numOfFilterCols1, &pFilterInfo1);
p[i] = createDummyInputOperator(pSqlObjList[i], pSchema1, n, pFilterInfo1, numOfFilterCols1);
memcpy(&schema[offset], pSchema1, n * sizeof(SSchema));
@@ -1126,8 +1153,8 @@ void handleDownstreamOperator(SSqlObj** pSqlObjList, int32_t numOfUpstream, SQue
memcpy(schema, pSchema, numOfCol1*sizeof(SSchema));
}
- SExprInfo* exprInfo = NULL;
- /*int32_t code = */ createQueryFunc(&info, numOfOutput, &exprInfo, px->exprList->pData, NULL, px->type, NULL);
+ // update the exprinfo
+ int32_t numOfOutput = (int32_t)tscNumOfExprs(px);
for(int32_t i = 0; i < numOfOutput; ++i) {
SExprInfo* pex = taosArrayGetP(px->exprList, i);
int32_t colId = pex->base.colInfo.colId;
@@ -1139,10 +1166,12 @@ void handleDownstreamOperator(SSqlObj** pSqlObjList, int32_t numOfUpstream, SQue
}
}
- px->pQInfo = createQInfoFromQueryNode(px, exprInfo, &tableGroupInfo, pSourceOperator, NULL, NULL, MASTER_SCAN);
+ px->pQInfo = createQInfoFromQueryNode(px, &tableGroupInfo, pSourceOperator, NULL, NULL, MASTER_SCAN);
tfree(pColumnInfo);
tfree(schema);
- tfree(exprInfo);
+
+ // set the pRuntimeEnv for pSourceOperator
+ pSourceOperator->pRuntimeEnv = &px->pQInfo->runtimeEnv;
}
uint64_t qId = 0;
@@ -1219,31 +1248,34 @@ void tscFreeQueryInfo(SSqlCmd* pCmd, bool removeMeta) {
pCmd->active = NULL;
}
-void destroyTableNameList(SSqlCmd* pCmd) {
- if (pCmd->insertParam.numOfTables == 0) {
- assert(pCmd->insertParam.pTableNameList == NULL);
+void destroyTableNameList(SInsertStatementParam* pInsertParam) {
+ if (pInsertParam->numOfTables == 0) {
+ assert(pInsertParam->pTableNameList == NULL);
return;
}
- for(int32_t i = 0; i < pCmd->insertParam.numOfTables; ++i) {
- tfree(pCmd->insertParam.pTableNameList[i]);
+ for(int32_t i = 0; i < pInsertParam->numOfTables; ++i) {
+ tfree(pInsertParam->pTableNameList[i]);
}
- pCmd->insertParam.numOfTables = 0;
- tfree(pCmd->insertParam.pTableNameList);
+ pInsertParam->numOfTables = 0;
+ tfree(pInsertParam->pTableNameList);
}
void tscResetSqlCmd(SSqlCmd* pCmd, bool clearCachedMeta) {
pCmd->command = 0;
pCmd->numOfCols = 0;
pCmd->count = 0;
- pCmd->curSql = NULL;
pCmd->msgType = 0;
- destroyTableNameList(pCmd);
+ pCmd->insertParam.sql = NULL;
+ destroyTableNameList(&pCmd->insertParam);
pCmd->insertParam.pTableBlockHashList = tscDestroyBlockHashTable(pCmd->insertParam.pTableBlockHashList, clearCachedMeta);
pCmd->insertParam.pDataBlocks = tscDestroyBlockArrayList(pCmd->insertParam.pDataBlocks);
+ tfree(pCmd->insertParam.tagData.data);
+ pCmd->insertParam.tagData.dataLen = 0;
+
tscFreeQueryInfo(pCmd, clearCachedMeta);
if (pCmd->pTableMetaMap != NULL) {
@@ -1262,8 +1294,8 @@ void tscResetSqlCmd(SSqlCmd* pCmd, bool clearCachedMeta) {
void tscFreeSqlResult(SSqlObj* pSql) {
SSqlRes* pRes = &pSql->res;
- tscDestroyLocalMerger(pRes->pLocalMerger);
- pRes->pLocalMerger = NULL;
+ tscDestroyGlobalMerger(pRes->pMerger);
+ pRes->pMerger = NULL;
tscDestroyResPointerInfo(pRes);
memset(&pSql->res, 0, sizeof(SSqlRes));
@@ -1356,9 +1388,6 @@ void tscFreeSqlObj(SSqlObj* pSql) {
tscFreeSqlResult(pSql);
tscResetSqlCmd(pCmd, false);
- tfree(pCmd->tagData.data);
- pCmd->tagData.dataLen = 0;
-
memset(pCmd->payload, 0, (size_t)pCmd->allocSize);
tfree(pCmd->payload);
pCmd->allocSize = 0;
@@ -1659,37 +1688,36 @@ static int32_t getRowExpandSize(STableMeta* pTableMeta) {
return result;
}
-static void extractTableNameList(SSqlCmd* pCmd, bool freeBlockMap) {
- pCmd->insertParam.numOfTables = (int32_t) taosHashGetSize(pCmd->insertParam.pTableBlockHashList);
- if (pCmd->insertParam.pTableNameList == NULL) {
- pCmd->insertParam.pTableNameList = calloc(pCmd->insertParam.numOfTables, POINTER_BYTES);
+static void extractTableNameList(SInsertStatementParam *pInsertParam, bool freeBlockMap) {
+ pInsertParam->numOfTables = (int32_t) taosHashGetSize(pInsertParam->pTableBlockHashList);
+ if (pInsertParam->pTableNameList == NULL) {
+ pInsertParam->pTableNameList = calloc(pInsertParam->numOfTables, POINTER_BYTES);
} else {
- memset(pCmd->insertParam.pTableNameList, 0, pCmd->insertParam.numOfTables * POINTER_BYTES);
+ memset(pInsertParam->pTableNameList, 0, pInsertParam->numOfTables * POINTER_BYTES);
}
- STableDataBlocks **p1 = taosHashIterate(pCmd->insertParam.pTableBlockHashList, NULL);
+ STableDataBlocks **p1 = taosHashIterate(pInsertParam->pTableBlockHashList, NULL);
int32_t i = 0;
while(p1) {
STableDataBlocks* pBlocks = *p1;
- tfree(pCmd->insertParam.pTableNameList[i]);
+ tfree(pInsertParam->pTableNameList[i]);
- pCmd->insertParam.pTableNameList[i++] = tNameDup(&pBlocks->tableName);
- p1 = taosHashIterate(pCmd->insertParam.pTableBlockHashList, p1);
+ pInsertParam->pTableNameList[i++] = tNameDup(&pBlocks->tableName);
+ p1 = taosHashIterate(pInsertParam->pTableBlockHashList, p1);
}
if (freeBlockMap) {
- pCmd->insertParam.pTableBlockHashList = tscDestroyBlockHashTable(pCmd->insertParam.pTableBlockHashList, false);
+ pInsertParam->pTableBlockHashList = tscDestroyBlockHashTable(pInsertParam->pTableBlockHashList, false);
}
}
-int32_t tscMergeTableDataBlocks(SSqlObj* pSql, bool freeBlockMap) {
+int32_t tscMergeTableDataBlocks(SInsertStatementParam *pInsertParam, bool freeBlockMap) {
const int INSERT_HEAD_SIZE = sizeof(SMsgDesc) + sizeof(SSubmitMsg);
- SSqlCmd* pCmd = &pSql->cmd;
void* pVnodeDataBlockHashList = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, false);
SArray* pVnodeDataBlockList = taosArrayInit(8, POINTER_BYTES);
- STableDataBlocks** p = taosHashIterate(pCmd->insertParam.pTableBlockHashList, NULL);
+ STableDataBlocks** p = taosHashIterate(pInsertParam->pTableBlockHashList, NULL);
STableDataBlocks* pOneTableBlock = *p;
while(pOneTableBlock) {
@@ -1702,7 +1730,7 @@ int32_t tscMergeTableDataBlocks(SSqlObj* pSql, bool freeBlockMap) {
int32_t ret = tscGetDataBlockFromList(pVnodeDataBlockHashList, pOneTableBlock->vgId, TSDB_PAYLOAD_SIZE,
INSERT_HEAD_SIZE, 0, &pOneTableBlock->tableName, pOneTableBlock->pTableMeta, &dataBuf, pVnodeDataBlockList);
if (ret != TSDB_CODE_SUCCESS) {
- tscError("0x%"PRIx64" failed to prepare the data block buffer for merging table data, code:%d", pSql->self, ret);
+ tscError("0x%"PRIx64" failed to prepare the data block buffer for merging table data, code:%d", pInsertParam->objectId, ret);
taosHashCleanup(pVnodeDataBlockHashList);
tscDestroyBlockArrayList(pVnodeDataBlockList);
return ret;
@@ -1720,7 +1748,7 @@ int32_t tscMergeTableDataBlocks(SSqlObj* pSql, bool freeBlockMap) {
dataBuf->pData = tmp;
memset(dataBuf->pData + dataBuf->size, 0, dataBuf->nAllocSize - dataBuf->size);
} else { // failed to allocate memory, free already allocated memory and return error code
- tscError("0x%"PRIx64" failed to allocate memory for merging submit block, size:%d", pSql->self, dataBuf->nAllocSize);
+ tscError("0x%"PRIx64" failed to allocate memory for merging submit block, size:%d", pInsertParam->objectId, dataBuf->nAllocSize);
taosHashCleanup(pVnodeDataBlockHashList);
tscDestroyBlockArrayList(pVnodeDataBlockList);
@@ -1733,7 +1761,7 @@ int32_t tscMergeTableDataBlocks(SSqlObj* pSql, bool freeBlockMap) {
tscSortRemoveDataBlockDupRows(pOneTableBlock);
char* ekey = (char*)pBlocks->data + pOneTableBlock->rowSize*(pBlocks->numOfRows-1);
- tscDebug("0x%"PRIx64" name:%s, name:%d rows:%d sversion:%d skey:%" PRId64 ", ekey:%" PRId64, pSql->self, tNameGetTableName(&pOneTableBlock->tableName),
+ tscDebug("0x%"PRIx64" name:%s, name:%d rows:%d sversion:%d skey:%" PRId64 ", ekey:%" PRId64, pInsertParam->objectId, tNameGetTableName(&pOneTableBlock->tableName),
pBlocks->tid, pBlocks->numOfRows, pBlocks->sversion, GET_INT64_VAL(pBlocks->data), GET_INT64_VAL(ekey));
int32_t len = pBlocks->numOfRows * (pOneTableBlock->rowSize + expandSize) + sizeof(STColumn) * tscGetNumOfColumns(pOneTableBlock->pTableMeta);
@@ -1745,7 +1773,7 @@ int32_t tscMergeTableDataBlocks(SSqlObj* pSql, bool freeBlockMap) {
pBlocks->schemaLen = 0;
// erase the empty space reserved for binary data
- int32_t finalLen = trimDataBlock(dataBuf->pData + dataBuf->size, pOneTableBlock, pCmd->insertParam.schemaAttached);
+ int32_t finalLen = trimDataBlock(dataBuf->pData + dataBuf->size, pOneTableBlock, pInsertParam->schemaAttached);
assert(finalLen <= len);
dataBuf->size += (finalLen + sizeof(SSubmitBlk));
@@ -1757,10 +1785,10 @@ int32_t tscMergeTableDataBlocks(SSqlObj* pSql, bool freeBlockMap) {
pBlocks->numOfRows = 0;
}else {
- tscDebug("0x%"PRIx64" table %s data block is empty", pSql->self, pOneTableBlock->tableName.tname);
+ tscDebug("0x%"PRIx64" table %s data block is empty", pInsertParam->objectId, pOneTableBlock->tableName.tname);
}
- p = taosHashIterate(pCmd->insertParam.pTableBlockHashList, p);
+ p = taosHashIterate(pInsertParam->pTableBlockHashList, p);
if (p == NULL) {
break;
}
@@ -1768,10 +1796,10 @@ int32_t tscMergeTableDataBlocks(SSqlObj* pSql, bool freeBlockMap) {
pOneTableBlock = *p;
}
- extractTableNameList(pCmd, freeBlockMap);
+ extractTableNameList(pInsertParam, freeBlockMap);
// free the table data blocks;
- pCmd->insertParam.pDataBlocks = pVnodeDataBlockList;
+ pInsertParam->pDataBlocks = pVnodeDataBlockList;
taosHashCleanup(pVnodeDataBlockHashList);
return TSDB_CODE_SUCCESS;
@@ -2048,16 +2076,14 @@ SExprInfo* tscExprCreate(SQueryInfo* pQueryInfo, int16_t functionId, SColumnInde
p->colInfo.colId = TSDB_TBNAME_COLUMN_INDEX;
p->colBytes = s->bytes;
p->colType = s->type;
- } else if (pColIndex->columnIndex == TSDB_BLOCK_DIST_COLUMN_INDEX) {
- SSchema s = tGetBlockDistColumnSchema();
-
- p->colInfo.colId = TSDB_BLOCK_DIST_COLUMN_INDEX;
- p->colBytes = s.bytes;
- p->colType = s.type;
} else if (pColIndex->columnIndex <= TSDB_UD_COLUMN_INDEX) {
p->colInfo.colId = pColIndex->columnIndex;
p->colBytes = size;
p->colType = type;
+ } else if (functionId == TSDB_FUNC_BLKINFO) {
+ p->colInfo.colId = pColIndex->columnIndex;
+ p->colBytes = TSDB_MAX_BINARY_LEN;
+ p->colType = TSDB_DATA_TYPE_BINARY;
} else {
if (TSDB_COL_IS_TAG(colType)) {
SSchema* pSchema = tscGetTableTagSchema(pTableMetaInfo->pTableMeta);
@@ -2553,7 +2579,7 @@ bool tscValidateColumnId(STableMetaInfo* pTableMetaInfo, int32_t colId, int32_t
return false;
}
- if (colId == TSDB_TBNAME_COLUMN_INDEX || colId == TSDB_BLOCK_DIST_COLUMN_INDEX || (colId <= TSDB_UD_COLUMN_INDEX && numOfParams == 2)) {
+ if (colId == TSDB_TBNAME_COLUMN_INDEX || (colId <= TSDB_UD_COLUMN_INDEX && numOfParams == 2)) {
return true;
}
@@ -3100,6 +3126,15 @@ void tscResetForNextRetrieve(SSqlRes* pRes) {
pRes->numOfRows = 0;
}
+void tscInitResForMerge(SSqlRes* pRes) {
+ pRes->qId = 1; // hack to pass the safety check in fetch_row function
+ pRes->rspType = 0; // used as a flag to denote if taos_retrieved() has been called yet
+ tscResetForNextRetrieve(pRes);
+
+ assert(pRes->pMerger != NULL);
+ pRes->data = pRes->pMerger->buf;
+}
+
void registerSqlObj(SSqlObj* pSql) {
taosAcquireRef(tscRefId, pSql->pTscObj->rid);
pSql->self = taosAddRef(tscObjRef, pSql);
@@ -3121,14 +3156,6 @@ SSqlObj* createSimpleSubObj(SSqlObj* pSql, __async_cb_func_t fp, void* param, in
SSqlCmd* pCmd = &pNew->cmd;
pCmd->command = cmd;
-
- int32_t code = copyTagData(&pNew->cmd.tagData, &pSql->cmd.tagData);
- if (code != TSDB_CODE_SUCCESS) {
- tscError("0x%"PRIx64" new subquery failed, unable to malloc tag data, tableIndex:%d", pSql->self, 0);
- free(pNew);
- return NULL;
- }
-
if (tscAddQueryInfo(pCmd) != TSDB_CODE_SUCCESS) {
#ifdef __APPLE__
// to satisfy later tsem_destroy in taos_free_result
@@ -3224,8 +3251,6 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, __async_cb_func_t
pnCmd->insertParam.numOfTables = 0;
pnCmd->insertParam.pTableNameList = NULL;
pnCmd->insertParam.pTableBlockHashList = NULL;
- pnCmd->tagData.data = NULL;
- pnCmd->tagData.dataLen = 0;
if (tscAddQueryInfo(pnCmd) != TSDB_CODE_SUCCESS) {
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
@@ -3391,7 +3416,11 @@ void doExecuteQuery(SSqlObj* pSql, SQueryInfo* pQueryInfo) {
tscHandleMasterSTableQuery(pSql);
tscUnlockByThread(&pSql->squeryLock);
} else if (TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_INSERT)) {
- tscHandleMultivnodeInsert(pSql);
+ if (TSDB_QUERY_HAS_TYPE(pSql->cmd.insertParam.insertType, TSDB_QUERY_TYPE_FILE_INSERT)) {
+ tscImportDataFromFile(pSql);
+ } else {
+ tscHandleMultivnodeInsert(pSql);
+ }
} else if (pSql->cmd.command > TSDB_SQL_LOCAL) {
tscProcessLocalCmd(pSql);
} else { // send request to server directly
@@ -3609,10 +3638,10 @@ int32_t tscSQLSyntaxErrMsg(char* msg, const char* additionalInfo, const char* s
return TSDB_CODE_TSC_SQL_SYNTAX_ERROR;
}
-int32_t tscInvalidSQLErrMsg(char* msg, const char* additionalInfo, const char* sql) {
- const char* msgFormat1 = "invalid SQL: %s";
- const char* msgFormat2 = "invalid SQL: \'%s\' (%s)";
- const char* msgFormat3 = "invalid SQL: \'%s\'";
+int32_t tscInvalidOperationMsg(char* msg, const char* additionalInfo, const char* sql) {
+ const char* msgFormat1 = "invalid operation: %s";
+ const char* msgFormat2 = "invalid operation: \'%s\' (%s)";
+ const char* msgFormat3 = "invalid operation: \'%s\'";
const int32_t BACKWARD_CHAR_STEP = 0;
@@ -4210,11 +4239,13 @@ int32_t tscCreateQueryFromQueryInfo(SQueryInfo* pQueryInfo, SQueryAttr* pQueryAt
pQueryAttr->simpleAgg = isSimpleAggregate(pQueryInfo);
pQueryAttr->needReverseScan = tscNeedReverseScan(pQueryInfo);
pQueryAttr->stableQuery = QUERY_IS_STABLE_QUERY(pQueryInfo->type);
- pQueryAttr->groupbyColumn = tscGroupbyColumn(pQueryInfo);
+ pQueryAttr->groupbyColumn = (!pQueryInfo->stateWindow) && tscGroupbyColumn(pQueryInfo);
pQueryAttr->queryBlockDist = isBlockDistQuery(pQueryInfo);
pQueryAttr->pointInterpQuery = tscIsPointInterpQuery(pQueryInfo);
pQueryAttr->timeWindowInterpo = timeWindowInterpoRequired(pQueryInfo);
pQueryAttr->distinctTag = pQueryInfo->distinctTag;
+ pQueryAttr->sw = pQueryInfo->sessionWindow;
+ pQueryAttr->stateWindow = pQueryInfo->stateWindow;
pQueryAttr->numOfCols = numOfCols;
pQueryAttr->numOfOutput = numOfOutput;
@@ -4222,8 +4253,8 @@ int32_t tscCreateQueryFromQueryInfo(SQueryInfo* pQueryInfo, SQueryAttr* pQueryAt
pQueryAttr->slimit = pQueryInfo->slimit;
pQueryAttr->order = pQueryInfo->order;
pQueryAttr->fillType = pQueryInfo->fillType;
- pQueryAttr->groupbyColumn = tscGroupbyColumn(pQueryInfo);
pQueryAttr->havingNum = pQueryInfo->havingFieldNum;
+
if (pQueryInfo->order.order == TSDB_ORDER_ASC) { // TODO refactor
pQueryAttr->window = pQueryInfo->window;
@@ -4412,3 +4443,38 @@ int tscTransferTableNameList(SSqlObj *pSql, const char *pNameList, int32_t lengt
return TSDB_CODE_SUCCESS;
}
+bool vgroupInfoIdentical(SNewVgroupInfo *pExisted, SVgroupMsg* src) {
+ assert(pExisted != NULL && src != NULL);
+ if (pExisted->numOfEps != src->numOfEps) {
+ return false;
+ }
+
+ for(int32_t i = 0; i < pExisted->numOfEps; ++i) {
+ if (pExisted->ep[i].port != src->epAddr[i].port) {
+ return false;
+ }
+
+ if (strncmp(pExisted->ep[i].fqdn, src->epAddr[i].fqdn, tListLen(pExisted->ep[i].fqdn)) != 0) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+SNewVgroupInfo createNewVgroupInfo(SVgroupMsg *pVgroupMsg) {
+ assert(pVgroupMsg != NULL);
+
+ SNewVgroupInfo info = {0};
+ info.numOfEps = pVgroupMsg->numOfEps;
+ info.vgId = pVgroupMsg->vgId;
+ info.inUse = 0; // 0 is the default value of inUse in case of multiple replica
+
+ assert(info.numOfEps >= 1 && info.vgId >= 1);
+ for(int32_t i = 0; i < pVgroupMsg->numOfEps; ++i) {
+ tstrncpy(info.ep[i].fqdn, pVgroupMsg->epAddr[i].fqdn, TSDB_FQDN_LEN);
+ info.ep[i].port = pVgroupMsg->epAddr[i].port;
+ }
+
+ return info;
+}
\ No newline at end of file
diff --git a/src/common/inc/tname.h b/src/common/inc/tname.h
index ec2d76147a..8c97059552 100644
--- a/src/common/inc/tname.h
+++ b/src/common/inc/tname.h
@@ -92,8 +92,6 @@ size_t tableIdPrefix(const char* name, char* prefix, int32_t len);
void extractTableNameFromToken(SStrToken *pToken, SStrToken* pTable);
-SSchema tGetBlockDistColumnSchema();
-
SSchema tGetUserSpecifiedColumnSchema(tVariant* pVal, SStrToken* exprStr, const char* name);
bool tscValidateTableNameLength(size_t len);
diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c
index d6bbc288ad..a1266bb2cb 100644
--- a/src/common/src/tglobal.c
+++ b/src/common/src/tglobal.c
@@ -46,7 +46,7 @@ char tsEmail[TSDB_FQDN_LEN] = {0};
int32_t tsDnodeId = 0;
// common
-int32_t tsRpcTimer = 1000;
+int32_t tsRpcTimer = 300;
int32_t tsRpcMaxTime = 600; // seconds;
int32_t tsRpcForceTcp = 0; //disable this, means query, show command use udp protocol as default
int32_t tsMaxShellConns = 50000;
diff --git a/src/common/src/tname.c b/src/common/src/tname.c
index dc868d8057..c1c6ffa4b3 100644
--- a/src/common/src/tname.c
+++ b/src/common/src/tname.c
@@ -33,15 +33,6 @@ size_t tableIdPrefix(const char* name, char* prefix, int32_t len) {
return strlen(prefix);
}
-SSchema tGetBlockDistColumnSchema() {
- SSchema s = {0};
- s.bytes = TSDB_MAX_BINARY_LEN;;
- s.type = TSDB_DATA_TYPE_BINARY;
- s.colId = TSDB_BLOCK_DIST_COLUMN_INDEX;
- tstrncpy(s.name, TSQL_BLOCK_DIST_L, TSDB_COL_NAME_LEN);
- return s;
-}
-
SSchema tGetUserSpecifiedColumnSchema(tVariant* pVal, SStrToken* exprStr, const char* name) {
SSchema s = {0};
diff --git a/src/connector/go b/src/connector/go
index 8ce6d86558..7a26c432f8 160000
--- a/src/connector/go
+++ b/src/connector/go
@@ -1 +1 @@
-Subproject commit 8ce6d86558afc8c0b50c10f990fd2b4270cf06fc
+Subproject commit 7a26c432f8b4203e42344ff3290b9b9b01b983d5
diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java
index 179bad2ced..256e735285 100755
--- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java
+++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java
@@ -16,13 +16,13 @@
*/
package com.taosdata.jdbc;
-import com.taosdata.jdbc.utils.TaosInfo;
-
import java.nio.ByteBuffer;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.util.List;
+import com.taosdata.jdbc.utils.TaosInfo;
+
/**
* JNI connector
*/
@@ -276,23 +276,14 @@ public class TSDBJNIConnector {
private native int validateCreateTableSqlImp(long connection, byte[] sqlBytes);
public long prepareStmt(String sql) throws SQLException {
- Long stmt = 0L;
- try {
- stmt = prepareStmtImp(sql.getBytes(), this.taos);
- } catch (Exception e) {
- e.printStackTrace();
- throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_ENCODING);
- }
-
- if (stmt == TSDBConstants.JNI_CONNECTION_NULL) {
+ Long stmt = prepareStmtImp(sql.getBytes(), this.taos);
+ if (stmt == TSDBConstants.JNI_TDENGINE_ERROR) {
+ throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_SQL);
+ } else if (stmt == TSDBConstants.JNI_CONNECTION_NULL) {
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_CONNECTION_NULL);
- }
-
- if (stmt == TSDBConstants.JNI_SQL_NULL) {
+ } else if (stmt == TSDBConstants.JNI_SQL_NULL) {
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_SQL_NULL);
- }
-
- if (stmt == TSDBConstants.JNI_OUT_OF_MEMORY) {
+ } else if (stmt == TSDBConstants.JNI_OUT_OF_MEMORY) {
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_OUT_OF_MEMORY);
}
diff --git a/src/connector/python/taos/__init__.py b/src/connector/python/taos/__init__.py
index 9732635738..52c6db311e 100644
--- a/src/connector/python/taos/__init__.py
+++ b/src/connector/python/taos/__init__.py
@@ -2,6 +2,10 @@
from .connection import TDengineConnection
from .cursor import TDengineCursor
+# For some reason, the following is needed for VS Code (through PyLance) to
+# recognize that "error" is a valid module of the "taos" package.
+from .error import ProgrammingError
+
# Globals
threadsafety = 0
paramstyle = 'pyformat'
diff --git a/src/dnode/CMakeLists.txt b/src/dnode/CMakeLists.txt
index dd18f00920..f8d8f88438 100644
--- a/src/dnode/CMakeLists.txt
+++ b/src/dnode/CMakeLists.txt
@@ -10,8 +10,15 @@ INCLUDE_DIRECTORIES(${TD_ENTERPRISE_DIR}/src/inc)
INCLUDE_DIRECTORIES(inc)
AUX_SOURCE_DIRECTORY(src SRC)
+IF (TD_LINUX_64 AND JEMALLOC_ENABLED)
+ ADD_DEFINITIONS(-DTD_JEMALLOC_ENABLED -I${CMAKE_BINARY_DIR}/build/include -L${CMAKE_BINARY_DIR}/build/lib -Wl,-rpath,${CMAKE_BINARY_DIR}/build/lib -ljemalloc)
+ SET(LINK_JEMALLOC "-L${CMAKE_BINARY_DIR}/build/lib -ljemalloc")
+ELSE ()
+ SET(LINK_JEMALLOC "")
+ENDIF ()
+
ADD_EXECUTABLE(taosd ${SRC})
-TARGET_LINK_LIBRARIES(taosd mnode monitor http tsdb twal vnode cJson lz4 balance sync)
+TARGET_LINK_LIBRARIES(taosd mnode monitor http tsdb twal vnode cJson lz4 balance sync ${LINK_JEMALLOC})
IF (TD_SOMODE_STATIC)
TARGET_LINK_LIBRARIES(taosd taos_static)
diff --git a/src/inc/taosdef.h b/src/inc/taosdef.h
index c00fde1816..5bdd197aa9 100644
--- a/src/inc/taosdef.h
+++ b/src/inc/taosdef.h
@@ -244,7 +244,6 @@ do { \
#define TSDB_MAX_REPLICA 5
#define TSDB_TBNAME_COLUMN_INDEX (-1)
-#define TSDB_BLOCK_DIST_COLUMN_INDEX (-2)
#define TSDB_UD_COLUMN_INDEX (-1000)
#define TSDB_RES_COL_ID (-5000)
diff --git a/src/inc/taoserror.h b/src/inc/taoserror.h
index 09f632ea32..ab15e851e7 100644
--- a/src/inc/taoserror.h
+++ b/src/inc/taoserror.h
@@ -215,11 +215,11 @@ int32_t* taosGetErrno();
#define TSDB_CODE_VND_IS_FLOWCTRL TAOS_DEF_ERROR_CODE(0, 0x050C) //"Database memory is full for waiting commit")
#define TSDB_CODE_VND_IS_DROPPING TAOS_DEF_ERROR_CODE(0, 0x050D) //"Database is dropping")
#define TSDB_CODE_VND_IS_BALANCING TAOS_DEF_ERROR_CODE(0, 0x050E) //"Database is balancing")
+#define TSDB_CODE_VND_IS_CLOSING TAOS_DEF_ERROR_CODE(0, 0x0510) //"Database is closing")
#define TSDB_CODE_VND_NOT_SYNCED TAOS_DEF_ERROR_CODE(0, 0x0511) //"Database suspended")
#define TSDB_CODE_VND_NO_WRITE_AUTH TAOS_DEF_ERROR_CODE(0, 0x0512) //"Database write operation denied")
#define TSDB_CODE_VND_IS_SYNCING TAOS_DEF_ERROR_CODE(0, 0x0513) //"Database is syncing")
#define TSDB_CODE_VND_INVALID_TSDB_STATE TAOS_DEF_ERROR_CODE(0, 0x0514) //"Invalid tsdb state")
-#define TSDB_CODE_VND_IS_CLOSING TAOS_DEF_ERROR_CODE(0, 0x0515) //"Database is closing")
// tsdb
#define TSDB_CODE_TDB_INVALID_TABLE_ID TAOS_DEF_ERROR_CODE(0, 0x0600) //"Invalid table ID")
diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h
index ff3cc6e956..0d8f555670 100644
--- a/src/inc/taosmsg.h
+++ b/src/inc/taosmsg.h
@@ -473,6 +473,7 @@ typedef struct {
bool simpleAgg;
bool pointInterpQuery; // point interpolation query
bool needReverseScan; // need reverse scan
+ bool stateWindow; // state window flag
STimeWindow window;
int32_t numOfTables;
diff --git a/src/inc/tsdb.h b/src/inc/tsdb.h
index 21d55d5d0f..376836369d 100644
--- a/src/inc/tsdb.h
+++ b/src/inc/tsdb.h
@@ -215,7 +215,7 @@ typedef struct SDataBlockInfo {
} SDataBlockInfo;
typedef struct SFileBlockInfo {
- int32_t numOfRows;
+ int32_t numBlocksOfStep;
} SFileBlockInfo;
typedef struct {
@@ -229,11 +229,15 @@ typedef struct {
SHashObj *map; // speedup acquire the tableQueryInfo by table uid
} STableGroupInfo;
+#define TSDB_BLOCK_DIST_STEP_ROWS 16
typedef struct {
uint16_t rowSize;
uint16_t numOfFiles;
uint32_t numOfTables;
uint64_t totalSize;
+ uint64_t totalRows;
+ int32_t maxRows;
+ int32_t minRows;
int32_t firstSeekTimeUs;
uint32_t numOfRowsInMemTable;
SArray *dataBlockInfos;
diff --git a/src/inc/ttokendef.h b/src/inc/ttokendef.h
index ef3f8ed1fb..e9585636fd 100644
--- a/src/inc/ttokendef.h
+++ b/src/inc/ttokendef.h
@@ -136,74 +136,74 @@
#define TK_VARIABLE 117
#define TK_INTERVAL 118
#define TK_SESSION 119
-#define TK_FILL 120
-#define TK_SLIDING 121
-#define TK_ORDER 122
-#define TK_BY 123
-#define TK_ASC 124
-#define TK_DESC 125
-#define TK_GROUP 126
-#define TK_HAVING 127
-#define TK_LIMIT 128
-#define TK_OFFSET 129
-#define TK_SLIMIT 130
-#define TK_SOFFSET 131
-#define TK_WHERE 132
-#define TK_NOW 133
-#define TK_RESET 134
-#define TK_QUERY 135
-#define TK_SYNCDB 136
-#define TK_ADD 137
-#define TK_COLUMN 138
-#define TK_TAG 139
-#define TK_CHANGE 140
-#define TK_SET 141
-#define TK_KILL 142
-#define TK_CONNECTION 143
-#define TK_STREAM 144
-#define TK_COLON 145
-#define TK_ABORT 146
-#define TK_AFTER 147
-#define TK_ATTACH 148
-#define TK_BEFORE 149
-#define TK_BEGIN 150
-#define TK_CASCADE 151
-#define TK_CLUSTER 152
-#define TK_CONFLICT 153
-#define TK_COPY 154
-#define TK_DEFERRED 155
-#define TK_DELIMITERS 156
-#define TK_DETACH 157
-#define TK_EACH 158
-#define TK_END 159
-#define TK_EXPLAIN 160
-#define TK_FAIL 161
-#define TK_FOR 162
-#define TK_IGNORE 163
-#define TK_IMMEDIATE 164
-#define TK_INITIALLY 165
-#define TK_INSTEAD 166
-#define TK_MATCH 167
-#define TK_KEY 168
-#define TK_OF 169
-#define TK_RAISE 170
-#define TK_REPLACE 171
-#define TK_RESTRICT 172
-#define TK_ROW 173
-#define TK_STATEMENT 174
-#define TK_TRIGGER 175
-#define TK_VIEW 176
-#define TK_SEMI 177
-#define TK_NONE 178
-#define TK_PREV 179
-#define TK_LINEAR 180
-#define TK_IMPORT 181
-#define TK_TBNAME 182
-#define TK_JOIN 183
-#define TK_INSERT 184
-#define TK_INTO 185
-#define TK_VALUES 186
-
+#define TK_STATE_WINDOW 120
+#define TK_FILL 121
+#define TK_SLIDING 122
+#define TK_ORDER 123
+#define TK_BY 124
+#define TK_ASC 125
+#define TK_DESC 126
+#define TK_GROUP 127
+#define TK_HAVING 128
+#define TK_LIMIT 129
+#define TK_OFFSET 130
+#define TK_SLIMIT 131
+#define TK_SOFFSET 132
+#define TK_WHERE 133
+#define TK_NOW 134
+#define TK_RESET 135
+#define TK_QUERY 136
+#define TK_SYNCDB 137
+#define TK_ADD 138
+#define TK_COLUMN 139
+#define TK_TAG 140
+#define TK_CHANGE 141
+#define TK_SET 142
+#define TK_KILL 143
+#define TK_CONNECTION 144
+#define TK_STREAM 145
+#define TK_COLON 146
+#define TK_ABORT 147
+#define TK_AFTER 148
+#define TK_ATTACH 149
+#define TK_BEFORE 150
+#define TK_BEGIN 151
+#define TK_CASCADE 152
+#define TK_CLUSTER 153
+#define TK_CONFLICT 154
+#define TK_COPY 155
+#define TK_DEFERRED 156
+#define TK_DELIMITERS 157
+#define TK_DETACH 158
+#define TK_EACH 159
+#define TK_END 160
+#define TK_EXPLAIN 161
+#define TK_FAIL 162
+#define TK_FOR 163
+#define TK_IGNORE 164
+#define TK_IMMEDIATE 165
+#define TK_INITIALLY 166
+#define TK_INSTEAD 167
+#define TK_MATCH 168
+#define TK_KEY 169
+#define TK_OF 170
+#define TK_RAISE 171
+#define TK_REPLACE 172
+#define TK_RESTRICT 173
+#define TK_ROW 174
+#define TK_STATEMENT 175
+#define TK_TRIGGER 176
+#define TK_VIEW 177
+#define TK_SEMI 178
+#define TK_NONE 179
+#define TK_PREV 180
+#define TK_LINEAR 181
+#define TK_IMPORT 182
+#define TK_TBNAME 183
+#define TK_JOIN 184
+#define TK_INSERT 185
+#define TK_INTO 186
+#define TK_VALUES 187
#define TK_SPACE 300
#define TK_COMMENT 301
diff --git a/src/kit/shell/CMakeLists.txt b/src/kit/shell/CMakeLists.txt
index d36c1e3fcc..d904945435 100644
--- a/src/kit/shell/CMakeLists.txt
+++ b/src/kit/shell/CMakeLists.txt
@@ -11,10 +11,17 @@ IF (TD_LINUX)
LIST(REMOVE_ITEM SRC ./src/shellDarwin.c)
ADD_EXECUTABLE(shell ${SRC})
+IF (TD_LINUX_64 AND JEMALLOC_ENABLED)
+ ADD_DEFINITIONS(-DTD_JEMALLOC_ENABLED -I${CMAKE_BINARY_DIR}/build/include -L${CMAKE_BINARY_DIR}/build/lib -Wl,-rpath,${CMAKE_BINARY_DIR}/build/lib -ljemalloc)
+ SET(LINK_JEMALLOC "-L${CMAKE_BINARY_DIR}/build/lib -ljemalloc")
+ELSE ()
+ SET(LINK_JEMALLOC "")
+ENDIF ()
+
IF (TD_SOMODE_STATIC)
- TARGET_LINK_LIBRARIES(shell taos_static)
+ TARGET_LINK_LIBRARIES(shell taos_static ${LINK_JEMALLOC})
ELSE ()
- TARGET_LINK_LIBRARIES(shell taos)
+ TARGET_LINK_LIBRARIES(shell taos ${LINK_JEMALLOC})
ENDIF ()
SET_TARGET_PROPERTIES(shell PROPERTIES OUTPUT_NAME taos)
diff --git a/src/kit/taosdemo/CMakeLists.txt b/src/kit/taosdemo/CMakeLists.txt
index 5f75be0e19..091eecfe27 100644
--- a/src/kit/taosdemo/CMakeLists.txt
+++ b/src/kit/taosdemo/CMakeLists.txt
@@ -55,14 +55,21 @@ ENDIF ()
MESSAGE("TD_VERSION_NUMBER is:" ${TD_VERSION_NUMBER})
ADD_DEFINITIONS(-DTD_VERNUMBER="${TD_VERSION_NUMBER}")
+IF (TD_LINUX_64 AND JEMALLOC_ENABLED)
+ ADD_DEFINITIONS(-DTD_JEMALLOC_ENABLED -I${CMAKE_BINARY_DIR}/build/include -L${CMAKE_BINARY_DIR}/build/lib -Wl,-rpath,${CMAKE_BINARY_DIR}/build/lib -ljemalloc)
+ SET(LINK_JEMALLOC "-L${CMAKE_BINARY_DIR}/build/lib -ljemalloc")
+ELSE ()
+ SET(LINK_JEMALLOC "")
+ENDIF ()
+
IF (TD_LINUX)
AUX_SOURCE_DIRECTORY(. SRC)
ADD_EXECUTABLE(taosdemo ${SRC})
IF (TD_SOMODE_STATIC)
- TARGET_LINK_LIBRARIES(taosdemo taos_static cJson)
+ TARGET_LINK_LIBRARIES(taosdemo taos_static cJson ${LINK_JEMALLOC})
ELSE ()
- TARGET_LINK_LIBRARIES(taosdemo taos cJson)
+ TARGET_LINK_LIBRARIES(taosdemo taos cJson ${LINK_JEMALLOC})
ENDIF ()
ELSEIF (TD_WINDOWS)
AUX_SOURCE_DIRECTORY(. SRC)
@@ -71,7 +78,7 @@ ELSEIF (TD_WINDOWS)
IF (TD_SOMODE_STATIC)
TARGET_LINK_LIBRARIES(taosdemo taos_static cJson)
ELSE ()
- TARGET_LINK_LIBRARIES(taosdemo taos cJson})
+ TARGET_LINK_LIBRARIES(taosdemo taos cJson)
ENDIF ()
ELSEIF (TD_DARWIN)
# missing a few dependencies, such as
diff --git a/src/mnode/src/mnodeSdb.c b/src/mnode/src/mnodeSdb.c
index ac3e5d86ec..e9acd5b9bc 100644
--- a/src/mnode/src/mnodeSdb.c
+++ b/src/mnode/src/mnodeSdb.c
@@ -656,8 +656,6 @@ static int32_t sdbProcessWrite(void *wparam, void *hparam, int32_t qtype, void *
dnodeReportStep("mnode-sdb", stepDesc, 0);
}
- if (qtype == TAOS_QTYPE_QUERY) return sdbPerformDeleteAction(pHead, pTable);
-
pthread_mutex_lock(&tsSdbMgmt.mutex);
if (pHead->version == 0) {
@@ -721,13 +719,11 @@ static int32_t sdbProcessWrite(void *wparam, void *hparam, int32_t qtype, void *
if (action == SDB_ACTION_INSERT) {
return sdbPerformInsertAction(pHead, pTable);
} else if (action == SDB_ACTION_DELETE) {
- //if (qtype == TAOS_QTYPE_FWD) {
- // Drop database/stable may take a long time and cause a timeout, so we confirm first then reput it into queue
- // sdbWriteFwdToQueue(1, hparam, TAOS_QTYPE_QUERY, unused);
- // return TSDB_CODE_SUCCESS;
- //} else {
- return sdbPerformDeleteAction(pHead, pTable);
- //}
+ if (qtype == TAOS_QTYPE_FWD) {
+ // Drop database/stable may take a long time and cause a timeout, so we confirm first
+ syncConfirmForward(tsSdbMgmt.sync, pHead->version, TSDB_CODE_SUCCESS, false);
+ }
+ return sdbPerformDeleteAction(pHead, pTable);
} else if (action == SDB_ACTION_UPDATE) {
return sdbPerformUpdateAction(pHead, pTable);
} else {
@@ -1140,7 +1136,10 @@ static void *sdbWorkerFp(void *pWorker) {
sdbConfirmForward(1, pRow, pRow->code);
} else {
if (qtype == TAOS_QTYPE_FWD) {
- syncConfirmForward(tsSdbMgmt.sync, pRow->pHead.version, pRow->code, false);
+ int32_t action = pRow->pHead.msgType % 10;
+ if (action != SDB_ACTION_DELETE) {
+ syncConfirmForward(tsSdbMgmt.sync, pRow->pHead.version, pRow->code, false);
+ }
}
sdbFreeFromQueue(pRow);
}
diff --git a/src/os/inc/osMemory.h b/src/os/inc/osMemory.h
index 27efd9f505..793992c197 100644
--- a/src/os/inc/osMemory.h
+++ b/src/os/inc/osMemory.h
@@ -22,6 +22,10 @@
extern "C" {
#endif
+#ifdef TD_JEMALLOC_ENABLED
+#include
+#endif
+
typedef enum {
TAOS_ALLOC_MODE_DEFAULT = 0,
TAOS_ALLOC_MODE_RANDOM_FAIL = 1,
diff --git a/src/query/inc/qExecutor.h b/src/query/inc/qExecutor.h
index 4ab718e09d..b5b4fb5854 100644
--- a/src/query/inc/qExecutor.h
+++ b/src/query/inc/qExecutor.h
@@ -22,6 +22,7 @@
#include "qFill.h"
#include "qResultbuf.h"
#include "qSqlparser.h"
+#include "qTableMeta.h"
#include "qTsbuf.h"
#include "query.h"
#include "taosdef.h"
@@ -70,14 +71,6 @@ typedef struct SResultRowPool {
SArray* pData; // SArray
} SResultRowPool;
-typedef struct SGroupbyExpr {
- int16_t tableIndex;
- SArray* columnInfo; // SArray, group by columns information
- int16_t numOfGroupCols; // todo remove it
- int16_t orderIndex; // order by column index
- int16_t orderType; // order by type: asc/desc
-} SGroupbyExpr;
-
typedef struct SResultRow {
int32_t pageId; // pageId & rowId is the position of current result in disk-based output buffer
int32_t offset:29; // row index in buffer page
@@ -196,6 +189,7 @@ typedef struct SQueryAttr {
bool pointInterpQuery; // point interpolation query
bool needReverseScan; // need reverse scan
bool distinctTag; // distinct tag query
+ bool stateWindow; // window State on sub/normal table
int32_t interBufSize; // intermediate buffer sizse
int32_t havingNum; // having expr number
@@ -216,7 +210,7 @@ typedef struct SQueryAttr {
int32_t intermediateResultRowSize; // intermediate result row size, in case of top-k query.
int32_t maxTableColumnWidth;
int32_t tagLen; // tag value length of current query
- SGroupbyExpr* pGroupbyExpr;
+ SGroupbyExpr *pGroupbyExpr;
SExprInfo* pExpr1;
SExprInfo* pExpr2;
@@ -303,6 +297,7 @@ enum OPERATOR_TYPE_E {
OP_Filter = 19,
OP_Distinct = 20,
OP_Join = 21,
+ OP_StateWindow = 22,
};
typedef struct SOperatorInfo {
@@ -467,6 +462,16 @@ typedef struct SSWindowOperatorInfo {
int32_t start; // start row index
} SSWindowOperatorInfo;
+typedef struct SStateWindowOperatorInfo {
+ SOptrBasicInfo binfo;
+ STimeWindow curWindow; // current time window
+ int32_t numOfRows; // number of rows
+ int32_t colIndex; // start row index
+ int32_t start;
+ char* prevData; // previous data
+
+} SStateWindowOperatorInfo ;
+
typedef struct SDistinctOperatorInfo {
SHashObj *pSet;
SSDataBlock *pRes;
@@ -475,10 +480,10 @@ typedef struct SDistinctOperatorInfo {
int64_t outputCapacity;
} SDistinctOperatorInfo;
-struct SLocalMerger;
+struct SGlobalMerger;
typedef struct SMultiwayMergeInfo {
- struct SLocalMerger *pMerge;
+ struct SGlobalMerger *pMerge;
SOptrBasicInfo binfo;
int32_t bufCapacity;
int64_t seed;
@@ -516,6 +521,7 @@ SOperatorInfo* createDistinctOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperat
SOperatorInfo* createTableBlockInfoScanOperator(void* pTsdbQueryHandle, SQueryRuntimeEnv* pRuntimeEnv);
SOperatorInfo* createMultiwaySortOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SExprInfo* pExpr, int32_t numOfOutput,
int32_t numOfRows, void* merger, bool groupMix);
+SOperatorInfo* createStatewindowOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorInfo* upstream, SExprInfo* pExpr, int32_t numOfOutput);
SOperatorInfo* createGlobalAggregateOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorInfo* upstream, SExprInfo* pExpr, int32_t numOfOutput, void* param);
SOperatorInfo* createSLimitOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorInfo* upstream, SExprInfo* pExpr, int32_t numOfOutput, void* merger);
SOperatorInfo* createFilterOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorInfo* upstream, SExprInfo* pExpr,
@@ -559,6 +565,8 @@ int32_t createFilterInfo(SQueryAttr* pQueryAttr, uint64_t qId);
void freeColumnFilterInfo(SColumnFilterInfo* pFilter, int32_t numOfFilters);
STableQueryInfo *createTableQueryInfo(SQueryAttr* pQueryAttr, void* pTable, bool groupbyColumn, STimeWindow win, void* buf);
+STableQueryInfo* createTmpTableQueryInfo(STimeWindow win);
+
int32_t buildArithmeticExprFromMsg(SExprInfo *pArithExprInfo, void *pQueryMsg);
bool isQueryKilled(SQInfo *pQInfo);
diff --git a/src/query/inc/qPlan.h b/src/query/inc/qPlan.h
index 30c0f8db4e..60a50ca70c 100644
--- a/src/query/inc/qPlan.h
+++ b/src/query/inc/qPlan.h
@@ -16,6 +16,8 @@
#ifndef TDENGINE_QPLAN_H
#define TDENGINE_QPLAN_H
+#include "qExecutor.h"
+
struct SQueryInfo;
typedef struct SQueryNodeBasicInfo {
diff --git a/src/query/inc/qSqlparser.h b/src/query/inc/qSqlparser.h
index bdbe3ac050..652191bf0f 100644
--- a/src/query/inc/qSqlparser.h
+++ b/src/query/inc/qSqlparser.h
@@ -89,6 +89,10 @@ typedef struct SSessionWindowVal {
SStrToken gap;
} SSessionWindowVal;
+typedef struct SWindowStateVal {
+ SStrToken col;
+} SWindowStateVal;
+
struct SRelationInfo;
typedef struct SSqlNode {
@@ -100,6 +104,7 @@ typedef struct SSqlNode {
SArray *fillType; // fill type[optional], SArray
SIntervalVal interval; // (interval, interval_offset) [optional]
SSessionWindowVal sessionVal; // session window [optional]
+ SWindowStateVal windowstateVal; // window_state(col) [optional]
SStrToken sliding; // sliding window [optional]
SLimitVal limit; // limit offset [optional]
SLimitVal slimit; // group limit offset [optional]
@@ -142,7 +147,7 @@ typedef struct SCreateTableSql {
} colInfo;
SArray *childTableInfo; // SArray
- SSqlNode *pSelect;
+ SSqlNode *pSelect;
} SCreateTableSql;
typedef struct SAlterTableInfo {
@@ -258,7 +263,6 @@ SArray *tVariantListInsert(SArray *pList, tVariant *pVar, uint8_t sortOrder, int
SArray *tVariantListAppendToken(SArray *pList, SStrToken *pAliasToken, uint8_t sortOrder);
SRelationInfo *setTableNameList(SRelationInfo* pFromInfo, SStrToken *pName, SStrToken* pAlias);
-//SRelationInfo *setSubquery(SRelationInfo* pFromInfo, SRelElementPair* p);
void *destroyRelationInfo(SRelationInfo* pFromInfo);
SRelationInfo *addSubqueryElem(SRelationInfo* pRelationInfo, SArray* pSub, SStrToken* pAlias);
@@ -276,7 +280,7 @@ SArray *tSqlExprListAppend(SArray *pList, tSqlExpr *pNode, SStrToken *pDistinc
void tSqlExprListDestroy(SArray *pList);
SSqlNode *tSetQuerySqlNode(SStrToken *pSelectToken, SArray *pSelNodeList, SRelationInfo *pFrom, tSqlExpr *pWhere,
- SArray *pGroupby, SArray *pSortOrder, SIntervalVal *pInterval, SSessionWindowVal *ps,
+ SArray *pGroupby, SArray *pSortOrder, SIntervalVal *pInterval, SSessionWindowVal *ps, SWindowStateVal *pw,
SStrToken *pSliding, SArray *pFill, SLimitVal *pLimit, SLimitVal *pgLimit, tSqlExpr *pHaving);
int32_t tSqlExprCompare(tSqlExpr *left, tSqlExpr *right);
diff --git a/src/query/inc/qTableMeta.h b/src/query/inc/qTableMeta.h
new file mode 100644
index 0000000000..4fc252b644
--- /dev/null
+++ b/src/query/inc/qTableMeta.h
@@ -0,0 +1,203 @@
+#ifndef TDENGINE_QTABLEUTIL_H
+#define TDENGINE_QTABLEUTIL_H
+
+#include "tsdb.h" //todo tsdb should not be here
+#include "qSqlparser.h"
+
+typedef struct SFieldInfo {
+ int16_t numOfOutput; // number of column in result
+ TAOS_FIELD* final;
+ SArray *internalField; // SArray
+} SFieldInfo;
+
+typedef struct SCond {
+ uint64_t uid;
+ int32_t len; // length of tag query condition data
+ char * cond;
+} SCond;
+
+typedef struct SJoinNode {
+ uint64_t uid;
+ int16_t tagColId;
+ SArray* tsJoin;
+ SArray* tagJoin;
+} SJoinNode;
+
+typedef struct SJoinInfo {
+ bool hasJoin;
+ SJoinNode *joinTables[TSDB_MAX_JOIN_TABLE_NUM];
+} SJoinInfo;
+
+typedef struct STagCond {
+ // relation between tbname list and query condition, including : TK_AND or TK_OR
+ int16_t relType;
+
+ // tbname query condition, only support tbname query condition on one table
+ SCond tbnameCond;
+
+ // join condition, only support two tables join currently
+ SJoinInfo joinInfo;
+
+ // for different table, the query condition must be seperated
+ SArray *pCond;
+} STagCond;
+
+typedef struct SGroupbyExpr {
+ int16_t tableIndex;
+ SArray* columnInfo; // SArray, group by columns information
+ int16_t numOfGroupCols; // todo remove it
+ int16_t orderIndex; // order by column index
+ int16_t orderType; // order by type: asc/desc
+} SGroupbyExpr;
+
+typedef struct STableComInfo {
+ uint8_t numOfTags;
+ uint8_t precision;
+ int16_t numOfColumns;
+ int32_t rowSize;
+} STableComInfo;
+
+typedef struct STableMeta {
+ int32_t vgId;
+ STableId id;
+ uint8_t tableType;
+ char sTableName[TSDB_TABLE_FNAME_LEN]; // super table name
+ uint64_t suid; // super table id
+ int16_t sversion;
+ int16_t tversion;
+ STableComInfo tableInfo;
+ SSchema schema[]; // if the table is TSDB_CHILD_TABLE, schema is acquired by super table meta info
+} STableMeta;
+
+typedef struct STableMetaInfo {
+ STableMeta *pTableMeta; // table meta, cached in client side and acquired by name
+ uint32_t tableMetaSize;
+ SVgroupsInfo *vgroupList;
+ SArray *pVgroupTables; // SArray
+
+ /*
+ * 1. keep the vgroup index during the multi-vnode super table projection query
+ * 2. keep the vgroup index for multi-vnode insertion
+ */
+ int32_t vgroupIndex;
+ SName name;
+ char aliasName[TSDB_TABLE_NAME_LEN]; // alias name of table specified in query sql
+ SArray *tagColList; // SArray, involved tag columns
+} STableMetaInfo;
+
+struct SQInfo; // global merge operator
+struct SQueryAttr; // query object
+
+typedef struct SQueryInfo {
+ int16_t command; // the command may be different for each subclause, so keep it seperately.
+ uint32_t type; // query/insert type
+ STimeWindow window; // the whole query time window
+
+ SInterval interval; // tumble time window
+ SSessionWindow sessionWindow; // session time window
+
+ SGroupbyExpr groupbyExpr; // groupby tags info
+ SArray * colList; // SArray
+ SFieldInfo fieldsInfo;
+ SArray * exprList; // SArray
+ SArray * exprList1; // final exprlist in case of arithmetic expression exists
+ SLimitVal limit;
+ SLimitVal slimit;
+ STagCond tagCond;
+
+ SOrderVal order;
+ int16_t fillType; // final result fill type
+ int16_t numOfTables;
+ STableMetaInfo **pTableMetaInfo;
+ struct STSBuf *tsBuf;
+ int64_t * fillVal; // default value for fill
+ char * msg; // pointer to the pCmd->payload to keep error message temporarily
+ 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 vgroupLimit; // table limit in case of super table projection query + global order + limit
+
+ int32_t udColumnId; // current user-defined constant output field column id, monotonically decreases from TSDB_UD_COLUMN_INDEX
+ int16_t resColumnId; // result column id
+ bool distinctTag; // distinct tag or not
+ int32_t round; // 0/1/....
+ int32_t bufLen;
+ char* buf;
+ struct SQInfo* pQInfo; // global merge operator
+ struct SQueryAttr* pQueryAttr; // query object
+
+ struct SQueryInfo *sibling; // sibling
+ SArray *pUpstream; // SArray
+ struct SQueryInfo *pDownstream;
+ int32_t havingFieldNum;
+ bool stableQuery;
+ bool groupbyColumn;
+ bool simpleAgg;
+ bool arithmeticOnAgg;
+ bool projectionQuery;
+ bool hasFilter;
+ bool onlyTagQuery;
+ bool orderProjectQuery;
+ bool stateWindow;
+} SQueryInfo;
+
+/**
+ * get the number of tags of this table
+ * @param pTableMeta
+ * @return
+ */
+int32_t tscGetNumOfTags(const STableMeta* pTableMeta);
+
+/**
+ * get the number of columns of this table
+ * @param pTableMeta
+ * @return
+ */
+int32_t tscGetNumOfColumns(const STableMeta* pTableMeta);
+
+/**
+ * get the basic info of this table
+ * @param pTableMeta
+ * @return
+ */
+STableComInfo tscGetTableInfo(const STableMeta* pTableMeta);
+
+/**
+ * get the schema
+ * @param pTableMeta
+ * @return
+ */
+SSchema* tscGetTableSchema(const STableMeta* pTableMeta);
+
+/**
+ * get the tag schema
+ * @param pMeta
+ * @return
+ */
+SSchema *tscGetTableTagSchema(const STableMeta *pMeta);
+
+/**
+ * get the column schema according to the column index
+ * @param pMeta
+ * @param colIndex
+ * @return
+ */
+SSchema *tscGetTableColumnSchema(const STableMeta *pMeta, int32_t colIndex);
+
+/**
+ * get the column schema according to the column id
+ * @param pTableMeta
+ * @param colId
+ * @return
+ */
+SSchema* tscGetColumnSchemaById(STableMeta* pTableMeta, int16_t colId);
+
+/**
+ * create the table meta from the msg
+ * @param pTableMetaMsg
+ * @param size size of the table meta
+ * @return
+ */
+STableMeta* tscCreateTableMetaFromMsg(STableMetaMsg* pTableMetaMsg);
+
+#endif // TDENGINE_QTABLEUTIL_H
diff --git a/src/query/inc/sql.y b/src/query/inc/sql.y
index 2b5126c2fd..ba16eef763 100644
--- a/src/query/inc/sql.y
+++ b/src/query/inc/sql.y
@@ -456,8 +456,8 @@ tagitem(A) ::= PLUS(X) FLOAT(Y). {
//////////////////////// The SELECT statement /////////////////////////////////
%type select {SSqlNode*}
%destructor select {destroySqlNode($$);}
-select(A) ::= SELECT(T) selcollist(W) from(X) where_opt(Y) interval_opt(K) session_option(H) fill_opt(F) sliding_opt(S) groupby_opt(P) orderby_opt(Z) having_opt(N) slimit_opt(G) limit_opt(L). {
- A = tSetQuerySqlNode(&T, W, X, Y, P, Z, &K, &H, &S, F, &L, &G, N);
+select(A) ::= SELECT(T) selcollist(W) from(X) where_opt(Y) interval_opt(K) session_option(H) windowstate_option(D) fill_opt(F) sliding_opt(S) groupby_opt(P) orderby_opt(Z) having_opt(N) slimit_opt(G) limit_opt(L). {
+ A = tSetQuerySqlNode(&T, W, X, Y, P, Z, &K, &H, &D, &S, F, &L, &G, N);
}
select(A) ::= LP select(B) RP. {A = B;}
@@ -475,7 +475,7 @@ cmd ::= union(X). { setSqlInfo(pInfo, X, NULL, TSDB_SQL_SELECT); }
// select client_version()
// select server_state()
select(A) ::= SELECT(T) selcollist(W). {
- A = tSetQuerySqlNode(&T, W, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+ A = tSetQuerySqlNode(&T, W, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
}
// selcollist is a list of expressions that are to become the return
@@ -558,6 +558,11 @@ session_option(X) ::= SESSION LP ids(V) cpxName(Z) COMMA tmvar(Y) RP. {
X.col = V;
X.gap = Y;
}
+%type windowstate_option {SWindowStateVal}
+windowstate_option(X) ::= . {X.col.n = 0;}
+windowstate_option(X) ::= STATE_WINDOW LP ids(V) RP. {
+ X.col = V;
+}
%type fill_opt {SArray*}
%destructor fill_opt {taosArrayDestroy($$);}
diff --git a/src/query/src/qAggMain.c b/src/query/src/qAggMain.c
index 177cea8b62..be0716ce99 100644
--- a/src/query/src/qAggMain.c
+++ b/src/query/src/qAggMain.c
@@ -19,6 +19,7 @@
#include "texpr.h"
#include "ttype.h"
#include "tsdb.h"
+#include "tglobal.h"
#include "qAggMain.h"
#include "qFill.h"
@@ -2489,7 +2490,6 @@ static void buildTopBotStruct(STopBotInfo *pTopBotInfo, SQLFunctionCtx *pCtx) {
tmp += POINTER_BYTES * pCtx->param[0].i64;
size_t size = sizeof(tValuePair) + pCtx->tagInfo.tagsLen;
-// assert(pCtx->param[0].i64 > 0);
for (int32_t i = 0; i < pCtx->param[0].i64; ++i) {
pTopBotInfo->res[i] = (tValuePair*) tmp;
@@ -2498,7 +2498,6 @@ static void buildTopBotStruct(STopBotInfo *pTopBotInfo, SQLFunctionCtx *pCtx) {
}
}
-
bool topbot_datablock_filter(SQLFunctionCtx *pCtx, const char *minval, const char *maxval) {
SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx);
if (pResInfo == NULL) {
@@ -2578,13 +2577,14 @@ static void top_function(SQLFunctionCtx *pCtx) {
for (int32_t i = 0; i < pCtx->size; ++i) {
char *data = GET_INPUT_DATA(pCtx, i);
- TSKEY ts = GET_TS_DATA(pCtx, i);
-
if (pCtx->hasNull && isNull(data, pCtx->inputType)) {
continue;
}
notNullElems++;
+
+ // NOTE: Set the default timestamp if it is missing [todo refactor]
+ TSKEY ts = (pCtx->ptsList != NULL)? GET_TS_DATA(pCtx, i):0;
do_top_function_add(pRes, (int32_t)pCtx->param[0].i64, data, ts, pCtx->inputType, &pCtx->tagInfo, NULL, 0);
}
@@ -2657,13 +2657,13 @@ static void bottom_function(SQLFunctionCtx *pCtx) {
for (int32_t i = 0; i < pCtx->size; ++i) {
char *data = GET_INPUT_DATA(pCtx, i);
- TSKEY ts = GET_TS_DATA(pCtx, i);
-
if (pCtx->hasNull && isNull(data, pCtx->inputType)) {
continue;
}
-
+
notNullElems++;
+ // NOTE: Set the default timestamp if it is missing [todo refactor]
+ TSKEY ts = (pCtx->ptsList != NULL)? GET_TS_DATA(pCtx, i):0;
do_bottom_function_add(pRes, (int32_t)pCtx->param[0].i64, data, ts, pCtx->inputType, &pCtx->tagInfo, NULL, 0);
}
@@ -2741,7 +2741,7 @@ static void top_bottom_func_finalizer(SQLFunctionCtx *pCtx) {
if (pCtx->param[1].i64 == PRIMARYKEY_TIMESTAMP_COL_INDEX) {
__compar_fn_t comparator = (pCtx->param[2].i64 == TSDB_ORDER_ASC) ? resAscComparFn : resDescComparFn;
qsort(tvp, (size_t)pResInfo->numOfRes, POINTER_BYTES, comparator);
- } else if (pCtx->param[1].i64 > PRIMARYKEY_TIMESTAMP_COL_INDEX) {
+ } else /*if (pCtx->param[1].i64 > PRIMARYKEY_TIMESTAMP_COL_INDEX)*/ {
__compar_fn_t comparator = (pCtx->param[2].i64 == TSDB_ORDER_ASC) ? resDataAscComparFn : resDataDescComparFn;
qsort(tvp, (size_t)pResInfo->numOfRes, POINTER_BYTES, comparator);
}
@@ -3298,8 +3298,12 @@ static void col_project_function(SQLFunctionCtx *pCtx) {
if (pCtx->numOfParams == 2) {
return;
}
+ if (pCtx->param[0].i64 == 1) {
+ SET_VAL(pCtx, pCtx->size, 1);
+ } else {
+ INC_INIT_VAL(pCtx, pCtx->size);
+ }
- INC_INIT_VAL(pCtx, pCtx->size);
char *pData = GET_INPUT_DATA_LIST(pCtx);
if (pCtx->order == TSDB_ORDER_ASC) {
@@ -4828,51 +4832,81 @@ void blockInfo_func(SQLFunctionCtx* pCtx) {
pResInfo->hasResult = DATA_SET_FLAG;
}
-static void mergeTableBlockDist(STableBlockDist* pDist, const STableBlockDist* pSrc) {
+static void mergeTableBlockDist(SResultRowCellInfo* pResInfo, const STableBlockDist* pSrc) {
+ STableBlockDist* pDist = (STableBlockDist*) GET_ROWCELL_INTERBUF(pResInfo);
assert(pDist != NULL && pSrc != NULL);
+
pDist->numOfTables += pSrc->numOfTables;
pDist->numOfRowsInMemTable += pSrc->numOfRowsInMemTable;
pDist->numOfFiles += pSrc->numOfFiles;
pDist->totalSize += pSrc->totalSize;
+ pDist->totalRows += pSrc->totalRows;
- if (pDist->dataBlockInfos == NULL) {
- pDist->dataBlockInfos = taosArrayInit(4, sizeof(SFileBlockInfo));
+ if (pResInfo->hasResult == DATA_SET_FLAG) {
+ pDist->maxRows = MAX(pDist->maxRows, pSrc->maxRows);
+ pDist->minRows = MIN(pDist->minRows, pSrc->minRows);
+ } else {
+ pDist->maxRows = pSrc->maxRows;
+ pDist->minRows = pSrc->minRows;
+
+ int32_t numSteps = tsMaxRowsInFileBlock/TSDB_BLOCK_DIST_STEP_ROWS;
+ pDist->dataBlockInfos = taosArrayInit(numSteps, sizeof(SFileBlockInfo));
+ taosArraySetSize(pDist->dataBlockInfos, numSteps);
}
- taosArrayAddBatch(pDist->dataBlockInfos, pSrc->dataBlockInfos->pData, (int32_t) taosArrayGetSize(pSrc->dataBlockInfos));
+ size_t steps = taosArrayGetSize(pDist->dataBlockInfos);
+ for (int32_t i = 0; i < steps; ++i) {
+ int32_t srcNumBlocks = ((SFileBlockInfo*)taosArrayGet(pSrc->dataBlockInfos, i))->numBlocksOfStep;
+ SFileBlockInfo* blockInfo = (SFileBlockInfo*)taosArrayGet(pDist->dataBlockInfos, i);
+ blockInfo->numBlocksOfStep += srcNumBlocks;
+ }
}
void block_func_merge(SQLFunctionCtx* pCtx) {
- SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx);
-
- STableBlockDist* pDist = (STableBlockDist*) GET_ROWCELL_INTERBUF(pResInfo);
STableBlockDist info = {0};
-
int32_t len = *(int32_t*) pCtx->pInput;
blockDistInfoFromBinary(((char*)pCtx->pInput) + sizeof(int32_t), len, &info);
- mergeTableBlockDist(pDist, &info);
+ SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx);
+ mergeTableBlockDist(pResInfo, &info);
+
+ pResInfo->numOfRes = 1;
+ pResInfo->hasResult = DATA_SET_FLAG;
}
-static int32_t doGetPercentile(const SArray* pArray, double rate) {
- int32_t len = (int32_t)taosArrayGetSize(pArray);
- if (len <= 0) {
- return 0;
+void getPercentiles(STableBlockDist *pTableBlockDist, int64_t totalBlocks, int32_t numOfPercents,
+ double* percents, int32_t* percentiles) {
+ if (totalBlocks == 0) {
+ for (int32_t i = 0; i < numOfPercents; ++i) {
+ percentiles[i] = 0;
+ }
+ return;
}
- assert(rate >= 0 && rate <= 1.0);
- int idx = (int32_t)((len - 1) * rate);
+ SArray *blocksInfos = pTableBlockDist->dataBlockInfos;
+ size_t numSteps = taosArrayGetSize(blocksInfos);
+ size_t cumulativeBlocks = 0;
- return ((SFileBlockInfo *)(taosArrayGet(pArray, idx)))->numOfRows;
-}
+ int percentIndex = 0;
+ for (int32_t indexStep = 0; indexStep < numSteps; ++indexStep) {
+ int32_t numStepBlocks = ((SFileBlockInfo *)taosArrayGet(blocksInfos, indexStep))->numBlocksOfStep;
+ if (numStepBlocks == 0) continue;
+ cumulativeBlocks += numStepBlocks;
-static int compareBlockInfo(const void *pLeft, const void *pRight) {
- int32_t left = ((SFileBlockInfo *)pLeft)->numOfRows;
- int32_t right = ((SFileBlockInfo *)pRight)->numOfRows;
+ while (percentIndex < numOfPercents) {
+ double blockRank = totalBlocks * percents[percentIndex];
+ if (blockRank <= cumulativeBlocks) {
+ percentiles[percentIndex] = indexStep;
+ ++percentIndex;
+ } else {
+ break;
+ }
+ }
+ }
- if (left > right) return 1;
- if (left < right) return -1;
- return 0;
+ for (int32_t i = 0; i < numOfPercents; ++i) {
+ percentiles[i] = (percentiles[i]+1) * TSDB_BLOCK_DIST_STEP_ROWS - TSDB_BLOCK_DIST_STEP_ROWS/2;
+ }
}
void generateBlockDistResult(STableBlockDist *pTableBlockDist, char* result) {
@@ -4880,40 +4914,41 @@ void generateBlockDistResult(STableBlockDist *pTableBlockDist, char* result) {
return;
}
- int64_t min = INT64_MAX, max = INT64_MIN, avg = 0;
- SArray* blockInfos= pTableBlockDist->dataBlockInfos;
- int64_t totalRows = 0, totalBlocks = taosArrayGetSize(blockInfos);
+ SArray* blockInfos = pTableBlockDist->dataBlockInfos;
+ uint64_t totalRows = pTableBlockDist->totalRows;
+ size_t numSteps = taosArrayGetSize(blockInfos);
+ int64_t totalBlocks = 0;
+ int64_t min = -1, max = -1, avg = 0;
- for (size_t i = 0; i < taosArrayGetSize(blockInfos); i++) {
+ for (int32_t i = 0; i < numSteps; i++) {
SFileBlockInfo *blockInfo = taosArrayGet(blockInfos, i);
- int64_t rows = blockInfo->numOfRows;
-
- min = MIN(min, rows);
- max = MAX(max, rows);
- totalRows += rows;
+ int64_t blocks = blockInfo->numBlocksOfStep;
+ totalBlocks += blocks;
}
avg = totalBlocks > 0 ? (int64_t)(totalRows/totalBlocks) : 0;
- taosArraySort(blockInfos, compareBlockInfo);
+ min = totalBlocks > 0 ? pTableBlockDist->minRows : 0;
+ max = totalBlocks > 0 ? pTableBlockDist->maxRows : 0;
+
+ double percents[] = {0.05, 0.10, 0.20, 0.30, 0.40, 0.50, 0.60, 0.70, 0.80, 0.90, 0.95, 0.99};
+ int32_t percentiles[] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
+ assert(sizeof(percents)/sizeof(double) == sizeof(percentiles)/sizeof(int32_t));
+ getPercentiles(pTableBlockDist, totalBlocks, sizeof(percents)/sizeof(double), percents, percentiles);
uint64_t totalLen = pTableBlockDist->totalSize;
int32_t rowSize = pTableBlockDist->rowSize;
-
+ double compRatio = (totalRows>0) ? ((double)(totalLen)/(rowSize*totalRows)) : 1;
int sz = sprintf(result + VARSTR_HEADER_SIZE,
"summary: \n\t "
"5th=[%d], 10th=[%d], 20th=[%d], 30th=[%d], 40th=[%d], 50th=[%d]\n\t "
"60th=[%d], 70th=[%d], 80th=[%d], 90th=[%d], 95th=[%d], 99th=[%d]\n\t "
"Min=[%"PRId64"(Rows)] Max=[%"PRId64"(Rows)] Avg=[%"PRId64"(Rows)] Stddev=[%.2f] \n\t "
- "Rows=[%"PRId64"], Blocks=[%"PRId64"], Size=[%.3f(Kb)] Comp=[%.2f%%]\n\t "
+ "Rows=[%"PRIu64"], Blocks=[%"PRId64"], Size=[%.3f(Kb)] Comp=[%.2f]\n\t "
"RowsInMem=[%d] \n\t SeekHeaderTime=[%d(us)]",
- doGetPercentile(blockInfos, 0.05), doGetPercentile(blockInfos, 0.10),
- doGetPercentile(blockInfos, 0.20), doGetPercentile(blockInfos, 0.30),
- doGetPercentile(blockInfos, 0.40), doGetPercentile(blockInfos, 0.50),
- doGetPercentile(blockInfos, 0.60), doGetPercentile(blockInfos, 0.70),
- doGetPercentile(blockInfos, 0.80), doGetPercentile(blockInfos, 0.90),
- doGetPercentile(blockInfos, 0.95), doGetPercentile(blockInfos, 0.99),
+ percentiles[0], percentiles[1], percentiles[2], percentiles[3], percentiles[4], percentiles[5],
+ percentiles[6], percentiles[7], percentiles[8], percentiles[9], percentiles[10], percentiles[11],
min, max, avg, 0.0,
- totalRows, totalBlocks, totalLen/1024.0, (double)(totalLen*100.0)/(rowSize*totalRows),
+ totalRows, totalBlocks, totalLen/1024.0, compRatio,
pTableBlockDist->numOfRowsInMemTable, pTableBlockDist->firstSeekTimeUs);
varDataSetLen(result, sz);
UNUSED(sz);
diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c
index cb94525614..25e7e446bd 100644
--- a/src/query/src/qExecutor.c
+++ b/src/query/src/qExecutor.c
@@ -189,12 +189,16 @@ static void destroySFillOperatorInfo(void* param, int32_t numOfOutput);
static void destroyGroupbyOperatorInfo(void* param, int32_t numOfOutput);
static void destroyArithOperatorInfo(void* param, int32_t numOfOutput);
static void destroyTagScanOperatorInfo(void* param, int32_t numOfOutput);
+static void destroySWindowOperatorInfo(void* param, int32_t numOfOutput);
+static void destroyStateWindowOperatorInfo(void* param, int32_t numOfOutput);
+static void destroyAggOperatorInfo(void* param, int32_t numOfOutput);
static void destroyOperatorInfo(SOperatorInfo* pOperator);
+
static int32_t doCopyToSDataBlock(SQueryRuntimeEnv* pRuntimeEnv, SGroupResInfo* pGroupResInfo, int32_t orderType, SSDataBlock* pBlock);
static int32_t getGroupbyColumnIndex(SGroupbyExpr *pGroupbyExpr, SSDataBlock* pDataBlock);
-static int32_t setGroupResultOutputBuf(SQueryRuntimeEnv *pRuntimeEnv, SGroupbyOperatorInfo *pInfo, int32_t numOfCols, char *pData, int16_t type, int16_t bytes, int32_t groupIndex);
+static int32_t setGroupResultOutputBuf(SQueryRuntimeEnv *pRuntimeEnv, SOptrBasicInfo *binf, int32_t numOfCols, char *pData, int16_t type, int16_t bytes, int32_t groupIndex);
static void initCtxOutputBuffer(SQLFunctionCtx* pCtx, int32_t size);
static void getAlignQueryTimeWindow(SQueryAttr *pQueryAttr, int64_t key, int64_t keyFirst, int64_t keyLast, STimeWindow *win);
@@ -731,7 +735,6 @@ static void doApplyFunctions(SQueryRuntimeEnv* pRuntimeEnv, SQLFunctionCtx* pCtx
if (pCtx[k].preAggVals.isSet && forwardStep < numOfTotal) {
pCtx[k].preAggVals.isSet = false;
}
-
if (functionNeedToExecute(pRuntimeEnv, &pCtx[k], functionId)) {
aAggs[functionId].xFunction(&pCtx[k]);
}
@@ -935,7 +938,7 @@ static void doSetInputDataBlock(SOperatorInfo* pOperator, SQLFunctionCtx* pCtx,
setArithParams((SArithmeticSupport*)pCtx[i].param[1].pz, &pOperator->pExpr[i], pBlock);
} else {
SColIndex* pCol = &pOperator->pExpr[i].base.colInfo;
- if (TSDB_COL_IS_NORMAL_COL(pCol->flag) || (pCol->colId == TSDB_BLOCK_DIST_COLUMN_INDEX) ||
+ if (TSDB_COL_IS_NORMAL_COL(pCol->flag) || (pCtx[i].functionId == TSDB_FUNC_BLKINFO) ||
(TSDB_COL_IS_TAG(pCol->flag) && pOperator->pRuntimeEnv->scanFlag == MERGE_STAGE)) {
SColIndex* pColIndex = &pOperator->pExpr[i].base.colInfo;
SColumnInfoData* p = taosArrayGet(pBlock->pDataBlock, pColIndex->colIndex);
@@ -947,7 +950,13 @@ static void doSetInputDataBlock(SOperatorInfo* pOperator, SQLFunctionCtx* pCtx,
uint32_t status = aAggs[pCtx[i].functionId].status;
if ((status & (TSDB_FUNCSTATE_SELECTIVITY | TSDB_FUNCSTATE_NEED_TS)) != 0) {
SColumnInfoData* tsInfo = taosArrayGet(pBlock->pDataBlock, 0);
- pCtx[i].ptsList = (int64_t*) tsInfo->pData;
+ // In case of the top/bottom query again the nest query result, which has no timestamp column
+ // don't set the ptsList attribute.
+ if (tsInfo->info.type == TSDB_DATA_TYPE_TIMESTAMP) {
+ pCtx[i].ptsList = (int64_t*) tsInfo->pData;
+ } else {
+ pCtx[i].ptsList = NULL;
+ }
}
} else if (TSDB_COL_IS_UD_COL(pCol->flag) && (pOperator->pRuntimeEnv->scanFlag == MERGE_STAGE)) {
SColIndex* pColIndex = &pOperator->pExpr[i].base.colInfo;
@@ -1299,7 +1308,7 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SGroupbyOperatorInfo *pIn
}
int32_t ret =
- setGroupResultOutputBuf(pRuntimeEnv, pInfo, pOperator->numOfOutput, val, type, bytes, item->groupIndex);
+ setGroupResultOutputBuf(pRuntimeEnv, &(pInfo->binfo), pOperator->numOfOutput, val, type, bytes, item->groupIndex);
if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code
longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_APP_ERROR);
}
@@ -1338,12 +1347,16 @@ static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSWindowOperatorInf
pInfo->start = j;
} else if (tsList[j] - pInfo->prevTs <= gap) {
pInfo->curWindow.ekey = tsList[j];
- pInfo->prevTs = tsList[j];
+ //pInfo->prevTs = tsList[j];
pInfo->numOfRows += 1;
- pInfo->start = j;
+ if (j == 0 && pInfo->start != 0) {
+ pInfo->numOfRows = 1;
+ pInfo->start = 0;
+ }
} else { // start a new session window
SResultRow* pResult = NULL;
+ pInfo->curWindow.ekey = pInfo->curWindow.skey;
int32_t ret = setWindowOutputBufByKey(pRuntimeEnv, &pBInfo->resultRowInfo, &pInfo->curWindow, masterScan,
&pResult, item->groupIndex, pBInfo->pCtx, pOperator->numOfOutput,
pBInfo->rowCellInfoOffset);
@@ -1364,6 +1377,7 @@ static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSWindowOperatorInf
SResultRow* pResult = NULL;
+ pInfo->curWindow.ekey = pInfo->curWindow.skey;
int32_t ret = setWindowOutputBufByKey(pRuntimeEnv, &pBInfo->resultRowInfo, &pInfo->curWindow, masterScan,
&pResult, item->groupIndex, pBInfo->pCtx, pOperator->numOfOutput,
pBInfo->rowCellInfoOffset);
@@ -1391,12 +1405,12 @@ static void setResultRowKey(SResultRow* pResultRow, char* pData, int16_t type) {
}
}
-static int32_t setGroupResultOutputBuf(SQueryRuntimeEnv *pRuntimeEnv, SGroupbyOperatorInfo *pInfo, int32_t numOfCols, char *pData, int16_t type, int16_t bytes, int32_t groupIndex) {
+static int32_t setGroupResultOutputBuf(SQueryRuntimeEnv *pRuntimeEnv, SOptrBasicInfo *binfo, int32_t numOfCols, char *pData, int16_t type, int16_t bytes, int32_t groupIndex) {
SDiskbasedResultBuf *pResultBuf = pRuntimeEnv->pResultBuf;
- int32_t *rowCellInfoOffset = pInfo->binfo.rowCellInfoOffset;
- SResultRowInfo *pResultRowInfo = &pInfo->binfo.resultRowInfo;
- SQLFunctionCtx *pCtx = pInfo->binfo.pCtx;
+ int32_t *rowCellInfoOffset = binfo->rowCellInfoOffset;
+ SResultRowInfo *pResultRowInfo = &binfo->resultRowInfo;
+ SQLFunctionCtx *pCtx = binfo->pCtx;
// not assign result buffer yet, add new result buffer, TODO remove it
char* d = pData;
@@ -1718,7 +1732,10 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int32_t numOf
case OP_TimeWindow: {
pRuntimeEnv->proot =
createTimeIntervalOperatorInfo(pRuntimeEnv, pRuntimeEnv->proot, pQueryAttr->pExpr1, pQueryAttr->numOfOutput);
- setTableScanFilterOperatorInfo(pRuntimeEnv->proot->upstream[0]->info, pRuntimeEnv->proot);
+ int32_t opType = pRuntimeEnv->proot->upstream[0]->operatorType;
+ if (opType != OP_DummyInput && opType != OP_Join) {
+ setTableScanFilterOperatorInfo(pRuntimeEnv->proot->upstream[0]->info, pRuntimeEnv->proot);
+ }
break;
}
case OP_Groupby: {
@@ -1764,6 +1781,11 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int32_t numOf
}
break;
}
+ case OP_StateWindow: {
+ pRuntimeEnv->proot = createStatewindowOperatorInfo(pRuntimeEnv, pRuntimeEnv->proot, pQueryAttr->pExpr1, pQueryAttr->numOfOutput);
+ setTableScanFilterOperatorInfo(pRuntimeEnv->proot->upstream[0]->info, pRuntimeEnv->proot);
+ break;
+ }
case OP_Limit: {
pRuntimeEnv->proot = createLimitOperatorInfo(pRuntimeEnv, pRuntimeEnv->proot);
@@ -2106,6 +2128,8 @@ static bool onlyFirstQuery(SQueryAttr *pQueryAttr) { return onlyOneQueryType(pQu
static bool onlyLastQuery(SQueryAttr *pQueryAttr) { return onlyOneQueryType(pQueryAttr, TSDB_FUNC_LAST, TSDB_FUNC_LAST_DST); }
+static bool notContainSessionOrStateWindow(SQueryAttr *pQueryAttr) { return !(pQueryAttr->sw.gap > 0 || pQueryAttr->stateWindow); }
+
static int32_t updateBlockLoadStatus(SQueryAttr *pQuery, int32_t status) {
bool hasFirstLastFunc = false;
bool hasOtherFunc = false;
@@ -2209,7 +2233,7 @@ static void changeExecuteScanOrder(SQInfo *pQInfo, SQueryTableMsg* pQueryMsg, bo
}
pQueryAttr->order.order = TSDB_ORDER_ASC;
- } else if (onlyLastQuery(pQueryAttr)) {
+ } else if (onlyLastQuery(pQueryAttr) && notContainSessionOrStateWindow(pQueryAttr)) {
if (QUERY_IS_ASC_QUERY(pQueryAttr)) {
qDebug(msg, pQInfo, "only-last", pQueryAttr->order.order, TSDB_ORDER_DESC, pQueryAttr->window.skey,
pQueryAttr->window.ekey, pQueryAttr->window.ekey, pQueryAttr->window.skey);
@@ -3201,7 +3225,7 @@ void finalizeQueryResult(SOperatorInfo* pOperator, SQLFunctionCtx* pCtx, SResult
SQueryAttr *pQueryAttr = pRuntimeEnv->pQueryAttr;
int32_t numOfOutput = pOperator->numOfOutput;
- if (pQueryAttr->groupbyColumn || QUERY_IS_INTERVAL_QUERY(pQueryAttr) || pQueryAttr->sw.gap > 0) {
+ if (pQueryAttr->groupbyColumn || QUERY_IS_INTERVAL_QUERY(pQueryAttr) || pQueryAttr->sw.gap > 0 || pQueryAttr->stateWindow) {
// for each group result, call the finalize function for each column
if (pQueryAttr->groupbyColumn) {
closeAllResultRows(pResultRowInfo);
@@ -3267,6 +3291,25 @@ STableQueryInfo *createTableQueryInfo(SQueryAttr* pQueryAttr, void* pTable, bool
return pTableQueryInfo;
}
+STableQueryInfo* createTmpTableQueryInfo(STimeWindow win) {
+ STableQueryInfo* pTableQueryInfo = calloc(1, sizeof(STableQueryInfo));
+
+ pTableQueryInfo->win = win;
+ pTableQueryInfo->lastKey = win.skey;
+
+ pTableQueryInfo->pTable = NULL;
+ pTableQueryInfo->cur.vgroupIndex = -1;
+
+ // set more initial size of interval/groupby query
+ int32_t initialSize = 16;
+ int32_t code = initResultRowInfo(&pTableQueryInfo->resInfo, initialSize, TSDB_DATA_TYPE_INT);
+ if (code != TSDB_CODE_SUCCESS) {
+ return NULL;
+ }
+
+ return pTableQueryInfo;
+}
+
void destroyTableQueryInfoImpl(STableQueryInfo *pTableQueryInfo) {
if (pTableQueryInfo == NULL) {
return;
@@ -3771,7 +3814,7 @@ void queryCostStatis(SQInfo *pQInfo) {
//
// int32_t numOfRes = tableApplyFunctionsOnBlock(pRuntimeEnv, pBlockInfo, NULL, binarySearchForKey, pDataBlock);
//
-// qDebug("QInfo:0x%"PRIx64" check data block, brange:%" PRId64 "-%" PRId64 ", numOfRows:%d, numOfRes:%d, lastKey:%"PRId64, GET_QID(pRuntimeEnv),
+// qDebug("QInfo:0x%"PRIx64" check data block, brange:%" PRId64 "-%" PRId64 ", numBlocksOfStep:%d, numOfRes:%d, lastKey:%"PRId64, GET_QID(pRuntimeEnv),
// pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows, numOfRes, pQuery->current->lastKey);
//}
@@ -4191,6 +4234,10 @@ static void updateTableIdInfo(STableQueryInfo* pTableQueryInfo, SSDataBlock* pBl
int32_t step = GET_FORWARD_DIRECTION_FACTOR(order);
pTableQueryInfo->lastKey = ((order == TSDB_ORDER_ASC)? pBlock->info.window.ekey:pBlock->info.window.skey) + step;
+ if (pTableQueryInfo->pTable == NULL) {
+ return;
+ }
+
STableIdInfo tidInfo = createTableIdInfo(pTableQueryInfo);
STableIdInfo *idinfo = taosHashGet(pTableIdInfo, &tidInfo.tid, sizeof(tidInfo.tid));
if (idinfo != NULL) {
@@ -4347,7 +4394,12 @@ static SSDataBlock* doBlockInfoScan(void* param, bool* newgroup) {
STableBlockDist tableBlockDist = {0};
tableBlockDist.numOfTables = (int32_t)pOperator->pRuntimeEnv->tableqinfoGroupInfo.numOfTables;
- tableBlockDist.dataBlockInfos = taosArrayInit(512, sizeof(SFileBlockInfo));
+
+ int32_t numRowSteps = tsMaxRowsInFileBlock / TSDB_BLOCK_DIST_STEP_ROWS;
+ tableBlockDist.dataBlockInfos = taosArrayInit(numRowSteps, sizeof(SFileBlockInfo));
+ taosArraySetSize(tableBlockDist.dataBlockInfos, numRowSteps);
+ tableBlockDist.maxRows = INT_MIN;
+ tableBlockDist.minRows = INT_MAX;
tsdbGetFileBlocksDistInfo(pTableScanInfo->pQueryHandle, &tableBlockDist);
tableBlockDist.numOfRowsInMemTable = (int32_t) tsdbGetNumOfRowsInMemTable(pTableScanInfo->pQueryHandle);
@@ -4429,7 +4481,7 @@ SOperatorInfo* createTableBlockInfoScanOperator(void* pTsdbQueryHandle, SQueryRu
SColumnInfoData infoData = {{0}};
infoData.info.type = TSDB_DATA_TYPE_BINARY;
infoData.info.bytes = 1024;
- infoData.info.colId = TSDB_BLOCK_DIST_COLUMN_INDEX;
+ infoData.info.colId = 0;
taosArrayPush(pInfo->block.pDataBlock, &infoData);
SOperatorInfo* pOperator = calloc(1, sizeof(SOperatorInfo));
@@ -4487,6 +4539,12 @@ void setTableScanFilterOperatorInfo(STableScanInfo* pTableScanInfo, SOperatorInf
} else if (pDownstream->operatorType == OP_SessionWindow) {
SSWindowOperatorInfo* pInfo = pDownstream->info;
+ pTableScanInfo->pCtx = pInfo->binfo.pCtx;
+ pTableScanInfo->pResultRowInfo = &pInfo->binfo.resultRowInfo;
+ pTableScanInfo->rowCellInfoOffset = pInfo->binfo.rowCellInfoOffset;
+ } else if (pDownstream->operatorType == OP_StateWindow) {
+ SStateWindowOperatorInfo* pInfo = pDownstream->info;
+
pTableScanInfo->pCtx = pInfo->binfo.pCtx;
pTableScanInfo->pResultRowInfo = &pInfo->binfo.resultRowInfo;
pTableScanInfo->rowCellInfoOffset = pInfo->binfo.rowCellInfoOffset;
@@ -4598,7 +4656,6 @@ static void destroyGlobalAggOperatorInfo(void* param, int32_t numOfOutput) {
tfree(pInfo->prevRow);
tfree(pInfo->currentGroupColData);
}
-
static void destroySlimitOperatorInfo(void* param, int32_t numOfOutput) {
SSLimitOperatorInfo *pInfo = (SSLimitOperatorInfo*) param;
taosArrayDestroy(pInfo->orderColumnList);
@@ -4858,8 +4915,7 @@ static SSDataBlock* doArithmeticOperation(void* param, bool* newgroup) {
updateOutputBuf(&pArithInfo->binfo, &pArithInfo->bufCapacity, pBlock->info.rows);
arithmeticApplyFunctions(pRuntimeEnv, pInfo->pCtx, pOperator->numOfOutput);
-
- if (pTableQueryInfo != NULL) { // TODO refactor
+ if (pTableQueryInfo != NULL) {
updateTableIdInfo(pTableQueryInfo, pBlock, pRuntimeEnv->pTableRetrieveTsMap, order);
}
@@ -4902,8 +4958,7 @@ static SSDataBlock* doArithmeticOperation(void* param, bool* newgroup) {
updateOutputBuf(&pArithInfo->binfo, &pArithInfo->bufCapacity, pBlock->info.rows);
arithmeticApplyFunctions(pRuntimeEnv, pInfo->pCtx, pOperator->numOfOutput);
-
- if (pTableQueryInfo != NULL) { // TODO refactor
+ if (pTableQueryInfo != NULL) {
updateTableIdInfo(pTableQueryInfo, pBlock, pRuntimeEnv->pTableRetrieveTsMap, order);
}
@@ -5104,13 +5159,83 @@ static SSDataBlock* doSTableIntervalAgg(void* param, bool* newgroup) {
return pIntervalInfo->pRes;
}
-static SSDataBlock* doSessionWindowAgg(void* param, bool* newgroup) {
+
+static void doStateWindowAggImpl(SOperatorInfo* pOperator, SStateWindowOperatorInfo *pInfo, SSDataBlock *pSDataBlock) {
+ SQueryRuntimeEnv* pRuntimeEnv = pOperator->pRuntimeEnv;
+ STableQueryInfo* item = pRuntimeEnv->current;
+ SColumnInfoData* pColInfoData = taosArrayGet(pSDataBlock->pDataBlock, pInfo->colIndex);
+
+ SOptrBasicInfo* pBInfo = &pInfo->binfo;
+
+ bool masterScan = IS_MASTER_SCAN(pRuntimeEnv);
+ int16_t bytes = pColInfoData->info.bytes;
+ int16_t type = pColInfoData->info.type;
+
+ SColumnInfoData* pTsColInfoData = taosArrayGet(pSDataBlock->pDataBlock, 0);
+ TSKEY* tsList = (TSKEY*)pTsColInfoData->pData;
+
+ pInfo->numOfRows = 0;
+ for (int32_t j = 0; j < pSDataBlock->info.rows; ++j) {
+ char* val = ((char*)pColInfoData->pData) + bytes * j;
+ if (isNull(val, type)) {
+ continue;
+ }
+ if (pInfo->prevData == NULL) {
+ pInfo->prevData = malloc(bytes);
+ memcpy(pInfo->prevData, val, bytes);
+ pInfo->numOfRows = 1;
+ pInfo->curWindow.skey = tsList[j];
+ pInfo->curWindow.ekey = tsList[j];
+ pInfo->start = j;
+
+ } else if (memcmp(pInfo->prevData, val, bytes) == 0) {
+ pInfo->curWindow.ekey = tsList[j];
+ pInfo->numOfRows += 1;
+ //pInfo->start = j;
+ if (j == 0 && pInfo->start != 0) {
+ pInfo->numOfRows = 1;
+ pInfo->start = 0;
+ }
+ } else {
+ SResultRow* pResult = NULL;
+ pInfo->curWindow.ekey = pInfo->curWindow.skey;
+ int32_t ret = setWindowOutputBufByKey(pRuntimeEnv, &pBInfo->resultRowInfo, &pInfo->curWindow, masterScan,
+ &pResult, item->groupIndex, pBInfo->pCtx, pOperator->numOfOutput,
+ pBInfo->rowCellInfoOffset);
+ if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code
+ longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_APP_ERROR);
+ }
+ doApplyFunctions(pRuntimeEnv, pBInfo->pCtx, &pInfo->curWindow, pInfo->start, pInfo->numOfRows, tsList,
+ pSDataBlock->info.rows, pOperator->numOfOutput);
+
+ pInfo->curWindow.skey = tsList[j];
+ pInfo->curWindow.ekey = tsList[j];
+ memcpy(pInfo->prevData, val, bytes);
+ pInfo->numOfRows = 1;
+ pInfo->start = j;
+
+ }
+ }
+ SResultRow* pResult = NULL;
+
+ pInfo->curWindow.ekey = pInfo->curWindow.skey;
+ int32_t ret = setWindowOutputBufByKey(pRuntimeEnv, &pBInfo->resultRowInfo, &pInfo->curWindow, masterScan,
+ &pResult, item->groupIndex, pBInfo->pCtx, pOperator->numOfOutput,
+ pBInfo->rowCellInfoOffset);
+ if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code
+ longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_APP_ERROR);
+ }
+
+ doApplyFunctions(pRuntimeEnv, pBInfo->pCtx, &pInfo->curWindow, pInfo->start, pInfo->numOfRows, tsList,
+ pSDataBlock->info.rows, pOperator->numOfOutput);
+}
+static SSDataBlock* doStateWindowAgg(void *param, bool* newgroup) {
SOperatorInfo* pOperator = (SOperatorInfo*) param;
if (pOperator->status == OP_EXEC_DONE) {
return NULL;
}
- SSWindowOperatorInfo* pWindowInfo = pOperator->info;
+ SStateWindowOperatorInfo* pWindowInfo = pOperator->info;
SOptrBasicInfo* pBInfo = &pWindowInfo->binfo;
SQueryRuntimeEnv* pRuntimeEnv = pOperator->pRuntimeEnv;
@@ -5127,6 +5252,62 @@ static SSDataBlock* doSessionWindowAgg(void* param, bool* newgroup) {
SQueryAttr* pQueryAttr = pRuntimeEnv->pQueryAttr;
int32_t order = pQueryAttr->order.order;
STimeWindow win = pQueryAttr->window;
+ SOperatorInfo* upstream = pOperator->upstream[0];
+ while (1) {
+ SSDataBlock* pBlock = upstream->exec(upstream, newgroup);
+ if (pBlock == NULL) {
+ break;
+ }
+ setInputDataBlock(pOperator, pBInfo->pCtx, pBlock, pQueryAttr->order.order);
+ if (pWindowInfo->colIndex == -1) {
+ pWindowInfo->colIndex = getGroupbyColumnIndex(pRuntimeEnv->pQueryAttr->pGroupbyExpr, pBlock);
+ }
+ doStateWindowAggImpl(pOperator, pWindowInfo, pBlock);
+ }
+
+ // restore the value
+ pQueryAttr->order.order = order;
+ pQueryAttr->window = win;
+
+ pOperator->status = OP_RES_TO_RETURN;
+ closeAllResultRows(&pBInfo->resultRowInfo);
+ setQueryStatus(pRuntimeEnv, QUERY_COMPLETED);
+ finalizeQueryResult(pOperator, pBInfo->pCtx, &pBInfo->resultRowInfo, pBInfo->rowCellInfoOffset);
+
+ initGroupResInfo(&pRuntimeEnv->groupResInfo, &pBInfo->resultRowInfo);
+ toSSDataBlock(&pRuntimeEnv->groupResInfo, pRuntimeEnv, pBInfo->pRes);
+
+ if (pBInfo->pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pRuntimeEnv->groupResInfo)) {
+ pOperator->status = OP_EXEC_DONE;
+ }
+
+ return pBInfo->pRes->info.rows == 0? NULL:pBInfo->pRes;
+}
+static SSDataBlock* doSessionWindowAgg(void* param, bool* newgroup) {
+ SOperatorInfo* pOperator = (SOperatorInfo*) param;
+ if (pOperator->status == OP_EXEC_DONE) {
+ return NULL;
+ }
+
+ SSWindowOperatorInfo* pWindowInfo = pOperator->info;
+ SOptrBasicInfo* pBInfo = &pWindowInfo->binfo;
+
+
+ SQueryRuntimeEnv* pRuntimeEnv = pOperator->pRuntimeEnv;
+ if (pOperator->status == OP_RES_TO_RETURN) {
+ toSSDataBlock(&pRuntimeEnv->groupResInfo, pRuntimeEnv, pBInfo->pRes);
+
+ if (pBInfo->pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pRuntimeEnv->groupResInfo)) {
+ pOperator->status = OP_EXEC_DONE;
+ }
+
+ return pBInfo->pRes;
+ }
+
+ SQueryAttr* pQueryAttr = pRuntimeEnv->pQueryAttr;
+ //pQueryAttr->order.order = TSDB_ORDER_ASC;
+ int32_t order = pQueryAttr->order.order;
+ STimeWindow win = pQueryAttr->window;
SOperatorInfo* upstream = pOperator->upstream[0];
@@ -5362,7 +5543,7 @@ SOperatorInfo* createAggregateOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOpera
pOperator->pRuntimeEnv = pRuntimeEnv;
pOperator->exec = doAggregate;
- pOperator->cleanup = destroyBasicOperatorInfo;
+ pOperator->cleanup = destroyAggOperatorInfo;
appendUpstream(pOperator, upstream);
return pOperator;
@@ -5382,6 +5563,19 @@ static void destroyBasicOperatorInfo(void* param, int32_t numOfOutput) {
SOptrBasicInfo* pInfo = (SOptrBasicInfo*) param;
doDestroyBasicInfo(pInfo, numOfOutput);
}
+static void destroyStateWindowOperatorInfo(void* param, int32_t numOfOutput) {
+ SStateWindowOperatorInfo* pInfo = (SStateWindowOperatorInfo*) param;
+ doDestroyBasicInfo(&pInfo->binfo, numOfOutput);
+ tfree(pInfo->prevData);
+}
+static void destroyAggOperatorInfo(void* param, int32_t numOfOutput) {
+ SAggOperatorInfo* pInfo = (SAggOperatorInfo*) param;
+ doDestroyBasicInfo(&pInfo->binfo, numOfOutput);
+}
+static void destroySWindowOperatorInfo(void* param, int32_t numOfOutput) {
+ SSWindowOperatorInfo* pInfo = (SSWindowOperatorInfo*) param;
+ doDestroyBasicInfo(&pInfo->binfo, numOfOutput);
+}
static void destroySFillOperatorInfo(void* param, int32_t numOfOutput) {
SFillOperatorInfo* pInfo = (SFillOperatorInfo*) param;
@@ -5436,7 +5630,7 @@ SOperatorInfo* createMultiTableAggOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SO
pOperator->pRuntimeEnv = pRuntimeEnv;
pOperator->exec = doSTableAggregate;
- pOperator->cleanup = destroyBasicOperatorInfo;
+ pOperator->cleanup = destroyAggOperatorInfo;
appendUpstream(pOperator, upstream);
return pOperator;
@@ -5562,7 +5756,29 @@ SOperatorInfo* createTimeIntervalOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOp
appendUpstream(pOperator, upstream);
return pOperator;
}
+SOperatorInfo* createStatewindowOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorInfo* upstream, SExprInfo* pExpr, int32_t numOfOutput) {
+ SStateWindowOperatorInfo* pInfo = calloc(1, sizeof(SStateWindowOperatorInfo));
+ pInfo->colIndex = -1;
+ pInfo->binfo.pCtx = createSQLFunctionCtx(pRuntimeEnv, pExpr, numOfOutput, &pInfo->binfo.rowCellInfoOffset);
+ pInfo->binfo.pRes = createOutputBuf(pExpr, numOfOutput, pRuntimeEnv->resultInfo.capacity);
+ initResultRowInfo(&pInfo->binfo.resultRowInfo, 8, TSDB_DATA_TYPE_INT);
+ SOperatorInfo* pOperator = calloc(1, sizeof(SOperatorInfo));
+ pOperator->name = "StateWindowOperator";
+ pOperator->operatorType = OP_StateWindow;
+ pOperator->blockingOptr = true;
+ pOperator->status = OP_IN_EXECUTING;
+ pOperator->pExpr = pExpr;
+ pOperator->numOfOutput = numOfOutput;
+ pOperator->info = pInfo;
+ pOperator->pRuntimeEnv = pRuntimeEnv;
+ pOperator->exec = doStateWindowAgg;
+ pOperator->cleanup = destroyStateWindowOperatorInfo;
+
+ appendUpstream(pOperator, upstream);
+ return pOperator;
+
+}
SOperatorInfo* createSWindowOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorInfo* upstream, SExprInfo* pExpr, int32_t numOfOutput) {
SSWindowOperatorInfo* pInfo = calloc(1, sizeof(SSWindowOperatorInfo));
@@ -5582,7 +5798,7 @@ SOperatorInfo* createSWindowOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperato
pOperator->info = pInfo;
pOperator->pRuntimeEnv = pRuntimeEnv;
pOperator->exec = doSessionWindowAgg;
- pOperator->cleanup = destroyBasicOperatorInfo;
+ pOperator->cleanup = destroySWindowOperatorInfo;
appendUpstream(pOperator, upstream);
return pOperator;
@@ -5958,10 +6174,7 @@ static int32_t getColumnIndexInSource(SQueriedTableInfo *pTableInfo, SSqlExpr *p
if (TSDB_COL_IS_TAG(pExpr->colInfo.flag)) {
if (pExpr->colInfo.colId == TSDB_TBNAME_COLUMN_INDEX) {
return TSDB_TBNAME_COLUMN_INDEX;
- } else if (pExpr->colInfo.colId == TSDB_BLOCK_DIST_COLUMN_INDEX) {
- return TSDB_BLOCK_DIST_COLUMN_INDEX;
}
-
while(j < pTableInfo->numOfTags) {
if (pExpr->colInfo.colId == pTagCols[j].colId) {
@@ -6531,14 +6744,14 @@ int32_t createQueryFunc(SQueriedTableInfo* pTableInfo, int32_t numOfOutput, SExp
type = TSDB_DATA_TYPE_DOUBLE;
bytes = tDataTypes[type].bytes;
+ } else if (pExprs[i].base.functionId == TSDB_FUNC_BLKINFO) {
+ SSchema s = {.type=TSDB_DATA_TYPE_BINARY, .bytes=TSDB_MAX_BINARY_LEN};
+ type = s.type;
+ bytes = s.bytes;
} else if (pExprs[i].base.colInfo.colId == TSDB_TBNAME_COLUMN_INDEX && pExprs[i].base.functionId == TSDB_FUNC_TAGPRJ) { // parse the normal column
SSchema* s = tGetTbnameColumnSchema();
type = s->type;
bytes = s->bytes;
- } else if (pExprs[i].base.colInfo.colId == TSDB_BLOCK_DIST_COLUMN_INDEX) {
- SSchema s = tGetBlockDistColumnSchema();
- type = s.type;
- bytes = s.bytes;
} else if (pExprs[i].base.colInfo.colId <= TSDB_UD_COLUMN_INDEX && pExprs[i].base.colInfo.colId > TSDB_RES_COL_ID) {
// it is a user-defined constant value column
assert(pExprs[i].base.functionId == TSDB_FUNC_PRJ);
@@ -6551,7 +6764,7 @@ int32_t createQueryFunc(SQueriedTableInfo* pTableInfo, int32_t numOfOutput, SExp
} else {
int32_t j = getColumnIndexInSource(pTableInfo, &pExprs[i].base, pTagCols);
if (TSDB_COL_IS_TAG(pExprs[i].base.colInfo.flag)) {
- if (j < TSDB_BLOCK_DIST_COLUMN_INDEX || j >= pTableInfo->numOfTags) {
+ if (j < TSDB_TBNAME_COLUMN_INDEX || j >= pTableInfo->numOfTags) {
return TSDB_CODE_QRY_INVALID_MSG;
}
} else {
@@ -6787,9 +7000,6 @@ static void doUpdateExprColumnIndex(SQueryAttr *pQueryAttr) {
assert(f < pQueryAttr->numOfCols);
} else if (pColIndex->colId <= TSDB_UD_COLUMN_INDEX) {
// do nothing for user-defined constant value result columns
- } else if (pColIndex->colId == TSDB_BLOCK_DIST_COLUMN_INDEX) {
- pColIndex->colIndex = 0;// only one source column, so it must be 0;
- assert(pQueryAttr->numOfOutput == 1);
} else {
int32_t f = 0;
for (f = 0; f < pQueryAttr->numOfTags; ++f) {
@@ -6799,7 +7009,7 @@ static void doUpdateExprColumnIndex(SQueryAttr *pQueryAttr) {
}
}
- assert(f < pQueryAttr->numOfTags || pColIndex->colId == TSDB_TBNAME_COLUMN_INDEX || pColIndex->colId == TSDB_BLOCK_DIST_COLUMN_INDEX);
+ assert(f < pQueryAttr->numOfTags || pColIndex->colId == TSDB_TBNAME_COLUMN_INDEX);
}
}
}
@@ -6880,6 +7090,7 @@ SQInfo* createQInfoImpl(SQueryTableMsg* pQueryMsg, SGroupbyExpr* pGroupbyExpr, S
pQueryAttr->simpleAgg = pQueryMsg->simpleAgg;
pQueryAttr->pointInterpQuery = pQueryMsg->pointInterpQuery;
pQueryAttr->needReverseScan = pQueryMsg->needReverseScan;
+ pQueryAttr->stateWindow = pQueryMsg->stateWindow;
pQueryAttr->vgId = vgId;
pQueryAttr->tableCols = calloc(numOfCols, sizeof(SSingleColumnFilterInfo));
@@ -6991,7 +7202,7 @@ SQInfo* createQInfoImpl(SQueryTableMsg* pQueryMsg, SGroupbyExpr* pGroupbyExpr, S
colIdCheck(pQueryAttr, pQInfo->qId);
// todo refactor
- pQInfo->query.queryBlockDist = (numOfOutput == 1 && pExprs[0].base.colInfo.colId == TSDB_BLOCK_DIST_COLUMN_INDEX);
+ pQInfo->query.queryBlockDist = (numOfOutput == 1 && pExprs[0].base.functionId == TSDB_FUNC_BLKINFO);
qDebug("qmsg:%p QInfo:0x%" PRIx64 "-%p created", pQueryMsg, pQInfo->qId, pQInfo);
return pQInfo;
diff --git a/src/query/src/qPlan.c b/src/query/src/qPlan.c
index 9079d830c9..24531c7f4e 100644
--- a/src/query/src/qPlan.c
+++ b/src/query/src/qPlan.c
@@ -1,5 +1,5 @@
#include "os.h"
-#include "tschemautil.h"
+#include "qTableMeta.h"
#include "qPlan.h"
#include "qExecutor.h"
#include "qUtil.h"
@@ -592,6 +592,14 @@ SArray* createExecOperatorPlan(SQueryAttr* pQueryAttr) {
op = OP_SessionWindow;
taosArrayPush(plan, &op);
+ if (pQueryAttr->pExpr2 != NULL) {
+ op = OP_Arithmetic;
+ taosArrayPush(plan, &op);
+ }
+ } else if (pQueryAttr->stateWindow) {
+ op = OP_StateWindow;
+ taosArrayPush(plan, &op);
+
if (pQueryAttr->pExpr2 != NULL) {
op = OP_Arithmetic;
taosArrayPush(plan, &op);
diff --git a/src/query/src/qSqlParser.c b/src/query/src/qSqlParser.c
index 4a18a1f4a4..efe35ba72b 100644
--- a/src/query/src/qSqlParser.c
+++ b/src/query/src/qSqlParser.c
@@ -726,9 +726,9 @@ void tSetColumnType(TAOS_FIELD *pField, SStrToken *type) {
* extract the select info out of sql string
*/
SSqlNode *tSetQuerySqlNode(SStrToken *pSelectToken, SArray *pSelNodeList, SRelationInfo *pFrom, tSqlExpr *pWhere,
- SArray *pGroupby, SArray *pSortOrder, SIntervalVal *pInterval, SSessionWindowVal *pSession,
- SStrToken *pSliding, SArray *pFill, SLimitVal *pLimit, SLimitVal *psLimit,
- tSqlExpr *pHaving) {
+ SArray *pGroupby, SArray *pSortOrder, SIntervalVal *pInterval,
+ SSessionWindowVal *pSession, SWindowStateVal *pWindowStateVal, SStrToken *pSliding, SArray *pFill, SLimitVal *pLimit,
+ SLimitVal *psLimit, tSqlExpr *pHaving) {
assert(pSelNodeList != NULL);
SSqlNode *pSqlNode = calloc(1, sizeof(SSqlNode));
@@ -779,6 +779,12 @@ SSqlNode *tSetQuerySqlNode(SStrToken *pSelectToken, SArray *pSelNodeList, SRelat
TPARSER_SET_NONE_TOKEN(pSqlNode->sessionVal.col);
}
+ if (pWindowStateVal != NULL) {
+ pSqlNode->windowstateVal = *pWindowStateVal;
+ } else {
+ TPARSER_SET_NONE_TOKEN(pSqlNode->windowstateVal.col);
+ }
+
return pSqlNode;
}
diff --git a/src/client/src/tscSchemaUtil.c b/src/query/src/qTableMeta.c
similarity index 57%
rename from src/client/src/tscSchemaUtil.c
rename to src/query/src/qTableMeta.c
index 114fc8ee73..d25d6b7004 100644
--- a/src/client/src/tscSchemaUtil.c
+++ b/src/query/src/qTableMeta.c
@@ -1,47 +1,32 @@
-/*
- * Copyright (c) 2019 TAOS Data, Inc.
- *
- * This program is free software: you can use, redistribute, and/or modify
- * it under the terms of the GNU Affero General Public License, version 3
- * or later ("AGPL"), as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
#include "os.h"
#include "taosmsg.h"
-#include "tschemautil.h"
+#include "qTableMeta.h"
#include "ttokendef.h"
#include "taosdef.h"
#include "tutil.h"
-#include "tsclient.h"
int32_t tscGetNumOfTags(const STableMeta* pTableMeta) {
assert(pTableMeta != NULL);
-
+
STableComInfo tinfo = tscGetTableInfo(pTableMeta);
-
+
if (pTableMeta->tableType == TSDB_NORMAL_TABLE) {
assert(tinfo.numOfTags == 0);
return 0;
}
-
+
if (pTableMeta->tableType == TSDB_SUPER_TABLE || pTableMeta->tableType == TSDB_CHILD_TABLE) {
return tinfo.numOfTags;
}
-
+
assert(tinfo.numOfTags == 0);
return 0;
}
int32_t tscGetNumOfColumns(const STableMeta* pTableMeta) {
assert(pTableMeta != NULL);
-
+
// table created according to super table, use data from super table
STableComInfo tinfo = tscGetTableInfo(pTableMeta);
return tinfo.numOfColumns;
@@ -54,10 +39,10 @@ SSchema *tscGetTableSchema(const STableMeta *pTableMeta) {
SSchema* tscGetTableTagSchema(const STableMeta* pTableMeta) {
assert(pTableMeta != NULL && (pTableMeta->tableType == TSDB_SUPER_TABLE || pTableMeta->tableType == TSDB_CHILD_TABLE));
-
+
STableComInfo tinfo = tscGetTableInfo(pTableMeta);
assert(tinfo.numOfTags > 0);
-
+
return tscGetTableColumnSchema(pTableMeta, tinfo.numOfColumns);
}
@@ -68,7 +53,7 @@ STableComInfo tscGetTableInfo(const STableMeta* pTableMeta) {
SSchema* tscGetTableColumnSchema(const STableMeta* pTableMeta, int32_t colIndex) {
assert(pTableMeta != NULL);
-
+
SSchema* pSchema = (SSchema*) pTableMeta->schema;
return &pSchema[colIndex];
}
@@ -88,7 +73,7 @@ SSchema* tscGetColumnSchemaById(STableMeta* pTableMeta, int16_t colId) {
STableMeta* tscCreateTableMetaFromMsg(STableMetaMsg* pTableMetaMsg) {
assert(pTableMetaMsg != NULL && pTableMetaMsg->numOfColumns >= 2 && pTableMetaMsg->numOfTags >= 0);
-
+
int32_t schemaSize = (pTableMetaMsg->numOfColumns + pTableMetaMsg->numOfTags) * sizeof(SSchema);
STableMeta* pTableMeta = calloc(1, sizeof(STableMeta) + schemaSize);
@@ -97,11 +82,11 @@ STableMeta* tscCreateTableMetaFromMsg(STableMetaMsg* pTableMetaMsg) {
pTableMeta->suid = pTableMetaMsg->suid;
pTableMeta->tableInfo = (STableComInfo) {
- .numOfTags = pTableMetaMsg->numOfTags,
- .precision = pTableMetaMsg->precision,
- .numOfColumns = pTableMetaMsg->numOfColumns,
+ .numOfTags = pTableMetaMsg->numOfTags,
+ .precision = pTableMetaMsg->precision,
+ .numOfColumns = pTableMetaMsg->numOfColumns,
};
-
+
pTableMeta->id.tid = pTableMetaMsg->tid;
pTableMeta->id.uid = pTableMetaMsg->uid;
@@ -109,69 +94,14 @@ STableMeta* tscCreateTableMetaFromMsg(STableMetaMsg* pTableMetaMsg) {
pTableMeta->tversion = pTableMetaMsg->tversion;
tstrncpy(pTableMeta->sTableName, pTableMetaMsg->sTableName, TSDB_TABLE_FNAME_LEN);
-
+
memcpy(pTableMeta->schema, pTableMetaMsg->schema, schemaSize);
-
+
int32_t numOfTotalCols = pTableMeta->tableInfo.numOfColumns;
for(int32_t i = 0; i < numOfTotalCols; ++i) {
pTableMeta->tableInfo.rowSize += pTableMeta->schema[i].bytes;
}
-
+
return pTableMeta;
}
-bool vgroupInfoIdentical(SNewVgroupInfo *pExisted, SVgroupMsg* src) {
- assert(pExisted != NULL && src != NULL);
- if (pExisted->numOfEps != src->numOfEps) {
- return false;
- }
-
- for(int32_t i = 0; i < pExisted->numOfEps; ++i) {
- if (pExisted->ep[i].port != src->epAddr[i].port) {
- return false;
- }
-
- if (strncmp(pExisted->ep[i].fqdn, src->epAddr[i].fqdn, tListLen(pExisted->ep[i].fqdn)) != 0) {
- return false;
- }
- }
-
- return true;
-}
-
-SNewVgroupInfo createNewVgroupInfo(SVgroupMsg *pVgroupMsg) {
- assert(pVgroupMsg != NULL);
-
- SNewVgroupInfo info = {0};
- info.numOfEps = pVgroupMsg->numOfEps;
- info.vgId = pVgroupMsg->vgId;
- info.inUse = 0; // 0 is the default value of inUse in case of multiple replica
-
- assert(info.numOfEps >= 1 && info.vgId >= 1);
- for(int32_t i = 0; i < pVgroupMsg->numOfEps; ++i) {
- tstrncpy(info.ep[i].fqdn, pVgroupMsg->epAddr[i].fqdn, TSDB_FQDN_LEN);
- info.ep[i].port = pVgroupMsg->epAddr[i].port;
- }
-
- return info;
-}
-
-// todo refactor
-UNUSED_FUNC static FORCE_INLINE char* skipSegments(char* input, char delim, int32_t num) {
- for (int32_t i = 0; i < num; ++i) {
- while (*input != 0 && *input++ != delim) {
- };
- }
- return input;
-}
-
-UNUSED_FUNC static FORCE_INLINE size_t copy(char* dst, const char* src, char delimiter) {
- size_t len = 0;
- while (*src != delimiter && *src != 0) {
- *dst++ = *src++;
- len++;
- }
-
- return len;
-}
-
diff --git a/src/query/src/qUtil.c b/src/query/src/qUtil.c
index 7ff2d16962..7b08450d3b 100644
--- a/src/query/src/qUtil.c
+++ b/src/query/src/qUtil.c
@@ -581,6 +581,9 @@ void blockDistInfoToBinary(STableBlockDist* pDist, struct SBufferWriter* bw) {
tbufWriteUint32(bw, pDist->numOfTables);
tbufWriteUint16(bw, pDist->numOfFiles);
tbufWriteUint64(bw, pDist->totalSize);
+ tbufWriteUint64(bw, pDist->totalRows);
+ tbufWriteInt32(bw, pDist->maxRows);
+ tbufWriteInt32(bw, pDist->minRows);
tbufWriteUint32(bw, pDist->numOfRowsInMemTable);
tbufWriteUint64(bw, taosArrayGetSize(pDist->dataBlockInfos));
@@ -616,13 +619,16 @@ void blockDistInfoFromBinary(const char* data, int32_t len, STableBlockDist* pDi
pDist->numOfTables = tbufReadUint32(&br);
pDist->numOfFiles = tbufReadUint16(&br);
pDist->totalSize = tbufReadUint64(&br);
+ pDist->totalRows = tbufReadUint64(&br);
+ pDist->maxRows = tbufReadInt32(&br);
+ pDist->minRows = tbufReadInt32(&br);
pDist->numOfRowsInMemTable = tbufReadUint32(&br);
- int64_t numOfBlocks = tbufReadUint64(&br);
+ int64_t numSteps = tbufReadUint64(&br);
bool comp = tbufReadUint8(&br);
uint32_t compLen = tbufReadUint32(&br);
- size_t originalLen = (size_t) (numOfBlocks*sizeof(SFileBlockInfo));
+ size_t originalLen = (size_t) (numSteps *sizeof(SFileBlockInfo));
char* outputBuf = NULL;
if (comp) {
@@ -633,12 +639,12 @@ void blockDistInfoFromBinary(const char* data, int32_t len, STableBlockDist* pDi
int32_t orignalLen = tsDecompressString(compStr, compLen, 1, outputBuf,
(int32_t)originalLen , ONE_STAGE_COMP, NULL, 0);
- assert(orignalLen == numOfBlocks*sizeof(SFileBlockInfo));
+ assert(orignalLen == numSteps *sizeof(SFileBlockInfo));
} else {
outputBuf = (char*) tbufReadBinary(&br, &originalLen);
}
- pDist->dataBlockInfos = taosArrayFromList(outputBuf, (uint32_t) numOfBlocks, sizeof(SFileBlockInfo));
+ pDist->dataBlockInfos = taosArrayFromList(outputBuf, (uint32_t)numSteps, sizeof(SFileBlockInfo));
if (comp) {
tfree(outputBuf);
}
diff --git a/src/query/src/sql.c b/src/query/src/sql.c
index 9a6a0989c7..55a6833cc1 100644
--- a/src/query/src/sql.c
+++ b/src/query/src/sql.c
@@ -97,27 +97,28 @@
#endif
/************* Begin control #defines *****************************************/
#define YYCODETYPE unsigned short int
-#define YYNOCODE 265
+#define YYNOCODE 267
#define YYACTIONTYPE unsigned short int
#define ParseTOKENTYPE SStrToken
typedef union {
int yyinit;
ParseTOKENTYPE yy0;
- SCreatedTableInfo yy96;
- SRelationInfo* yy148;
- tSqlExpr* yy178;
- SCreateAcctInfo yy187;
- SArray* yy285;
- TAOS_FIELD yy295;
- SSqlNode* yy344;
- tVariant yy362;
- SIntervalVal yy376;
- SLimitVal yy438;
- int yy460;
- SCreateTableSql* yy470;
- SSessionWindowVal yy523;
- int64_t yy525;
- SCreateDbInfo yy526;
+ TAOS_FIELD yy27;
+ SWindowStateVal yy76;
+ SCreateDbInfo yy114;
+ SSqlNode* yy124;
+ SCreateAcctInfo yy183;
+ SCreatedTableInfo yy192;
+ SArray* yy193;
+ SCreateTableSql* yy270;
+ int yy312;
+ SRelationInfo* yy332;
+ SIntervalVal yy392;
+ tVariant yy442;
+ SSessionWindowVal yy447;
+ tSqlExpr* yy454;
+ int64_t yy473;
+ SLimitVal yy482;
} YYMINORTYPE;
#ifndef YYSTACKDEPTH
#define YYSTACKDEPTH 100
@@ -127,17 +128,17 @@ typedef union {
#define ParseARG_FETCH SSqlInfo* pInfo = yypParser->pInfo
#define ParseARG_STORE yypParser->pInfo = pInfo
#define YYFALLBACK 1
-#define YYNSTATE 323
-#define YYNRULE 273
-#define YYNTOKEN 187
-#define YY_MAX_SHIFT 322
-#define YY_MIN_SHIFTREDUCE 518
-#define YY_MAX_SHIFTREDUCE 790
-#define YY_ERROR_ACTION 791
-#define YY_ACCEPT_ACTION 792
-#define YY_NO_ACTION 793
-#define YY_MIN_REDUCE 794
-#define YY_MAX_REDUCE 1066
+#define YYNSTATE 327
+#define YYNRULE 275
+#define YYNTOKEN 188
+#define YY_MAX_SHIFT 326
+#define YY_MIN_SHIFTREDUCE 523
+#define YY_MAX_SHIFTREDUCE 797
+#define YY_ERROR_ACTION 798
+#define YY_ACCEPT_ACTION 799
+#define YY_NO_ACTION 800
+#define YY_MIN_REDUCE 801
+#define YY_MAX_REDUCE 1075
/************* End control #defines *******************************************/
/* Define the yytestcase() macro to be a no-op if is not already defined
@@ -203,266 +204,266 @@ typedef union {
** yy_default[] Default action for each state.
**
*********** Begin parsing tables **********************************************/
-#define YY_ACTTAB_COUNT (695)
+#define YY_ACTTAB_COUNT (700)
static const YYACTIONTYPE yy_action[] = {
- /* 0 */ 962, 566, 209, 320, 70, 18, 215, 953, 186, 567,
- /* 10 */ 792, 322, 184, 48, 49, 144, 52, 53, 218, 1048,
- /* 20 */ 221, 42, 212, 51, 270, 56, 54, 58, 55, 927,
- /* 30 */ 645, 186, 941, 47, 46, 186, 926, 45, 44, 43,
- /* 40 */ 48, 49, 1047, 52, 53, 217, 1048, 221, 42, 566,
- /* 50 */ 51, 270, 56, 54, 58, 55, 953, 567, 296, 295,
- /* 60 */ 47, 46, 959, 144, 45, 44, 43, 49, 31, 52,
- /* 70 */ 53, 248, 137, 221, 42, 83, 51, 270, 56, 54,
- /* 80 */ 58, 55, 286, 997, 88, 265, 47, 46, 72, 306,
- /* 90 */ 45, 44, 43, 519, 520, 521, 522, 523, 524, 525,
- /* 100 */ 526, 527, 528, 529, 530, 531, 321, 233, 286, 210,
- /* 110 */ 71, 566, 937, 48, 49, 31, 52, 53, 929, 567,
- /* 120 */ 221, 42, 566, 51, 270, 56, 54, 58, 55, 267,
- /* 130 */ 567, 81, 734, 47, 46, 255, 254, 45, 44, 43,
- /* 140 */ 48, 50, 939, 52, 53, 232, 190, 221, 42, 240,
- /* 150 */ 51, 270, 56, 54, 58, 55, 211, 244, 243, 938,
- /* 160 */ 47, 46, 1, 158, 45, 44, 43, 24, 284, 315,
- /* 170 */ 314, 283, 282, 281, 313, 280, 312, 311, 310, 279,
- /* 180 */ 309, 308, 901, 31, 889, 890, 891, 892, 893, 894,
- /* 190 */ 895, 896, 897, 898, 899, 900, 902, 903, 52, 53,
- /* 200 */ 715, 716, 221, 42, 230, 51, 270, 56, 54, 58,
- /* 210 */ 55, 935, 19, 1044, 234, 47, 46, 293, 292, 45,
- /* 220 */ 44, 43, 220, 749, 224, 25, 738, 938, 741, 195,
- /* 230 */ 744, 220, 749, 3, 171, 738, 196, 741, 740, 744,
- /* 240 */ 743, 121, 120, 194, 45, 44, 43, 1043, 56, 54,
- /* 250 */ 58, 55, 681, 227, 205, 206, 47, 46, 269, 8,
- /* 260 */ 45, 44, 43, 205, 206, 1042, 77, 739, 24, 742,
- /* 270 */ 315, 314, 77, 231, 37, 313, 288, 312, 311, 310,
- /* 280 */ 37, 309, 308, 909, 108, 669, 907, 908, 666, 306,
- /* 290 */ 667, 910, 668, 912, 913, 911, 85, 914, 915, 106,
- /* 300 */ 100, 111, 247, 203, 69, 31, 110, 116, 119, 109,
- /* 310 */ 202, 5, 34, 160, 226, 113, 235, 236, 159, 95,
- /* 320 */ 90, 94, 228, 31, 31, 57, 684, 924, 925, 30,
- /* 330 */ 928, 31, 750, 31, 57, 178, 176, 174, 746, 144,
- /* 340 */ 941, 750, 173, 124, 123, 122, 225, 746, 941, 938,
- /* 350 */ 747, 47, 46, 204, 745, 45, 44, 43, 319, 318,
- /* 360 */ 129, 316, 144, 745, 289, 290, 271, 938, 938, 135,
- /* 370 */ 133, 132, 294, 953, 298, 938, 13, 938, 188, 748,
- /* 380 */ 87, 840, 84, 736, 74, 170, 849, 941, 213, 841,
- /* 390 */ 170, 249, 251, 170, 670, 32, 700, 75, 219, 706,
- /* 400 */ 139, 189, 707, 61, 688, 251, 21, 996, 770, 62,
- /* 410 */ 751, 191, 20, 655, 20, 65, 273, 32, 657, 737,
- /* 420 */ 32, 275, 61, 1058, 656, 86, 29, 185, 61, 276,
- /* 430 */ 82, 63, 940, 99, 98, 66, 15, 14, 192, 105,
- /* 440 */ 104, 68, 6, 644, 118, 117, 193, 17, 16, 673,
- /* 450 */ 199, 674, 200, 671, 198, 672, 183, 197, 187, 1007,
- /* 460 */ 245, 1006, 753, 222, 40, 1003, 1002, 223, 297, 136,
- /* 470 */ 989, 961, 972, 969, 988, 970, 954, 252, 974, 138,
- /* 480 */ 936, 142, 154, 134, 256, 214, 905, 155, 699, 150,
- /* 490 */ 934, 258, 145, 156, 260, 157, 148, 146, 951, 147,
- /* 500 */ 59, 852, 67, 278, 263, 38, 181, 64, 35, 268,
- /* 510 */ 266, 287, 848, 264, 1063, 96, 1062, 1060, 161, 291,
- /* 520 */ 1057, 102, 1056, 1054, 162, 870, 36, 33, 149, 262,
- /* 530 */ 39, 182, 837, 112, 835, 114, 115, 833, 832, 237,
- /* 540 */ 172, 830, 257, 829, 828, 827, 826, 825, 175, 177,
- /* 550 */ 822, 820, 818, 816, 179, 813, 180, 41, 250, 73,
- /* 560 */ 307, 78, 259, 107, 990, 299, 300, 301, 302, 303,
- /* 570 */ 304, 207, 305, 229, 317, 277, 790, 238, 239, 789,
- /* 580 */ 208, 201, 91, 92, 241, 242, 788, 776, 775, 246,
- /* 590 */ 831, 251, 272, 125, 126, 824, 165, 164, 871, 168,
- /* 600 */ 163, 166, 167, 169, 127, 823, 2, 128, 815, 814,
- /* 610 */ 9, 26, 4, 676, 76, 701, 216, 151, 152, 153,
- /* 620 */ 253, 79, 917, 140, 10, 704, 141, 80, 261, 754,
- /* 630 */ 708, 143, 11, 89, 752, 27, 7, 28, 12, 22,
- /* 640 */ 274, 23, 608, 604, 87, 602, 601, 600, 597, 570,
- /* 650 */ 285, 93, 97, 32, 647, 60, 646, 643, 592, 590,
- /* 660 */ 101, 103, 582, 588, 584, 586, 580, 578, 611, 610,
- /* 670 */ 609, 607, 606, 605, 603, 599, 598, 61, 568, 535,
- /* 680 */ 533, 794, 793, 793, 793, 793, 793, 793, 793, 793,
- /* 690 */ 793, 793, 793, 130, 131,
+ /* 0 */ 969, 571, 211, 324, 934, 18, 217, 186, 188, 572,
+ /* 10 */ 799, 326, 192, 48, 49, 145, 52, 53, 220, 1057,
+ /* 20 */ 223, 42, 275, 51, 274, 56, 54, 58, 55, 1053,
+ /* 30 */ 650, 188, 948, 47, 46, 188, 228, 45, 44, 43,
+ /* 40 */ 48, 49, 1056, 52, 53, 219, 1057, 223, 42, 571,
+ /* 50 */ 51, 274, 56, 54, 58, 55, 960, 572, 300, 299,
+ /* 60 */ 47, 46, 948, 966, 45, 44, 43, 49, 31, 52,
+ /* 70 */ 53, 138, 250, 223, 42, 1067, 51, 274, 56, 54,
+ /* 80 */ 58, 55, 271, 290, 82, 1052, 47, 46, 89, 234,
+ /* 90 */ 45, 44, 43, 524, 525, 526, 527, 528, 529, 530,
+ /* 100 */ 531, 532, 533, 534, 535, 536, 325, 571, 290, 212,
+ /* 110 */ 71, 571, 944, 48, 49, 572, 52, 53, 760, 572,
+ /* 120 */ 223, 42, 936, 51, 274, 56, 54, 58, 55, 45,
+ /* 130 */ 44, 43, 741, 47, 46, 257, 256, 45, 44, 43,
+ /* 140 */ 48, 50, 145, 52, 53, 1, 160, 223, 42, 145,
+ /* 150 */ 51, 274, 56, 54, 58, 55, 323, 322, 130, 236,
+ /* 160 */ 47, 46, 297, 296, 45, 44, 43, 24, 288, 319,
+ /* 170 */ 318, 287, 286, 285, 317, 284, 316, 315, 314, 283,
+ /* 180 */ 313, 312, 908, 31, 896, 897, 898, 899, 900, 901,
+ /* 190 */ 902, 903, 904, 905, 906, 907, 909, 910, 52, 53,
+ /* 200 */ 847, 960, 223, 42, 172, 51, 274, 56, 54, 58,
+ /* 210 */ 55, 1005, 19, 86, 25, 47, 46, 214, 83, 45,
+ /* 220 */ 44, 43, 222, 756, 213, 310, 745, 945, 748, 197,
+ /* 230 */ 751, 222, 756, 230, 13, 745, 198, 748, 88, 751,
+ /* 240 */ 85, 122, 121, 196, 931, 932, 30, 935, 56, 54,
+ /* 250 */ 58, 55, 3, 173, 207, 208, 47, 46, 273, 948,
+ /* 260 */ 45, 44, 43, 207, 208, 242, 232, 747, 24, 750,
+ /* 270 */ 319, 318, 77, 246, 245, 317, 689, 316, 315, 314,
+ /* 280 */ 37, 313, 312, 62, 916, 47, 46, 914, 915, 45,
+ /* 290 */ 44, 43, 917, 942, 919, 920, 918, 145, 921, 922,
+ /* 300 */ 107, 101, 112, 249, 31, 69, 63, 111, 117, 120,
+ /* 310 */ 110, 204, 674, 109, 235, 671, 114, 672, 310, 673,
+ /* 320 */ 5, 34, 162, 1051, 70, 57, 31, 161, 96, 91,
+ /* 330 */ 95, 31, 757, 31, 57, 229, 233, 31, 753, 292,
+ /* 340 */ 746, 757, 749, 237, 238, 226, 31, 753, 945, 946,
+ /* 350 */ 180, 178, 176, 205, 693, 752, 933, 175, 125, 124,
+ /* 360 */ 123, 136, 134, 133, 752, 77, 1006, 227, 269, 320,
+ /* 370 */ 945, 84, 293, 37, 294, 945, 856, 945, 298, 754,
+ /* 380 */ 172, 945, 848, 960, 686, 72, 172, 302, 722, 723,
+ /* 390 */ 945, 8, 251, 743, 74, 948, 32, 75, 221, 215,
+ /* 400 */ 705, 206, 253, 713, 140, 253, 714, 61, 777, 758,
+ /* 410 */ 21, 65, 20, 20, 660, 678, 277, 679, 32, 662,
+ /* 420 */ 32, 675, 279, 61, 661, 190, 87, 29, 61, 744,
+ /* 430 */ 280, 191, 66, 100, 99, 15, 14, 119, 118, 106,
+ /* 440 */ 105, 68, 6, 649, 17, 16, 676, 193, 677, 187,
+ /* 450 */ 194, 195, 755, 201, 202, 200, 185, 199, 189, 947,
+ /* 460 */ 1016, 1015, 224, 1012, 1011, 247, 137, 40, 225, 301,
+ /* 470 */ 968, 979, 976, 977, 981, 139, 143, 961, 254, 998,
+ /* 480 */ 997, 943, 263, 156, 135, 157, 704, 258, 311, 941,
+ /* 490 */ 912, 306, 108, 303, 155, 150, 148, 958, 158, 159,
+ /* 500 */ 859, 67, 146, 216, 282, 38, 260, 183, 35, 267,
+ /* 510 */ 291, 64, 855, 1072, 97, 59, 1071, 1069, 163, 295,
+ /* 520 */ 1066, 103, 1065, 1063, 164, 877, 36, 272, 33, 270,
+ /* 530 */ 268, 39, 184, 844, 113, 842, 115, 116, 840, 839,
+ /* 540 */ 239, 174, 837, 836, 835, 834, 833, 832, 177, 179,
+ /* 550 */ 829, 827, 825, 266, 823, 181, 820, 182, 264, 252,
+ /* 560 */ 73, 78, 262, 261, 999, 259, 41, 304, 305, 307,
+ /* 570 */ 209, 231, 308, 309, 281, 321, 797, 240, 241, 210,
+ /* 580 */ 796, 92, 93, 203, 244, 243, 795, 783, 782, 838,
+ /* 590 */ 248, 253, 681, 276, 126, 171, 166, 878, 167, 165,
+ /* 600 */ 168, 169, 831, 170, 9, 127, 128, 830, 76, 129,
+ /* 610 */ 822, 821, 2, 26, 4, 255, 79, 706, 153, 151,
+ /* 620 */ 149, 147, 152, 154, 141, 924, 709, 142, 80, 218,
+ /* 630 */ 711, 81, 265, 761, 715, 144, 90, 10, 11, 27,
+ /* 640 */ 759, 28, 7, 12, 22, 88, 23, 613, 278, 609,
+ /* 650 */ 607, 606, 605, 602, 575, 289, 94, 32, 60, 98,
+ /* 660 */ 652, 651, 648, 102, 597, 595, 104, 587, 593, 589,
+ /* 670 */ 591, 585, 583, 616, 615, 614, 612, 611, 610, 608,
+ /* 680 */ 604, 603, 573, 540, 538, 61, 801, 800, 800, 800,
+ /* 690 */ 800, 800, 800, 800, 800, 800, 800, 800, 131, 132,
};
static const YYCODETYPE yy_lookahead[] = {
- /* 0 */ 191, 1, 190, 191, 197, 252, 210, 234, 252, 9,
- /* 10 */ 188, 189, 252, 13, 14, 191, 16, 17, 262, 263,
- /* 20 */ 20, 21, 249, 23, 24, 25, 26, 27, 28, 0,
- /* 30 */ 5, 252, 236, 33, 34, 252, 229, 37, 38, 39,
- /* 40 */ 13, 14, 263, 16, 17, 262, 263, 20, 21, 1,
- /* 50 */ 23, 24, 25, 26, 27, 28, 234, 9, 33, 34,
- /* 60 */ 33, 34, 253, 191, 37, 38, 39, 14, 191, 16,
- /* 70 */ 17, 249, 191, 20, 21, 237, 23, 24, 25, 26,
- /* 80 */ 27, 28, 79, 259, 197, 261, 33, 34, 250, 81,
+ /* 0 */ 192, 1, 191, 192, 0, 254, 211, 254, 254, 9,
+ /* 10 */ 189, 190, 254, 13, 14, 192, 16, 17, 264, 265,
+ /* 20 */ 20, 21, 15, 23, 24, 25, 26, 27, 28, 254,
+ /* 30 */ 5, 254, 237, 33, 34, 254, 211, 37, 38, 39,
+ /* 40 */ 13, 14, 265, 16, 17, 264, 265, 20, 21, 1,
+ /* 50 */ 23, 24, 25, 26, 27, 28, 235, 9, 33, 34,
+ /* 60 */ 33, 34, 237, 255, 37, 38, 39, 14, 192, 16,
+ /* 70 */ 17, 192, 251, 20, 21, 237, 23, 24, 25, 26,
+ /* 80 */ 27, 28, 259, 79, 261, 254, 33, 34, 198, 68,
/* 90 */ 37, 38, 39, 45, 46, 47, 48, 49, 50, 51,
- /* 100 */ 52, 53, 54, 55, 56, 57, 58, 191, 79, 61,
- /* 110 */ 110, 1, 235, 13, 14, 191, 16, 17, 231, 9,
- /* 120 */ 20, 21, 1, 23, 24, 25, 26, 27, 28, 257,
- /* 130 */ 9, 259, 105, 33, 34, 254, 255, 37, 38, 39,
- /* 140 */ 13, 14, 226, 16, 17, 68, 252, 20, 21, 135,
- /* 150 */ 23, 24, 25, 26, 27, 28, 232, 143, 144, 235,
- /* 160 */ 33, 34, 198, 199, 37, 38, 39, 88, 89, 90,
+ /* 100 */ 52, 53, 54, 55, 56, 57, 58, 1, 79, 61,
+ /* 110 */ 110, 1, 236, 13, 14, 9, 16, 17, 111, 9,
+ /* 120 */ 20, 21, 232, 23, 24, 25, 26, 27, 28, 37,
+ /* 130 */ 38, 39, 105, 33, 34, 256, 257, 37, 38, 39,
+ /* 140 */ 13, 14, 192, 16, 17, 199, 200, 20, 21, 192,
+ /* 150 */ 23, 24, 25, 26, 27, 28, 65, 66, 67, 138,
+ /* 160 */ 33, 34, 141, 142, 37, 38, 39, 88, 89, 90,
/* 170 */ 91, 92, 93, 94, 95, 96, 97, 98, 99, 100,
- /* 180 */ 101, 102, 209, 191, 211, 212, 213, 214, 215, 216,
- /* 190 */ 217, 218, 219, 220, 221, 222, 223, 224, 16, 17,
- /* 200 */ 124, 125, 20, 21, 68, 23, 24, 25, 26, 27,
- /* 210 */ 28, 191, 44, 252, 137, 33, 34, 140, 141, 37,
- /* 220 */ 38, 39, 1, 2, 232, 104, 5, 235, 7, 61,
- /* 230 */ 9, 1, 2, 194, 195, 5, 68, 7, 5, 9,
- /* 240 */ 7, 73, 74, 75, 37, 38, 39, 252, 25, 26,
- /* 250 */ 27, 28, 109, 233, 33, 34, 33, 34, 37, 116,
- /* 260 */ 37, 38, 39, 33, 34, 252, 104, 5, 88, 7,
- /* 270 */ 90, 91, 104, 137, 112, 95, 140, 97, 98, 99,
- /* 280 */ 112, 101, 102, 209, 76, 2, 212, 213, 5, 81,
- /* 290 */ 7, 217, 9, 219, 220, 221, 197, 223, 224, 62,
- /* 300 */ 63, 64, 134, 252, 136, 191, 69, 70, 71, 72,
- /* 310 */ 142, 62, 63, 64, 210, 78, 33, 34, 69, 70,
- /* 320 */ 71, 72, 210, 191, 191, 104, 37, 228, 229, 230,
- /* 330 */ 231, 191, 111, 191, 104, 62, 63, 64, 117, 191,
- /* 340 */ 236, 111, 69, 70, 71, 72, 232, 117, 236, 235,
- /* 350 */ 117, 33, 34, 252, 133, 37, 38, 39, 65, 66,
- /* 360 */ 67, 210, 191, 133, 232, 232, 15, 235, 235, 62,
- /* 370 */ 63, 64, 232, 234, 232, 235, 104, 235, 252, 117,
- /* 380 */ 108, 196, 110, 1, 105, 200, 196, 236, 249, 196,
- /* 390 */ 200, 105, 113, 200, 111, 109, 105, 105, 60, 105,
- /* 400 */ 109, 252, 105, 109, 115, 113, 109, 259, 105, 109,
- /* 410 */ 105, 252, 109, 105, 109, 109, 105, 109, 105, 37,
- /* 420 */ 109, 105, 109, 236, 105, 109, 104, 252, 109, 107,
- /* 430 */ 259, 131, 236, 138, 139, 129, 138, 139, 252, 138,
- /* 440 */ 139, 104, 104, 106, 76, 77, 252, 138, 139, 5,
- /* 450 */ 252, 7, 252, 5, 252, 7, 252, 252, 252, 227,
- /* 460 */ 191, 227, 111, 227, 251, 227, 227, 227, 227, 191,
- /* 470 */ 260, 191, 191, 191, 260, 191, 234, 234, 191, 191,
- /* 480 */ 234, 191, 238, 60, 256, 256, 225, 191, 117, 242,
- /* 490 */ 191, 256, 247, 191, 119, 191, 244, 246, 248, 245,
- /* 500 */ 127, 191, 128, 191, 256, 191, 191, 130, 191, 122,
- /* 510 */ 126, 191, 191, 121, 191, 191, 191, 191, 191, 191,
- /* 520 */ 191, 191, 191, 191, 191, 191, 191, 191, 243, 120,
- /* 530 */ 191, 191, 191, 191, 191, 191, 191, 191, 191, 191,
- /* 540 */ 191, 191, 118, 191, 191, 191, 191, 191, 191, 191,
- /* 550 */ 191, 191, 191, 191, 191, 191, 191, 132, 192, 192,
- /* 560 */ 103, 192, 192, 87, 192, 86, 50, 83, 85, 54,
- /* 570 */ 84, 192, 82, 192, 79, 192, 5, 145, 5, 5,
- /* 580 */ 192, 192, 197, 197, 145, 5, 5, 90, 89, 135,
- /* 590 */ 192, 113, 107, 193, 193, 192, 202, 206, 208, 204,
- /* 600 */ 207, 205, 203, 201, 193, 192, 198, 193, 192, 192,
- /* 610 */ 104, 104, 194, 105, 114, 105, 1, 241, 240, 239,
- /* 620 */ 109, 109, 225, 104, 123, 105, 109, 104, 104, 111,
- /* 630 */ 105, 104, 123, 76, 105, 109, 104, 109, 104, 104,
- /* 640 */ 107, 104, 9, 5, 108, 5, 5, 5, 5, 80,
- /* 650 */ 15, 76, 139, 109, 5, 16, 5, 105, 5, 5,
- /* 660 */ 139, 139, 5, 5, 5, 5, 5, 5, 5, 5,
- /* 670 */ 5, 5, 5, 5, 5, 5, 5, 109, 80, 60,
- /* 680 */ 59, 0, 264, 264, 264, 264, 264, 264, 264, 264,
- /* 690 */ 264, 264, 264, 21, 21, 264, 264, 264, 264, 264,
- /* 700 */ 264, 264, 264, 264, 264, 264, 264, 264, 264, 264,
- /* 710 */ 264, 264, 264, 264, 264, 264, 264, 264, 264, 264,
- /* 720 */ 264, 264, 264, 264, 264, 264, 264, 264, 264, 264,
- /* 730 */ 264, 264, 264, 264, 264, 264, 264, 264, 264, 264,
- /* 740 */ 264, 264, 264, 264, 264, 264, 264, 264, 264, 264,
- /* 750 */ 264, 264, 264, 264, 264, 264, 264, 264, 264, 264,
- /* 760 */ 264, 264, 264, 264, 264, 264, 264, 264, 264, 264,
- /* 770 */ 264, 264, 264, 264, 264, 264, 264, 264, 264, 264,
- /* 780 */ 264, 264, 264, 264, 264, 264, 264, 264, 264, 264,
- /* 790 */ 264, 264, 264, 264, 264, 264, 264, 264, 264, 264,
- /* 800 */ 264, 264, 264, 264, 264, 264, 264, 264, 264, 264,
- /* 810 */ 264, 264, 264, 264, 264, 264, 264, 264, 264, 264,
- /* 820 */ 264, 264, 264, 264, 264, 264, 264, 264, 264, 264,
- /* 830 */ 264, 264, 264, 264, 264, 264, 264, 264, 264, 264,
- /* 840 */ 264, 264, 264, 264, 264, 264, 264, 264, 264, 264,
- /* 850 */ 264, 264, 264, 264, 264, 264, 264, 264, 264, 264,
- /* 860 */ 264, 264, 264, 264, 264, 264, 264, 264, 264, 264,
- /* 870 */ 264, 264, 264, 264, 264, 264, 264, 264, 264, 264,
- /* 880 */ 264, 264,
+ /* 180 */ 101, 102, 210, 192, 212, 213, 214, 215, 216, 217,
+ /* 190 */ 218, 219, 220, 221, 222, 223, 224, 225, 16, 17,
+ /* 200 */ 197, 235, 20, 21, 201, 23, 24, 25, 26, 27,
+ /* 210 */ 28, 261, 44, 198, 104, 33, 34, 251, 261, 37,
+ /* 220 */ 38, 39, 1, 2, 233, 81, 5, 236, 7, 61,
+ /* 230 */ 9, 1, 2, 211, 104, 5, 68, 7, 108, 9,
+ /* 240 */ 110, 73, 74, 75, 229, 230, 231, 232, 25, 26,
+ /* 250 */ 27, 28, 195, 196, 33, 34, 33, 34, 37, 237,
+ /* 260 */ 37, 38, 39, 33, 34, 136, 68, 5, 88, 7,
+ /* 270 */ 90, 91, 104, 144, 145, 95, 37, 97, 98, 99,
+ /* 280 */ 112, 101, 102, 109, 210, 33, 34, 213, 214, 37,
+ /* 290 */ 38, 39, 218, 192, 220, 221, 222, 192, 224, 225,
+ /* 300 */ 62, 63, 64, 135, 192, 137, 132, 69, 70, 71,
+ /* 310 */ 72, 143, 2, 76, 192, 5, 78, 7, 81, 9,
+ /* 320 */ 62, 63, 64, 254, 198, 104, 192, 69, 70, 71,
+ /* 330 */ 72, 192, 111, 192, 104, 234, 138, 192, 117, 141,
+ /* 340 */ 5, 111, 7, 33, 34, 233, 192, 117, 236, 227,
+ /* 350 */ 62, 63, 64, 254, 115, 134, 230, 69, 70, 71,
+ /* 360 */ 72, 62, 63, 64, 134, 104, 261, 233, 263, 211,
+ /* 370 */ 236, 238, 233, 112, 233, 236, 197, 236, 233, 117,
+ /* 380 */ 201, 236, 197, 235, 109, 252, 201, 233, 125, 126,
+ /* 390 */ 236, 116, 105, 1, 105, 237, 109, 105, 60, 251,
+ /* 400 */ 105, 254, 113, 105, 109, 113, 105, 109, 105, 105,
+ /* 410 */ 109, 109, 109, 109, 105, 5, 105, 7, 109, 105,
+ /* 420 */ 109, 111, 105, 109, 105, 254, 109, 104, 109, 37,
+ /* 430 */ 107, 254, 130, 139, 140, 139, 140, 76, 77, 139,
+ /* 440 */ 140, 104, 104, 106, 139, 140, 5, 254, 7, 254,
+ /* 450 */ 254, 254, 117, 254, 254, 254, 254, 254, 254, 237,
+ /* 460 */ 228, 228, 228, 228, 228, 192, 192, 253, 228, 228,
+ /* 470 */ 192, 192, 192, 192, 192, 192, 192, 235, 235, 262,
+ /* 480 */ 262, 235, 192, 239, 60, 192, 117, 258, 103, 192,
+ /* 490 */ 226, 85, 87, 86, 240, 245, 247, 250, 192, 192,
+ /* 500 */ 192, 129, 249, 258, 192, 192, 258, 192, 192, 258,
+ /* 510 */ 192, 131, 192, 192, 192, 128, 192, 192, 192, 192,
+ /* 520 */ 192, 192, 192, 192, 192, 192, 192, 123, 192, 127,
+ /* 530 */ 122, 192, 192, 192, 192, 192, 192, 192, 192, 192,
+ /* 540 */ 192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
+ /* 550 */ 192, 192, 192, 121, 192, 192, 192, 192, 120, 193,
+ /* 560 */ 193, 193, 119, 193, 193, 118, 133, 50, 83, 54,
+ /* 570 */ 193, 193, 84, 82, 193, 79, 5, 146, 5, 193,
+ /* 580 */ 5, 198, 198, 193, 5, 146, 5, 90, 89, 193,
+ /* 590 */ 136, 113, 105, 107, 194, 202, 207, 209, 203, 208,
+ /* 600 */ 206, 204, 193, 205, 104, 194, 194, 193, 114, 194,
+ /* 610 */ 193, 193, 199, 104, 195, 109, 109, 105, 242, 244,
+ /* 620 */ 246, 248, 243, 241, 104, 226, 105, 109, 104, 1,
+ /* 630 */ 105, 104, 104, 111, 105, 104, 76, 124, 124, 109,
+ /* 640 */ 105, 109, 104, 104, 104, 108, 104, 9, 107, 5,
+ /* 650 */ 5, 5, 5, 5, 80, 15, 76, 109, 16, 140,
+ /* 660 */ 5, 5, 105, 140, 5, 5, 140, 5, 5, 5,
+ /* 670 */ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
+ /* 680 */ 5, 5, 80, 60, 59, 109, 0, 266, 266, 266,
+ /* 690 */ 266, 266, 266, 266, 266, 266, 266, 266, 21, 21,
+ /* 700 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266,
+ /* 710 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266,
+ /* 720 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266,
+ /* 730 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266,
+ /* 740 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266,
+ /* 750 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266,
+ /* 760 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266,
+ /* 770 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266,
+ /* 780 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266,
+ /* 790 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266,
+ /* 800 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266,
+ /* 810 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266,
+ /* 820 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266,
+ /* 830 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266,
+ /* 840 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266,
+ /* 850 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266,
+ /* 860 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266,
+ /* 870 */ 266, 266, 266, 266, 266, 266, 266, 266, 266, 266,
+ /* 880 */ 266, 266, 266, 266, 266, 266, 266, 266,
};
-#define YY_SHIFT_COUNT (322)
+#define YY_SHIFT_COUNT (326)
#define YY_SHIFT_MIN (0)
-#define YY_SHIFT_MAX (681)
+#define YY_SHIFT_MAX (686)
static const unsigned short int yy_shift_ofst[] = {
- /* 0 */ 168, 79, 79, 180, 180, 3, 221, 230, 121, 110,
- /* 10 */ 110, 110, 110, 110, 110, 110, 110, 110, 0, 48,
- /* 20 */ 230, 283, 283, 283, 283, 162, 162, 110, 110, 110,
- /* 30 */ 29, 110, 110, 208, 3, 8, 8, 695, 695, 695,
+ /* 0 */ 168, 79, 79, 180, 180, 29, 221, 230, 110, 106,
+ /* 10 */ 106, 106, 106, 106, 106, 106, 106, 106, 0, 48,
+ /* 20 */ 230, 310, 310, 310, 310, 261, 261, 106, 106, 106,
+ /* 30 */ 4, 106, 106, 237, 29, 144, 144, 700, 700, 700,
/* 40 */ 230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
/* 50 */ 230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
- /* 60 */ 283, 283, 25, 25, 25, 25, 25, 25, 25, 110,
- /* 70 */ 110, 110, 289, 110, 110, 110, 162, 162, 110, 110,
- /* 80 */ 110, 76, 76, 143, 162, 110, 110, 110, 110, 110,
- /* 90 */ 110, 110, 110, 110, 110, 110, 110, 110, 110, 110,
- /* 100 */ 110, 110, 110, 110, 110, 110, 110, 110, 110, 110,
- /* 110 */ 110, 110, 110, 110, 110, 110, 110, 110, 110, 110,
- /* 120 */ 110, 110, 110, 110, 110, 110, 110, 110, 110, 110,
- /* 130 */ 110, 110, 110, 110, 110, 110, 423, 423, 423, 371,
- /* 140 */ 371, 371, 423, 371, 423, 374, 377, 373, 387, 384,
- /* 150 */ 392, 409, 375, 424, 425, 423, 423, 423, 457, 3,
- /* 160 */ 3, 423, 423, 476, 479, 516, 484, 483, 515, 486,
- /* 170 */ 490, 457, 423, 495, 495, 423, 495, 423, 495, 423,
- /* 180 */ 423, 695, 695, 27, 100, 127, 100, 100, 53, 182,
- /* 190 */ 223, 223, 223, 223, 237, 249, 273, 318, 318, 318,
- /* 200 */ 318, 77, 14, 207, 207, 233, 262, 272, 136, 293,
- /* 210 */ 307, 286, 279, 292, 291, 294, 297, 303, 305, 382,
- /* 220 */ 338, 351, 300, 306, 308, 311, 313, 316, 319, 322,
- /* 230 */ 295, 298, 301, 337, 309, 444, 448, 368, 571, 432,
- /* 240 */ 573, 574, 439, 580, 581, 497, 499, 454, 478, 485,
- /* 250 */ 506, 500, 508, 507, 511, 512, 510, 519, 520, 517,
- /* 260 */ 523, 615, 524, 525, 527, 526, 501, 528, 509, 529,
- /* 270 */ 532, 518, 534, 485, 535, 533, 537, 536, 557, 633,
- /* 280 */ 638, 640, 641, 642, 643, 569, 635, 575, 513, 544,
- /* 290 */ 544, 639, 521, 522, 544, 649, 651, 552, 544, 653,
- /* 300 */ 654, 657, 658, 659, 660, 661, 662, 663, 664, 665,
- /* 310 */ 666, 667, 668, 669, 670, 671, 568, 598, 672, 673,
- /* 320 */ 619, 621, 681,
+ /* 60 */ 310, 310, 25, 25, 25, 25, 25, 25, 25, 106,
+ /* 70 */ 106, 106, 239, 106, 106, 106, 261, 261, 106, 106,
+ /* 80 */ 106, 106, 263, 263, 275, 261, 106, 106, 106, 106,
+ /* 90 */ 106, 106, 106, 106, 106, 106, 106, 106, 106, 106,
+ /* 100 */ 106, 106, 106, 106, 106, 106, 106, 106, 106, 106,
+ /* 110 */ 106, 106, 106, 106, 106, 106, 106, 106, 106, 106,
+ /* 120 */ 106, 106, 106, 106, 106, 106, 106, 106, 106, 106,
+ /* 130 */ 106, 106, 106, 106, 106, 106, 106, 424, 424, 424,
+ /* 140 */ 369, 369, 369, 424, 369, 424, 372, 380, 387, 404,
+ /* 150 */ 402, 408, 432, 438, 443, 447, 433, 424, 424, 424,
+ /* 160 */ 385, 29, 29, 424, 424, 405, 407, 517, 485, 406,
+ /* 170 */ 515, 488, 491, 385, 424, 496, 496, 424, 496, 424,
+ /* 180 */ 496, 424, 424, 700, 700, 27, 100, 127, 100, 100,
+ /* 190 */ 53, 182, 223, 223, 223, 223, 238, 258, 288, 252,
+ /* 200 */ 252, 252, 252, 21, 129, 92, 92, 262, 335, 130,
+ /* 210 */ 198, 91, 299, 287, 289, 292, 295, 298, 301, 303,
+ /* 220 */ 304, 392, 338, 7, 174, 302, 309, 311, 314, 317,
+ /* 230 */ 319, 323, 294, 296, 300, 337, 305, 410, 441, 361,
+ /* 240 */ 571, 431, 573, 575, 439, 579, 581, 497, 499, 454,
+ /* 250 */ 478, 486, 500, 494, 487, 509, 506, 507, 512, 520,
+ /* 260 */ 521, 518, 524, 525, 527, 628, 528, 529, 531, 530,
+ /* 270 */ 513, 532, 514, 535, 538, 522, 539, 486, 540, 541,
+ /* 280 */ 542, 537, 560, 638, 644, 645, 646, 647, 648, 574,
+ /* 290 */ 640, 580, 519, 548, 548, 642, 523, 526, 548, 655,
+ /* 300 */ 656, 557, 548, 659, 660, 662, 663, 664, 665, 666,
+ /* 310 */ 667, 668, 669, 670, 671, 672, 673, 674, 675, 676,
+ /* 320 */ 576, 602, 677, 678, 623, 625, 686,
};
-#define YY_REDUCE_COUNT (182)
-#define YY_REDUCE_MIN (-247)
-#define YY_REDUCE_MAX (418)
+#define YY_REDUCE_COUNT (184)
+#define YY_REDUCE_MIN (-249)
+#define YY_REDUCE_MAX (419)
static const short yy_reduce_ofst[] = {
- /* 0 */ -178, -27, -27, 74, 74, 99, -244, -217, -119, -76,
- /* 10 */ -176, -128, -8, 114, 132, 133, 140, 142, -191, -188,
- /* 20 */ -221, -204, 104, 112, 151, -227, 139, 148, 171, 20,
- /* 30 */ -113, -84, -123, 185, -193, 190, 193, -162, -36, 39,
- /* 40 */ -247, -240, -106, -39, -5, 13, 51, 101, 126, 149,
- /* 50 */ 159, 175, 186, 194, 198, 200, 202, 204, 205, 206,
- /* 60 */ 187, 196, 232, 234, 236, 238, 239, 240, 241, 269,
- /* 70 */ 278, 280, 213, 281, 282, 284, 242, 243, 287, 288,
- /* 80 */ 290, 210, 214, 244, 246, 296, 299, 302, 304, 310,
- /* 90 */ 312, 314, 315, 317, 320, 321, 323, 324, 325, 326,
- /* 100 */ 327, 328, 329, 330, 331, 332, 333, 334, 335, 336,
- /* 110 */ 339, 340, 341, 342, 343, 344, 345, 346, 347, 348,
- /* 120 */ 349, 350, 352, 353, 354, 355, 356, 357, 358, 359,
- /* 130 */ 360, 361, 362, 363, 364, 365, 366, 367, 369, 228,
- /* 140 */ 229, 235, 370, 248, 372, 250, 245, 251, 254, 252,
- /* 150 */ 285, 247, 376, 378, 380, 379, 381, 383, 261, 385,
- /* 160 */ 386, 388, 389, 390, 393, 391, 394, 396, 399, 395,
- /* 170 */ 402, 397, 398, 400, 401, 403, 411, 413, 414, 416,
- /* 180 */ 417, 408, 418,
+ /* 0 */ -179, -28, -28, 74, 74, 15, -246, -219, -121, -9,
+ /* 10 */ 105, -177, 112, 134, 139, 141, 145, 154, -192, -189,
+ /* 20 */ -223, -205, -175, 22, 158, -34, 148, -50, -43, 101,
+ /* 30 */ -110, 122, -124, 3, 126, 179, 185, 133, -54, 57,
+ /* 40 */ -249, -247, -242, -225, -169, 69, 99, 147, 171, 177,
+ /* 50 */ 193, 195, 196, 197, 199, 200, 201, 202, 203, 204,
+ /* 60 */ -162, 222, 232, 233, 234, 235, 236, 240, 241, 273,
+ /* 70 */ 274, 278, 214, 279, 280, 281, 242, 243, 282, 283,
+ /* 80 */ 284, 290, 217, 218, 244, 246, 293, 297, 306, 307,
+ /* 90 */ 308, 312, 313, 315, 316, 318, 320, 321, 322, 324,
+ /* 100 */ 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
+ /* 110 */ 336, 339, 340, 341, 342, 343, 344, 345, 346, 347,
+ /* 120 */ 348, 349, 350, 351, 352, 353, 354, 355, 356, 357,
+ /* 130 */ 358, 359, 360, 362, 363, 364, 365, 366, 367, 368,
+ /* 140 */ 229, 245, 248, 370, 251, 371, 247, 253, 373, 249,
+ /* 150 */ 374, 250, 375, 379, 376, 382, 254, 377, 378, 381,
+ /* 160 */ 264, 383, 384, 386, 390, 388, 391, 389, 395, 394,
+ /* 170 */ 397, 398, 393, 399, 396, 400, 411, 409, 412, 414,
+ /* 180 */ 415, 417, 418, 413, 419,
};
static const YYACTIONTYPE yy_default[] = {
- /* 0 */ 791, 904, 850, 916, 838, 847, 1050, 1050, 791, 791,
- /* 10 */ 791, 791, 791, 791, 791, 791, 791, 791, 963, 810,
- /* 20 */ 1050, 791, 791, 791, 791, 791, 791, 791, 791, 791,
- /* 30 */ 847, 791, 791, 853, 847, 853, 853, 958, 888, 906,
- /* 40 */ 791, 791, 791, 791, 791, 791, 791, 791, 791, 791,
- /* 50 */ 791, 791, 791, 791, 791, 791, 791, 791, 791, 791,
- /* 60 */ 791, 791, 791, 791, 791, 791, 791, 791, 791, 791,
- /* 70 */ 791, 791, 965, 971, 968, 791, 791, 791, 973, 791,
- /* 80 */ 791, 993, 993, 956, 791, 791, 791, 791, 791, 791,
- /* 90 */ 791, 791, 791, 791, 791, 791, 791, 791, 791, 791,
- /* 100 */ 791, 791, 791, 791, 791, 791, 791, 791, 791, 791,
- /* 110 */ 791, 791, 836, 791, 834, 791, 791, 791, 791, 791,
- /* 120 */ 791, 791, 791, 791, 791, 791, 791, 791, 791, 821,
- /* 130 */ 791, 791, 791, 791, 791, 791, 812, 812, 812, 791,
- /* 140 */ 791, 791, 812, 791, 812, 1000, 1004, 998, 986, 994,
- /* 150 */ 985, 981, 979, 978, 1008, 812, 812, 812, 851, 847,
- /* 160 */ 847, 812, 812, 869, 867, 865, 857, 863, 859, 861,
- /* 170 */ 855, 839, 812, 845, 845, 812, 845, 812, 845, 812,
- /* 180 */ 812, 888, 906, 791, 1009, 791, 1049, 999, 1039, 1038,
- /* 190 */ 1045, 1037, 1036, 1035, 791, 791, 791, 1031, 1032, 1034,
- /* 200 */ 1033, 791, 791, 1041, 1040, 791, 791, 791, 791, 791,
- /* 210 */ 791, 791, 791, 791, 791, 791, 791, 791, 791, 791,
- /* 220 */ 1011, 791, 1005, 1001, 791, 791, 791, 791, 791, 791,
- /* 230 */ 791, 791, 791, 918, 791, 791, 791, 791, 791, 791,
- /* 240 */ 791, 791, 791, 791, 791, 791, 791, 791, 955, 791,
- /* 250 */ 791, 791, 791, 791, 967, 966, 791, 791, 791, 791,
- /* 260 */ 791, 791, 791, 791, 791, 995, 791, 987, 791, 791,
- /* 270 */ 791, 791, 791, 930, 791, 791, 791, 791, 791, 791,
- /* 280 */ 791, 791, 791, 791, 791, 791, 791, 791, 791, 1061,
- /* 290 */ 1059, 791, 791, 791, 1055, 791, 791, 791, 1053, 791,
- /* 300 */ 791, 791, 791, 791, 791, 791, 791, 791, 791, 791,
- /* 310 */ 791, 791, 791, 791, 791, 791, 872, 791, 819, 817,
- /* 320 */ 791, 808, 791,
+ /* 0 */ 798, 911, 857, 923, 845, 854, 1059, 1059, 798, 798,
+ /* 10 */ 798, 798, 798, 798, 798, 798, 798, 798, 970, 817,
+ /* 20 */ 1059, 798, 798, 798, 798, 798, 798, 798, 798, 798,
+ /* 30 */ 854, 798, 798, 860, 854, 860, 860, 965, 895, 913,
+ /* 40 */ 798, 798, 798, 798, 798, 798, 798, 798, 798, 798,
+ /* 50 */ 798, 798, 798, 798, 798, 798, 798, 798, 798, 798,
+ /* 60 */ 798, 798, 798, 798, 798, 798, 798, 798, 798, 798,
+ /* 70 */ 798, 798, 972, 978, 975, 798, 798, 798, 980, 798,
+ /* 80 */ 798, 798, 1002, 1002, 963, 798, 798, 798, 798, 798,
+ /* 90 */ 798, 798, 798, 798, 798, 798, 798, 798, 798, 798,
+ /* 100 */ 798, 798, 798, 798, 798, 798, 798, 798, 798, 798,
+ /* 110 */ 798, 798, 798, 843, 798, 841, 798, 798, 798, 798,
+ /* 120 */ 798, 798, 798, 798, 798, 798, 798, 798, 798, 798,
+ /* 130 */ 828, 798, 798, 798, 798, 798, 798, 819, 819, 819,
+ /* 140 */ 798, 798, 798, 819, 798, 819, 1009, 1013, 1007, 995,
+ /* 150 */ 1003, 994, 990, 988, 986, 985, 1017, 819, 819, 819,
+ /* 160 */ 858, 854, 854, 819, 819, 876, 874, 872, 864, 870,
+ /* 170 */ 866, 868, 862, 846, 819, 852, 852, 819, 852, 819,
+ /* 180 */ 852, 819, 819, 895, 913, 798, 1018, 798, 1058, 1008,
+ /* 190 */ 1048, 1047, 1054, 1046, 1045, 1044, 798, 798, 798, 1040,
+ /* 200 */ 1041, 1043, 1042, 798, 798, 1050, 1049, 798, 798, 798,
+ /* 210 */ 798, 798, 798, 798, 798, 798, 798, 798, 798, 798,
+ /* 220 */ 798, 798, 1020, 798, 1014, 1010, 798, 798, 798, 798,
+ /* 230 */ 798, 798, 798, 798, 798, 925, 798, 798, 798, 798,
+ /* 240 */ 798, 798, 798, 798, 798, 798, 798, 798, 798, 798,
+ /* 250 */ 962, 798, 798, 798, 798, 798, 974, 973, 798, 798,
+ /* 260 */ 798, 798, 798, 798, 798, 798, 798, 798, 798, 1004,
+ /* 270 */ 798, 996, 798, 798, 798, 798, 798, 937, 798, 798,
+ /* 280 */ 798, 798, 798, 798, 798, 798, 798, 798, 798, 798,
+ /* 290 */ 798, 798, 798, 1070, 1068, 798, 798, 798, 1064, 798,
+ /* 300 */ 798, 798, 1062, 798, 798, 798, 798, 798, 798, 798,
+ /* 310 */ 798, 798, 798, 798, 798, 798, 798, 798, 798, 798,
+ /* 320 */ 879, 798, 826, 824, 798, 815, 798,
};
/********** End of lemon-generated parsing tables *****************************/
@@ -602,6 +603,7 @@ static const YYCODETYPE yyFallback[] = {
0, /* VARIABLE => nothing */
0, /* INTERVAL => nothing */
0, /* SESSION => nothing */
+ 0, /* STATE_WINDOW => nothing */
0, /* FILL => nothing */
0, /* SLIDING => nothing */
0, /* ORDER => nothing */
@@ -875,150 +877,152 @@ static const char *const yyTokenName[] = {
/* 117 */ "VARIABLE",
/* 118 */ "INTERVAL",
/* 119 */ "SESSION",
- /* 120 */ "FILL",
- /* 121 */ "SLIDING",
- /* 122 */ "ORDER",
- /* 123 */ "BY",
- /* 124 */ "ASC",
- /* 125 */ "DESC",
- /* 126 */ "GROUP",
- /* 127 */ "HAVING",
- /* 128 */ "LIMIT",
- /* 129 */ "OFFSET",
- /* 130 */ "SLIMIT",
- /* 131 */ "SOFFSET",
- /* 132 */ "WHERE",
- /* 133 */ "NOW",
- /* 134 */ "RESET",
- /* 135 */ "QUERY",
- /* 136 */ "SYNCDB",
- /* 137 */ "ADD",
- /* 138 */ "COLUMN",
- /* 139 */ "TAG",
- /* 140 */ "CHANGE",
- /* 141 */ "SET",
- /* 142 */ "KILL",
- /* 143 */ "CONNECTION",
- /* 144 */ "STREAM",
- /* 145 */ "COLON",
- /* 146 */ "ABORT",
- /* 147 */ "AFTER",
- /* 148 */ "ATTACH",
- /* 149 */ "BEFORE",
- /* 150 */ "BEGIN",
- /* 151 */ "CASCADE",
- /* 152 */ "CLUSTER",
- /* 153 */ "CONFLICT",
- /* 154 */ "COPY",
- /* 155 */ "DEFERRED",
- /* 156 */ "DELIMITERS",
- /* 157 */ "DETACH",
- /* 158 */ "EACH",
- /* 159 */ "END",
- /* 160 */ "EXPLAIN",
- /* 161 */ "FAIL",
- /* 162 */ "FOR",
- /* 163 */ "IGNORE",
- /* 164 */ "IMMEDIATE",
- /* 165 */ "INITIALLY",
- /* 166 */ "INSTEAD",
- /* 167 */ "MATCH",
- /* 168 */ "KEY",
- /* 169 */ "OF",
- /* 170 */ "RAISE",
- /* 171 */ "REPLACE",
- /* 172 */ "RESTRICT",
- /* 173 */ "ROW",
- /* 174 */ "STATEMENT",
- /* 175 */ "TRIGGER",
- /* 176 */ "VIEW",
- /* 177 */ "SEMI",
- /* 178 */ "NONE",
- /* 179 */ "PREV",
- /* 180 */ "LINEAR",
- /* 181 */ "IMPORT",
- /* 182 */ "TBNAME",
- /* 183 */ "JOIN",
- /* 184 */ "INSERT",
- /* 185 */ "INTO",
- /* 186 */ "VALUES",
- /* 187 */ "error",
- /* 188 */ "program",
- /* 189 */ "cmd",
- /* 190 */ "dbPrefix",
- /* 191 */ "ids",
- /* 192 */ "cpxName",
- /* 193 */ "ifexists",
- /* 194 */ "alter_db_optr",
- /* 195 */ "alter_topic_optr",
- /* 196 */ "acct_optr",
- /* 197 */ "ifnotexists",
- /* 198 */ "db_optr",
- /* 199 */ "topic_optr",
- /* 200 */ "pps",
- /* 201 */ "tseries",
- /* 202 */ "dbs",
- /* 203 */ "streams",
- /* 204 */ "storage",
- /* 205 */ "qtime",
- /* 206 */ "users",
- /* 207 */ "conns",
- /* 208 */ "state",
- /* 209 */ "keep",
- /* 210 */ "tagitemlist",
- /* 211 */ "cache",
- /* 212 */ "replica",
- /* 213 */ "quorum",
- /* 214 */ "days",
- /* 215 */ "minrows",
- /* 216 */ "maxrows",
- /* 217 */ "blocks",
- /* 218 */ "ctime",
- /* 219 */ "wal",
- /* 220 */ "fsync",
- /* 221 */ "comp",
- /* 222 */ "prec",
- /* 223 */ "update",
- /* 224 */ "cachelast",
- /* 225 */ "partitions",
- /* 226 */ "typename",
- /* 227 */ "signed",
- /* 228 */ "create_table_args",
- /* 229 */ "create_stable_args",
- /* 230 */ "create_table_list",
- /* 231 */ "create_from_stable",
- /* 232 */ "columnlist",
- /* 233 */ "tagNamelist",
- /* 234 */ "select",
- /* 235 */ "column",
- /* 236 */ "tagitem",
- /* 237 */ "selcollist",
- /* 238 */ "from",
- /* 239 */ "where_opt",
- /* 240 */ "interval_opt",
- /* 241 */ "session_option",
- /* 242 */ "fill_opt",
- /* 243 */ "sliding_opt",
- /* 244 */ "groupby_opt",
- /* 245 */ "orderby_opt",
- /* 246 */ "having_opt",
- /* 247 */ "slimit_opt",
- /* 248 */ "limit_opt",
- /* 249 */ "union",
- /* 250 */ "sclp",
- /* 251 */ "distinct",
- /* 252 */ "expr",
- /* 253 */ "as",
- /* 254 */ "tablelist",
- /* 255 */ "sub",
- /* 256 */ "tmvar",
- /* 257 */ "sortlist",
- /* 258 */ "sortitem",
- /* 259 */ "item",
- /* 260 */ "sortorder",
- /* 261 */ "grouplist",
- /* 262 */ "exprlist",
- /* 263 */ "expritem",
+ /* 120 */ "STATE_WINDOW",
+ /* 121 */ "FILL",
+ /* 122 */ "SLIDING",
+ /* 123 */ "ORDER",
+ /* 124 */ "BY",
+ /* 125 */ "ASC",
+ /* 126 */ "DESC",
+ /* 127 */ "GROUP",
+ /* 128 */ "HAVING",
+ /* 129 */ "LIMIT",
+ /* 130 */ "OFFSET",
+ /* 131 */ "SLIMIT",
+ /* 132 */ "SOFFSET",
+ /* 133 */ "WHERE",
+ /* 134 */ "NOW",
+ /* 135 */ "RESET",
+ /* 136 */ "QUERY",
+ /* 137 */ "SYNCDB",
+ /* 138 */ "ADD",
+ /* 139 */ "COLUMN",
+ /* 140 */ "TAG",
+ /* 141 */ "CHANGE",
+ /* 142 */ "SET",
+ /* 143 */ "KILL",
+ /* 144 */ "CONNECTION",
+ /* 145 */ "STREAM",
+ /* 146 */ "COLON",
+ /* 147 */ "ABORT",
+ /* 148 */ "AFTER",
+ /* 149 */ "ATTACH",
+ /* 150 */ "BEFORE",
+ /* 151 */ "BEGIN",
+ /* 152 */ "CASCADE",
+ /* 153 */ "CLUSTER",
+ /* 154 */ "CONFLICT",
+ /* 155 */ "COPY",
+ /* 156 */ "DEFERRED",
+ /* 157 */ "DELIMITERS",
+ /* 158 */ "DETACH",
+ /* 159 */ "EACH",
+ /* 160 */ "END",
+ /* 161 */ "EXPLAIN",
+ /* 162 */ "FAIL",
+ /* 163 */ "FOR",
+ /* 164 */ "IGNORE",
+ /* 165 */ "IMMEDIATE",
+ /* 166 */ "INITIALLY",
+ /* 167 */ "INSTEAD",
+ /* 168 */ "MATCH",
+ /* 169 */ "KEY",
+ /* 170 */ "OF",
+ /* 171 */ "RAISE",
+ /* 172 */ "REPLACE",
+ /* 173 */ "RESTRICT",
+ /* 174 */ "ROW",
+ /* 175 */ "STATEMENT",
+ /* 176 */ "TRIGGER",
+ /* 177 */ "VIEW",
+ /* 178 */ "SEMI",
+ /* 179 */ "NONE",
+ /* 180 */ "PREV",
+ /* 181 */ "LINEAR",
+ /* 182 */ "IMPORT",
+ /* 183 */ "TBNAME",
+ /* 184 */ "JOIN",
+ /* 185 */ "INSERT",
+ /* 186 */ "INTO",
+ /* 187 */ "VALUES",
+ /* 188 */ "error",
+ /* 189 */ "program",
+ /* 190 */ "cmd",
+ /* 191 */ "dbPrefix",
+ /* 192 */ "ids",
+ /* 193 */ "cpxName",
+ /* 194 */ "ifexists",
+ /* 195 */ "alter_db_optr",
+ /* 196 */ "alter_topic_optr",
+ /* 197 */ "acct_optr",
+ /* 198 */ "ifnotexists",
+ /* 199 */ "db_optr",
+ /* 200 */ "topic_optr",
+ /* 201 */ "pps",
+ /* 202 */ "tseries",
+ /* 203 */ "dbs",
+ /* 204 */ "streams",
+ /* 205 */ "storage",
+ /* 206 */ "qtime",
+ /* 207 */ "users",
+ /* 208 */ "conns",
+ /* 209 */ "state",
+ /* 210 */ "keep",
+ /* 211 */ "tagitemlist",
+ /* 212 */ "cache",
+ /* 213 */ "replica",
+ /* 214 */ "quorum",
+ /* 215 */ "days",
+ /* 216 */ "minrows",
+ /* 217 */ "maxrows",
+ /* 218 */ "blocks",
+ /* 219 */ "ctime",
+ /* 220 */ "wal",
+ /* 221 */ "fsync",
+ /* 222 */ "comp",
+ /* 223 */ "prec",
+ /* 224 */ "update",
+ /* 225 */ "cachelast",
+ /* 226 */ "partitions",
+ /* 227 */ "typename",
+ /* 228 */ "signed",
+ /* 229 */ "create_table_args",
+ /* 230 */ "create_stable_args",
+ /* 231 */ "create_table_list",
+ /* 232 */ "create_from_stable",
+ /* 233 */ "columnlist",
+ /* 234 */ "tagNamelist",
+ /* 235 */ "select",
+ /* 236 */ "column",
+ /* 237 */ "tagitem",
+ /* 238 */ "selcollist",
+ /* 239 */ "from",
+ /* 240 */ "where_opt",
+ /* 241 */ "interval_opt",
+ /* 242 */ "session_option",
+ /* 243 */ "windowstate_option",
+ /* 244 */ "fill_opt",
+ /* 245 */ "sliding_opt",
+ /* 246 */ "groupby_opt",
+ /* 247 */ "orderby_opt",
+ /* 248 */ "having_opt",
+ /* 249 */ "slimit_opt",
+ /* 250 */ "limit_opt",
+ /* 251 */ "union",
+ /* 252 */ "sclp",
+ /* 253 */ "distinct",
+ /* 254 */ "expr",
+ /* 255 */ "as",
+ /* 256 */ "tablelist",
+ /* 257 */ "sub",
+ /* 258 */ "tmvar",
+ /* 259 */ "sortlist",
+ /* 260 */ "sortitem",
+ /* 261 */ "item",
+ /* 262 */ "sortorder",
+ /* 263 */ "grouplist",
+ /* 264 */ "exprlist",
+ /* 265 */ "expritem",
};
#endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */
@@ -1183,7 +1187,7 @@ static const char *const yyRuleName[] = {
/* 154 */ "tagitem ::= MINUS FLOAT",
/* 155 */ "tagitem ::= PLUS INTEGER",
/* 156 */ "tagitem ::= PLUS FLOAT",
- /* 157 */ "select ::= SELECT selcollist from where_opt interval_opt session_option fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt",
+ /* 157 */ "select ::= SELECT selcollist from where_opt interval_opt session_option windowstate_option fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt",
/* 158 */ "select ::= LP select RP",
/* 159 */ "union ::= select",
/* 160 */ "union ::= union UNION ALL select",
@@ -1213,92 +1217,94 @@ static const char *const yyRuleName[] = {
/* 184 */ "interval_opt ::=",
/* 185 */ "session_option ::=",
/* 186 */ "session_option ::= SESSION LP ids cpxName COMMA tmvar RP",
- /* 187 */ "fill_opt ::=",
- /* 188 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP",
- /* 189 */ "fill_opt ::= FILL LP ID RP",
- /* 190 */ "sliding_opt ::= SLIDING LP tmvar RP",
- /* 191 */ "sliding_opt ::=",
- /* 192 */ "orderby_opt ::=",
- /* 193 */ "orderby_opt ::= ORDER BY sortlist",
- /* 194 */ "sortlist ::= sortlist COMMA item sortorder",
- /* 195 */ "sortlist ::= item sortorder",
- /* 196 */ "item ::= ids cpxName",
- /* 197 */ "sortorder ::= ASC",
- /* 198 */ "sortorder ::= DESC",
- /* 199 */ "sortorder ::=",
- /* 200 */ "groupby_opt ::=",
- /* 201 */ "groupby_opt ::= GROUP BY grouplist",
- /* 202 */ "grouplist ::= grouplist COMMA item",
- /* 203 */ "grouplist ::= item",
- /* 204 */ "having_opt ::=",
- /* 205 */ "having_opt ::= HAVING expr",
- /* 206 */ "limit_opt ::=",
- /* 207 */ "limit_opt ::= LIMIT signed",
- /* 208 */ "limit_opt ::= LIMIT signed OFFSET signed",
- /* 209 */ "limit_opt ::= LIMIT signed COMMA signed",
- /* 210 */ "slimit_opt ::=",
- /* 211 */ "slimit_opt ::= SLIMIT signed",
- /* 212 */ "slimit_opt ::= SLIMIT signed SOFFSET signed",
- /* 213 */ "slimit_opt ::= SLIMIT signed COMMA signed",
- /* 214 */ "where_opt ::=",
- /* 215 */ "where_opt ::= WHERE expr",
- /* 216 */ "expr ::= LP expr RP",
- /* 217 */ "expr ::= ID",
- /* 218 */ "expr ::= ID DOT ID",
- /* 219 */ "expr ::= ID DOT STAR",
- /* 220 */ "expr ::= INTEGER",
- /* 221 */ "expr ::= MINUS INTEGER",
- /* 222 */ "expr ::= PLUS INTEGER",
- /* 223 */ "expr ::= FLOAT",
- /* 224 */ "expr ::= MINUS FLOAT",
- /* 225 */ "expr ::= PLUS FLOAT",
- /* 226 */ "expr ::= STRING",
- /* 227 */ "expr ::= NOW",
- /* 228 */ "expr ::= VARIABLE",
- /* 229 */ "expr ::= PLUS VARIABLE",
- /* 230 */ "expr ::= MINUS VARIABLE",
- /* 231 */ "expr ::= BOOL",
- /* 232 */ "expr ::= NULL",
- /* 233 */ "expr ::= ID LP exprlist RP",
- /* 234 */ "expr ::= ID LP STAR RP",
- /* 235 */ "expr ::= expr IS NULL",
- /* 236 */ "expr ::= expr IS NOT NULL",
- /* 237 */ "expr ::= expr LT expr",
- /* 238 */ "expr ::= expr GT expr",
- /* 239 */ "expr ::= expr LE expr",
- /* 240 */ "expr ::= expr GE expr",
- /* 241 */ "expr ::= expr NE expr",
- /* 242 */ "expr ::= expr EQ expr",
- /* 243 */ "expr ::= expr BETWEEN expr AND expr",
- /* 244 */ "expr ::= expr AND expr",
- /* 245 */ "expr ::= expr OR expr",
- /* 246 */ "expr ::= expr PLUS expr",
- /* 247 */ "expr ::= expr MINUS expr",
- /* 248 */ "expr ::= expr STAR expr",
- /* 249 */ "expr ::= expr SLASH expr",
- /* 250 */ "expr ::= expr REM expr",
- /* 251 */ "expr ::= expr LIKE expr",
- /* 252 */ "expr ::= expr IN LP exprlist RP",
- /* 253 */ "exprlist ::= exprlist COMMA expritem",
- /* 254 */ "exprlist ::= expritem",
- /* 255 */ "expritem ::= expr",
- /* 256 */ "expritem ::=",
- /* 257 */ "cmd ::= RESET QUERY CACHE",
- /* 258 */ "cmd ::= SYNCDB ids REPLICA",
- /* 259 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist",
- /* 260 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids",
- /* 261 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist",
- /* 262 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids",
- /* 263 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids",
- /* 264 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem",
- /* 265 */ "cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist",
- /* 266 */ "cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids",
- /* 267 */ "cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist",
- /* 268 */ "cmd ::= ALTER STABLE ids cpxName DROP TAG ids",
- /* 269 */ "cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids",
- /* 270 */ "cmd ::= KILL CONNECTION INTEGER",
- /* 271 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER",
- /* 272 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER",
+ /* 187 */ "windowstate_option ::=",
+ /* 188 */ "windowstate_option ::= STATE_WINDOW LP ids RP",
+ /* 189 */ "fill_opt ::=",
+ /* 190 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP",
+ /* 191 */ "fill_opt ::= FILL LP ID RP",
+ /* 192 */ "sliding_opt ::= SLIDING LP tmvar RP",
+ /* 193 */ "sliding_opt ::=",
+ /* 194 */ "orderby_opt ::=",
+ /* 195 */ "orderby_opt ::= ORDER BY sortlist",
+ /* 196 */ "sortlist ::= sortlist COMMA item sortorder",
+ /* 197 */ "sortlist ::= item sortorder",
+ /* 198 */ "item ::= ids cpxName",
+ /* 199 */ "sortorder ::= ASC",
+ /* 200 */ "sortorder ::= DESC",
+ /* 201 */ "sortorder ::=",
+ /* 202 */ "groupby_opt ::=",
+ /* 203 */ "groupby_opt ::= GROUP BY grouplist",
+ /* 204 */ "grouplist ::= grouplist COMMA item",
+ /* 205 */ "grouplist ::= item",
+ /* 206 */ "having_opt ::=",
+ /* 207 */ "having_opt ::= HAVING expr",
+ /* 208 */ "limit_opt ::=",
+ /* 209 */ "limit_opt ::= LIMIT signed",
+ /* 210 */ "limit_opt ::= LIMIT signed OFFSET signed",
+ /* 211 */ "limit_opt ::= LIMIT signed COMMA signed",
+ /* 212 */ "slimit_opt ::=",
+ /* 213 */ "slimit_opt ::= SLIMIT signed",
+ /* 214 */ "slimit_opt ::= SLIMIT signed SOFFSET signed",
+ /* 215 */ "slimit_opt ::= SLIMIT signed COMMA signed",
+ /* 216 */ "where_opt ::=",
+ /* 217 */ "where_opt ::= WHERE expr",
+ /* 218 */ "expr ::= LP expr RP",
+ /* 219 */ "expr ::= ID",
+ /* 220 */ "expr ::= ID DOT ID",
+ /* 221 */ "expr ::= ID DOT STAR",
+ /* 222 */ "expr ::= INTEGER",
+ /* 223 */ "expr ::= MINUS INTEGER",
+ /* 224 */ "expr ::= PLUS INTEGER",
+ /* 225 */ "expr ::= FLOAT",
+ /* 226 */ "expr ::= MINUS FLOAT",
+ /* 227 */ "expr ::= PLUS FLOAT",
+ /* 228 */ "expr ::= STRING",
+ /* 229 */ "expr ::= NOW",
+ /* 230 */ "expr ::= VARIABLE",
+ /* 231 */ "expr ::= PLUS VARIABLE",
+ /* 232 */ "expr ::= MINUS VARIABLE",
+ /* 233 */ "expr ::= BOOL",
+ /* 234 */ "expr ::= NULL",
+ /* 235 */ "expr ::= ID LP exprlist RP",
+ /* 236 */ "expr ::= ID LP STAR RP",
+ /* 237 */ "expr ::= expr IS NULL",
+ /* 238 */ "expr ::= expr IS NOT NULL",
+ /* 239 */ "expr ::= expr LT expr",
+ /* 240 */ "expr ::= expr GT expr",
+ /* 241 */ "expr ::= expr LE expr",
+ /* 242 */ "expr ::= expr GE expr",
+ /* 243 */ "expr ::= expr NE expr",
+ /* 244 */ "expr ::= expr EQ expr",
+ /* 245 */ "expr ::= expr BETWEEN expr AND expr",
+ /* 246 */ "expr ::= expr AND expr",
+ /* 247 */ "expr ::= expr OR expr",
+ /* 248 */ "expr ::= expr PLUS expr",
+ /* 249 */ "expr ::= expr MINUS expr",
+ /* 250 */ "expr ::= expr STAR expr",
+ /* 251 */ "expr ::= expr SLASH expr",
+ /* 252 */ "expr ::= expr REM expr",
+ /* 253 */ "expr ::= expr LIKE expr",
+ /* 254 */ "expr ::= expr IN LP exprlist RP",
+ /* 255 */ "exprlist ::= exprlist COMMA expritem",
+ /* 256 */ "exprlist ::= expritem",
+ /* 257 */ "expritem ::= expr",
+ /* 258 */ "expritem ::=",
+ /* 259 */ "cmd ::= RESET QUERY CACHE",
+ /* 260 */ "cmd ::= SYNCDB ids REPLICA",
+ /* 261 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist",
+ /* 262 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids",
+ /* 263 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist",
+ /* 264 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids",
+ /* 265 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids",
+ /* 266 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem",
+ /* 267 */ "cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist",
+ /* 268 */ "cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids",
+ /* 269 */ "cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist",
+ /* 270 */ "cmd ::= ALTER STABLE ids cpxName DROP TAG ids",
+ /* 271 */ "cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids",
+ /* 272 */ "cmd ::= KILL CONNECTION INTEGER",
+ /* 273 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER",
+ /* 274 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER",
};
#endif /* NDEBUG */
@@ -1419,59 +1425,59 @@ static void yy_destructor(
** inside the C code.
*/
/********* Begin destructor definitions ***************************************/
- case 209: /* keep */
- case 210: /* tagitemlist */
- case 232: /* columnlist */
- case 233: /* tagNamelist */
- case 242: /* fill_opt */
- case 244: /* groupby_opt */
- case 245: /* orderby_opt */
- case 257: /* sortlist */
- case 261: /* grouplist */
+ case 210: /* keep */
+ case 211: /* tagitemlist */
+ case 233: /* columnlist */
+ case 234: /* tagNamelist */
+ case 244: /* fill_opt */
+ case 246: /* groupby_opt */
+ case 247: /* orderby_opt */
+ case 259: /* sortlist */
+ case 263: /* grouplist */
{
-taosArrayDestroy((yypminor->yy285));
+taosArrayDestroy((yypminor->yy193));
}
break;
- case 230: /* create_table_list */
+ case 231: /* create_table_list */
{
-destroyCreateTableSql((yypminor->yy470));
+destroyCreateTableSql((yypminor->yy270));
}
break;
- case 234: /* select */
+ case 235: /* select */
{
-destroySqlNode((yypminor->yy344));
+destroySqlNode((yypminor->yy124));
}
break;
- case 237: /* selcollist */
- case 250: /* sclp */
- case 262: /* exprlist */
+ case 238: /* selcollist */
+ case 252: /* sclp */
+ case 264: /* exprlist */
{
-tSqlExprListDestroy((yypminor->yy285));
+tSqlExprListDestroy((yypminor->yy193));
}
break;
- case 238: /* from */
- case 254: /* tablelist */
- case 255: /* sub */
+ case 239: /* from */
+ case 256: /* tablelist */
+ case 257: /* sub */
{
-destroyRelationInfo((yypminor->yy148));
+destroyRelationInfo((yypminor->yy332));
}
break;
- case 239: /* where_opt */
- case 246: /* having_opt */
- case 252: /* expr */
- case 263: /* expritem */
+ case 240: /* where_opt */
+ case 248: /* having_opt */
+ case 254: /* expr */
+ case 265: /* expritem */
{
-tSqlExprDestroy((yypminor->yy178));
+tSqlExprDestroy((yypminor->yy454));
}
break;
- case 249: /* union */
+ case 251: /* union */
{
-destroyAllSqlNode((yypminor->yy285));
+destroyAllSqlNode((yypminor->yy193));
}
break;
- case 258: /* sortitem */
+ case 260: /* sortitem */
{
-tVariantDestroy(&(yypminor->yy362));
+tVariantDestroy(&(yypminor->yy442));
}
break;
/********* End destructor definitions *****************************************/
@@ -1765,279 +1771,281 @@ static const struct {
YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
signed char nrhs; /* Negative of the number of RHS symbols in the rule */
} yyRuleInfo[] = {
- { 188, -1 }, /* (0) program ::= cmd */
- { 189, -2 }, /* (1) cmd ::= SHOW DATABASES */
- { 189, -2 }, /* (2) cmd ::= SHOW TOPICS */
- { 189, -2 }, /* (3) cmd ::= SHOW MNODES */
- { 189, -2 }, /* (4) cmd ::= SHOW DNODES */
- { 189, -2 }, /* (5) cmd ::= SHOW ACCOUNTS */
- { 189, -2 }, /* (6) cmd ::= SHOW USERS */
- { 189, -2 }, /* (7) cmd ::= SHOW MODULES */
- { 189, -2 }, /* (8) cmd ::= SHOW QUERIES */
- { 189, -2 }, /* (9) cmd ::= SHOW CONNECTIONS */
- { 189, -2 }, /* (10) cmd ::= SHOW STREAMS */
- { 189, -2 }, /* (11) cmd ::= SHOW VARIABLES */
- { 189, -2 }, /* (12) cmd ::= SHOW SCORES */
- { 189, -2 }, /* (13) cmd ::= SHOW GRANTS */
- { 189, -2 }, /* (14) cmd ::= SHOW VNODES */
- { 189, -3 }, /* (15) cmd ::= SHOW VNODES IPTOKEN */
- { 190, 0 }, /* (16) dbPrefix ::= */
- { 190, -2 }, /* (17) dbPrefix ::= ids DOT */
- { 192, 0 }, /* (18) cpxName ::= */
- { 192, -2 }, /* (19) cpxName ::= DOT ids */
- { 189, -5 }, /* (20) cmd ::= SHOW CREATE TABLE ids cpxName */
- { 189, -5 }, /* (21) cmd ::= SHOW CREATE STABLE ids cpxName */
- { 189, -4 }, /* (22) cmd ::= SHOW CREATE DATABASE ids */
- { 189, -3 }, /* (23) cmd ::= SHOW dbPrefix TABLES */
- { 189, -5 }, /* (24) cmd ::= SHOW dbPrefix TABLES LIKE ids */
- { 189, -3 }, /* (25) cmd ::= SHOW dbPrefix STABLES */
- { 189, -5 }, /* (26) cmd ::= SHOW dbPrefix STABLES LIKE ids */
- { 189, -3 }, /* (27) cmd ::= SHOW dbPrefix VGROUPS */
- { 189, -4 }, /* (28) cmd ::= SHOW dbPrefix VGROUPS ids */
- { 189, -5 }, /* (29) cmd ::= DROP TABLE ifexists ids cpxName */
- { 189, -5 }, /* (30) cmd ::= DROP STABLE ifexists ids cpxName */
- { 189, -4 }, /* (31) cmd ::= DROP DATABASE ifexists ids */
- { 189, -4 }, /* (32) cmd ::= DROP TOPIC ifexists ids */
- { 189, -3 }, /* (33) cmd ::= DROP DNODE ids */
- { 189, -3 }, /* (34) cmd ::= DROP USER ids */
- { 189, -3 }, /* (35) cmd ::= DROP ACCOUNT ids */
- { 189, -2 }, /* (36) cmd ::= USE ids */
- { 189, -3 }, /* (37) cmd ::= DESCRIBE ids cpxName */
- { 189, -5 }, /* (38) cmd ::= ALTER USER ids PASS ids */
- { 189, -5 }, /* (39) cmd ::= ALTER USER ids PRIVILEGE ids */
- { 189, -4 }, /* (40) cmd ::= ALTER DNODE ids ids */
- { 189, -5 }, /* (41) cmd ::= ALTER DNODE ids ids ids */
- { 189, -3 }, /* (42) cmd ::= ALTER LOCAL ids */
- { 189, -4 }, /* (43) cmd ::= ALTER LOCAL ids ids */
- { 189, -4 }, /* (44) cmd ::= ALTER DATABASE ids alter_db_optr */
- { 189, -4 }, /* (45) cmd ::= ALTER TOPIC ids alter_topic_optr */
- { 189, -4 }, /* (46) cmd ::= ALTER ACCOUNT ids acct_optr */
- { 189, -6 }, /* (47) cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */
- { 191, -1 }, /* (48) ids ::= ID */
- { 191, -1 }, /* (49) ids ::= STRING */
- { 193, -2 }, /* (50) ifexists ::= IF EXISTS */
- { 193, 0 }, /* (51) ifexists ::= */
- { 197, -3 }, /* (52) ifnotexists ::= IF NOT EXISTS */
- { 197, 0 }, /* (53) ifnotexists ::= */
- { 189, -3 }, /* (54) cmd ::= CREATE DNODE ids */
- { 189, -6 }, /* (55) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */
- { 189, -5 }, /* (56) cmd ::= CREATE DATABASE ifnotexists ids db_optr */
- { 189, -5 }, /* (57) cmd ::= CREATE TOPIC ifnotexists ids topic_optr */
- { 189, -5 }, /* (58) cmd ::= CREATE USER ids PASS ids */
- { 200, 0 }, /* (59) pps ::= */
- { 200, -2 }, /* (60) pps ::= PPS INTEGER */
- { 201, 0 }, /* (61) tseries ::= */
- { 201, -2 }, /* (62) tseries ::= TSERIES INTEGER */
- { 202, 0 }, /* (63) dbs ::= */
- { 202, -2 }, /* (64) dbs ::= DBS INTEGER */
- { 203, 0 }, /* (65) streams ::= */
- { 203, -2 }, /* (66) streams ::= STREAMS INTEGER */
- { 204, 0 }, /* (67) storage ::= */
- { 204, -2 }, /* (68) storage ::= STORAGE INTEGER */
- { 205, 0 }, /* (69) qtime ::= */
- { 205, -2 }, /* (70) qtime ::= QTIME INTEGER */
- { 206, 0 }, /* (71) users ::= */
- { 206, -2 }, /* (72) users ::= USERS INTEGER */
- { 207, 0 }, /* (73) conns ::= */
- { 207, -2 }, /* (74) conns ::= CONNS INTEGER */
- { 208, 0 }, /* (75) state ::= */
- { 208, -2 }, /* (76) state ::= STATE ids */
- { 196, -9 }, /* (77) acct_optr ::= pps tseries storage streams qtime dbs users conns state */
- { 209, -2 }, /* (78) keep ::= KEEP tagitemlist */
- { 211, -2 }, /* (79) cache ::= CACHE INTEGER */
- { 212, -2 }, /* (80) replica ::= REPLICA INTEGER */
- { 213, -2 }, /* (81) quorum ::= QUORUM INTEGER */
- { 214, -2 }, /* (82) days ::= DAYS INTEGER */
- { 215, -2 }, /* (83) minrows ::= MINROWS INTEGER */
- { 216, -2 }, /* (84) maxrows ::= MAXROWS INTEGER */
- { 217, -2 }, /* (85) blocks ::= BLOCKS INTEGER */
- { 218, -2 }, /* (86) ctime ::= CTIME INTEGER */
- { 219, -2 }, /* (87) wal ::= WAL INTEGER */
- { 220, -2 }, /* (88) fsync ::= FSYNC INTEGER */
- { 221, -2 }, /* (89) comp ::= COMP INTEGER */
- { 222, -2 }, /* (90) prec ::= PRECISION STRING */
- { 223, -2 }, /* (91) update ::= UPDATE INTEGER */
- { 224, -2 }, /* (92) cachelast ::= CACHELAST INTEGER */
- { 225, -2 }, /* (93) partitions ::= PARTITIONS INTEGER */
- { 198, 0 }, /* (94) db_optr ::= */
- { 198, -2 }, /* (95) db_optr ::= db_optr cache */
- { 198, -2 }, /* (96) db_optr ::= db_optr replica */
- { 198, -2 }, /* (97) db_optr ::= db_optr quorum */
- { 198, -2 }, /* (98) db_optr ::= db_optr days */
- { 198, -2 }, /* (99) db_optr ::= db_optr minrows */
- { 198, -2 }, /* (100) db_optr ::= db_optr maxrows */
- { 198, -2 }, /* (101) db_optr ::= db_optr blocks */
- { 198, -2 }, /* (102) db_optr ::= db_optr ctime */
- { 198, -2 }, /* (103) db_optr ::= db_optr wal */
- { 198, -2 }, /* (104) db_optr ::= db_optr fsync */
- { 198, -2 }, /* (105) db_optr ::= db_optr comp */
- { 198, -2 }, /* (106) db_optr ::= db_optr prec */
- { 198, -2 }, /* (107) db_optr ::= db_optr keep */
- { 198, -2 }, /* (108) db_optr ::= db_optr update */
- { 198, -2 }, /* (109) db_optr ::= db_optr cachelast */
- { 199, -1 }, /* (110) topic_optr ::= db_optr */
- { 199, -2 }, /* (111) topic_optr ::= topic_optr partitions */
- { 194, 0 }, /* (112) alter_db_optr ::= */
- { 194, -2 }, /* (113) alter_db_optr ::= alter_db_optr replica */
- { 194, -2 }, /* (114) alter_db_optr ::= alter_db_optr quorum */
- { 194, -2 }, /* (115) alter_db_optr ::= alter_db_optr keep */
- { 194, -2 }, /* (116) alter_db_optr ::= alter_db_optr blocks */
- { 194, -2 }, /* (117) alter_db_optr ::= alter_db_optr comp */
- { 194, -2 }, /* (118) alter_db_optr ::= alter_db_optr wal */
- { 194, -2 }, /* (119) alter_db_optr ::= alter_db_optr fsync */
- { 194, -2 }, /* (120) alter_db_optr ::= alter_db_optr update */
- { 194, -2 }, /* (121) alter_db_optr ::= alter_db_optr cachelast */
- { 195, -1 }, /* (122) alter_topic_optr ::= alter_db_optr */
- { 195, -2 }, /* (123) alter_topic_optr ::= alter_topic_optr partitions */
- { 226, -1 }, /* (124) typename ::= ids */
- { 226, -4 }, /* (125) typename ::= ids LP signed RP */
- { 226, -2 }, /* (126) typename ::= ids UNSIGNED */
- { 227, -1 }, /* (127) signed ::= INTEGER */
- { 227, -2 }, /* (128) signed ::= PLUS INTEGER */
- { 227, -2 }, /* (129) signed ::= MINUS INTEGER */
- { 189, -3 }, /* (130) cmd ::= CREATE TABLE create_table_args */
- { 189, -3 }, /* (131) cmd ::= CREATE TABLE create_stable_args */
- { 189, -3 }, /* (132) cmd ::= CREATE STABLE create_stable_args */
- { 189, -3 }, /* (133) cmd ::= CREATE TABLE create_table_list */
- { 230, -1 }, /* (134) create_table_list ::= create_from_stable */
- { 230, -2 }, /* (135) create_table_list ::= create_table_list create_from_stable */
- { 228, -6 }, /* (136) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */
- { 229, -10 }, /* (137) create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */
- { 231, -10 }, /* (138) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */
- { 231, -13 }, /* (139) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */
- { 233, -3 }, /* (140) tagNamelist ::= tagNamelist COMMA ids */
- { 233, -1 }, /* (141) tagNamelist ::= ids */
- { 228, -5 }, /* (142) create_table_args ::= ifnotexists ids cpxName AS select */
- { 232, -3 }, /* (143) columnlist ::= columnlist COMMA column */
- { 232, -1 }, /* (144) columnlist ::= column */
- { 235, -2 }, /* (145) column ::= ids typename */
- { 210, -3 }, /* (146) tagitemlist ::= tagitemlist COMMA tagitem */
- { 210, -1 }, /* (147) tagitemlist ::= tagitem */
- { 236, -1 }, /* (148) tagitem ::= INTEGER */
- { 236, -1 }, /* (149) tagitem ::= FLOAT */
- { 236, -1 }, /* (150) tagitem ::= STRING */
- { 236, -1 }, /* (151) tagitem ::= BOOL */
- { 236, -1 }, /* (152) tagitem ::= NULL */
- { 236, -2 }, /* (153) tagitem ::= MINUS INTEGER */
- { 236, -2 }, /* (154) tagitem ::= MINUS FLOAT */
- { 236, -2 }, /* (155) tagitem ::= PLUS INTEGER */
- { 236, -2 }, /* (156) tagitem ::= PLUS FLOAT */
- { 234, -13 }, /* (157) select ::= SELECT selcollist from where_opt interval_opt session_option fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */
- { 234, -3 }, /* (158) select ::= LP select RP */
- { 249, -1 }, /* (159) union ::= select */
- { 249, -4 }, /* (160) union ::= union UNION ALL select */
- { 189, -1 }, /* (161) cmd ::= union */
- { 234, -2 }, /* (162) select ::= SELECT selcollist */
- { 250, -2 }, /* (163) sclp ::= selcollist COMMA */
- { 250, 0 }, /* (164) sclp ::= */
- { 237, -4 }, /* (165) selcollist ::= sclp distinct expr as */
- { 237, -2 }, /* (166) selcollist ::= sclp STAR */
- { 253, -2 }, /* (167) as ::= AS ids */
- { 253, -1 }, /* (168) as ::= ids */
- { 253, 0 }, /* (169) as ::= */
- { 251, -1 }, /* (170) distinct ::= DISTINCT */
- { 251, 0 }, /* (171) distinct ::= */
- { 238, -2 }, /* (172) from ::= FROM tablelist */
- { 238, -2 }, /* (173) from ::= FROM sub */
- { 255, -3 }, /* (174) sub ::= LP union RP */
- { 255, -4 }, /* (175) sub ::= LP union RP ids */
- { 255, -6 }, /* (176) sub ::= sub COMMA LP union RP ids */
- { 254, -2 }, /* (177) tablelist ::= ids cpxName */
- { 254, -3 }, /* (178) tablelist ::= ids cpxName ids */
- { 254, -4 }, /* (179) tablelist ::= tablelist COMMA ids cpxName */
- { 254, -5 }, /* (180) tablelist ::= tablelist COMMA ids cpxName ids */
- { 256, -1 }, /* (181) tmvar ::= VARIABLE */
- { 240, -4 }, /* (182) interval_opt ::= INTERVAL LP tmvar RP */
- { 240, -6 }, /* (183) interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */
- { 240, 0 }, /* (184) interval_opt ::= */
- { 241, 0 }, /* (185) session_option ::= */
- { 241, -7 }, /* (186) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */
- { 242, 0 }, /* (187) fill_opt ::= */
- { 242, -6 }, /* (188) fill_opt ::= FILL LP ID COMMA tagitemlist RP */
- { 242, -4 }, /* (189) fill_opt ::= FILL LP ID RP */
- { 243, -4 }, /* (190) sliding_opt ::= SLIDING LP tmvar RP */
- { 243, 0 }, /* (191) sliding_opt ::= */
- { 245, 0 }, /* (192) orderby_opt ::= */
- { 245, -3 }, /* (193) orderby_opt ::= ORDER BY sortlist */
- { 257, -4 }, /* (194) sortlist ::= sortlist COMMA item sortorder */
- { 257, -2 }, /* (195) sortlist ::= item sortorder */
- { 259, -2 }, /* (196) item ::= ids cpxName */
- { 260, -1 }, /* (197) sortorder ::= ASC */
- { 260, -1 }, /* (198) sortorder ::= DESC */
- { 260, 0 }, /* (199) sortorder ::= */
- { 244, 0 }, /* (200) groupby_opt ::= */
- { 244, -3 }, /* (201) groupby_opt ::= GROUP BY grouplist */
- { 261, -3 }, /* (202) grouplist ::= grouplist COMMA item */
- { 261, -1 }, /* (203) grouplist ::= item */
- { 246, 0 }, /* (204) having_opt ::= */
- { 246, -2 }, /* (205) having_opt ::= HAVING expr */
- { 248, 0 }, /* (206) limit_opt ::= */
- { 248, -2 }, /* (207) limit_opt ::= LIMIT signed */
- { 248, -4 }, /* (208) limit_opt ::= LIMIT signed OFFSET signed */
- { 248, -4 }, /* (209) limit_opt ::= LIMIT signed COMMA signed */
- { 247, 0 }, /* (210) slimit_opt ::= */
- { 247, -2 }, /* (211) slimit_opt ::= SLIMIT signed */
- { 247, -4 }, /* (212) slimit_opt ::= SLIMIT signed SOFFSET signed */
- { 247, -4 }, /* (213) slimit_opt ::= SLIMIT signed COMMA signed */
- { 239, 0 }, /* (214) where_opt ::= */
- { 239, -2 }, /* (215) where_opt ::= WHERE expr */
- { 252, -3 }, /* (216) expr ::= LP expr RP */
- { 252, -1 }, /* (217) expr ::= ID */
- { 252, -3 }, /* (218) expr ::= ID DOT ID */
- { 252, -3 }, /* (219) expr ::= ID DOT STAR */
- { 252, -1 }, /* (220) expr ::= INTEGER */
- { 252, -2 }, /* (221) expr ::= MINUS INTEGER */
- { 252, -2 }, /* (222) expr ::= PLUS INTEGER */
- { 252, -1 }, /* (223) expr ::= FLOAT */
- { 252, -2 }, /* (224) expr ::= MINUS FLOAT */
- { 252, -2 }, /* (225) expr ::= PLUS FLOAT */
- { 252, -1 }, /* (226) expr ::= STRING */
- { 252, -1 }, /* (227) expr ::= NOW */
- { 252, -1 }, /* (228) expr ::= VARIABLE */
- { 252, -2 }, /* (229) expr ::= PLUS VARIABLE */
- { 252, -2 }, /* (230) expr ::= MINUS VARIABLE */
- { 252, -1 }, /* (231) expr ::= BOOL */
- { 252, -1 }, /* (232) expr ::= NULL */
- { 252, -4 }, /* (233) expr ::= ID LP exprlist RP */
- { 252, -4 }, /* (234) expr ::= ID LP STAR RP */
- { 252, -3 }, /* (235) expr ::= expr IS NULL */
- { 252, -4 }, /* (236) expr ::= expr IS NOT NULL */
- { 252, -3 }, /* (237) expr ::= expr LT expr */
- { 252, -3 }, /* (238) expr ::= expr GT expr */
- { 252, -3 }, /* (239) expr ::= expr LE expr */
- { 252, -3 }, /* (240) expr ::= expr GE expr */
- { 252, -3 }, /* (241) expr ::= expr NE expr */
- { 252, -3 }, /* (242) expr ::= expr EQ expr */
- { 252, -5 }, /* (243) expr ::= expr BETWEEN expr AND expr */
- { 252, -3 }, /* (244) expr ::= expr AND expr */
- { 252, -3 }, /* (245) expr ::= expr OR expr */
- { 252, -3 }, /* (246) expr ::= expr PLUS expr */
- { 252, -3 }, /* (247) expr ::= expr MINUS expr */
- { 252, -3 }, /* (248) expr ::= expr STAR expr */
- { 252, -3 }, /* (249) expr ::= expr SLASH expr */
- { 252, -3 }, /* (250) expr ::= expr REM expr */
- { 252, -3 }, /* (251) expr ::= expr LIKE expr */
- { 252, -5 }, /* (252) expr ::= expr IN LP exprlist RP */
- { 262, -3 }, /* (253) exprlist ::= exprlist COMMA expritem */
- { 262, -1 }, /* (254) exprlist ::= expritem */
- { 263, -1 }, /* (255) expritem ::= expr */
- { 263, 0 }, /* (256) expritem ::= */
- { 189, -3 }, /* (257) cmd ::= RESET QUERY CACHE */
- { 189, -3 }, /* (258) cmd ::= SYNCDB ids REPLICA */
- { 189, -7 }, /* (259) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */
- { 189, -7 }, /* (260) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */
- { 189, -7 }, /* (261) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */
- { 189, -7 }, /* (262) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */
- { 189, -8 }, /* (263) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */
- { 189, -9 }, /* (264) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */
- { 189, -7 }, /* (265) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */
- { 189, -7 }, /* (266) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */
- { 189, -7 }, /* (267) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */
- { 189, -7 }, /* (268) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */
- { 189, -8 }, /* (269) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */
- { 189, -3 }, /* (270) cmd ::= KILL CONNECTION INTEGER */
- { 189, -5 }, /* (271) cmd ::= KILL STREAM INTEGER COLON INTEGER */
- { 189, -5 }, /* (272) cmd ::= KILL QUERY INTEGER COLON INTEGER */
+ { 189, -1 }, /* (0) program ::= cmd */
+ { 190, -2 }, /* (1) cmd ::= SHOW DATABASES */
+ { 190, -2 }, /* (2) cmd ::= SHOW TOPICS */
+ { 190, -2 }, /* (3) cmd ::= SHOW MNODES */
+ { 190, -2 }, /* (4) cmd ::= SHOW DNODES */
+ { 190, -2 }, /* (5) cmd ::= SHOW ACCOUNTS */
+ { 190, -2 }, /* (6) cmd ::= SHOW USERS */
+ { 190, -2 }, /* (7) cmd ::= SHOW MODULES */
+ { 190, -2 }, /* (8) cmd ::= SHOW QUERIES */
+ { 190, -2 }, /* (9) cmd ::= SHOW CONNECTIONS */
+ { 190, -2 }, /* (10) cmd ::= SHOW STREAMS */
+ { 190, -2 }, /* (11) cmd ::= SHOW VARIABLES */
+ { 190, -2 }, /* (12) cmd ::= SHOW SCORES */
+ { 190, -2 }, /* (13) cmd ::= SHOW GRANTS */
+ { 190, -2 }, /* (14) cmd ::= SHOW VNODES */
+ { 190, -3 }, /* (15) cmd ::= SHOW VNODES IPTOKEN */
+ { 191, 0 }, /* (16) dbPrefix ::= */
+ { 191, -2 }, /* (17) dbPrefix ::= ids DOT */
+ { 193, 0 }, /* (18) cpxName ::= */
+ { 193, -2 }, /* (19) cpxName ::= DOT ids */
+ { 190, -5 }, /* (20) cmd ::= SHOW CREATE TABLE ids cpxName */
+ { 190, -5 }, /* (21) cmd ::= SHOW CREATE STABLE ids cpxName */
+ { 190, -4 }, /* (22) cmd ::= SHOW CREATE DATABASE ids */
+ { 190, -3 }, /* (23) cmd ::= SHOW dbPrefix TABLES */
+ { 190, -5 }, /* (24) cmd ::= SHOW dbPrefix TABLES LIKE ids */
+ { 190, -3 }, /* (25) cmd ::= SHOW dbPrefix STABLES */
+ { 190, -5 }, /* (26) cmd ::= SHOW dbPrefix STABLES LIKE ids */
+ { 190, -3 }, /* (27) cmd ::= SHOW dbPrefix VGROUPS */
+ { 190, -4 }, /* (28) cmd ::= SHOW dbPrefix VGROUPS ids */
+ { 190, -5 }, /* (29) cmd ::= DROP TABLE ifexists ids cpxName */
+ { 190, -5 }, /* (30) cmd ::= DROP STABLE ifexists ids cpxName */
+ { 190, -4 }, /* (31) cmd ::= DROP DATABASE ifexists ids */
+ { 190, -4 }, /* (32) cmd ::= DROP TOPIC ifexists ids */
+ { 190, -3 }, /* (33) cmd ::= DROP DNODE ids */
+ { 190, -3 }, /* (34) cmd ::= DROP USER ids */
+ { 190, -3 }, /* (35) cmd ::= DROP ACCOUNT ids */
+ { 190, -2 }, /* (36) cmd ::= USE ids */
+ { 190, -3 }, /* (37) cmd ::= DESCRIBE ids cpxName */
+ { 190, -5 }, /* (38) cmd ::= ALTER USER ids PASS ids */
+ { 190, -5 }, /* (39) cmd ::= ALTER USER ids PRIVILEGE ids */
+ { 190, -4 }, /* (40) cmd ::= ALTER DNODE ids ids */
+ { 190, -5 }, /* (41) cmd ::= ALTER DNODE ids ids ids */
+ { 190, -3 }, /* (42) cmd ::= ALTER LOCAL ids */
+ { 190, -4 }, /* (43) cmd ::= ALTER LOCAL ids ids */
+ { 190, -4 }, /* (44) cmd ::= ALTER DATABASE ids alter_db_optr */
+ { 190, -4 }, /* (45) cmd ::= ALTER TOPIC ids alter_topic_optr */
+ { 190, -4 }, /* (46) cmd ::= ALTER ACCOUNT ids acct_optr */
+ { 190, -6 }, /* (47) cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */
+ { 192, -1 }, /* (48) ids ::= ID */
+ { 192, -1 }, /* (49) ids ::= STRING */
+ { 194, -2 }, /* (50) ifexists ::= IF EXISTS */
+ { 194, 0 }, /* (51) ifexists ::= */
+ { 198, -3 }, /* (52) ifnotexists ::= IF NOT EXISTS */
+ { 198, 0 }, /* (53) ifnotexists ::= */
+ { 190, -3 }, /* (54) cmd ::= CREATE DNODE ids */
+ { 190, -6 }, /* (55) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */
+ { 190, -5 }, /* (56) cmd ::= CREATE DATABASE ifnotexists ids db_optr */
+ { 190, -5 }, /* (57) cmd ::= CREATE TOPIC ifnotexists ids topic_optr */
+ { 190, -5 }, /* (58) cmd ::= CREATE USER ids PASS ids */
+ { 201, 0 }, /* (59) pps ::= */
+ { 201, -2 }, /* (60) pps ::= PPS INTEGER */
+ { 202, 0 }, /* (61) tseries ::= */
+ { 202, -2 }, /* (62) tseries ::= TSERIES INTEGER */
+ { 203, 0 }, /* (63) dbs ::= */
+ { 203, -2 }, /* (64) dbs ::= DBS INTEGER */
+ { 204, 0 }, /* (65) streams ::= */
+ { 204, -2 }, /* (66) streams ::= STREAMS INTEGER */
+ { 205, 0 }, /* (67) storage ::= */
+ { 205, -2 }, /* (68) storage ::= STORAGE INTEGER */
+ { 206, 0 }, /* (69) qtime ::= */
+ { 206, -2 }, /* (70) qtime ::= QTIME INTEGER */
+ { 207, 0 }, /* (71) users ::= */
+ { 207, -2 }, /* (72) users ::= USERS INTEGER */
+ { 208, 0 }, /* (73) conns ::= */
+ { 208, -2 }, /* (74) conns ::= CONNS INTEGER */
+ { 209, 0 }, /* (75) state ::= */
+ { 209, -2 }, /* (76) state ::= STATE ids */
+ { 197, -9 }, /* (77) acct_optr ::= pps tseries storage streams qtime dbs users conns state */
+ { 210, -2 }, /* (78) keep ::= KEEP tagitemlist */
+ { 212, -2 }, /* (79) cache ::= CACHE INTEGER */
+ { 213, -2 }, /* (80) replica ::= REPLICA INTEGER */
+ { 214, -2 }, /* (81) quorum ::= QUORUM INTEGER */
+ { 215, -2 }, /* (82) days ::= DAYS INTEGER */
+ { 216, -2 }, /* (83) minrows ::= MINROWS INTEGER */
+ { 217, -2 }, /* (84) maxrows ::= MAXROWS INTEGER */
+ { 218, -2 }, /* (85) blocks ::= BLOCKS INTEGER */
+ { 219, -2 }, /* (86) ctime ::= CTIME INTEGER */
+ { 220, -2 }, /* (87) wal ::= WAL INTEGER */
+ { 221, -2 }, /* (88) fsync ::= FSYNC INTEGER */
+ { 222, -2 }, /* (89) comp ::= COMP INTEGER */
+ { 223, -2 }, /* (90) prec ::= PRECISION STRING */
+ { 224, -2 }, /* (91) update ::= UPDATE INTEGER */
+ { 225, -2 }, /* (92) cachelast ::= CACHELAST INTEGER */
+ { 226, -2 }, /* (93) partitions ::= PARTITIONS INTEGER */
+ { 199, 0 }, /* (94) db_optr ::= */
+ { 199, -2 }, /* (95) db_optr ::= db_optr cache */
+ { 199, -2 }, /* (96) db_optr ::= db_optr replica */
+ { 199, -2 }, /* (97) db_optr ::= db_optr quorum */
+ { 199, -2 }, /* (98) db_optr ::= db_optr days */
+ { 199, -2 }, /* (99) db_optr ::= db_optr minrows */
+ { 199, -2 }, /* (100) db_optr ::= db_optr maxrows */
+ { 199, -2 }, /* (101) db_optr ::= db_optr blocks */
+ { 199, -2 }, /* (102) db_optr ::= db_optr ctime */
+ { 199, -2 }, /* (103) db_optr ::= db_optr wal */
+ { 199, -2 }, /* (104) db_optr ::= db_optr fsync */
+ { 199, -2 }, /* (105) db_optr ::= db_optr comp */
+ { 199, -2 }, /* (106) db_optr ::= db_optr prec */
+ { 199, -2 }, /* (107) db_optr ::= db_optr keep */
+ { 199, -2 }, /* (108) db_optr ::= db_optr update */
+ { 199, -2 }, /* (109) db_optr ::= db_optr cachelast */
+ { 200, -1 }, /* (110) topic_optr ::= db_optr */
+ { 200, -2 }, /* (111) topic_optr ::= topic_optr partitions */
+ { 195, 0 }, /* (112) alter_db_optr ::= */
+ { 195, -2 }, /* (113) alter_db_optr ::= alter_db_optr replica */
+ { 195, -2 }, /* (114) alter_db_optr ::= alter_db_optr quorum */
+ { 195, -2 }, /* (115) alter_db_optr ::= alter_db_optr keep */
+ { 195, -2 }, /* (116) alter_db_optr ::= alter_db_optr blocks */
+ { 195, -2 }, /* (117) alter_db_optr ::= alter_db_optr comp */
+ { 195, -2 }, /* (118) alter_db_optr ::= alter_db_optr wal */
+ { 195, -2 }, /* (119) alter_db_optr ::= alter_db_optr fsync */
+ { 195, -2 }, /* (120) alter_db_optr ::= alter_db_optr update */
+ { 195, -2 }, /* (121) alter_db_optr ::= alter_db_optr cachelast */
+ { 196, -1 }, /* (122) alter_topic_optr ::= alter_db_optr */
+ { 196, -2 }, /* (123) alter_topic_optr ::= alter_topic_optr partitions */
+ { 227, -1 }, /* (124) typename ::= ids */
+ { 227, -4 }, /* (125) typename ::= ids LP signed RP */
+ { 227, -2 }, /* (126) typename ::= ids UNSIGNED */
+ { 228, -1 }, /* (127) signed ::= INTEGER */
+ { 228, -2 }, /* (128) signed ::= PLUS INTEGER */
+ { 228, -2 }, /* (129) signed ::= MINUS INTEGER */
+ { 190, -3 }, /* (130) cmd ::= CREATE TABLE create_table_args */
+ { 190, -3 }, /* (131) cmd ::= CREATE TABLE create_stable_args */
+ { 190, -3 }, /* (132) cmd ::= CREATE STABLE create_stable_args */
+ { 190, -3 }, /* (133) cmd ::= CREATE TABLE create_table_list */
+ { 231, -1 }, /* (134) create_table_list ::= create_from_stable */
+ { 231, -2 }, /* (135) create_table_list ::= create_table_list create_from_stable */
+ { 229, -6 }, /* (136) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */
+ { 230, -10 }, /* (137) create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */
+ { 232, -10 }, /* (138) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */
+ { 232, -13 }, /* (139) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */
+ { 234, -3 }, /* (140) tagNamelist ::= tagNamelist COMMA ids */
+ { 234, -1 }, /* (141) tagNamelist ::= ids */
+ { 229, -5 }, /* (142) create_table_args ::= ifnotexists ids cpxName AS select */
+ { 233, -3 }, /* (143) columnlist ::= columnlist COMMA column */
+ { 233, -1 }, /* (144) columnlist ::= column */
+ { 236, -2 }, /* (145) column ::= ids typename */
+ { 211, -3 }, /* (146) tagitemlist ::= tagitemlist COMMA tagitem */
+ { 211, -1 }, /* (147) tagitemlist ::= tagitem */
+ { 237, -1 }, /* (148) tagitem ::= INTEGER */
+ { 237, -1 }, /* (149) tagitem ::= FLOAT */
+ { 237, -1 }, /* (150) tagitem ::= STRING */
+ { 237, -1 }, /* (151) tagitem ::= BOOL */
+ { 237, -1 }, /* (152) tagitem ::= NULL */
+ { 237, -2 }, /* (153) tagitem ::= MINUS INTEGER */
+ { 237, -2 }, /* (154) tagitem ::= MINUS FLOAT */
+ { 237, -2 }, /* (155) tagitem ::= PLUS INTEGER */
+ { 237, -2 }, /* (156) tagitem ::= PLUS FLOAT */
+ { 235, -14 }, /* (157) select ::= SELECT selcollist from where_opt interval_opt session_option windowstate_option fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */
+ { 235, -3 }, /* (158) select ::= LP select RP */
+ { 251, -1 }, /* (159) union ::= select */
+ { 251, -4 }, /* (160) union ::= union UNION ALL select */
+ { 190, -1 }, /* (161) cmd ::= union */
+ { 235, -2 }, /* (162) select ::= SELECT selcollist */
+ { 252, -2 }, /* (163) sclp ::= selcollist COMMA */
+ { 252, 0 }, /* (164) sclp ::= */
+ { 238, -4 }, /* (165) selcollist ::= sclp distinct expr as */
+ { 238, -2 }, /* (166) selcollist ::= sclp STAR */
+ { 255, -2 }, /* (167) as ::= AS ids */
+ { 255, -1 }, /* (168) as ::= ids */
+ { 255, 0 }, /* (169) as ::= */
+ { 253, -1 }, /* (170) distinct ::= DISTINCT */
+ { 253, 0 }, /* (171) distinct ::= */
+ { 239, -2 }, /* (172) from ::= FROM tablelist */
+ { 239, -2 }, /* (173) from ::= FROM sub */
+ { 257, -3 }, /* (174) sub ::= LP union RP */
+ { 257, -4 }, /* (175) sub ::= LP union RP ids */
+ { 257, -6 }, /* (176) sub ::= sub COMMA LP union RP ids */
+ { 256, -2 }, /* (177) tablelist ::= ids cpxName */
+ { 256, -3 }, /* (178) tablelist ::= ids cpxName ids */
+ { 256, -4 }, /* (179) tablelist ::= tablelist COMMA ids cpxName */
+ { 256, -5 }, /* (180) tablelist ::= tablelist COMMA ids cpxName ids */
+ { 258, -1 }, /* (181) tmvar ::= VARIABLE */
+ { 241, -4 }, /* (182) interval_opt ::= INTERVAL LP tmvar RP */
+ { 241, -6 }, /* (183) interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */
+ { 241, 0 }, /* (184) interval_opt ::= */
+ { 242, 0 }, /* (185) session_option ::= */
+ { 242, -7 }, /* (186) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */
+ { 243, 0 }, /* (187) windowstate_option ::= */
+ { 243, -4 }, /* (188) windowstate_option ::= STATE_WINDOW LP ids RP */
+ { 244, 0 }, /* (189) fill_opt ::= */
+ { 244, -6 }, /* (190) fill_opt ::= FILL LP ID COMMA tagitemlist RP */
+ { 244, -4 }, /* (191) fill_opt ::= FILL LP ID RP */
+ { 245, -4 }, /* (192) sliding_opt ::= SLIDING LP tmvar RP */
+ { 245, 0 }, /* (193) sliding_opt ::= */
+ { 247, 0 }, /* (194) orderby_opt ::= */
+ { 247, -3 }, /* (195) orderby_opt ::= ORDER BY sortlist */
+ { 259, -4 }, /* (196) sortlist ::= sortlist COMMA item sortorder */
+ { 259, -2 }, /* (197) sortlist ::= item sortorder */
+ { 261, -2 }, /* (198) item ::= ids cpxName */
+ { 262, -1 }, /* (199) sortorder ::= ASC */
+ { 262, -1 }, /* (200) sortorder ::= DESC */
+ { 262, 0 }, /* (201) sortorder ::= */
+ { 246, 0 }, /* (202) groupby_opt ::= */
+ { 246, -3 }, /* (203) groupby_opt ::= GROUP BY grouplist */
+ { 263, -3 }, /* (204) grouplist ::= grouplist COMMA item */
+ { 263, -1 }, /* (205) grouplist ::= item */
+ { 248, 0 }, /* (206) having_opt ::= */
+ { 248, -2 }, /* (207) having_opt ::= HAVING expr */
+ { 250, 0 }, /* (208) limit_opt ::= */
+ { 250, -2 }, /* (209) limit_opt ::= LIMIT signed */
+ { 250, -4 }, /* (210) limit_opt ::= LIMIT signed OFFSET signed */
+ { 250, -4 }, /* (211) limit_opt ::= LIMIT signed COMMA signed */
+ { 249, 0 }, /* (212) slimit_opt ::= */
+ { 249, -2 }, /* (213) slimit_opt ::= SLIMIT signed */
+ { 249, -4 }, /* (214) slimit_opt ::= SLIMIT signed SOFFSET signed */
+ { 249, -4 }, /* (215) slimit_opt ::= SLIMIT signed COMMA signed */
+ { 240, 0 }, /* (216) where_opt ::= */
+ { 240, -2 }, /* (217) where_opt ::= WHERE expr */
+ { 254, -3 }, /* (218) expr ::= LP expr RP */
+ { 254, -1 }, /* (219) expr ::= ID */
+ { 254, -3 }, /* (220) expr ::= ID DOT ID */
+ { 254, -3 }, /* (221) expr ::= ID DOT STAR */
+ { 254, -1 }, /* (222) expr ::= INTEGER */
+ { 254, -2 }, /* (223) expr ::= MINUS INTEGER */
+ { 254, -2 }, /* (224) expr ::= PLUS INTEGER */
+ { 254, -1 }, /* (225) expr ::= FLOAT */
+ { 254, -2 }, /* (226) expr ::= MINUS FLOAT */
+ { 254, -2 }, /* (227) expr ::= PLUS FLOAT */
+ { 254, -1 }, /* (228) expr ::= STRING */
+ { 254, -1 }, /* (229) expr ::= NOW */
+ { 254, -1 }, /* (230) expr ::= VARIABLE */
+ { 254, -2 }, /* (231) expr ::= PLUS VARIABLE */
+ { 254, -2 }, /* (232) expr ::= MINUS VARIABLE */
+ { 254, -1 }, /* (233) expr ::= BOOL */
+ { 254, -1 }, /* (234) expr ::= NULL */
+ { 254, -4 }, /* (235) expr ::= ID LP exprlist RP */
+ { 254, -4 }, /* (236) expr ::= ID LP STAR RP */
+ { 254, -3 }, /* (237) expr ::= expr IS NULL */
+ { 254, -4 }, /* (238) expr ::= expr IS NOT NULL */
+ { 254, -3 }, /* (239) expr ::= expr LT expr */
+ { 254, -3 }, /* (240) expr ::= expr GT expr */
+ { 254, -3 }, /* (241) expr ::= expr LE expr */
+ { 254, -3 }, /* (242) expr ::= expr GE expr */
+ { 254, -3 }, /* (243) expr ::= expr NE expr */
+ { 254, -3 }, /* (244) expr ::= expr EQ expr */
+ { 254, -5 }, /* (245) expr ::= expr BETWEEN expr AND expr */
+ { 254, -3 }, /* (246) expr ::= expr AND expr */
+ { 254, -3 }, /* (247) expr ::= expr OR expr */
+ { 254, -3 }, /* (248) expr ::= expr PLUS expr */
+ { 254, -3 }, /* (249) expr ::= expr MINUS expr */
+ { 254, -3 }, /* (250) expr ::= expr STAR expr */
+ { 254, -3 }, /* (251) expr ::= expr SLASH expr */
+ { 254, -3 }, /* (252) expr ::= expr REM expr */
+ { 254, -3 }, /* (253) expr ::= expr LIKE expr */
+ { 254, -5 }, /* (254) expr ::= expr IN LP exprlist RP */
+ { 264, -3 }, /* (255) exprlist ::= exprlist COMMA expritem */
+ { 264, -1 }, /* (256) exprlist ::= expritem */
+ { 265, -1 }, /* (257) expritem ::= expr */
+ { 265, 0 }, /* (258) expritem ::= */
+ { 190, -3 }, /* (259) cmd ::= RESET QUERY CACHE */
+ { 190, -3 }, /* (260) cmd ::= SYNCDB ids REPLICA */
+ { 190, -7 }, /* (261) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */
+ { 190, -7 }, /* (262) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */
+ { 190, -7 }, /* (263) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */
+ { 190, -7 }, /* (264) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */
+ { 190, -8 }, /* (265) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */
+ { 190, -9 }, /* (266) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */
+ { 190, -7 }, /* (267) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */
+ { 190, -7 }, /* (268) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */
+ { 190, -7 }, /* (269) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */
+ { 190, -7 }, /* (270) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */
+ { 190, -8 }, /* (271) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */
+ { 190, -3 }, /* (272) cmd ::= KILL CONNECTION INTEGER */
+ { 190, -5 }, /* (273) cmd ::= KILL STREAM INTEGER COLON INTEGER */
+ { 190, -5 }, /* (274) cmd ::= KILL QUERY INTEGER COLON INTEGER */
};
static void yy_accept(yyParser*); /* Forward Declaration */
@@ -2290,13 +2298,13 @@ static void yy_reduce(
break;
case 44: /* cmd ::= ALTER DATABASE ids alter_db_optr */
case 45: /* cmd ::= ALTER TOPIC ids alter_topic_optr */ yytestcase(yyruleno==45);
-{ SStrToken t = {0}; setCreateDbInfo(pInfo, TSDB_SQL_ALTER_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy526, &t);}
+{ SStrToken t = {0}; setCreateDbInfo(pInfo, TSDB_SQL_ALTER_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy114, &t);}
break;
case 46: /* cmd ::= ALTER ACCOUNT ids acct_optr */
-{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-1].minor.yy0, NULL, &yymsp[0].minor.yy187);}
+{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-1].minor.yy0, NULL, &yymsp[0].minor.yy183);}
break;
case 47: /* cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */
-{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy187);}
+{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy183);}
break;
case 48: /* ids ::= ID */
case 49: /* ids ::= STRING */ yytestcase(yyruleno==49);
@@ -2318,11 +2326,11 @@ static void yy_reduce(
{ setDCLSqlElems(pInfo, TSDB_SQL_CREATE_DNODE, 1, &yymsp[0].minor.yy0);}
break;
case 55: /* cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */
-{ setCreateAcctSql(pInfo, TSDB_SQL_CREATE_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy187);}
+{ setCreateAcctSql(pInfo, TSDB_SQL_CREATE_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy183);}
break;
case 56: /* cmd ::= CREATE DATABASE ifnotexists ids db_optr */
case 57: /* cmd ::= CREATE TOPIC ifnotexists ids topic_optr */ yytestcase(yyruleno==57);
-{ setCreateDbInfo(pInfo, TSDB_SQL_CREATE_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy526, &yymsp[-2].minor.yy0);}
+{ setCreateDbInfo(pInfo, TSDB_SQL_CREATE_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy114, &yymsp[-2].minor.yy0);}
break;
case 58: /* cmd ::= CREATE USER ids PASS ids */
{ setCreateUserSql(pInfo, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);}
@@ -2351,20 +2359,20 @@ static void yy_reduce(
break;
case 77: /* acct_optr ::= pps tseries storage streams qtime dbs users conns state */
{
- yylhsminor.yy187.maxUsers = (yymsp[-2].minor.yy0.n>0)?atoi(yymsp[-2].minor.yy0.z):-1;
- yylhsminor.yy187.maxDbs = (yymsp[-3].minor.yy0.n>0)?atoi(yymsp[-3].minor.yy0.z):-1;
- yylhsminor.yy187.maxTimeSeries = (yymsp[-7].minor.yy0.n>0)?atoi(yymsp[-7].minor.yy0.z):-1;
- yylhsminor.yy187.maxStreams = (yymsp[-5].minor.yy0.n>0)?atoi(yymsp[-5].minor.yy0.z):-1;
- yylhsminor.yy187.maxPointsPerSecond = (yymsp[-8].minor.yy0.n>0)?atoi(yymsp[-8].minor.yy0.z):-1;
- yylhsminor.yy187.maxStorage = (yymsp[-6].minor.yy0.n>0)?strtoll(yymsp[-6].minor.yy0.z, NULL, 10):-1;
- yylhsminor.yy187.maxQueryTime = (yymsp[-4].minor.yy0.n>0)?strtoll(yymsp[-4].minor.yy0.z, NULL, 10):-1;
- yylhsminor.yy187.maxConnections = (yymsp[-1].minor.yy0.n>0)?atoi(yymsp[-1].minor.yy0.z):-1;
- yylhsminor.yy187.stat = yymsp[0].minor.yy0;
+ yylhsminor.yy183.maxUsers = (yymsp[-2].minor.yy0.n>0)?atoi(yymsp[-2].minor.yy0.z):-1;
+ yylhsminor.yy183.maxDbs = (yymsp[-3].minor.yy0.n>0)?atoi(yymsp[-3].minor.yy0.z):-1;
+ yylhsminor.yy183.maxTimeSeries = (yymsp[-7].minor.yy0.n>0)?atoi(yymsp[-7].minor.yy0.z):-1;
+ yylhsminor.yy183.maxStreams = (yymsp[-5].minor.yy0.n>0)?atoi(yymsp[-5].minor.yy0.z):-1;
+ yylhsminor.yy183.maxPointsPerSecond = (yymsp[-8].minor.yy0.n>0)?atoi(yymsp[-8].minor.yy0.z):-1;
+ yylhsminor.yy183.maxStorage = (yymsp[-6].minor.yy0.n>0)?strtoll(yymsp[-6].minor.yy0.z, NULL, 10):-1;
+ yylhsminor.yy183.maxQueryTime = (yymsp[-4].minor.yy0.n>0)?strtoll(yymsp[-4].minor.yy0.z, NULL, 10):-1;
+ yylhsminor.yy183.maxConnections = (yymsp[-1].minor.yy0.n>0)?atoi(yymsp[-1].minor.yy0.z):-1;
+ yylhsminor.yy183.stat = yymsp[0].minor.yy0;
}
- yymsp[-8].minor.yy187 = yylhsminor.yy187;
+ yymsp[-8].minor.yy183 = yylhsminor.yy183;
break;
case 78: /* keep ::= KEEP tagitemlist */
-{ yymsp[-1].minor.yy285 = yymsp[0].minor.yy285; }
+{ yymsp[-1].minor.yy193 = yymsp[0].minor.yy193; }
break;
case 79: /* cache ::= CACHE INTEGER */
case 80: /* replica ::= REPLICA INTEGER */ yytestcase(yyruleno==80);
@@ -2384,234 +2392,234 @@ static void yy_reduce(
{ yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; }
break;
case 94: /* db_optr ::= */
-{setDefaultCreateDbOption(&yymsp[1].minor.yy526); yymsp[1].minor.yy526.dbType = TSDB_DB_TYPE_DEFAULT;}
+{setDefaultCreateDbOption(&yymsp[1].minor.yy114); yymsp[1].minor.yy114.dbType = TSDB_DB_TYPE_DEFAULT;}
break;
case 95: /* db_optr ::= db_optr cache */
-{ yylhsminor.yy526 = yymsp[-1].minor.yy526; yylhsminor.yy526.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
- yymsp[-1].minor.yy526 = yylhsminor.yy526;
+{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
+ yymsp[-1].minor.yy114 = yylhsminor.yy114;
break;
case 96: /* db_optr ::= db_optr replica */
case 113: /* alter_db_optr ::= alter_db_optr replica */ yytestcase(yyruleno==113);
-{ yylhsminor.yy526 = yymsp[-1].minor.yy526; yylhsminor.yy526.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
- yymsp[-1].minor.yy526 = yylhsminor.yy526;
+{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
+ yymsp[-1].minor.yy114 = yylhsminor.yy114;
break;
case 97: /* db_optr ::= db_optr quorum */
case 114: /* alter_db_optr ::= alter_db_optr quorum */ yytestcase(yyruleno==114);
-{ yylhsminor.yy526 = yymsp[-1].minor.yy526; yylhsminor.yy526.quorum = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
- yymsp[-1].minor.yy526 = yylhsminor.yy526;
+{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.quorum = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
+ yymsp[-1].minor.yy114 = yylhsminor.yy114;
break;
case 98: /* db_optr ::= db_optr days */
-{ yylhsminor.yy526 = yymsp[-1].minor.yy526; yylhsminor.yy526.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
- yymsp[-1].minor.yy526 = yylhsminor.yy526;
+{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
+ yymsp[-1].minor.yy114 = yylhsminor.yy114;
break;
case 99: /* db_optr ::= db_optr minrows */
-{ yylhsminor.yy526 = yymsp[-1].minor.yy526; yylhsminor.yy526.minRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); }
- yymsp[-1].minor.yy526 = yylhsminor.yy526;
+{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.minRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); }
+ yymsp[-1].minor.yy114 = yylhsminor.yy114;
break;
case 100: /* db_optr ::= db_optr maxrows */
-{ yylhsminor.yy526 = yymsp[-1].minor.yy526; yylhsminor.yy526.maxRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); }
- yymsp[-1].minor.yy526 = yylhsminor.yy526;
+{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.maxRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); }
+ yymsp[-1].minor.yy114 = yylhsminor.yy114;
break;
case 101: /* db_optr ::= db_optr blocks */
case 116: /* alter_db_optr ::= alter_db_optr blocks */ yytestcase(yyruleno==116);
-{ yylhsminor.yy526 = yymsp[-1].minor.yy526; yylhsminor.yy526.numOfBlocks = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
- yymsp[-1].minor.yy526 = yylhsminor.yy526;
+{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.numOfBlocks = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
+ yymsp[-1].minor.yy114 = yylhsminor.yy114;
break;
case 102: /* db_optr ::= db_optr ctime */
-{ yylhsminor.yy526 = yymsp[-1].minor.yy526; yylhsminor.yy526.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
- yymsp[-1].minor.yy526 = yylhsminor.yy526;
+{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
+ yymsp[-1].minor.yy114 = yylhsminor.yy114;
break;
case 103: /* db_optr ::= db_optr wal */
case 118: /* alter_db_optr ::= alter_db_optr wal */ yytestcase(yyruleno==118);
-{ yylhsminor.yy526 = yymsp[-1].minor.yy526; yylhsminor.yy526.walLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
- yymsp[-1].minor.yy526 = yylhsminor.yy526;
+{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.walLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
+ yymsp[-1].minor.yy114 = yylhsminor.yy114;
break;
case 104: /* db_optr ::= db_optr fsync */
case 119: /* alter_db_optr ::= alter_db_optr fsync */ yytestcase(yyruleno==119);
-{ yylhsminor.yy526 = yymsp[-1].minor.yy526; yylhsminor.yy526.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
- yymsp[-1].minor.yy526 = yylhsminor.yy526;
+{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
+ yymsp[-1].minor.yy114 = yylhsminor.yy114;
break;
case 105: /* db_optr ::= db_optr comp */
case 117: /* alter_db_optr ::= alter_db_optr comp */ yytestcase(yyruleno==117);
-{ yylhsminor.yy526 = yymsp[-1].minor.yy526; yylhsminor.yy526.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
- yymsp[-1].minor.yy526 = yylhsminor.yy526;
+{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
+ yymsp[-1].minor.yy114 = yylhsminor.yy114;
break;
case 106: /* db_optr ::= db_optr prec */
-{ yylhsminor.yy526 = yymsp[-1].minor.yy526; yylhsminor.yy526.precision = yymsp[0].minor.yy0; }
- yymsp[-1].minor.yy526 = yylhsminor.yy526;
+{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.precision = yymsp[0].minor.yy0; }
+ yymsp[-1].minor.yy114 = yylhsminor.yy114;
break;
case 107: /* db_optr ::= db_optr keep */
case 115: /* alter_db_optr ::= alter_db_optr keep */ yytestcase(yyruleno==115);
-{ yylhsminor.yy526 = yymsp[-1].minor.yy526; yylhsminor.yy526.keep = yymsp[0].minor.yy285; }
- yymsp[-1].minor.yy526 = yylhsminor.yy526;
+{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.keep = yymsp[0].minor.yy193; }
+ yymsp[-1].minor.yy114 = yylhsminor.yy114;
break;
case 108: /* db_optr ::= db_optr update */
case 120: /* alter_db_optr ::= alter_db_optr update */ yytestcase(yyruleno==120);
-{ yylhsminor.yy526 = yymsp[-1].minor.yy526; yylhsminor.yy526.update = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
- yymsp[-1].minor.yy526 = yylhsminor.yy526;
+{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.update = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
+ yymsp[-1].minor.yy114 = yylhsminor.yy114;
break;
case 109: /* db_optr ::= db_optr cachelast */
case 121: /* alter_db_optr ::= alter_db_optr cachelast */ yytestcase(yyruleno==121);
-{ yylhsminor.yy526 = yymsp[-1].minor.yy526; yylhsminor.yy526.cachelast = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
- yymsp[-1].minor.yy526 = yylhsminor.yy526;
+{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.cachelast = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
+ yymsp[-1].minor.yy114 = yylhsminor.yy114;
break;
case 110: /* topic_optr ::= db_optr */
case 122: /* alter_topic_optr ::= alter_db_optr */ yytestcase(yyruleno==122);
-{ yylhsminor.yy526 = yymsp[0].minor.yy526; yylhsminor.yy526.dbType = TSDB_DB_TYPE_TOPIC; }
- yymsp[0].minor.yy526 = yylhsminor.yy526;
+{ yylhsminor.yy114 = yymsp[0].minor.yy114; yylhsminor.yy114.dbType = TSDB_DB_TYPE_TOPIC; }
+ yymsp[0].minor.yy114 = yylhsminor.yy114;
break;
case 111: /* topic_optr ::= topic_optr partitions */
case 123: /* alter_topic_optr ::= alter_topic_optr partitions */ yytestcase(yyruleno==123);
-{ yylhsminor.yy526 = yymsp[-1].minor.yy526; yylhsminor.yy526.partitions = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
- yymsp[-1].minor.yy526 = yylhsminor.yy526;
+{ yylhsminor.yy114 = yymsp[-1].minor.yy114; yylhsminor.yy114.partitions = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
+ yymsp[-1].minor.yy114 = yylhsminor.yy114;
break;
case 112: /* alter_db_optr ::= */
-{ setDefaultCreateDbOption(&yymsp[1].minor.yy526); yymsp[1].minor.yy526.dbType = TSDB_DB_TYPE_DEFAULT;}
+{ setDefaultCreateDbOption(&yymsp[1].minor.yy114); yymsp[1].minor.yy114.dbType = TSDB_DB_TYPE_DEFAULT;}
break;
case 124: /* typename ::= ids */
{
yymsp[0].minor.yy0.type = 0;
- tSetColumnType (&yylhsminor.yy295, &yymsp[0].minor.yy0);
+ tSetColumnType (&yylhsminor.yy27, &yymsp[0].minor.yy0);
}
- yymsp[0].minor.yy295 = yylhsminor.yy295;
+ yymsp[0].minor.yy27 = yylhsminor.yy27;
break;
case 125: /* typename ::= ids LP signed RP */
{
- if (yymsp[-1].minor.yy525 <= 0) {
+ if (yymsp[-1].minor.yy473 <= 0) {
yymsp[-3].minor.yy0.type = 0;
- tSetColumnType(&yylhsminor.yy295, &yymsp[-3].minor.yy0);
+ tSetColumnType(&yylhsminor.yy27, &yymsp[-3].minor.yy0);
} else {
- yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy525; // negative value of name length
- tSetColumnType(&yylhsminor.yy295, &yymsp[-3].minor.yy0);
+ yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy473; // negative value of name length
+ tSetColumnType(&yylhsminor.yy27, &yymsp[-3].minor.yy0);
}
}
- yymsp[-3].minor.yy295 = yylhsminor.yy295;
+ yymsp[-3].minor.yy27 = yylhsminor.yy27;
break;
case 126: /* typename ::= ids UNSIGNED */
{
yymsp[-1].minor.yy0.type = 0;
yymsp[-1].minor.yy0.n = ((yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z);
- tSetColumnType (&yylhsminor.yy295, &yymsp[-1].minor.yy0);
+ tSetColumnType (&yylhsminor.yy27, &yymsp[-1].minor.yy0);
}
- yymsp[-1].minor.yy295 = yylhsminor.yy295;
+ yymsp[-1].minor.yy27 = yylhsminor.yy27;
break;
case 127: /* signed ::= INTEGER */
-{ yylhsminor.yy525 = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
- yymsp[0].minor.yy525 = yylhsminor.yy525;
+{ yylhsminor.yy473 = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
+ yymsp[0].minor.yy473 = yylhsminor.yy473;
break;
case 128: /* signed ::= PLUS INTEGER */
-{ yymsp[-1].minor.yy525 = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
+{ yymsp[-1].minor.yy473 = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
break;
case 129: /* signed ::= MINUS INTEGER */
-{ yymsp[-1].minor.yy525 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);}
+{ yymsp[-1].minor.yy473 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);}
break;
case 133: /* cmd ::= CREATE TABLE create_table_list */
-{ pInfo->type = TSDB_SQL_CREATE_TABLE; pInfo->pCreateTableInfo = yymsp[0].minor.yy470;}
+{ pInfo->type = TSDB_SQL_CREATE_TABLE; pInfo->pCreateTableInfo = yymsp[0].minor.yy270;}
break;
case 134: /* create_table_list ::= create_from_stable */
{
SCreateTableSql* pCreateTable = calloc(1, sizeof(SCreateTableSql));
pCreateTable->childTableInfo = taosArrayInit(4, sizeof(SCreatedTableInfo));
- taosArrayPush(pCreateTable->childTableInfo, &yymsp[0].minor.yy96);
+ taosArrayPush(pCreateTable->childTableInfo, &yymsp[0].minor.yy192);
pCreateTable->type = TSQL_CREATE_TABLE_FROM_STABLE;
- yylhsminor.yy470 = pCreateTable;
+ yylhsminor.yy270 = pCreateTable;
}
- yymsp[0].minor.yy470 = yylhsminor.yy470;
+ yymsp[0].minor.yy270 = yylhsminor.yy270;
break;
case 135: /* create_table_list ::= create_table_list create_from_stable */
{
- taosArrayPush(yymsp[-1].minor.yy470->childTableInfo, &yymsp[0].minor.yy96);
- yylhsminor.yy470 = yymsp[-1].minor.yy470;
+ taosArrayPush(yymsp[-1].minor.yy270->childTableInfo, &yymsp[0].minor.yy192);
+ yylhsminor.yy270 = yymsp[-1].minor.yy270;
}
- yymsp[-1].minor.yy470 = yylhsminor.yy470;
+ yymsp[-1].minor.yy270 = yylhsminor.yy270;
break;
case 136: /* create_table_args ::= ifnotexists ids cpxName LP columnlist RP */
{
- yylhsminor.yy470 = tSetCreateTableInfo(yymsp[-1].minor.yy285, NULL, NULL, TSQL_CREATE_TABLE);
- setSqlInfo(pInfo, yylhsminor.yy470, NULL, TSDB_SQL_CREATE_TABLE);
+ yylhsminor.yy270 = tSetCreateTableInfo(yymsp[-1].minor.yy193, NULL, NULL, TSQL_CREATE_TABLE);
+ setSqlInfo(pInfo, yylhsminor.yy270, NULL, TSDB_SQL_CREATE_TABLE);
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
setCreatedTableName(pInfo, &yymsp[-4].minor.yy0, &yymsp[-5].minor.yy0);
}
- yymsp[-5].minor.yy470 = yylhsminor.yy470;
+ yymsp[-5].minor.yy270 = yylhsminor.yy270;
break;
case 137: /* create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */
{
- yylhsminor.yy470 = tSetCreateTableInfo(yymsp[-5].minor.yy285, yymsp[-1].minor.yy285, NULL, TSQL_CREATE_STABLE);
- setSqlInfo(pInfo, yylhsminor.yy470, NULL, TSDB_SQL_CREATE_TABLE);
+ yylhsminor.yy270 = tSetCreateTableInfo(yymsp[-5].minor.yy193, yymsp[-1].minor.yy193, NULL, TSQL_CREATE_STABLE);
+ setSqlInfo(pInfo, yylhsminor.yy270, NULL, TSDB_SQL_CREATE_TABLE);
yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n;
setCreatedTableName(pInfo, &yymsp[-8].minor.yy0, &yymsp[-9].minor.yy0);
}
- yymsp[-9].minor.yy470 = yylhsminor.yy470;
+ yymsp[-9].minor.yy270 = yylhsminor.yy270;
break;
case 138: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */
{
yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n;
yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n;
- yylhsminor.yy96 = createNewChildTableInfo(&yymsp[-5].minor.yy0, NULL, yymsp[-1].minor.yy285, &yymsp[-8].minor.yy0, &yymsp[-9].minor.yy0);
+ yylhsminor.yy192 = createNewChildTableInfo(&yymsp[-5].minor.yy0, NULL, yymsp[-1].minor.yy193, &yymsp[-8].minor.yy0, &yymsp[-9].minor.yy0);
}
- yymsp[-9].minor.yy96 = yylhsminor.yy96;
+ yymsp[-9].minor.yy192 = yylhsminor.yy192;
break;
case 139: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */
{
yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n;
yymsp[-11].minor.yy0.n += yymsp[-10].minor.yy0.n;
- yylhsminor.yy96 = createNewChildTableInfo(&yymsp[-8].minor.yy0, yymsp[-5].minor.yy285, yymsp[-1].minor.yy285, &yymsp[-11].minor.yy0, &yymsp[-12].minor.yy0);
+ yylhsminor.yy192 = createNewChildTableInfo(&yymsp[-8].minor.yy0, yymsp[-5].minor.yy193, yymsp[-1].minor.yy193, &yymsp[-11].minor.yy0, &yymsp[-12].minor.yy0);
}
- yymsp[-12].minor.yy96 = yylhsminor.yy96;
+ yymsp[-12].minor.yy192 = yylhsminor.yy192;
break;
case 140: /* tagNamelist ::= tagNamelist COMMA ids */
-{taosArrayPush(yymsp[-2].minor.yy285, &yymsp[0].minor.yy0); yylhsminor.yy285 = yymsp[-2].minor.yy285; }
- yymsp[-2].minor.yy285 = yylhsminor.yy285;
+{taosArrayPush(yymsp[-2].minor.yy193, &yymsp[0].minor.yy0); yylhsminor.yy193 = yymsp[-2].minor.yy193; }
+ yymsp[-2].minor.yy193 = yylhsminor.yy193;
break;
case 141: /* tagNamelist ::= ids */
-{yylhsminor.yy285 = taosArrayInit(4, sizeof(SStrToken)); taosArrayPush(yylhsminor.yy285, &yymsp[0].minor.yy0);}
- yymsp[0].minor.yy285 = yylhsminor.yy285;
+{yylhsminor.yy193 = taosArrayInit(4, sizeof(SStrToken)); taosArrayPush(yylhsminor.yy193, &yymsp[0].minor.yy0);}
+ yymsp[0].minor.yy193 = yylhsminor.yy193;
break;
case 142: /* create_table_args ::= ifnotexists ids cpxName AS select */
{
- yylhsminor.yy470 = tSetCreateTableInfo(NULL, NULL, yymsp[0].minor.yy344, TSQL_CREATE_STREAM);
- setSqlInfo(pInfo, yylhsminor.yy470, NULL, TSDB_SQL_CREATE_TABLE);
+ yylhsminor.yy270 = tSetCreateTableInfo(NULL, NULL, yymsp[0].minor.yy124, TSQL_CREATE_STREAM);
+ setSqlInfo(pInfo, yylhsminor.yy270, NULL, TSDB_SQL_CREATE_TABLE);
yymsp[-3].minor.yy0.n += yymsp[-2].minor.yy0.n;
setCreatedTableName(pInfo, &yymsp[-3].minor.yy0, &yymsp[-4].minor.yy0);
}
- yymsp[-4].minor.yy470 = yylhsminor.yy470;
+ yymsp[-4].minor.yy270 = yylhsminor.yy270;
break;
case 143: /* columnlist ::= columnlist COMMA column */
-{taosArrayPush(yymsp[-2].minor.yy285, &yymsp[0].minor.yy295); yylhsminor.yy285 = yymsp[-2].minor.yy285; }
- yymsp[-2].minor.yy285 = yylhsminor.yy285;
+{taosArrayPush(yymsp[-2].minor.yy193, &yymsp[0].minor.yy27); yylhsminor.yy193 = yymsp[-2].minor.yy193; }
+ yymsp[-2].minor.yy193 = yylhsminor.yy193;
break;
case 144: /* columnlist ::= column */
-{yylhsminor.yy285 = taosArrayInit(4, sizeof(TAOS_FIELD)); taosArrayPush(yylhsminor.yy285, &yymsp[0].minor.yy295);}
- yymsp[0].minor.yy285 = yylhsminor.yy285;
+{yylhsminor.yy193 = taosArrayInit(4, sizeof(TAOS_FIELD)); taosArrayPush(yylhsminor.yy193, &yymsp[0].minor.yy27);}
+ yymsp[0].minor.yy193 = yylhsminor.yy193;
break;
case 145: /* column ::= ids typename */
{
- tSetColumnInfo(&yylhsminor.yy295, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy295);
+ tSetColumnInfo(&yylhsminor.yy27, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy27);
}
- yymsp[-1].minor.yy295 = yylhsminor.yy295;
+ yymsp[-1].minor.yy27 = yylhsminor.yy27;
break;
case 146: /* tagitemlist ::= tagitemlist COMMA tagitem */
-{ yylhsminor.yy285 = tVariantListAppend(yymsp[-2].minor.yy285, &yymsp[0].minor.yy362, -1); }
- yymsp[-2].minor.yy285 = yylhsminor.yy285;
+{ yylhsminor.yy193 = tVariantListAppend(yymsp[-2].minor.yy193, &yymsp[0].minor.yy442, -1); }
+ yymsp[-2].minor.yy193 = yylhsminor.yy193;
break;
case 147: /* tagitemlist ::= tagitem */
-{ yylhsminor.yy285 = tVariantListAppend(NULL, &yymsp[0].minor.yy362, -1); }
- yymsp[0].minor.yy285 = yylhsminor.yy285;
+{ yylhsminor.yy193 = tVariantListAppend(NULL, &yymsp[0].minor.yy442, -1); }
+ yymsp[0].minor.yy193 = yylhsminor.yy193;
break;
case 148: /* tagitem ::= INTEGER */
case 149: /* tagitem ::= FLOAT */ yytestcase(yyruleno==149);
case 150: /* tagitem ::= STRING */ yytestcase(yyruleno==150);
case 151: /* tagitem ::= BOOL */ yytestcase(yyruleno==151);
-{ toTSDBType(yymsp[0].minor.yy0.type); tVariantCreate(&yylhsminor.yy362, &yymsp[0].minor.yy0); }
- yymsp[0].minor.yy362 = yylhsminor.yy362;
+{ toTSDBType(yymsp[0].minor.yy0.type); tVariantCreate(&yylhsminor.yy442, &yymsp[0].minor.yy0); }
+ yymsp[0].minor.yy442 = yylhsminor.yy442;
break;
case 152: /* tagitem ::= NULL */
-{ yymsp[0].minor.yy0.type = 0; tVariantCreate(&yylhsminor.yy362, &yymsp[0].minor.yy0); }
- yymsp[0].minor.yy362 = yylhsminor.yy362;
+{ yymsp[0].minor.yy0.type = 0; tVariantCreate(&yylhsminor.yy442, &yymsp[0].minor.yy0); }
+ yymsp[0].minor.yy442 = yylhsminor.yy442;
break;
case 153: /* tagitem ::= MINUS INTEGER */
case 154: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==154);
@@ -2621,56 +2629,56 @@ static void yy_reduce(
yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n;
yymsp[-1].minor.yy0.type = yymsp[0].minor.yy0.type;
toTSDBType(yymsp[-1].minor.yy0.type);
- tVariantCreate(&yylhsminor.yy362, &yymsp[-1].minor.yy0);
+ tVariantCreate(&yylhsminor.yy442, &yymsp[-1].minor.yy0);
}
- yymsp[-1].minor.yy362 = yylhsminor.yy362;
+ yymsp[-1].minor.yy442 = yylhsminor.yy442;
break;
- case 157: /* select ::= SELECT selcollist from where_opt interval_opt session_option fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */
+ case 157: /* select ::= SELECT selcollist from where_opt interval_opt session_option windowstate_option fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */
{
- yylhsminor.yy344 = tSetQuerySqlNode(&yymsp[-12].minor.yy0, yymsp[-11].minor.yy285, yymsp[-10].minor.yy148, yymsp[-9].minor.yy178, yymsp[-4].minor.yy285, yymsp[-3].minor.yy285, &yymsp[-8].minor.yy376, &yymsp[-7].minor.yy523, &yymsp[-5].minor.yy0, yymsp[-6].minor.yy285, &yymsp[0].minor.yy438, &yymsp[-1].minor.yy438, yymsp[-2].minor.yy178);
+ yylhsminor.yy124 = tSetQuerySqlNode(&yymsp[-13].minor.yy0, yymsp[-12].minor.yy193, yymsp[-11].minor.yy332, yymsp[-10].minor.yy454, yymsp[-4].minor.yy193, yymsp[-3].minor.yy193, &yymsp[-9].minor.yy392, &yymsp[-8].minor.yy447, &yymsp[-7].minor.yy76, &yymsp[-5].minor.yy0, yymsp[-6].minor.yy193, &yymsp[0].minor.yy482, &yymsp[-1].minor.yy482, yymsp[-2].minor.yy454);
}
- yymsp[-12].minor.yy344 = yylhsminor.yy344;
+ yymsp[-13].minor.yy124 = yylhsminor.yy124;
break;
case 158: /* select ::= LP select RP */
-{yymsp[-2].minor.yy344 = yymsp[-1].minor.yy344;}
+{yymsp[-2].minor.yy124 = yymsp[-1].minor.yy124;}
break;
case 159: /* union ::= select */
-{ yylhsminor.yy285 = setSubclause(NULL, yymsp[0].minor.yy344); }
- yymsp[0].minor.yy285 = yylhsminor.yy285;
+{ yylhsminor.yy193 = setSubclause(NULL, yymsp[0].minor.yy124); }
+ yymsp[0].minor.yy193 = yylhsminor.yy193;
break;
case 160: /* union ::= union UNION ALL select */
-{ yylhsminor.yy285 = appendSelectClause(yymsp[-3].minor.yy285, yymsp[0].minor.yy344); }
- yymsp[-3].minor.yy285 = yylhsminor.yy285;
+{ yylhsminor.yy193 = appendSelectClause(yymsp[-3].minor.yy193, yymsp[0].minor.yy124); }
+ yymsp[-3].minor.yy193 = yylhsminor.yy193;
break;
case 161: /* cmd ::= union */
-{ setSqlInfo(pInfo, yymsp[0].minor.yy285, NULL, TSDB_SQL_SELECT); }
+{ setSqlInfo(pInfo, yymsp[0].minor.yy193, NULL, TSDB_SQL_SELECT); }
break;
case 162: /* select ::= SELECT selcollist */
{
- yylhsminor.yy344 = tSetQuerySqlNode(&yymsp[-1].minor.yy0, yymsp[0].minor.yy285, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+ yylhsminor.yy124 = tSetQuerySqlNode(&yymsp[-1].minor.yy0, yymsp[0].minor.yy193, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
}
- yymsp[-1].minor.yy344 = yylhsminor.yy344;
+ yymsp[-1].minor.yy124 = yylhsminor.yy124;
break;
case 163: /* sclp ::= selcollist COMMA */
-{yylhsminor.yy285 = yymsp[-1].minor.yy285;}
- yymsp[-1].minor.yy285 = yylhsminor.yy285;
+{yylhsminor.yy193 = yymsp[-1].minor.yy193;}
+ yymsp[-1].minor.yy193 = yylhsminor.yy193;
break;
case 164: /* sclp ::= */
- case 192: /* orderby_opt ::= */ yytestcase(yyruleno==192);
-{yymsp[1].minor.yy285 = 0;}
+ case 194: /* orderby_opt ::= */ yytestcase(yyruleno==194);
+{yymsp[1].minor.yy193 = 0;}
break;
case 165: /* selcollist ::= sclp distinct expr as */
{
- yylhsminor.yy285 = tSqlExprListAppend(yymsp[-3].minor.yy285, yymsp[-1].minor.yy178, yymsp[-2].minor.yy0.n? &yymsp[-2].minor.yy0:0, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0);
+ yylhsminor.yy193 = tSqlExprListAppend(yymsp[-3].minor.yy193, yymsp[-1].minor.yy454, yymsp[-2].minor.yy0.n? &yymsp[-2].minor.yy0:0, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0);
}
- yymsp[-3].minor.yy285 = yylhsminor.yy285;
+ yymsp[-3].minor.yy193 = yylhsminor.yy193;
break;
case 166: /* selcollist ::= sclp STAR */
{
tSqlExpr *pNode = tSqlExprCreateIdValue(NULL, TK_ALL);
- yylhsminor.yy285 = tSqlExprListAppend(yymsp[-1].minor.yy285, pNode, 0, 0);
+ yylhsminor.yy193 = tSqlExprListAppend(yymsp[-1].minor.yy193, pNode, 0, 0);
}
- yymsp[-1].minor.yy285 = yylhsminor.yy285;
+ yymsp[-1].minor.yy193 = yylhsminor.yy193;
break;
case 167: /* as ::= AS ids */
{ yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; }
@@ -2688,339 +2696,347 @@ static void yy_reduce(
break;
case 172: /* from ::= FROM tablelist */
case 173: /* from ::= FROM sub */ yytestcase(yyruleno==173);
-{yymsp[-1].minor.yy148 = yymsp[0].minor.yy148;}
+{yymsp[-1].minor.yy332 = yymsp[0].minor.yy332;}
break;
case 174: /* sub ::= LP union RP */
-{yymsp[-2].minor.yy148 = addSubqueryElem(NULL, yymsp[-1].minor.yy285, NULL);}
+{yymsp[-2].minor.yy332 = addSubqueryElem(NULL, yymsp[-1].minor.yy193, NULL);}
break;
case 175: /* sub ::= LP union RP ids */
-{yymsp[-3].minor.yy148 = addSubqueryElem(NULL, yymsp[-2].minor.yy285, &yymsp[0].minor.yy0);}
+{yymsp[-3].minor.yy332 = addSubqueryElem(NULL, yymsp[-2].minor.yy193, &yymsp[0].minor.yy0);}
break;
case 176: /* sub ::= sub COMMA LP union RP ids */
-{yylhsminor.yy148 = addSubqueryElem(yymsp[-5].minor.yy148, yymsp[-2].minor.yy285, &yymsp[0].minor.yy0);}
- yymsp[-5].minor.yy148 = yylhsminor.yy148;
+{yylhsminor.yy332 = addSubqueryElem(yymsp[-5].minor.yy332, yymsp[-2].minor.yy193, &yymsp[0].minor.yy0);}
+ yymsp[-5].minor.yy332 = yylhsminor.yy332;
break;
case 177: /* tablelist ::= ids cpxName */
{
yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n;
- yylhsminor.yy148 = setTableNameList(NULL, &yymsp[-1].minor.yy0, NULL);
+ yylhsminor.yy332 = setTableNameList(NULL, &yymsp[-1].minor.yy0, NULL);
}
- yymsp[-1].minor.yy148 = yylhsminor.yy148;
+ yymsp[-1].minor.yy332 = yylhsminor.yy332;
break;
case 178: /* tablelist ::= ids cpxName ids */
{
yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n;
- yylhsminor.yy148 = setTableNameList(NULL, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
+ yylhsminor.yy332 = setTableNameList(NULL, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
}
- yymsp[-2].minor.yy148 = yylhsminor.yy148;
+ yymsp[-2].minor.yy332 = yylhsminor.yy332;
break;
case 179: /* tablelist ::= tablelist COMMA ids cpxName */
{
yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n;
- yylhsminor.yy148 = setTableNameList(yymsp[-3].minor.yy148, &yymsp[-1].minor.yy0, NULL);
+ yylhsminor.yy332 = setTableNameList(yymsp[-3].minor.yy332, &yymsp[-1].minor.yy0, NULL);
}
- yymsp[-3].minor.yy148 = yylhsminor.yy148;
+ yymsp[-3].minor.yy332 = yylhsminor.yy332;
break;
case 180: /* tablelist ::= tablelist COMMA ids cpxName ids */
{
yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n;
- yylhsminor.yy148 = setTableNameList(yymsp[-4].minor.yy148, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
+ yylhsminor.yy332 = setTableNameList(yymsp[-4].minor.yy332, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
}
- yymsp[-4].minor.yy148 = yylhsminor.yy148;
+ yymsp[-4].minor.yy332 = yylhsminor.yy332;
break;
case 181: /* tmvar ::= VARIABLE */
{yylhsminor.yy0 = yymsp[0].minor.yy0;}
yymsp[0].minor.yy0 = yylhsminor.yy0;
break;
case 182: /* interval_opt ::= INTERVAL LP tmvar RP */
-{yymsp[-3].minor.yy376.interval = yymsp[-1].minor.yy0; yymsp[-3].minor.yy376.offset.n = 0;}
+{yymsp[-3].minor.yy392.interval = yymsp[-1].minor.yy0; yymsp[-3].minor.yy392.offset.n = 0;}
break;
case 183: /* interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */
-{yymsp[-5].minor.yy376.interval = yymsp[-3].minor.yy0; yymsp[-5].minor.yy376.offset = yymsp[-1].minor.yy0;}
+{yymsp[-5].minor.yy392.interval = yymsp[-3].minor.yy0; yymsp[-5].minor.yy392.offset = yymsp[-1].minor.yy0;}
break;
case 184: /* interval_opt ::= */
-{memset(&yymsp[1].minor.yy376, 0, sizeof(yymsp[1].minor.yy376));}
+{memset(&yymsp[1].minor.yy392, 0, sizeof(yymsp[1].minor.yy392));}
break;
case 185: /* session_option ::= */
-{yymsp[1].minor.yy523.col.n = 0; yymsp[1].minor.yy523.gap.n = 0;}
+{yymsp[1].minor.yy447.col.n = 0; yymsp[1].minor.yy447.gap.n = 0;}
break;
case 186: /* session_option ::= SESSION LP ids cpxName COMMA tmvar RP */
{
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
- yymsp[-6].minor.yy523.col = yymsp[-4].minor.yy0;
- yymsp[-6].minor.yy523.gap = yymsp[-1].minor.yy0;
+ yymsp[-6].minor.yy447.col = yymsp[-4].minor.yy0;
+ yymsp[-6].minor.yy447.gap = yymsp[-1].minor.yy0;
}
break;
- case 187: /* fill_opt ::= */
-{ yymsp[1].minor.yy285 = 0; }
+ case 187: /* windowstate_option ::= */
+{yymsp[1].minor.yy76.col.n = 0;}
break;
- case 188: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */
+ case 188: /* windowstate_option ::= STATE_WINDOW LP ids RP */
+{
+ yymsp[-3].minor.yy76.col = yymsp[-1].minor.yy0;
+}
+ break;
+ case 189: /* fill_opt ::= */
+{ yymsp[1].minor.yy193 = 0; }
+ break;
+ case 190: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */
{
tVariant A = {0};
toTSDBType(yymsp[-3].minor.yy0.type);
tVariantCreate(&A, &yymsp[-3].minor.yy0);
- tVariantListInsert(yymsp[-1].minor.yy285, &A, -1, 0);
- yymsp[-5].minor.yy285 = yymsp[-1].minor.yy285;
+ tVariantListInsert(yymsp[-1].minor.yy193, &A, -1, 0);
+ yymsp[-5].minor.yy193 = yymsp[-1].minor.yy193;
}
break;
- case 189: /* fill_opt ::= FILL LP ID RP */
+ case 191: /* fill_opt ::= FILL LP ID RP */
{
toTSDBType(yymsp[-1].minor.yy0.type);
- yymsp[-3].minor.yy285 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1);
+ yymsp[-3].minor.yy193 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1);
}
break;
- case 190: /* sliding_opt ::= SLIDING LP tmvar RP */
+ case 192: /* sliding_opt ::= SLIDING LP tmvar RP */
{yymsp[-3].minor.yy0 = yymsp[-1].minor.yy0; }
break;
- case 191: /* sliding_opt ::= */
+ case 193: /* sliding_opt ::= */
{yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = NULL; yymsp[1].minor.yy0.type = 0; }
break;
- case 193: /* orderby_opt ::= ORDER BY sortlist */
-{yymsp[-2].minor.yy285 = yymsp[0].minor.yy285;}
+ case 195: /* orderby_opt ::= ORDER BY sortlist */
+{yymsp[-2].minor.yy193 = yymsp[0].minor.yy193;}
break;
- case 194: /* sortlist ::= sortlist COMMA item sortorder */
+ case 196: /* sortlist ::= sortlist COMMA item sortorder */
{
- yylhsminor.yy285 = tVariantListAppend(yymsp[-3].minor.yy285, &yymsp[-1].minor.yy362, yymsp[0].minor.yy460);
+ yylhsminor.yy193 = tVariantListAppend(yymsp[-3].minor.yy193, &yymsp[-1].minor.yy442, yymsp[0].minor.yy312);
}
- yymsp[-3].minor.yy285 = yylhsminor.yy285;
+ yymsp[-3].minor.yy193 = yylhsminor.yy193;
break;
- case 195: /* sortlist ::= item sortorder */
+ case 197: /* sortlist ::= item sortorder */
{
- yylhsminor.yy285 = tVariantListAppend(NULL, &yymsp[-1].minor.yy362, yymsp[0].minor.yy460);
+ yylhsminor.yy193 = tVariantListAppend(NULL, &yymsp[-1].minor.yy442, yymsp[0].minor.yy312);
}
- yymsp[-1].minor.yy285 = yylhsminor.yy285;
+ yymsp[-1].minor.yy193 = yylhsminor.yy193;
break;
- case 196: /* item ::= ids cpxName */
+ case 198: /* item ::= ids cpxName */
{
toTSDBType(yymsp[-1].minor.yy0.type);
yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n;
- tVariantCreate(&yylhsminor.yy362, &yymsp[-1].minor.yy0);
+ tVariantCreate(&yylhsminor.yy442, &yymsp[-1].minor.yy0);
}
- yymsp[-1].minor.yy362 = yylhsminor.yy362;
+ yymsp[-1].minor.yy442 = yylhsminor.yy442;
break;
- case 197: /* sortorder ::= ASC */
-{ yymsp[0].minor.yy460 = TSDB_ORDER_ASC; }
+ case 199: /* sortorder ::= ASC */
+{ yymsp[0].minor.yy312 = TSDB_ORDER_ASC; }
break;
- case 198: /* sortorder ::= DESC */
-{ yymsp[0].minor.yy460 = TSDB_ORDER_DESC;}
+ case 200: /* sortorder ::= DESC */
+{ yymsp[0].minor.yy312 = TSDB_ORDER_DESC;}
break;
- case 199: /* sortorder ::= */
-{ yymsp[1].minor.yy460 = TSDB_ORDER_ASC; }
+ case 201: /* sortorder ::= */
+{ yymsp[1].minor.yy312 = TSDB_ORDER_ASC; }
break;
- case 200: /* groupby_opt ::= */
-{ yymsp[1].minor.yy285 = 0;}
+ case 202: /* groupby_opt ::= */
+{ yymsp[1].minor.yy193 = 0;}
break;
- case 201: /* groupby_opt ::= GROUP BY grouplist */
-{ yymsp[-2].minor.yy285 = yymsp[0].minor.yy285;}
+ case 203: /* groupby_opt ::= GROUP BY grouplist */
+{ yymsp[-2].minor.yy193 = yymsp[0].minor.yy193;}
break;
- case 202: /* grouplist ::= grouplist COMMA item */
+ case 204: /* grouplist ::= grouplist COMMA item */
{
- yylhsminor.yy285 = tVariantListAppend(yymsp[-2].minor.yy285, &yymsp[0].minor.yy362, -1);
+ yylhsminor.yy193 = tVariantListAppend(yymsp[-2].minor.yy193, &yymsp[0].minor.yy442, -1);
}
- yymsp[-2].minor.yy285 = yylhsminor.yy285;
+ yymsp[-2].minor.yy193 = yylhsminor.yy193;
break;
- case 203: /* grouplist ::= item */
+ case 205: /* grouplist ::= item */
{
- yylhsminor.yy285 = tVariantListAppend(NULL, &yymsp[0].minor.yy362, -1);
+ yylhsminor.yy193 = tVariantListAppend(NULL, &yymsp[0].minor.yy442, -1);
}
- yymsp[0].minor.yy285 = yylhsminor.yy285;
+ yymsp[0].minor.yy193 = yylhsminor.yy193;
break;
- case 204: /* having_opt ::= */
- case 214: /* where_opt ::= */ yytestcase(yyruleno==214);
- case 256: /* expritem ::= */ yytestcase(yyruleno==256);
-{yymsp[1].minor.yy178 = 0;}
+ case 206: /* having_opt ::= */
+ case 216: /* where_opt ::= */ yytestcase(yyruleno==216);
+ case 258: /* expritem ::= */ yytestcase(yyruleno==258);
+{yymsp[1].minor.yy454 = 0;}
break;
- case 205: /* having_opt ::= HAVING expr */
- case 215: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==215);
-{yymsp[-1].minor.yy178 = yymsp[0].minor.yy178;}
+ case 207: /* having_opt ::= HAVING expr */
+ case 217: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==217);
+{yymsp[-1].minor.yy454 = yymsp[0].minor.yy454;}
break;
- case 206: /* limit_opt ::= */
- case 210: /* slimit_opt ::= */ yytestcase(yyruleno==210);
-{yymsp[1].minor.yy438.limit = -1; yymsp[1].minor.yy438.offset = 0;}
+ case 208: /* limit_opt ::= */
+ case 212: /* slimit_opt ::= */ yytestcase(yyruleno==212);
+{yymsp[1].minor.yy482.limit = -1; yymsp[1].minor.yy482.offset = 0;}
break;
- case 207: /* limit_opt ::= LIMIT signed */
- case 211: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==211);
-{yymsp[-1].minor.yy438.limit = yymsp[0].minor.yy525; yymsp[-1].minor.yy438.offset = 0;}
+ case 209: /* limit_opt ::= LIMIT signed */
+ case 213: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==213);
+{yymsp[-1].minor.yy482.limit = yymsp[0].minor.yy473; yymsp[-1].minor.yy482.offset = 0;}
break;
- case 208: /* limit_opt ::= LIMIT signed OFFSET signed */
-{ yymsp[-3].minor.yy438.limit = yymsp[-2].minor.yy525; yymsp[-3].minor.yy438.offset = yymsp[0].minor.yy525;}
+ case 210: /* limit_opt ::= LIMIT signed OFFSET signed */
+{ yymsp[-3].minor.yy482.limit = yymsp[-2].minor.yy473; yymsp[-3].minor.yy482.offset = yymsp[0].minor.yy473;}
break;
- case 209: /* limit_opt ::= LIMIT signed COMMA signed */
-{ yymsp[-3].minor.yy438.limit = yymsp[0].minor.yy525; yymsp[-3].minor.yy438.offset = yymsp[-2].minor.yy525;}
+ case 211: /* limit_opt ::= LIMIT signed COMMA signed */
+{ yymsp[-3].minor.yy482.limit = yymsp[0].minor.yy473; yymsp[-3].minor.yy482.offset = yymsp[-2].minor.yy473;}
break;
- case 212: /* slimit_opt ::= SLIMIT signed SOFFSET signed */
-{yymsp[-3].minor.yy438.limit = yymsp[-2].minor.yy525; yymsp[-3].minor.yy438.offset = yymsp[0].minor.yy525;}
+ case 214: /* slimit_opt ::= SLIMIT signed SOFFSET signed */
+{yymsp[-3].minor.yy482.limit = yymsp[-2].minor.yy473; yymsp[-3].minor.yy482.offset = yymsp[0].minor.yy473;}
break;
- case 213: /* slimit_opt ::= SLIMIT signed COMMA signed */
-{yymsp[-3].minor.yy438.limit = yymsp[0].minor.yy525; yymsp[-3].minor.yy438.offset = yymsp[-2].minor.yy525;}
+ case 215: /* slimit_opt ::= SLIMIT signed COMMA signed */
+{yymsp[-3].minor.yy482.limit = yymsp[0].minor.yy473; yymsp[-3].minor.yy482.offset = yymsp[-2].minor.yy473;}
break;
- case 216: /* expr ::= LP expr RP */
-{yylhsminor.yy178 = yymsp[-1].minor.yy178; yylhsminor.yy178->token.z = yymsp[-2].minor.yy0.z; yylhsminor.yy178->token.n = (yymsp[0].minor.yy0.z - yymsp[-2].minor.yy0.z + 1);}
- yymsp[-2].minor.yy178 = yylhsminor.yy178;
+ case 218: /* expr ::= LP expr RP */
+{yylhsminor.yy454 = yymsp[-1].minor.yy454; yylhsminor.yy454->token.z = yymsp[-2].minor.yy0.z; yylhsminor.yy454->token.n = (yymsp[0].minor.yy0.z - yymsp[-2].minor.yy0.z + 1);}
+ yymsp[-2].minor.yy454 = yylhsminor.yy454;
break;
- case 217: /* expr ::= ID */
-{ yylhsminor.yy178 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_ID);}
- yymsp[0].minor.yy178 = yylhsminor.yy178;
+ case 219: /* expr ::= ID */
+{ yylhsminor.yy454 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_ID);}
+ yymsp[0].minor.yy454 = yylhsminor.yy454;
break;
- case 218: /* expr ::= ID DOT ID */
-{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy178 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ID);}
- yymsp[-2].minor.yy178 = yylhsminor.yy178;
+ case 220: /* expr ::= ID DOT ID */
+{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy454 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ID);}
+ yymsp[-2].minor.yy454 = yylhsminor.yy454;
break;
- case 219: /* expr ::= ID DOT STAR */
-{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy178 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ALL);}
- yymsp[-2].minor.yy178 = yylhsminor.yy178;
+ case 221: /* expr ::= ID DOT STAR */
+{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy454 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ALL);}
+ yymsp[-2].minor.yy454 = yylhsminor.yy454;
break;
- case 220: /* expr ::= INTEGER */
-{ yylhsminor.yy178 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_INTEGER);}
- yymsp[0].minor.yy178 = yylhsminor.yy178;
+ case 222: /* expr ::= INTEGER */
+{ yylhsminor.yy454 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_INTEGER);}
+ yymsp[0].minor.yy454 = yylhsminor.yy454;
break;
- case 221: /* expr ::= MINUS INTEGER */
- case 222: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==222);
-{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy178 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_INTEGER);}
- yymsp[-1].minor.yy178 = yylhsminor.yy178;
+ case 223: /* expr ::= MINUS INTEGER */
+ case 224: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==224);
+{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy454 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_INTEGER);}
+ yymsp[-1].minor.yy454 = yylhsminor.yy454;
break;
- case 223: /* expr ::= FLOAT */
-{ yylhsminor.yy178 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_FLOAT);}
- yymsp[0].minor.yy178 = yylhsminor.yy178;
+ case 225: /* expr ::= FLOAT */
+{ yylhsminor.yy454 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_FLOAT);}
+ yymsp[0].minor.yy454 = yylhsminor.yy454;
break;
- case 224: /* expr ::= MINUS FLOAT */
- case 225: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==225);
-{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy178 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_FLOAT);}
- yymsp[-1].minor.yy178 = yylhsminor.yy178;
+ case 226: /* expr ::= MINUS FLOAT */
+ case 227: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==227);
+{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy454 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_FLOAT);}
+ yymsp[-1].minor.yy454 = yylhsminor.yy454;
break;
- case 226: /* expr ::= STRING */
-{ yylhsminor.yy178 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_STRING);}
- yymsp[0].minor.yy178 = yylhsminor.yy178;
+ case 228: /* expr ::= STRING */
+{ yylhsminor.yy454 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_STRING);}
+ yymsp[0].minor.yy454 = yylhsminor.yy454;
break;
- case 227: /* expr ::= NOW */
-{ yylhsminor.yy178 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NOW); }
- yymsp[0].minor.yy178 = yylhsminor.yy178;
+ case 229: /* expr ::= NOW */
+{ yylhsminor.yy454 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NOW); }
+ yymsp[0].minor.yy454 = yylhsminor.yy454;
break;
- case 228: /* expr ::= VARIABLE */
-{ yylhsminor.yy178 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_VARIABLE);}
- yymsp[0].minor.yy178 = yylhsminor.yy178;
+ case 230: /* expr ::= VARIABLE */
+{ yylhsminor.yy454 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_VARIABLE);}
+ yymsp[0].minor.yy454 = yylhsminor.yy454;
break;
- case 229: /* expr ::= PLUS VARIABLE */
- case 230: /* expr ::= MINUS VARIABLE */ yytestcase(yyruleno==230);
-{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_VARIABLE; yylhsminor.yy178 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_VARIABLE);}
- yymsp[-1].minor.yy178 = yylhsminor.yy178;
+ case 231: /* expr ::= PLUS VARIABLE */
+ case 232: /* expr ::= MINUS VARIABLE */ yytestcase(yyruleno==232);
+{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_VARIABLE; yylhsminor.yy454 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_VARIABLE);}
+ yymsp[-1].minor.yy454 = yylhsminor.yy454;
break;
- case 231: /* expr ::= BOOL */
-{ yylhsminor.yy178 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_BOOL);}
- yymsp[0].minor.yy178 = yylhsminor.yy178;
+ case 233: /* expr ::= BOOL */
+{ yylhsminor.yy454 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_BOOL);}
+ yymsp[0].minor.yy454 = yylhsminor.yy454;
break;
- case 232: /* expr ::= NULL */
-{ yylhsminor.yy178 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NULL);}
- yymsp[0].minor.yy178 = yylhsminor.yy178;
+ case 234: /* expr ::= NULL */
+{ yylhsminor.yy454 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NULL);}
+ yymsp[0].minor.yy454 = yylhsminor.yy454;
break;
- case 233: /* expr ::= ID LP exprlist RP */
-{ yylhsminor.yy178 = tSqlExprCreateFunction(yymsp[-1].minor.yy285, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); }
- yymsp[-3].minor.yy178 = yylhsminor.yy178;
+ case 235: /* expr ::= ID LP exprlist RP */
+{ yylhsminor.yy454 = tSqlExprCreateFunction(yymsp[-1].minor.yy193, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); }
+ yymsp[-3].minor.yy454 = yylhsminor.yy454;
break;
- case 234: /* expr ::= ID LP STAR RP */
-{ yylhsminor.yy178 = tSqlExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); }
- yymsp[-3].minor.yy178 = yylhsminor.yy178;
+ case 236: /* expr ::= ID LP STAR RP */
+{ yylhsminor.yy454 = tSqlExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); }
+ yymsp[-3].minor.yy454 = yylhsminor.yy454;
break;
- case 235: /* expr ::= expr IS NULL */
-{yylhsminor.yy178 = tSqlExprCreate(yymsp[-2].minor.yy178, NULL, TK_ISNULL);}
- yymsp[-2].minor.yy178 = yylhsminor.yy178;
+ case 237: /* expr ::= expr IS NULL */
+{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, NULL, TK_ISNULL);}
+ yymsp[-2].minor.yy454 = yylhsminor.yy454;
break;
- case 236: /* expr ::= expr IS NOT NULL */
-{yylhsminor.yy178 = tSqlExprCreate(yymsp[-3].minor.yy178, NULL, TK_NOTNULL);}
- yymsp[-3].minor.yy178 = yylhsminor.yy178;
+ case 238: /* expr ::= expr IS NOT NULL */
+{yylhsminor.yy454 = tSqlExprCreate(yymsp[-3].minor.yy454, NULL, TK_NOTNULL);}
+ yymsp[-3].minor.yy454 = yylhsminor.yy454;
break;
- case 237: /* expr ::= expr LT expr */
-{yylhsminor.yy178 = tSqlExprCreate(yymsp[-2].minor.yy178, yymsp[0].minor.yy178, TK_LT);}
- yymsp[-2].minor.yy178 = yylhsminor.yy178;
+ case 239: /* expr ::= expr LT expr */
+{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, yymsp[0].minor.yy454, TK_LT);}
+ yymsp[-2].minor.yy454 = yylhsminor.yy454;
break;
- case 238: /* expr ::= expr GT expr */
-{yylhsminor.yy178 = tSqlExprCreate(yymsp[-2].minor.yy178, yymsp[0].minor.yy178, TK_GT);}
- yymsp[-2].minor.yy178 = yylhsminor.yy178;
+ case 240: /* expr ::= expr GT expr */
+{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, yymsp[0].minor.yy454, TK_GT);}
+ yymsp[-2].minor.yy454 = yylhsminor.yy454;
break;
- case 239: /* expr ::= expr LE expr */
-{yylhsminor.yy178 = tSqlExprCreate(yymsp[-2].minor.yy178, yymsp[0].minor.yy178, TK_LE);}
- yymsp[-2].minor.yy178 = yylhsminor.yy178;
+ case 241: /* expr ::= expr LE expr */
+{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, yymsp[0].minor.yy454, TK_LE);}
+ yymsp[-2].minor.yy454 = yylhsminor.yy454;
break;
- case 240: /* expr ::= expr GE expr */
-{yylhsminor.yy178 = tSqlExprCreate(yymsp[-2].minor.yy178, yymsp[0].minor.yy178, TK_GE);}
- yymsp[-2].minor.yy178 = yylhsminor.yy178;
+ case 242: /* expr ::= expr GE expr */
+{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, yymsp[0].minor.yy454, TK_GE);}
+ yymsp[-2].minor.yy454 = yylhsminor.yy454;
break;
- case 241: /* expr ::= expr NE expr */
-{yylhsminor.yy178 = tSqlExprCreate(yymsp[-2].minor.yy178, yymsp[0].minor.yy178, TK_NE);}
- yymsp[-2].minor.yy178 = yylhsminor.yy178;
+ case 243: /* expr ::= expr NE expr */
+{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, yymsp[0].minor.yy454, TK_NE);}
+ yymsp[-2].minor.yy454 = yylhsminor.yy454;
break;
- case 242: /* expr ::= expr EQ expr */
-{yylhsminor.yy178 = tSqlExprCreate(yymsp[-2].minor.yy178, yymsp[0].minor.yy178, TK_EQ);}
- yymsp[-2].minor.yy178 = yylhsminor.yy178;
+ case 244: /* expr ::= expr EQ expr */
+{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, yymsp[0].minor.yy454, TK_EQ);}
+ yymsp[-2].minor.yy454 = yylhsminor.yy454;
break;
- case 243: /* expr ::= expr BETWEEN expr AND expr */
-{ tSqlExpr* X2 = tSqlExprClone(yymsp[-4].minor.yy178); yylhsminor.yy178 = tSqlExprCreate(tSqlExprCreate(yymsp[-4].minor.yy178, yymsp[-2].minor.yy178, TK_GE), tSqlExprCreate(X2, yymsp[0].minor.yy178, TK_LE), TK_AND);}
- yymsp[-4].minor.yy178 = yylhsminor.yy178;
+ case 245: /* expr ::= expr BETWEEN expr AND expr */
+{ tSqlExpr* X2 = tSqlExprClone(yymsp[-4].minor.yy454); yylhsminor.yy454 = tSqlExprCreate(tSqlExprCreate(yymsp[-4].minor.yy454, yymsp[-2].minor.yy454, TK_GE), tSqlExprCreate(X2, yymsp[0].minor.yy454, TK_LE), TK_AND);}
+ yymsp[-4].minor.yy454 = yylhsminor.yy454;
break;
- case 244: /* expr ::= expr AND expr */
-{yylhsminor.yy178 = tSqlExprCreate(yymsp[-2].minor.yy178, yymsp[0].minor.yy178, TK_AND);}
- yymsp[-2].minor.yy178 = yylhsminor.yy178;
+ case 246: /* expr ::= expr AND expr */
+{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, yymsp[0].minor.yy454, TK_AND);}
+ yymsp[-2].minor.yy454 = yylhsminor.yy454;
break;
- case 245: /* expr ::= expr OR expr */
-{yylhsminor.yy178 = tSqlExprCreate(yymsp[-2].minor.yy178, yymsp[0].minor.yy178, TK_OR); }
- yymsp[-2].minor.yy178 = yylhsminor.yy178;
+ case 247: /* expr ::= expr OR expr */
+{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, yymsp[0].minor.yy454, TK_OR); }
+ yymsp[-2].minor.yy454 = yylhsminor.yy454;
break;
- case 246: /* expr ::= expr PLUS expr */
-{yylhsminor.yy178 = tSqlExprCreate(yymsp[-2].minor.yy178, yymsp[0].minor.yy178, TK_PLUS); }
- yymsp[-2].minor.yy178 = yylhsminor.yy178;
+ case 248: /* expr ::= expr PLUS expr */
+{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, yymsp[0].minor.yy454, TK_PLUS); }
+ yymsp[-2].minor.yy454 = yylhsminor.yy454;
break;
- case 247: /* expr ::= expr MINUS expr */
-{yylhsminor.yy178 = tSqlExprCreate(yymsp[-2].minor.yy178, yymsp[0].minor.yy178, TK_MINUS); }
- yymsp[-2].minor.yy178 = yylhsminor.yy178;
+ case 249: /* expr ::= expr MINUS expr */
+{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, yymsp[0].minor.yy454, TK_MINUS); }
+ yymsp[-2].minor.yy454 = yylhsminor.yy454;
break;
- case 248: /* expr ::= expr STAR expr */
-{yylhsminor.yy178 = tSqlExprCreate(yymsp[-2].minor.yy178, yymsp[0].minor.yy178, TK_STAR); }
- yymsp[-2].minor.yy178 = yylhsminor.yy178;
+ case 250: /* expr ::= expr STAR expr */
+{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, yymsp[0].minor.yy454, TK_STAR); }
+ yymsp[-2].minor.yy454 = yylhsminor.yy454;
break;
- case 249: /* expr ::= expr SLASH expr */
-{yylhsminor.yy178 = tSqlExprCreate(yymsp[-2].minor.yy178, yymsp[0].minor.yy178, TK_DIVIDE);}
- yymsp[-2].minor.yy178 = yylhsminor.yy178;
+ case 251: /* expr ::= expr SLASH expr */
+{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, yymsp[0].minor.yy454, TK_DIVIDE);}
+ yymsp[-2].minor.yy454 = yylhsminor.yy454;
break;
- case 250: /* expr ::= expr REM expr */
-{yylhsminor.yy178 = tSqlExprCreate(yymsp[-2].minor.yy178, yymsp[0].minor.yy178, TK_REM); }
- yymsp[-2].minor.yy178 = yylhsminor.yy178;
+ case 252: /* expr ::= expr REM expr */
+{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, yymsp[0].minor.yy454, TK_REM); }
+ yymsp[-2].minor.yy454 = yylhsminor.yy454;
break;
- case 251: /* expr ::= expr LIKE expr */
-{yylhsminor.yy178 = tSqlExprCreate(yymsp[-2].minor.yy178, yymsp[0].minor.yy178, TK_LIKE); }
- yymsp[-2].minor.yy178 = yylhsminor.yy178;
+ case 253: /* expr ::= expr LIKE expr */
+{yylhsminor.yy454 = tSqlExprCreate(yymsp[-2].minor.yy454, yymsp[0].minor.yy454, TK_LIKE); }
+ yymsp[-2].minor.yy454 = yylhsminor.yy454;
break;
- case 252: /* expr ::= expr IN LP exprlist RP */
-{yylhsminor.yy178 = tSqlExprCreate(yymsp[-4].minor.yy178, (tSqlExpr*)yymsp[-1].minor.yy285, TK_IN); }
- yymsp[-4].minor.yy178 = yylhsminor.yy178;
+ case 254: /* expr ::= expr IN LP exprlist RP */
+{yylhsminor.yy454 = tSqlExprCreate(yymsp[-4].minor.yy454, (tSqlExpr*)yymsp[-1].minor.yy193, TK_IN); }
+ yymsp[-4].minor.yy454 = yylhsminor.yy454;
break;
- case 253: /* exprlist ::= exprlist COMMA expritem */
-{yylhsminor.yy285 = tSqlExprListAppend(yymsp[-2].minor.yy285,yymsp[0].minor.yy178,0, 0);}
- yymsp[-2].minor.yy285 = yylhsminor.yy285;
+ case 255: /* exprlist ::= exprlist COMMA expritem */
+{yylhsminor.yy193 = tSqlExprListAppend(yymsp[-2].minor.yy193,yymsp[0].minor.yy454,0, 0);}
+ yymsp[-2].minor.yy193 = yylhsminor.yy193;
break;
- case 254: /* exprlist ::= expritem */
-{yylhsminor.yy285 = tSqlExprListAppend(0,yymsp[0].minor.yy178,0, 0);}
- yymsp[0].minor.yy285 = yylhsminor.yy285;
+ case 256: /* exprlist ::= expritem */
+{yylhsminor.yy193 = tSqlExprListAppend(0,yymsp[0].minor.yy454,0, 0);}
+ yymsp[0].minor.yy193 = yylhsminor.yy193;
break;
- case 255: /* expritem ::= expr */
-{yylhsminor.yy178 = yymsp[0].minor.yy178;}
- yymsp[0].minor.yy178 = yylhsminor.yy178;
+ case 257: /* expritem ::= expr */
+{yylhsminor.yy454 = yymsp[0].minor.yy454;}
+ yymsp[0].minor.yy454 = yylhsminor.yy454;
break;
- case 257: /* cmd ::= RESET QUERY CACHE */
+ case 259: /* cmd ::= RESET QUERY CACHE */
{ setDCLSqlElems(pInfo, TSDB_SQL_RESET_CACHE, 0);}
break;
- case 258: /* cmd ::= SYNCDB ids REPLICA */
+ case 260: /* cmd ::= SYNCDB ids REPLICA */
{ setDCLSqlElems(pInfo, TSDB_SQL_SYNC_DB_REPLICA, 1, &yymsp[-1].minor.yy0);}
break;
- case 259: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */
+ case 261: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */
{
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
- SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy285, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, -1);
+ SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy193, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, -1);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
break;
- case 260: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */
+ case 262: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */
{
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
@@ -3031,14 +3047,14 @@ static void yy_reduce(
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
break;
- case 261: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */
+ case 263: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */
{
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
- SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy285, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, -1);
+ SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy193, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, -1);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
break;
- case 262: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */
+ case 264: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */
{
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
@@ -3049,7 +3065,7 @@ static void yy_reduce(
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
break;
- case 263: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */
+ case 265: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */
{
yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n;
@@ -3063,26 +3079,26 @@ static void yy_reduce(
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
break;
- case 264: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */
+ case 266: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */
{
yymsp[-6].minor.yy0.n += yymsp[-5].minor.yy0.n;
toTSDBType(yymsp[-2].minor.yy0.type);
SArray* A = tVariantListAppendToken(NULL, &yymsp[-2].minor.yy0, -1);
- A = tVariantListAppend(A, &yymsp[0].minor.yy362, -1);
+ A = tVariantListAppend(A, &yymsp[0].minor.yy442, -1);
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-6].minor.yy0, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_VAL, -1);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
break;
- case 265: /* cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */
+ case 267: /* cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */
{
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
- SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy285, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, TSDB_SUPER_TABLE);
+ SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy193, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, TSDB_SUPER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
break;
- case 266: /* cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */
+ case 268: /* cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */
{
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
@@ -3093,14 +3109,14 @@ static void yy_reduce(
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
break;
- case 267: /* cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */
+ case 269: /* cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */
{
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
- SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy285, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, TSDB_SUPER_TABLE);
+ SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy193, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, TSDB_SUPER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
break;
- case 268: /* cmd ::= ALTER STABLE ids cpxName DROP TAG ids */
+ case 270: /* cmd ::= ALTER STABLE ids cpxName DROP TAG ids */
{
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
@@ -3111,7 +3127,7 @@ static void yy_reduce(
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
break;
- case 269: /* cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */
+ case 271: /* cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */
{
yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n;
@@ -3125,13 +3141,13 @@ static void yy_reduce(
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
break;
- case 270: /* cmd ::= KILL CONNECTION INTEGER */
+ case 272: /* cmd ::= KILL CONNECTION INTEGER */
{setKillSql(pInfo, TSDB_SQL_KILL_CONNECTION, &yymsp[0].minor.yy0);}
break;
- case 271: /* cmd ::= KILL STREAM INTEGER COLON INTEGER */
+ case 273: /* cmd ::= KILL STREAM INTEGER COLON INTEGER */
{yymsp[-2].minor.yy0.n += (yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setKillSql(pInfo, TSDB_SQL_KILL_STREAM, &yymsp[-2].minor.yy0);}
break;
- case 272: /* cmd ::= KILL QUERY INTEGER COLON INTEGER */
+ case 274: /* cmd ::= KILL QUERY INTEGER COLON INTEGER */
{yymsp[-2].minor.yy0.n += (yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setKillSql(pInfo, TSDB_SQL_KILL_QUERY, &yymsp[-2].minor.yy0);}
break;
default:
diff --git a/src/tsdb/inc/tsdbCommit.h b/src/tsdb/inc/tsdbCommit.h
index 5e740081d1..6bd5dc4325 100644
--- a/src/tsdb/inc/tsdbCommit.h
+++ b/src/tsdb/inc/tsdbCommit.h
@@ -33,6 +33,7 @@ void tsdbGetRtnSnap(STsdbRepo *pRepo, SRtn *pRtn);
int tsdbEncodeKVRecord(void **buf, SKVRecord *pRecord);
void *tsdbDecodeKVRecord(void *buf, SKVRecord *pRecord);
void *tsdbCommitData(STsdbRepo *pRepo);
+int tsdbApplyRtn(STsdbRepo *pRepo);
static FORCE_INLINE int tsdbGetFidLevel(int fid, SRtn *pRtn) {
if (fid >= pRtn->maxFid) {
diff --git a/src/tsdb/inc/tsdbint.h b/src/tsdb/inc/tsdbint.h
index e74c3238e2..945b74af35 100644
--- a/src/tsdb/inc/tsdbint.h
+++ b/src/tsdb/inc/tsdbint.h
@@ -86,6 +86,7 @@ struct STsdbRepo {
SMemTable* mem;
SMemTable* imem;
STsdbFS* fs;
+ SRtn rtn;
tsem_t readyToCommit;
pthread_mutex_t mutex;
bool repoLocked;
diff --git a/src/tsdb/src/tsdbCommit.c b/src/tsdb/src/tsdbCommit.c
index 734b47a718..f2bbe347bd 100644
--- a/src/tsdb/src/tsdbCommit.c
+++ b/src/tsdb/src/tsdbCommit.c
@@ -86,7 +86,6 @@ static void tsdbCloseCommitFile(SCommitH *pCommith, bool hasError);
static bool tsdbCanAddSubBlock(SCommitH *pCommith, SBlock *pBlock, SMergeInfo *pInfo);
static void tsdbLoadAndMergeFromCache(SDataCols *pDataCols, int *iter, SCommitIter *pCommitIter, SDataCols *pTarget,
TSKEY maxKey, int maxRows, int8_t update);
-static int tsdbApplyRtn(STsdbRepo *pRepo);
static int tsdbApplyRtnOnFSet(STsdbRepo *pRepo, SDFileSet *pSet, SRtn *pRtn);
void *tsdbCommitData(STsdbRepo *pRepo) {
@@ -1431,7 +1430,7 @@ static bool tsdbCanAddSubBlock(SCommitH *pCommith, SBlock *pBlock, SMergeInfo *p
return false;
}
-static int tsdbApplyRtn(STsdbRepo *pRepo) {
+int tsdbApplyRtn(STsdbRepo *pRepo) {
SRtn rtn;
SFSIter fsiter;
STsdbFS * pfs = REPO_FS(pRepo);
diff --git a/src/tsdb/src/tsdbFS.c b/src/tsdb/src/tsdbFS.c
index fd9b5e77e3..54372ae8c2 100644
--- a/src/tsdb/src/tsdbFS.c
+++ b/src/tsdb/src/tsdbFS.c
@@ -33,7 +33,9 @@ static int tsdbScanDataDir(STsdbRepo *pRepo);
static bool tsdbIsTFileInFS(STsdbFS *pfs, const TFILE *pf);
static int tsdbRestoreCurrent(STsdbRepo *pRepo);
static int tsdbComparTFILE(const void *arg1, const void *arg2);
-static void tsdbScanAndTryFixDFilesHeader(STsdbRepo *pRepo);
+static void tsdbScanAndTryFixDFilesHeader(STsdbRepo *pRepo, int32_t *nExpired);
+static int tsdbProcessExpiredFS(STsdbRepo *pRepo);
+static int tsdbCreateMeta(STsdbRepo *pRepo);
// ================== CURRENT file header info
static int tsdbEncodeFSHeader(void **buf, SFSHeader *pHeader) {
@@ -212,6 +214,8 @@ STsdbFS *tsdbNewFS(STsdbCfg *pCfg) {
return NULL;
}
+ pfs->intxn = false;
+
pfs->nstatus = tsdbNewFSStatus(maxFSet);
if (pfs->nstatus == NULL) {
tsdbFreeFS(pfs);
@@ -234,22 +238,84 @@ void *tsdbFreeFS(STsdbFS *pfs) {
return NULL;
}
+static int tsdbProcessExpiredFS(STsdbRepo *pRepo) {
+ tsdbStartFSTxn(pRepo, 0, 0);
+ if (tsdbCreateMeta(pRepo) < 0) {
+ tsdbError("vgId:%d failed to create meta since %s", REPO_ID(pRepo), tstrerror(terrno));
+ return -1;
+ }
+
+ if (tsdbApplyRtn(pRepo) < 0) {
+ tsdbEndFSTxnWithError(REPO_FS(pRepo));
+ tsdbError("vgId:%d failed to apply rtn since %s", REPO_ID(pRepo), tstrerror(terrno));
+ return -1;
+ }
+ if (tsdbEndFSTxn(pRepo) < 0) {
+ tsdbError("vgId:%d failed to end fs txn since %s", REPO_ID(pRepo), tstrerror(terrno));
+ return -1;
+ }
+ return 0;
+}
+
+static int tsdbCreateMeta(STsdbRepo *pRepo) {
+ STsdbFS *pfs = REPO_FS(pRepo);
+ SMFile * pOMFile = pfs->cstatus->pmf;
+ SMFile mf;
+ SDiskID did;
+
+ if (pOMFile != NULL) {
+ // keep the old meta file
+ tsdbUpdateMFile(pfs, pOMFile);
+ return 0;
+ }
+
+ // Create a new meta file
+ did.level = TFS_PRIMARY_LEVEL;
+ did.id = TFS_PRIMARY_ID;
+ tsdbInitMFile(&mf, did, REPO_ID(pRepo), FS_TXN_VERSION(REPO_FS(pRepo)));
+
+ if (tsdbCreateMFile(&mf, true) < 0) {
+ tsdbError("vgId:%d failed to create META file since %s", REPO_ID(pRepo), tstrerror(terrno));
+ return -1;
+ }
+
+ tsdbInfo("vgId:%d meta file %s is created", REPO_ID(pRepo), TSDB_FILE_FULL_NAME(&mf));
+
+ if (tsdbUpdateMFileHeader(&mf) < 0) {
+ tsdbError("vgId:%d failed to update META file header since %s, revert it", REPO_ID(pRepo), tstrerror(terrno));
+ tsdbApplyMFileChange(&mf, pOMFile);
+ return -1;
+ }
+
+ TSDB_FILE_FSYNC(&mf);
+ tsdbCloseMFile(&mf);
+ tsdbUpdateMFile(pfs, &mf);
+
+ return 0;
+}
+
int tsdbOpenFS(STsdbRepo *pRepo) {
STsdbFS *pfs = REPO_FS(pRepo);
char current[TSDB_FILENAME_LEN] = "\0";
+ int nExpired = 0;
ASSERT(pfs != NULL);
tsdbGetTxnFname(REPO_ID(pRepo), TSDB_TXN_CURR_FILE, current);
+ tsdbGetRtnSnap(pRepo, &pRepo->rtn);
if (access(current, F_OK) == 0) {
if (tsdbOpenFSFromCurrent(pRepo) < 0) {
tsdbError("vgId:%d failed to open FS since %s", REPO_ID(pRepo), tstrerror(terrno));
return -1;
}
- tsdbScanAndTryFixDFilesHeader(pRepo);
+ tsdbScanAndTryFixDFilesHeader(pRepo, &nExpired);
+ if (nExpired > 0) {
+ tsdbProcessExpiredFS(pRepo);
+ }
} else {
+ // should skip expired fileset inside of the function
if (tsdbRestoreCurrent(pRepo) < 0) {
tsdbError("vgId:%d failed to restore current file since %s", REPO_ID(pRepo), tstrerror(terrno));
return -1;
@@ -1110,6 +1176,11 @@ static int tsdbRestoreDFileSet(STsdbRepo *pRepo) {
ASSERT(tvid == REPO_ID(pRepo));
+ if (tfid < pRepo->rtn.minFid) { // skip file expired
+ ++index;
+ continue;
+ }
+
if (ftype == 0) {
fset.fid = tfid;
} else {
@@ -1206,7 +1277,7 @@ static int tsdbComparTFILE(const void *arg1, const void *arg2) {
}
}
-static void tsdbScanAndTryFixDFilesHeader(STsdbRepo *pRepo) {
+static void tsdbScanAndTryFixDFilesHeader(STsdbRepo *pRepo, int32_t *nExpired) {
STsdbFS * pfs = REPO_FS(pRepo);
SFSStatus *pStatus = pfs->cstatus;
SDFInfo info;
@@ -1214,7 +1285,9 @@ static void tsdbScanAndTryFixDFilesHeader(STsdbRepo *pRepo) {
for (size_t i = 0; i < taosArrayGetSize(pStatus->df); i++) {
SDFileSet fset;
tsdbInitDFileSetEx(&fset, (SDFileSet *)taosArrayGet(pStatus->df, i));
-
+ if (fset.fid < pRepo->rtn.minFid) {
+ ++*nExpired;
+ }
tsdbDebug("vgId:%d scan DFileSet %d header", REPO_ID(pRepo), fset.fid);
if (tsdbOpenDFileSet(&fset, O_RDWR) < 0) {
diff --git a/src/tsdb/src/tsdbMeta.c b/src/tsdb/src/tsdbMeta.c
index 324a7c79c5..8174698197 100644
--- a/src/tsdb/src/tsdbMeta.c
+++ b/src/tsdb/src/tsdbMeta.c
@@ -68,7 +68,7 @@ int tsdbCreateTable(STsdbRepo *repo, STableCfg *pCfg) {
TABLE_CHAR_NAME(pMeta->tables[tid]), TABLE_TID(pMeta->tables[tid]), TABLE_UID(pMeta->tables[tid]));
return 0;
} else {
- tsdbError("vgId:%d table %s at tid %d uid %" PRIu64
+ tsdbInfo("vgId:%d table %s at tid %d uid %" PRIu64
" exists, replace it with new table, this can be not reasonable",
REPO_ID(pRepo), TABLE_CHAR_NAME(pMeta->tables[tid]), TABLE_TID(pMeta->tables[tid]),
TABLE_UID(pMeta->tables[tid]));
@@ -1055,10 +1055,7 @@ static int tsdbRemoveTableFromIndex(STsdbMeta *pMeta, STable *pTable) {
STable *pSTable = pTable->pSuper;
ASSERT(pSTable != NULL);
- STSchema *pSchema = tsdbGetTableTagSchema(pTable);
- STColumn *pCol = schemaColAt(pSchema, DEFAULT_TAG_INDEX_COLUMN);
-
- char * key = tdGetKVRowValOfCol(pTable->tagVal, pCol->colId);
+ char* key = getTagIndexKey(pTable);
SArray *res = tSkipListGet(pSTable->pIndex, key);
size_t size = taosArrayGetSize(res);
diff --git a/src/tsdb/src/tsdbRead.c b/src/tsdb/src/tsdbRead.c
index 0a39dba021..1545d44395 100644
--- a/src/tsdb/src/tsdbRead.c
+++ b/src/tsdb/src/tsdbRead.c
@@ -368,40 +368,39 @@ static STsdbQueryHandle* tsdbQueryTablesImpl(STsdbRepo* tsdb, STsdbQueryCond* pC
goto out_of_memory;
}
- assert(pCond != NULL && pCond->numOfCols > 0 && pMemRef != NULL);
+ assert(pCond != NULL && pMemRef != NULL);
if (ASCENDING_TRAVERSE(pCond->order)) {
assert(pQueryHandle->window.skey <= pQueryHandle->window.ekey);
} else {
assert(pQueryHandle->window.skey >= pQueryHandle->window.ekey);
}
-
- // allocate buffer in order to load data blocks from file
- pQueryHandle->statis = calloc(pCond->numOfCols, sizeof(SDataStatis));
- if (pQueryHandle->statis == NULL) {
- goto out_of_memory;
- }
-
- pQueryHandle->pColumns = taosArrayInit(pCond->numOfCols, sizeof(SColumnInfoData)); // todo: use list instead of array?
- if (pQueryHandle->pColumns == NULL) {
- goto out_of_memory;
- }
-
- for (int32_t i = 0; i < pCond->numOfCols; ++i) {
- SColumnInfoData colInfo = {{0}, 0};
-
- colInfo.info = pCond->colList[i];
- colInfo.pData = calloc(1, EXTRA_BYTES + pQueryHandle->outputCapacity * pCond->colList[i].bytes);
- if (colInfo.pData == NULL) {
+ if (pCond->numOfCols > 0) {
+ // allocate buffer in order to load data blocks from file
+ pQueryHandle->statis = calloc(pCond->numOfCols, sizeof(SDataStatis));
+ if (pQueryHandle->statis == NULL) {
goto out_of_memory;
}
- taosArrayPush(pQueryHandle->pColumns, &colInfo);
- pQueryHandle->statis[i].colId = colInfo.info.colId;
- }
- if (pCond->numOfCols > 0) {
+ pQueryHandle->pColumns =
+ taosArrayInit(pCond->numOfCols, sizeof(SColumnInfoData)); // todo: use list instead of array?
+ if (pQueryHandle->pColumns == NULL) {
+ goto out_of_memory;
+ }
+
+ for (int32_t i = 0; i < pCond->numOfCols; ++i) {
+ SColumnInfoData colInfo = {{0}, 0};
+
+ colInfo.info = pCond->colList[i];
+ colInfo.pData = calloc(1, EXTRA_BYTES + pQueryHandle->outputCapacity * pCond->colList[i].bytes);
+ if (colInfo.pData == NULL) {
+ goto out_of_memory;
+ }
+ taosArrayPush(pQueryHandle->pColumns, &colInfo);
+ pQueryHandle->statis[i].colId = colInfo.info.colId;
+ }
+
pQueryHandle->defaultLoadColumn = getDefaultLoadColumns(pQueryHandle, true);
}
-
STsdbMeta* pMeta = tsdbGetMeta(tsdb);
assert(pMeta != NULL);
@@ -2128,6 +2127,7 @@ int32_t tsdbGetFileBlocksDistInfo(TsdbQueryHandleT* queryHandle, STableBlockDist
STsdbQueryHandle* pQueryHandle = (STsdbQueryHandle*) queryHandle;
pTableBlockInfo->totalSize = 0;
+ pTableBlockInfo->totalRows = 0;
STsdbFS* pFileHandle = REPO_FS(pQueryHandle->pTsdb);
// find the start data block in file
@@ -2201,7 +2201,12 @@ int32_t tsdbGetFileBlocksDistInfo(TsdbQueryHandleT* queryHandle, STableBlockDist
pTableBlockInfo->totalSize += pBlock[j].len;
int32_t numOfRows = pBlock[j].numOfRows;
- taosArrayPush(pTableBlockInfo->dataBlockInfos, &numOfRows);
+ pTableBlockInfo->totalRows += numOfRows;
+ if (numOfRows > pTableBlockInfo->maxRows) pTableBlockInfo->maxRows = numOfRows;
+ if (numOfRows < pTableBlockInfo->minRows) pTableBlockInfo->minRows = numOfRows;
+ int32_t stepIndex = (numOfRows-1)/TSDB_BLOCK_DIST_STEP_ROWS;
+ SFileBlockInfo *blockInfo = (SFileBlockInfo*)taosArrayGet(pTableBlockInfo->dataBlockInfos, stepIndex);
+ blockInfo->numBlocksOfStep++;
}
}
}
diff --git a/src/tsdb/src/tsdbSync.c b/src/tsdb/src/tsdbSync.c
index 5a2756537e..edcb84d091 100644
--- a/src/tsdb/src/tsdbSync.c
+++ b/src/tsdb/src/tsdbSync.c
@@ -424,24 +424,42 @@ static int32_t tsdbSyncRecvDFileSetArray(SSyncH *pSynch) {
}
if (tsdbSendDecision(pSynch, false) < 0) {
- tsdbError("vgId:%d, filed to send decision since %s", REPO_ID(pRepo), tstrerror(terrno));
+ tsdbError("vgId:%d, failed to send decision since %s", REPO_ID(pRepo), tstrerror(terrno));
return -1;
}
} else {
// Need to copy from remote
- tsdbInfo("vgId:%d, fileset:%d will be received", REPO_ID(pRepo), pSynch->pdf->fid);
-
- // Notify remote to send there file here
- if (tsdbSendDecision(pSynch, true) < 0) {
- tsdbError("vgId:%d, failed to send decision since %s", REPO_ID(pRepo), tstrerror(terrno));
- return -1;
+ int fidLevel = tsdbGetFidLevel(pSynch->pdf->fid, &(pSynch->rtn));
+ if (fidLevel < 0) { // expired fileset
+ tsdbInfo("vgId:%d, fileset:%d will be skipped as expired", REPO_ID(pRepo), pSynch->pdf->fid);
+ if (tsdbSendDecision(pSynch, false) < 0) {
+ tsdbError("vgId:%d, failed to send decision since %s", REPO_ID(pRepo), tstrerror(terrno));
+ return -1;
+ }
+ // Move forward
+ if (tsdbRecvDFileSetInfo(pSynch) < 0) {
+ tsdbError("vgId:%d, failed to recv fileset since %s", REPO_ID(pRepo), tstrerror(terrno));
+ return -1;
+ }
+ if (pLSet) {
+ pLSet = tsdbFSIterNext(&fsiter);
+ }
+ // Next loop
+ continue;
+ } else {
+ tsdbInfo("vgId:%d, fileset:%d will be received", REPO_ID(pRepo), pSynch->pdf->fid);
+ // Notify remote to send there file here
+ if (tsdbSendDecision(pSynch, true) < 0) {
+ tsdbError("vgId:%d, failed to send decision since %s", REPO_ID(pRepo), tstrerror(terrno));
+ return -1;
+ }
}
// Create local files and copy from remote
SDiskID did;
SDFileSet fset;
- tfsAllocDisk(tsdbGetFidLevel(pSynch->pdf->fid, &(pSynch->rtn)), &(did.level), &(did.id));
+ tfsAllocDisk(fidLevel, &(did.level), &(did.id));
if (did.level == TFS_UNDECIDED_LEVEL) {
terrno = TSDB_CODE_TDB_NO_AVAIL_DISK;
tsdbError("vgId:%d, failed allc disk since %s", REPO_ID(pRepo), tstrerror(terrno));
@@ -548,6 +566,13 @@ static int32_t tsdbSyncSendDFileSet(SSyncH *pSynch, SDFileSet *pSet) {
STsdbRepo *pRepo = pSynch->pRepo;
bool toSend = false;
+ // skip expired fileset
+ if (pSet && tsdbGetFidLevel(pSet->fid, &(pSynch->rtn)) < 0) {
+ tsdbInfo("vgId:%d, don't sync send since fileset:%d smaller than minFid:%d", REPO_ID(pRepo), pSet->fid,
+ pSynch->rtn.minFid);
+ return 0;
+ }
+
if (tsdbSendDFileSetInfo(pSynch, pSet) < 0) {
tsdbError("vgId:%d, failed to send fileset:%d info since %s", REPO_ID(pRepo), pSet ? pSet->fid : -1, tstrerror(terrno));
return -1;
diff --git a/src/util/inc/tarray.h b/src/util/inc/tarray.h
index bc25776caa..fc7b6b8584 100644
--- a/src/util/inc/tarray.h
+++ b/src/util/inc/tarray.h
@@ -106,6 +106,14 @@ void* taosArrayGetLast(const SArray* pArray);
*/
size_t taosArrayGetSize(const SArray* pArray);
+/**
+ * set the size of array
+ * @param pArray
+ * @param size size of the array
+ * @return
+ */
+void taosArraySetSize(SArray* pArray, size_t size);
+
/**
* insert data into array
* @param pArray
diff --git a/src/util/inc/ttoken.h b/src/util/inc/ttoken.h
index 3bf030a9eb..f62329183f 100644
--- a/src/util/inc/ttoken.h
+++ b/src/util/inc/ttoken.h
@@ -183,6 +183,7 @@ void taosCleanupKeywordsTable();
SStrToken tscReplaceStrToken(char **str, SStrToken *token, const char* newToken);
+SStrToken taosTokenDup(SStrToken* pToken, char* buf, int32_t len);
#ifdef __cplusplus
}
diff --git a/src/util/src/tarray.c b/src/util/src/tarray.c
index 45cb878668..5e7d9d14da 100644
--- a/src/util/src/tarray.c
+++ b/src/util/src/tarray.c
@@ -115,6 +115,11 @@ void* taosArrayGetLast(const SArray* pArray) {
size_t taosArrayGetSize(const SArray* pArray) { return pArray->size; }
+void taosArraySetSize(SArray* pArray, size_t size) {
+ assert(size <= pArray->capacity);
+ pArray->size = size;
+}
+
void* taosArrayInsert(SArray* pArray, size_t index, void* pData) {
if (pArray == NULL || pData == NULL) {
return NULL;
diff --git a/src/util/src/terror.c b/src/util/src/terror.c
index 887b231ec6..382f872486 100644
--- a/src/util/src/terror.c
+++ b/src/util/src/terror.c
@@ -224,6 +224,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_VND_IS_FULL, "Database memory is fu
TAOS_DEFINE_ERROR(TSDB_CODE_VND_IS_FLOWCTRL, "Database memory is full for waiting commit")
TAOS_DEFINE_ERROR(TSDB_CODE_VND_IS_DROPPING, "Database is dropping")
TAOS_DEFINE_ERROR(TSDB_CODE_VND_IS_BALANCING, "Database is balancing")
+TAOS_DEFINE_ERROR(TSDB_CODE_VND_IS_CLOSING, "Database is closing")
TAOS_DEFINE_ERROR(TSDB_CODE_VND_NOT_SYNCED, "Database suspended")
TAOS_DEFINE_ERROR(TSDB_CODE_VND_NO_WRITE_AUTH, "Database write operation denied")
TAOS_DEFINE_ERROR(TSDB_CODE_VND_IS_SYNCING, "Database is syncing")
diff --git a/src/util/src/ttokenizer.c b/src/util/src/ttokenizer.c
index 138a79511c..ea15ced898 100644
--- a/src/util/src/ttokenizer.c
+++ b/src/util/src/ttokenizer.c
@@ -141,6 +141,7 @@ static SKeyword keywordTable[] = {
{"VARIABLE", TK_VARIABLE},
{"INTERVAL", TK_INTERVAL},
{"SESSION", TK_SESSION},
+ {"STATE_WINDOW", TK_STATE_WINDOW},
{"FILL", TK_FILL},
{"SLIDING", TK_SLIDING},
{"ORDER", TK_ORDER},
@@ -673,3 +674,15 @@ void taosCleanupKeywordsTable() {
taosHashCleanup(m);
}
}
+
+SStrToken taosTokenDup(SStrToken* pToken, char* buf, int32_t len) {
+ assert(pToken != NULL && buf != NULL);
+ SStrToken token = *pToken;
+ token.z = buf;
+
+ assert(len > token.n);
+ strncpy(token.z, pToken->z, pToken->n);
+ token.z[token.n] = 0;
+
+ return token;
+}
diff --git a/src/vnode/src/vnodeMgmt.c b/src/vnode/src/vnodeMgmt.c
index 32f9532138..7e6022fc87 100644
--- a/src/vnode/src/vnodeMgmt.c
+++ b/src/vnode/src/vnodeMgmt.c
@@ -91,18 +91,18 @@ static void vnodeIncRef(void *ptNode) {
}
void *vnodeAcquire(int32_t vgId) {
- SVnodeObj **ppVnode = NULL;
+ SVnodeObj *pVnode = NULL;
if (tsVnodesHash != NULL) {
- ppVnode = taosHashGetClone(tsVnodesHash, &vgId, sizeof(int32_t), vnodeIncRef, NULL, sizeof(void *));
+ taosHashGetClone(tsVnodesHash, &vgId, sizeof(int32_t), vnodeIncRef, &pVnode, sizeof(void *));
}
- if (ppVnode == NULL || *ppVnode == NULL) {
+ if (pVnode == NULL) {
terrno = TSDB_CODE_VND_INVALID_VGROUP_ID;
vDebug("vgId:%d, not exist", vgId);
return NULL;
}
- return *ppVnode;
+ return pVnode;
}
void vnodeRelease(void *vparam) {
diff --git a/src/vnode/src/vnodeWrite.c b/src/vnode/src/vnodeWrite.c
index 16089c8e91..555eda6d13 100644
--- a/src/vnode/src/vnodeWrite.c
+++ b/src/vnode/src/vnodeWrite.c
@@ -303,6 +303,17 @@ static int32_t vnodeWriteToWQueueImp(SVWriteMsg *pWrite) {
}
int32_t vnodeWriteToWQueue(void *vparam, void *wparam, int32_t qtype, void *rparam) {
+ SVnodeObj *pVnode = vparam;
+ if (qtype == TAOS_QTYPE_RPC) {
+ if (!vnodeInReadyStatus(pVnode)) {
+ return TSDB_CODE_APP_NOT_READY; // it may be in deleting or closing state
+ }
+
+ if (pVnode->role != TAOS_SYNC_ROLE_MASTER) {
+ return TSDB_CODE_APP_NOT_READY;
+ }
+ }
+
SVWriteMsg *pWrite = vnodeBuildVWriteMsg(vparam, wparam, qtype, rparam);
if (pWrite == NULL) {
assert(terrno != 0);
diff --git a/tests/Jenkinsfile b/tests/Jenkinsfile
index 2f2b9f6933..0c1f651059 100644
--- a/tests/Jenkinsfile
+++ b/tests/Jenkinsfile
@@ -29,8 +29,8 @@ pipeline {
agent none
environment{
- WK = '/var/lib/jenkins/workspace/TDinternal'
- WKC= '/var/lib/jenkins/workspace/TDinternal/community'
+ WK = '/data/lib/jenkins/workspace/TDinternal'
+ WKC= '/data/lib/jenkins/workspace/TDinternal/community'
}
stages {
diff --git a/tests/examples/c/apitest.c b/tests/examples/c/apitest.c
index 0ca92eaf1d..b2411d1212 100644
--- a/tests/examples/c/apitest.c
+++ b/tests/examples/c/apitest.c
@@ -402,6 +402,471 @@ void verify_prepare(TAOS* taos) {
taos_stmt_close(stmt);
}
+
+
+
+
+void verify_prepare2(TAOS* taos) {
+ TAOS_RES* result = taos_query(taos, "drop database if exists test;");
+ taos_free_result(result);
+ usleep(100000);
+ result = taos_query(taos, "create database test;");
+
+ int code = taos_errno(result);
+ if (code != 0) {
+ printf("\033[31mfailed to create database, reason:%s\033[0m\n", taos_errstr(result));
+ taos_free_result(result);
+ return;
+ }
+ taos_free_result(result);
+
+ usleep(100000);
+ taos_select_db(taos, "test");
+
+ // create table
+ const char* sql = "create table m1 (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, bin binary(40), blob nchar(10))";
+ result = taos_query(taos, sql);
+ code = taos_errno(result);
+ if (code != 0) {
+ printf("\033[31mfailed to create table, reason:%s\033[0m\n", taos_errstr(result));
+ taos_free_result(result);
+ return;
+ }
+ taos_free_result(result);
+
+ // insert 10 records
+ struct {
+ int64_t ts[10];
+ int8_t b[10];
+ int8_t v1[10];
+ int16_t v2[10];
+ int32_t v4[10];
+ int64_t v8[10];
+ float f4[10];
+ double f8[10];
+ char bin[10][40];
+ char blob[10][80];
+ } v;
+
+ int32_t *t8_len = malloc(sizeof(int32_t) * 10);
+ int32_t *t16_len = malloc(sizeof(int32_t) * 10);
+ int32_t *t32_len = malloc(sizeof(int32_t) * 10);
+ int32_t *t64_len = malloc(sizeof(int32_t) * 10);
+ int32_t *float_len = malloc(sizeof(int32_t) * 10);
+ int32_t *double_len = malloc(sizeof(int32_t) * 10);
+ int32_t *bin_len = malloc(sizeof(int32_t) * 10);
+ int32_t *blob_len = malloc(sizeof(int32_t) * 10);
+
+ TAOS_STMT* stmt = taos_stmt_init(taos);
+ TAOS_MULTI_BIND params[10];
+ char is_null[10] = {0};
+
+ params[0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP;
+ params[0].buffer_length = sizeof(v.ts[0]);
+ params[0].buffer = v.ts;
+ params[0].length = t64_len;
+ params[0].is_null = is_null;
+ params[0].num = 10;
+
+ params[1].buffer_type = TSDB_DATA_TYPE_BOOL;
+ params[1].buffer_length = sizeof(v.b[0]);
+ params[1].buffer = v.b;
+ params[1].length = t8_len;
+ params[1].is_null = is_null;
+ params[1].num = 10;
+
+ params[2].buffer_type = TSDB_DATA_TYPE_TINYINT;
+ params[2].buffer_length = sizeof(v.v1[0]);
+ params[2].buffer = v.v1;
+ params[2].length = t8_len;
+ params[2].is_null = is_null;
+ params[2].num = 10;
+
+ params[3].buffer_type = TSDB_DATA_TYPE_SMALLINT;
+ params[3].buffer_length = sizeof(v.v2[0]);
+ params[3].buffer = v.v2;
+ params[3].length = t16_len;
+ params[3].is_null = is_null;
+ params[3].num = 10;
+
+ params[4].buffer_type = TSDB_DATA_TYPE_INT;
+ params[4].buffer_length = sizeof(v.v4[0]);
+ params[4].buffer = v.v4;
+ params[4].length = t32_len;
+ params[4].is_null = is_null;
+ params[4].num = 10;
+
+ params[5].buffer_type = TSDB_DATA_TYPE_BIGINT;
+ params[5].buffer_length = sizeof(v.v8[0]);
+ params[5].buffer = v.v8;
+ params[5].length = t64_len;
+ params[5].is_null = is_null;
+ params[5].num = 10;
+
+ params[6].buffer_type = TSDB_DATA_TYPE_FLOAT;
+ params[6].buffer_length = sizeof(v.f4[0]);
+ params[6].buffer = v.f4;
+ params[6].length = float_len;
+ params[6].is_null = is_null;
+ params[6].num = 10;
+
+ params[7].buffer_type = TSDB_DATA_TYPE_DOUBLE;
+ params[7].buffer_length = sizeof(v.f8[0]);
+ params[7].buffer = v.f8;
+ params[7].length = double_len;
+ params[7].is_null = is_null;
+ params[7].num = 10;
+
+ params[8].buffer_type = TSDB_DATA_TYPE_BINARY;
+ params[8].buffer_length = sizeof(v.bin[0]);
+ params[8].buffer = v.bin;
+ params[8].length = bin_len;
+ params[8].is_null = is_null;
+ params[8].num = 10;
+
+ params[9].buffer_type = TSDB_DATA_TYPE_NCHAR;
+ params[9].buffer_length = sizeof(v.blob[0]);
+ params[9].buffer = v.blob;
+ params[9].length = blob_len;
+ params[9].is_null = is_null;
+ params[9].num = 10;
+
+
+ sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?)";
+ code = taos_stmt_prepare(stmt, sql, 0);
+ if (code != 0){
+ printf("\033[31mfailed to execute taos_stmt_prepare. code:0x%x\033[0m\n", code);
+ }
+
+ code = taos_stmt_set_tbname(stmt, "m1");
+ if (code != 0){
+ printf("\033[31mfailed to execute taos_stmt_prepare. code:0x%x\033[0m\n", code);
+ }
+
+ int64_t ts = 1591060628000;
+ for (int i = 0; i < 10; ++i) {
+ v.ts[i] = ts++;
+ is_null[i] = 0;
+
+ v.b[i] = (int8_t)i % 2;
+ v.v1[i] = (int8_t)i;
+ v.v2[i] = (int16_t)(i * 2);
+ v.v4[i] = (int32_t)(i * 4);
+ v.v8[i] = (int64_t)(i * 8);
+ v.f4[i] = (float)(i * 40);
+ v.f8[i] = (double)(i * 80);
+ for (int j = 0; j < sizeof(v.bin[0]) - 1; ++j) {
+ v.bin[i][j] = (char)(i + '0');
+ }
+ strcpy(v.blob[i], "一二三四五六七八九十");
+
+ t8_len[i] = sizeof(int8_t);
+ t16_len[i] = sizeof(int16_t);
+ t32_len[i] = sizeof(int32_t);
+ t64_len[i] = sizeof(int64_t);
+ float_len[i] = sizeof(float);
+ double_len[i] = sizeof(double);
+ bin_len[i] = sizeof(v.bin[0]);
+ blob_len[i] = (int32_t)strlen(v.blob[i]);
+ }
+
+ taos_stmt_bind_param_batch(stmt, params);
+ taos_stmt_add_batch(stmt);
+
+ if (taos_stmt_execute(stmt) != 0) {
+ printf("\033[31mfailed to execute insert statement.\033[0m\n");
+ return;
+ }
+ taos_stmt_close(stmt);
+
+
+
+ // query the records
+ stmt = taos_stmt_init(taos);
+ taos_stmt_prepare(stmt, "SELECT * FROM m1 WHERE v1 > ? AND v2 < ?", 0);
+ TAOS_BIND qparams[2];
+
+ int8_t v1 = 5;
+ int16_t v2 = 15;
+ qparams[0].buffer_type = TSDB_DATA_TYPE_TINYINT;
+ qparams[0].buffer_length = sizeof(v1);
+ qparams[0].buffer = &v1;
+ qparams[0].length = &qparams[0].buffer_length;
+ qparams[0].is_null = NULL;
+
+ qparams[1].buffer_type = TSDB_DATA_TYPE_SMALLINT;
+ qparams[1].buffer_length = sizeof(v2);
+ qparams[1].buffer = &v2;
+ qparams[1].length = &qparams[1].buffer_length;
+ qparams[1].is_null = NULL;
+
+ taos_stmt_bind_param(stmt, qparams);
+ if (taos_stmt_execute(stmt) != 0) {
+ printf("\033[31mfailed to execute select statement.\033[0m\n");
+ return;
+ }
+
+ result = taos_stmt_use_result(stmt);
+
+ TAOS_ROW row;
+ int rows = 0;
+ int num_fields = taos_num_fields(result);
+ TAOS_FIELD *fields = taos_fetch_fields(result);
+ char temp[256];
+
+ // fetch the records row by row
+ while ((row = taos_fetch_row(result))) {
+ rows++;
+ taos_print_row(temp, row, fields, num_fields);
+ printf("%s\n", temp);
+ }
+
+ taos_free_result(result);
+ taos_stmt_close(stmt);
+}
+
+
+
+void verify_prepare3(TAOS* taos) {
+ TAOS_RES* result = taos_query(taos, "drop database if exists test;");
+ taos_free_result(result);
+ usleep(100000);
+ result = taos_query(taos, "create database test;");
+
+ int code = taos_errno(result);
+ if (code != 0) {
+ printf("\033[31mfailed to create database, reason:%s\033[0m\n", taos_errstr(result));
+ taos_free_result(result);
+ return;
+ }
+ taos_free_result(result);
+
+ usleep(100000);
+ taos_select_db(taos, "test");
+
+ // create table
+ const char* sql = "create stable st1 (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, bin binary(40), blob nchar(10)) tags (id1 int, id2 binary(40))";
+ result = taos_query(taos, sql);
+ code = taos_errno(result);
+ if (code != 0) {
+ printf("\033[31mfailed to create table, reason:%s\033[0m\n", taos_errstr(result));
+ taos_free_result(result);
+ return;
+ }
+ taos_free_result(result);
+
+ TAOS_BIND tags[2];
+
+ int32_t id1 = 1;
+ char id2[40] = "abcdefghijklmnopqrstuvwxyz0123456789";
+ uintptr_t id2_len = strlen(id2);
+
+ tags[0].buffer_type = TSDB_DATA_TYPE_INT;
+ tags[0].buffer_length = sizeof(int);
+ tags[0].buffer = &id1;
+ tags[0].length = NULL;
+ tags[0].is_null = NULL;
+
+ tags[1].buffer_type = TSDB_DATA_TYPE_BINARY;
+ tags[1].buffer_length = sizeof(id2);
+ tags[1].buffer = id2;
+ tags[1].length = &id2_len;
+ tags[1].is_null = NULL;
+
+
+ // insert 10 records
+ struct {
+ int64_t ts[10];
+ int8_t b[10];
+ int8_t v1[10];
+ int16_t v2[10];
+ int32_t v4[10];
+ int64_t v8[10];
+ float f4[10];
+ double f8[10];
+ char bin[10][40];
+ char blob[10][80];
+ } v;
+
+ int32_t *t8_len = malloc(sizeof(int32_t) * 10);
+ int32_t *t16_len = malloc(sizeof(int32_t) * 10);
+ int32_t *t32_len = malloc(sizeof(int32_t) * 10);
+ int32_t *t64_len = malloc(sizeof(int32_t) * 10);
+ int32_t *float_len = malloc(sizeof(int32_t) * 10);
+ int32_t *double_len = malloc(sizeof(int32_t) * 10);
+ int32_t *bin_len = malloc(sizeof(int32_t) * 10);
+ int32_t *blob_len = malloc(sizeof(int32_t) * 10);
+
+ TAOS_STMT* stmt = taos_stmt_init(taos);
+ TAOS_MULTI_BIND params[10];
+ char is_null[10] = {0};
+
+ params[0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP;
+ params[0].buffer_length = sizeof(v.ts[0]);
+ params[0].buffer = v.ts;
+ params[0].length = t64_len;
+ params[0].is_null = is_null;
+ params[0].num = 10;
+
+ params[1].buffer_type = TSDB_DATA_TYPE_BOOL;
+ params[1].buffer_length = sizeof(v.b[0]);
+ params[1].buffer = v.b;
+ params[1].length = t8_len;
+ params[1].is_null = is_null;
+ params[1].num = 10;
+
+ params[2].buffer_type = TSDB_DATA_TYPE_TINYINT;
+ params[2].buffer_length = sizeof(v.v1[0]);
+ params[2].buffer = v.v1;
+ params[2].length = t8_len;
+ params[2].is_null = is_null;
+ params[2].num = 10;
+
+ params[3].buffer_type = TSDB_DATA_TYPE_SMALLINT;
+ params[3].buffer_length = sizeof(v.v2[0]);
+ params[3].buffer = v.v2;
+ params[3].length = t16_len;
+ params[3].is_null = is_null;
+ params[3].num = 10;
+
+ params[4].buffer_type = TSDB_DATA_TYPE_INT;
+ params[4].buffer_length = sizeof(v.v4[0]);
+ params[4].buffer = v.v4;
+ params[4].length = t32_len;
+ params[4].is_null = is_null;
+ params[4].num = 10;
+
+ params[5].buffer_type = TSDB_DATA_TYPE_BIGINT;
+ params[5].buffer_length = sizeof(v.v8[0]);
+ params[5].buffer = v.v8;
+ params[5].length = t64_len;
+ params[5].is_null = is_null;
+ params[5].num = 10;
+
+ params[6].buffer_type = TSDB_DATA_TYPE_FLOAT;
+ params[6].buffer_length = sizeof(v.f4[0]);
+ params[6].buffer = v.f4;
+ params[6].length = float_len;
+ params[6].is_null = is_null;
+ params[6].num = 10;
+
+ params[7].buffer_type = TSDB_DATA_TYPE_DOUBLE;
+ params[7].buffer_length = sizeof(v.f8[0]);
+ params[7].buffer = v.f8;
+ params[7].length = double_len;
+ params[7].is_null = is_null;
+ params[7].num = 10;
+
+ params[8].buffer_type = TSDB_DATA_TYPE_BINARY;
+ params[8].buffer_length = sizeof(v.bin[0]);
+ params[8].buffer = v.bin;
+ params[8].length = bin_len;
+ params[8].is_null = is_null;
+ params[8].num = 10;
+
+ params[9].buffer_type = TSDB_DATA_TYPE_NCHAR;
+ params[9].buffer_length = sizeof(v.blob[0]);
+ params[9].buffer = v.blob;
+ params[9].length = blob_len;
+ params[9].is_null = is_null;
+ params[9].num = 10;
+
+
+ sql = "insert into ? using st1 tags(?,?) values(?,?,?,?,?,?,?,?,?,?)";
+ code = taos_stmt_prepare(stmt, sql, 0);
+ if (code != 0){
+ printf("\033[31mfailed to execute taos_stmt_prepare. code:0x%x\033[0m\n", code);
+ }
+
+ code = taos_stmt_set_tbname_tags(stmt, "m1", tags);
+ if (code != 0){
+ printf("\033[31mfailed to execute taos_stmt_prepare. code:0x%x\033[0m\n", code);
+ }
+
+ int64_t ts = 1591060628000;
+ for (int i = 0; i < 10; ++i) {
+ v.ts[i] = ts++;
+ is_null[i] = 0;
+
+ v.b[i] = (int8_t)i % 2;
+ v.v1[i] = (int8_t)i;
+ v.v2[i] = (int16_t)(i * 2);
+ v.v4[i] = (int32_t)(i * 4);
+ v.v8[i] = (int64_t)(i * 8);
+ v.f4[i] = (float)(i * 40);
+ v.f8[i] = (double)(i * 80);
+ for (int j = 0; j < sizeof(v.bin[0]) - 1; ++j) {
+ v.bin[i][j] = (char)(i + '0');
+ }
+ strcpy(v.blob[i], "一二三四五六七八九十");
+
+ t8_len[i] = sizeof(int8_t);
+ t16_len[i] = sizeof(int16_t);
+ t32_len[i] = sizeof(int32_t);
+ t64_len[i] = sizeof(int64_t);
+ float_len[i] = sizeof(float);
+ double_len[i] = sizeof(double);
+ bin_len[i] = sizeof(v.bin[0]);
+ blob_len[i] = (int32_t)strlen(v.blob[i]);
+ }
+
+
+ taos_stmt_bind_param_batch(stmt, params);
+ taos_stmt_add_batch(stmt);
+
+ if (taos_stmt_execute(stmt) != 0) {
+ printf("\033[31mfailed to execute insert statement.\033[0m\n");
+ return;
+ }
+ taos_stmt_close(stmt);
+
+ // query the records
+ stmt = taos_stmt_init(taos);
+ taos_stmt_prepare(stmt, "SELECT * FROM m1 WHERE v1 > ? AND v2 < ?", 0);
+
+ TAOS_BIND qparams[2];
+
+ int8_t v1 = 5;
+ int16_t v2 = 15;
+ qparams[0].buffer_type = TSDB_DATA_TYPE_TINYINT;
+ qparams[0].buffer_length = sizeof(v1);
+ qparams[0].buffer = &v1;
+ qparams[0].length = &qparams[0].buffer_length;
+ qparams[0].is_null = NULL;
+
+ qparams[1].buffer_type = TSDB_DATA_TYPE_SMALLINT;
+ qparams[1].buffer_length = sizeof(v2);
+ qparams[1].buffer = &v2;
+ qparams[1].length = &qparams[1].buffer_length;
+ qparams[1].is_null = NULL;
+
+ taos_stmt_bind_param(stmt, qparams);
+ if (taos_stmt_execute(stmt) != 0) {
+ printf("\033[31mfailed to execute select statement.\033[0m\n");
+ return;
+ }
+
+ result = taos_stmt_use_result(stmt);
+
+ TAOS_ROW row;
+ int rows = 0;
+ int num_fields = taos_num_fields(result);
+ TAOS_FIELD *fields = taos_fetch_fields(result);
+ char temp[256];
+
+ // fetch the records row by row
+ while ((row = taos_fetch_row(result))) {
+ rows++;
+ taos_print_row(temp, row, fields, num_fields);
+ printf("%s\n", temp);
+ }
+
+ taos_free_result(result);
+ taos_stmt_close(stmt);
+}
+
+
+
void retrieve_callback(void *param, TAOS_RES *tres, int numOfRows)
{
if (numOfRows > 0) {
@@ -493,6 +958,12 @@ int main(int argc, char *argv[]) {
printf("************ verify prepare *************\n");
verify_prepare(taos);
+ printf("************ verify prepare2 *************\n");
+ verify_prepare2(taos);
+
+ printf("************ verify prepare3 *************\n");
+ verify_prepare3(taos);
+
printf("************ verify stream *************\n");
verify_stream(taos);
printf("done\n");
diff --git a/tests/examples/lua/OpenResty/conf/nginx.conf b/tests/examples/lua/OpenResty/conf/nginx.conf
index 2f838c21fc..960cac606a 100644
--- a/tests/examples/lua/OpenResty/conf/nginx.conf
+++ b/tests/examples/lua/OpenResty/conf/nginx.conf
@@ -6,9 +6,9 @@ events {
}
http {
- lua_package_path '$prefix/lua/?.lua;$prefix/rest/?.lua;/blah/?.lua;;';
+ lua_package_path '$prefix/lua/?.lua;$prefix/rest/?.lua;$prefix/rest/?/init.lua;;';
lua_package_cpath "$prefix/so/?.so;;";
- lua_code_cache off;
+ lua_code_cache on;
server {
listen 7000;
server_name restapi;
diff --git a/tests/examples/lua/OpenResty/rest/config.lua b/tests/examples/lua/OpenResty/rest/config.lua
new file mode 100644
index 0000000000..72a4fd8ec6
--- /dev/null
+++ b/tests/examples/lua/OpenResty/rest/config.lua
@@ -0,0 +1,10 @@
+local config = {
+ host = "127.0.0.1",
+ port = 6030,
+ database = "",
+ user = "root",
+ password = "taosdata",
+ max_packet_size = 1024 * 1024 ,
+ connection_pool_size = 64
+}
+return config
diff --git a/tests/examples/lua/OpenResty/rest/tdpool/init.lua b/tests/examples/lua/OpenResty/rest/tdpool/init.lua
new file mode 100644
index 0000000000..ebf8e91756
--- /dev/null
+++ b/tests/examples/lua/OpenResty/rest/tdpool/init.lua
@@ -0,0 +1,72 @@
+local _M = {}
+local driver = require "luaconnector51"
+local water_mark = 0
+local occupied = 0
+local connection_pool = {}
+
+function _M.new(o,config)
+ o = o or {}
+ o.connection_pool = connection_pool
+ o.water_mark = water_mark
+ o.occupied = occupied
+ if #connection_pool == 0 then
+
+ for i = 1, config.connection_pool_size do
+ local res = driver.connect(config)
+ if res.code ~= 0 then
+ ngx.log(ngx.ERR, "connect--- failed:"..res.error)
+ return nil
+ else
+ local object = {obj = res.conn, state = 0}
+ table.insert(o.connection_pool,i, object)
+ ngx.log(ngx.INFO, "add connection, now pool size:"..#(o.connection_pool))
+ end
+ end
+
+ end
+
+ return setmetatable(o, { __index = _M })
+end
+
+function _M:get_connection()
+
+ local connection_obj
+
+ for i = 1, #connection_pool do
+ connection_obj = connection_pool[i]
+ if connection_obj.state == 0 then
+ connection_obj.state = 1
+ occupied = occupied +1
+ if occupied > water_mark then
+ water_mark = occupied
+ end
+ return connection_obj["obj"]
+ end
+ end
+
+ ngx.log(ngx.ERR,"ALERT! NO FREE CONNECTION.")
+
+ return nil
+end
+
+function _M:get_water_mark()
+
+ return water_mark
+end
+
+function _M:release_connection(conn)
+
+ local connection_obj
+
+ for i = 1, #connection_pool do
+ connection_obj = connection_pool[i]
+
+ if connection_obj["obj"] == conn then
+ connection_obj["state"] = 0
+ occupied = occupied -1
+ return
+ end
+ end
+end
+
+return _M
diff --git a/tests/examples/lua/OpenResty/rest/test.lua b/tests/examples/lua/OpenResty/rest/test.lua
index 179950cbe7..48aeef3fb4 100644
--- a/tests/examples/lua/OpenResty/rest/test.lua
+++ b/tests/examples/lua/OpenResty/rest/test.lua
@@ -1,26 +1,11 @@
local driver = require "luaconnector51"
local cjson = require "cjson"
+local Pool = require "tdpool"
+local config = require "config"
ngx.say("start time:"..os.time())
-
-local config = {
- host = "127.0.0.1",
- port = 6030,
- database = "",
- user = "root",
- password = "taosdata",
- max_packet_size = 1024 * 1024
-}
-
-local conn
-local res = driver.connect(config)
-if res.code ~=0 then
- ngx.say("connect--- failed: "..res.error)
- return
-else
- conn = res.conn
- ngx.say("connect--- pass.")
-end
+local pool = Pool.new(Pool,config)
+local conn = pool:get_connection()
local res = driver.query(conn,"drop database if exists nginx")
if res.code ~=0 then
@@ -51,7 +36,7 @@ else
ngx.say("create table--- pass.")
end
-res = driver.query(conn,"insert into m1 values ('2019-09-01 00:00:00.001',0,'robotspace'), ('2019-09-01 00:00:00.002',1,'Hilink'),('2019-09-01 00:00:00.003',2,'Harmony')")
+res = driver.query(conn,"insert into m1 values ('2019-09-01 00:00:00.001', 0, 'robotspace'), ('2019-09-01 00:00:00.002',1,'Hilink'),('2019-09-01 00:00:00.003',2,'Harmony')")
if res.code ~=0 then
ngx.say("insert records failed: "..res.error)
return
@@ -77,7 +62,29 @@ else
end
end
-driver.close(conn)
-ngx.say("end time:"..os.time())
---ngx.log(ngx.ERR,"in test file.")
+local flag = false
+function query_callback(res)
+ if res.code ~=0 then
+ ngx.say("async_query_callback--- failed:"..res.error)
+ else
+ if(res.affected == 3) then
+ ngx.say("async_query_callback, insert records--- pass")
+ else
+ ngx.say("async_query_callback, insert records---failed: expect 3 affected records, actually affected "..res.affected)
+ end
+ end
+ flag = true
+end
+
+driver.query_a(conn,"insert into m1 values ('2019-09-01 00:00:00.001', 3, 'robotspace'),('2019-09-01 00:00:00.006', 4, 'Hilink'),('2019-09-01 00:00:00.007', 6, 'Harmony')", query_callback)
+
+while not flag do
+-- ngx.say("i am here once...")
+ ngx.sleep(0.001) -- time unit is second
+end
+
+ngx.say("pool water_mark:"..pool:get_water_mark())
+
+pool:release_connection(conn)
+ngx.say("end time:"..os.time())
diff --git a/tests/examples/lua/OpenResty/so/luaconnector51.so b/tests/examples/lua/OpenResty/so/luaconnector51.so
index 442de6e39f..d8e4f00fec 100755
Binary files a/tests/examples/lua/OpenResty/so/luaconnector51.so and b/tests/examples/lua/OpenResty/so/luaconnector51.so differ
diff --git a/tests/examples/lua/build.sh b/tests/examples/lua/build.sh
index cbd47bdfd2..9d00c68425 100755
--- a/tests/examples/lua/build.sh
+++ b/tests/examples/lua/build.sh
@@ -1,2 +1,8 @@
-gcc -std=c99 lua_connector.c -fPIC -shared -o luaconnector.so -Wall -ltaos
+lua_header_installed=`apt-cache policy liblua5.3-dev|grep Installed|grep none > /dev/null; echo $?`
+if [ "$lua_header_installed" = "0" ]; then
+ echo "If need, please input root password to install liblua5.3-dev for build the connector.."
+ sudo apt install -y liblua5.3-dev
+fi
+
+gcc -std=c99 lua_connector.c -fPIC -shared -o luaconnector.so -Wall -ltaos -I/usr/include/lua5.3
diff --git a/tests/examples/lua/lua51/lua_connector51.c b/tests/examples/lua/lua51/lua_connector51.c
index 9b932337fe..fe2152945d 100644
--- a/tests/examples/lua/lua51/lua_connector51.c
+++ b/tests/examples/lua/lua51/lua_connector51.c
@@ -13,6 +13,11 @@ struct cb_param{
void * stream;
};
+struct async_query_callback_param{
+ lua_State* state;
+ int callback;
+};
+
static int l_connect(lua_State *L){
TAOS * taos=NULL;
const char* host;
@@ -23,7 +28,7 @@ static int l_connect(lua_State *L){
luaL_checktype(L, 1, LUA_TTABLE);
- lua_getfield(L,-1,"host");
+ lua_getfield(L, 1,"host");
if (lua_isstring(L,-1)){
host = lua_tostring(L, -1);
// printf("host = %s\n", host);
@@ -178,6 +183,58 @@ static int l_query(lua_State *L){
return 1;
}
+void async_query_callback(void *param, TAOS_RES *result, int code){
+ struct async_query_callback_param* p = (struct async_query_callback_param*) param;
+
+ //printf("\nin c,numfields:%d\n", numFields);
+ //printf("\nin c, code:%d\n", code);
+
+ lua_State *L = p->state;
+ lua_rawgeti(L, LUA_REGISTRYINDEX, p->callback);
+ lua_newtable(L);
+ int table_index = lua_gettop(L);
+ if( code < 0){
+ printf("failed, reason:%s\n", taos_errstr(result));
+ lua_pushinteger(L, -1);
+ lua_setfield(L, table_index, "code");
+ lua_pushstring(L,"something is wrong");// taos_errstr(taos));
+ lua_setfield(L, table_index, "error");
+ }else{
+ //printf("success to async query.\n");
+ const int affectRows = taos_affected_rows(result);
+ //printf(" affect rows:%d\r\n", affectRows);
+ lua_pushinteger(L, 0);
+ lua_setfield(L, table_index, "code");
+ lua_pushinteger(L, affectRows);
+ lua_setfield(L, table_index, "affected");
+ }
+
+ lua_call(L, 1, 0);
+}
+
+static int l_async_query(lua_State *L){
+ int r = luaL_ref(L, LUA_REGISTRYINDEX);
+ TAOS * taos = (TAOS*)lua_topointer(L,1);
+ const char * sqlstr = lua_tostring(L,2);
+ // int stime = luaL_checknumber(L,3);
+
+ lua_newtable(L);
+ int table_index = lua_gettop(L);
+
+ struct async_query_callback_param *p = malloc(sizeof(struct async_query_callback_param));
+ p->state = L;
+ p->callback=r;
+ // printf("r:%d, L:%d\n",r,L);
+ taos_query_a(taos,sqlstr,async_query_callback,p);
+
+ lua_pushnumber(L, 0);
+ lua_setfield(L, table_index, "code");
+ lua_pushstring(L, "ok");
+ lua_setfield(L, table_index, "error");
+
+ return 1;
+}
+
void stream_cb(void *param, TAOS_RES *result, TAOS_ROW row){
struct cb_param* p = (struct cb_param*) param;
TAOS_FIELD *fields = taos_fetch_fields(result);
@@ -308,6 +365,7 @@ static int l_close(lua_State *L){
static const struct luaL_Reg lib[] = {
{"connect", l_connect},
{"query", l_query},
+ {"query_a",l_async_query},
{"close", l_close},
{"open_stream", l_open_stream},
{"close_stream", l_close_stream},
diff --git a/tests/examples/lua/lua_connector.c b/tests/examples/lua/lua_connector.c
index 8078ed2665..8c2ea3e9e8 100644
--- a/tests/examples/lua/lua_connector.c
+++ b/tests/examples/lua/lua_connector.c
@@ -13,6 +13,11 @@ struct cb_param{
void * stream;
};
+struct async_query_callback_param{
+ lua_State* state;
+ int callback;
+};
+
static int l_connect(lua_State *L){
TAOS * taos=NULL;
const char* host;
@@ -56,6 +61,7 @@ static int l_connect(lua_State *L){
lua_settop(L,0);
taos_init();
+
lua_newtable(L);
int table_index = lua_gettop(L);
@@ -177,6 +183,58 @@ static int l_query(lua_State *L){
return 1;
}
+void async_query_callback(void *param, TAOS_RES *result, int code){
+ struct async_query_callback_param* p = (struct async_query_callback_param*) param;
+
+ //printf("\nin c,numfields:%d\n", numFields);
+ //printf("\nin c, code:%d\n", code);
+
+ lua_State *L = p->state;
+ lua_rawgeti(L, LUA_REGISTRYINDEX, p->callback);
+ lua_newtable(L);
+ int table_index = lua_gettop(L);
+ if( code < 0){
+ printf("failed, reason:%s\n", taos_errstr(result));
+ lua_pushinteger(L, -1);
+ lua_setfield(L, table_index, "code");
+ lua_pushstring(L,"something is wrong");// taos_errstr(taos));
+ lua_setfield(L, table_index, "error");
+ }else{
+ //printf("success to async query.\n");
+ const int affectRows = taos_affected_rows(result);
+ //printf(" affect rows:%d\r\n", affectRows);
+ lua_pushinteger(L, 0);
+ lua_setfield(L, table_index, "code");
+ lua_pushinteger(L, affectRows);
+ lua_setfield(L, table_index, "affected");
+ }
+
+ lua_call(L, 1, 0);
+}
+
+static int l_async_query(lua_State *L){
+ int r = luaL_ref(L, LUA_REGISTRYINDEX);
+ TAOS * taos = (TAOS*)lua_topointer(L,1);
+ const char * sqlstr = lua_tostring(L,2);
+ // int stime = luaL_checknumber(L,3);
+
+ lua_newtable(L);
+ int table_index = lua_gettop(L);
+
+ struct async_query_callback_param *p = malloc(sizeof(struct async_query_callback_param));
+ p->state = L;
+ p->callback=r;
+ // printf("r:%d, L:%d\n",r,L);
+ taos_query_a(taos,sqlstr,async_query_callback,p);
+
+ lua_pushnumber(L, 0);
+ lua_setfield(L, table_index, "code");
+ lua_pushstring(L, "ok");
+ lua_setfield(L, table_index, "error");
+
+ return 1;
+}
+
void stream_cb(void *param, TAOS_RES *result, TAOS_ROW row){
struct cb_param* p = (struct cb_param*) param;
TAOS_FIELD *fields = taos_fetch_fields(result);
@@ -307,6 +365,7 @@ static int l_close(lua_State *L){
static const struct luaL_Reg lib[] = {
{"connect", l_connect},
{"query", l_query},
+ {"query_a",l_async_query},
{"close", l_close},
{"open_stream", l_open_stream},
{"close_stream", l_close_stream},
diff --git a/tests/examples/lua/test.lua b/tests/examples/lua/test.lua
index 9f9c6934aa..89c0904c6a 100644
--- a/tests/examples/lua/test.lua
+++ b/tests/examples/lua/test.lua
@@ -110,7 +110,25 @@ else
end
end
-function callback(t)
+function async_query_callback(res)
+ if res.code ~=0 then
+ print("async_query_callback--- failed:"..res.error)
+ return
+ else
+
+ if(res.affected == 3) then
+ print("async_query_callback, insert records--- pass")
+ else
+ print("async_query_callback, insert records---failed: expect 3 affected records, actually affected "..res.affected)
+ end
+
+ end
+end
+
+driver.query_a(conn,"INSERT INTO therm1 VALUES ('2019-09-01 00:00:00.005', 100),('2019-09-01 00:00:00.006', 101),('2019-09-01 00:00:00.007', 102)", async_query_callback)
+
+
+function stream_callback(t)
print("------------------------")
print("continuous query result:")
for key, value in pairs(t) do
@@ -119,7 +137,7 @@ function callback(t)
end
local stream
-res = driver.open_stream(conn,"SELECT COUNT(*) as count, AVG(degree) as avg, MAX(degree) as max, MIN(degree) as min FROM thermometer interval(2s) sliding(2s);)",0,callback)
+res = driver.open_stream(conn,"SELECT COUNT(*) as count, AVG(degree) as avg, MAX(degree) as max, MIN(degree) as min FROM thermometer interval(2s) sliding(2s);)",0, stream_callback)
if res.code ~=0 then
print("open stream--- failed:"..res.error)
return
@@ -146,4 +164,5 @@ while loop_index < 30 do
end
driver.close_stream(stream)
+
driver.close(conn)
diff --git a/tests/mas/Jenkinsfile b/tests/mas/Jenkinsfile
index b2a1a5e116..0e6e94a037 100644
--- a/tests/mas/Jenkinsfile
+++ b/tests/mas/Jenkinsfile
@@ -29,8 +29,8 @@ pipeline {
agent none
environment{
- WK = '/var/lib/jenkins/workspace/TDinternal'
- WKC= '/var/lib/jenkins/workspace/TDinternal/community'
+ WK = '/data/lib/jenkins/workspace/TDinternal'
+ WKC= '/data/lib/jenkins/workspace/TDinternal/community'
}
stages {
diff --git a/tests/pytest/connector/lua.py b/tests/pytest/connector/lua.py
new file mode 100644
index 0000000000..23f0602e12
--- /dev/null
+++ b/tests/pytest/connector/lua.py
@@ -0,0 +1,73 @@
+###################################################################
+# Copyright (c) 2016 by TAOS Technologies, Inc.
+# All rights reserved.
+#
+# This file is proprietary and confidential to TAOS Technologies.
+# No part of this file may be reproduced, stored, transmitted,
+# disclosed or used in any form or by any means other than as
+# expressly provided by the written permission from Jianhui Tao
+#
+###################################################################
+
+# -*- coding: utf-8 -*-
+
+import sys
+from util.log import *
+from util.cases import *
+from util.sql import *
+
+
+class TDTestCase:
+ def init(self, conn, logSql):
+ tdLog.debug("start to execute %s" % __file__)
+ tdSql.init(conn.cursor(), logSql)
+
+ def getBuildPath(self):
+ selfPath = os.path.dirname(os.path.realpath(__file__))
+
+ if ("community" in selfPath):
+ projPath = selfPath[:selfPath.find("community")]
+ else:
+ projPath = selfPath[:selfPath.find("tests")]
+
+ for root, dirs, files in os.walk(projPath):
+ if ("taosd" in files):
+ rootRealPath = os.path.dirname(os.path.realpath(root))
+ if ("packaging" not in rootRealPath):
+ buildPath = root[:len(root) - len("/build/bin")]
+ break
+ return buildPath
+
+ def isLuaInstalled(self):
+ if not which('lua'):
+ tdLog.exit("Lua not found!")
+ return False
+ else:
+ return True
+
+ def run(self):
+ tdSql.prepare()
+# tdLog.info("Check if Lua installed")
+# if not self.isLuaInstalled():
+# sys.exit(1)
+
+ buildPath = self.getBuildPath()
+ if (buildPath == ""):
+ tdLog.exit("taosd not found!")
+ else:
+ tdLog.info("taosd found in %s" % buildPath)
+
+ targetPath = buildPath + "/../tests/examples/lua"
+ tdLog.info(targetPath)
+ currentPath = os.getcwd()
+ os.chdir(targetPath)
+ os.system('./build.sh')
+ os.system('lua test.lua')
+
+ def stop(self):
+ tdSql.close()
+ tdLog.success("%s successfully executed" % __file__)
+
+
+#tdCases.addWindows(__file__, TDTestCase())
+tdCases.addLinux(__file__, TDTestCase())
diff --git a/tests/pytest/crash_gen/crash_gen_main.py b/tests/pytest/crash_gen/crash_gen_main.py
index 644aa79916..b743eee2ef 100755
--- a/tests/pytest/crash_gen/crash_gen_main.py
+++ b/tests/pytest/crash_gen/crash_gen_main.py
@@ -37,6 +37,7 @@ import requests
import gc
import taos
+
from .shared.types import TdColumns, TdTags
# from crash_gen import ServiceManager, TdeInstance, TdeSubProcess
@@ -160,6 +161,7 @@ class WorkerThread:
Logging.debug("[TRD] Thread Coordinator not running any more, worker thread now stopping...")
break
+
# Before we fetch the task and run it, let's ensure we properly "use" the database (not needed any more)
try:
if (Config.getConfig().per_thread_db_connection): # most likely TRUE
@@ -1362,9 +1364,12 @@ class Task():
Progress.emit(Progress.ACCEPTABLE_ERROR)
self._err = err
else: # not an acceptable error
- errMsg = "[=] Unexpected Taos library exception ({}): errno=0x{:X}, msg: {}, SQL: {}".format(
+ shortTid = threading.get_ident() % 10000
+ errMsg = "[=] Unexpected Taos library exception ({}): errno=0x{:X}, thread={}, msg: {}, SQL: {}".format(
self.__class__.__name__,
- errno2, err, wt.getDbConn().getLastSql())
+ errno2,
+ shortTid,
+ err, wt.getDbConn().getLastSql())
self.logDebug(errMsg)
if Config.getConfig().debug:
# raise # so that we see full stack
@@ -1411,21 +1416,31 @@ class Task():
def lockTable(self, ftName): # full table name
# print(" <<" + ftName + '_', end="", flush=True)
- with Task._lock:
- if not ftName in Task._tableLocks:
+ with Task._lock: # SHORT lock! so we only protect lock creation
+ if not ftName in Task._tableLocks: # Create new lock and add to list, if needed
Task._tableLocks[ftName] = threading.Lock()
- Task._tableLocks[ftName].acquire()
+ # No lock protection, anybody can do this any time
+ lock = Task._tableLocks[ftName]
+ # Logging.info("Acquiring lock: {}, {}".format(ftName, lock))
+ lock.acquire()
+ # Logging.info("Acquiring lock successful: {}".format(lock))
def unlockTable(self, ftName):
# print('_' + ftName + ">> ", end="", flush=True)
- with Task._lock:
+ with Task._lock:
if not ftName in self._tableLocks:
raise RuntimeError("Corrupt state, no such lock")
lock = Task._tableLocks[ftName]
if not lock.locked():
raise RuntimeError("Corrupte state, already unlocked")
- lock.release()
+
+ # Important note, we want to protect unlocking under the task level
+ # locking, because we don't want the lock to be deleted (maybe in the futur)
+ # while we unlock it
+ # Logging.info("Releasing lock: {}".format(lock))
+ lock.release()
+ # Logging.info("Releasing lock successful: {}".format(lock))
class ExecutionStats:
@@ -1696,6 +1711,11 @@ class TdSuperTable:
return dbc.query("SELECT * FROM {}.{}".format(self._dbName, self._stName)) > 0
def ensureRegTable(self, task: Optional[Task], dbc: DbConn, regTableName: str):
+ '''
+ Make sure a regular table exists for this super table, creating it if necessary.
+ If there is an associated "Task" that wants to do this, "lock" this table so that
+ others don't access it while we create it.
+ '''
dbName = self._dbName
sql = "select tbname from {}.{} where tbname in ('{}')".format(dbName, self._stName, regTableName)
if dbc.query(sql) >= 1 : # reg table exists already
@@ -1703,18 +1723,24 @@ class TdSuperTable:
# acquire a lock first, so as to be able to *verify*. More details in TD-1471
fullTableName = dbName + '.' + regTableName
- if task is not None: # TODO: what happens if we don't lock the table
- task.lockTable(fullTableName)
+ if task is not None: # Somethime thie operation is requested on behalf of a "task"
+ # Logging.info("Locking table for creation: {}".format(fullTableName))
+ task.lockTable(fullTableName) # in which case we'll lock this table to ensure serialized access
+ # Logging.info("Table locked for creation".format(fullTableName))
Progress.emit(Progress.CREATE_TABLE_ATTEMPT) # ATTEMPT to create a new table
# print("(" + fullTableName[-3:] + ")", end="", flush=True)
try:
sql = "CREATE TABLE {} USING {}.{} tags ({})".format(
fullTableName, dbName, self._stName, self._getTagStrForSql(dbc)
)
+ # Logging.info("Creating regular with SQL: {}".format(sql))
dbc.execute(sql)
+ # Logging.info("Regular table created: {}".format(sql))
finally:
if task is not None:
+ # Logging.info("Unlocking table after creation: {}".format(fullTableName))
task.unlockTable(fullTableName) # no matter what
+ # Logging.info("Table unlocked after creation: {}".format(fullTableName))
def _getTagStrForSql(self, dbc) :
tags = self._getTags(dbc)
@@ -2011,9 +2037,30 @@ class TaskAddData(StateTransitionTask):
def canBeginFrom(cls, state: AnyState):
return state.canAddData()
+ def _lockTableIfNeeded(self, fullTableName, extraMsg = ''):
+ if Config.getConfig().verify_data:
+ # Logging.info("Locking table: {}".format(fullTableName))
+ self.lockTable(fullTableName)
+ # Logging.info("Table locked {}: {}".format(extraMsg, fullTableName))
+ # print("_w" + str(nextInt % 100), end="", flush=True) # Trace what was written
+ else:
+ # Logging.info("Skipping locking table")
+ pass
+
+ def _unlockTableIfNeeded(self, fullTableName):
+ if Config.getConfig().verify_data:
+ # Logging.info("Unlocking table: {}".format(fullTableName))
+ self.unlockTable(fullTableName)
+ # Logging.info("Table unlocked: {}".format(fullTableName))
+ else:
+ pass
+ # Logging.info("Skipping unlocking table")
+
def _addDataInBatch(self, db, dbc, regTableName, te: TaskExecutor):
numRecords = self.LARGE_NUMBER_OF_RECORDS if Config.getConfig().larger_data else self.SMALL_NUMBER_OF_RECORDS
+
fullTableName = db.getName() + '.' + regTableName
+ self._lockTableIfNeeded(fullTableName, 'batch')
sql = "INSERT INTO {} VALUES ".format(fullTableName)
for j in range(numRecords): # number of records per table
@@ -2021,51 +2068,60 @@ class TaskAddData(StateTransitionTask):
nextTick = db.getNextTick()
nextColor = db.getNextColor()
sql += "('{}', {}, '{}');".format(nextTick, nextInt, nextColor)
- dbc.execute(sql)
+
+ # Logging.info("Adding data in batch: {}".format(sql))
+ try:
+ dbc.execute(sql)
+ finally:
+ # Logging.info("Data added in batch: {}".format(sql))
+ self._unlockTableIfNeeded(fullTableName)
+
+
def _addData(self, db: Database, dbc, regTableName, te: TaskExecutor): # implied: NOT in batches
numRecords = self.LARGE_NUMBER_OF_RECORDS if Config.getConfig().larger_data else self.SMALL_NUMBER_OF_RECORDS
for j in range(numRecords): # number of records per table
- nextInt = db.getNextInt()
+ intToWrite = db.getNextInt()
nextTick = db.getNextTick()
nextColor = db.getNextColor()
if Config.getConfig().record_ops:
self.prepToRecordOps()
if self.fAddLogReady is None:
raise CrashGenError("Unexpected empty fAddLogReady")
- self.fAddLogReady.write("Ready to write {} to {}\n".format(nextInt, regTableName))
+ self.fAddLogReady.write("Ready to write {} to {}\n".format(intToWrite, regTableName))
self.fAddLogReady.flush()
os.fsync(self.fAddLogReady.fileno())
# TODO: too ugly trying to lock the table reliably, refactor...
fullTableName = db.getName() + '.' + regTableName
- if Config.getConfig().verify_data:
- self.lockTable(fullTableName)
- # print("_w" + str(nextInt % 100), end="", flush=True) # Trace what was written
-
+ self._lockTableIfNeeded(fullTableName) # so that we are verify read-back. TODO: deal with exceptions before unlock
+
try:
sql = "INSERT INTO {} VALUES ('{}', {}, '{}');".format( # removed: tags ('{}', {})
fullTableName,
# ds.getFixedSuperTableName(),
# ds.getNextBinary(), ds.getNextFloat(),
- nextTick, nextInt, nextColor)
+ nextTick, intToWrite, nextColor)
+ # Logging.info("Adding data: {}".format(sql))
dbc.execute(sql)
+ # Logging.info("Data added: {}".format(sql))
+ intWrote = intToWrite
# Quick hack, attach an update statement here. TODO: create an "update" task
if (not Config.getConfig().use_shadow_db) and Dice.throw(5) == 0: # 1 in N chance, plus not using shaddow DB
- nextInt = db.getNextInt()
+ intToUpdate = db.getNextInt() # Updated, but should not succeed
nextColor = db.getNextColor()
sql = "INSERt INTO {} VALUES ('{}', {}, '{}');".format( # "INSERt" means "update" here
fullTableName,
- nextTick, nextInt, nextColor)
+ nextTick, intToUpdate, nextColor)
# sql = "UPDATE {} set speed={}, color='{}' WHERE ts='{}'".format(
# fullTableName, db.getNextInt(), db.getNextColor(), nextTick)
dbc.execute(sql)
+ intWrote = intToUpdate # We updated, seems TDengine non-cluster accepts this.
except: # Any exception at all
- if Config.getConfig().verify_data:
- self.unlockTable(fullTableName)
+ self._unlockTableIfNeeded(fullTableName)
raise
# Now read it back and verify, we might encounter an error if table is dropped
@@ -2073,33 +2129,41 @@ class TaskAddData(StateTransitionTask):
try:
readBack = dbc.queryScalar("SELECT speed from {}.{} WHERE ts='{}'".
format(db.getName(), regTableName, nextTick))
- if readBack != nextInt :
+ if readBack != intWrote :
raise taos.error.ProgrammingError(
"Failed to read back same data, wrote: {}, read: {}"
- .format(nextInt, readBack), 0x999)
+ .format(intWrote, readBack), 0x999)
except taos.error.ProgrammingError as err:
errno = Helper.convertErrno(err.errno)
- if errno in [CrashGenError.INVALID_EMPTY_RESULT, CrashGenError.INVALID_MULTIPLE_RESULT] : # not a single result
+ if errno == CrashGenError.INVALID_EMPTY_RESULT: # empty result
raise taos.error.ProgrammingError(
- "Failed to read back same data for tick: {}, wrote: {}, read: {}"
- .format(nextTick, nextInt, "Empty Result" if errno == CrashGenError.INVALID_EMPTY_RESULT else "Multiple Result"),
+ "Failed to read back same data for tick: {}, wrote: {}, read: EMPTY"
+ .format(nextTick, intWrote),
+ errno)
+ elif errno == CrashGenError.INVALID_MULTIPLE_RESULT : # multiple results
+ raise taos.error.ProgrammingError(
+ "Failed to read back same data for tick: {}, wrote: {}, read: MULTIPLE RESULTS"
+ .format(nextTick, intWrote),
errno)
elif errno in [0x218, 0x362]: # table doesn't exist
# do nothing
- dummy = 0
+ pass
else:
# Re-throw otherwise
raise
finally:
- self.unlockTable(fullTableName) # Unlock the table no matter what
+ self._unlockTableIfNeeded(fullTableName) # Quite ugly, refactor lock/unlock
+ # Done with read-back verification, unlock the table now
+ else:
+ self._unlockTableIfNeeded(fullTableName)
# Successfully wrote the data into the DB, let's record it somehow
- te.recordDataMark(nextInt)
+ te.recordDataMark(intWrote)
if Config.getConfig().record_ops:
if self.fAddLogDone is None:
raise CrashGenError("Unexpected empty fAddLogDone")
- self.fAddLogDone.write("Wrote {} to {}\n".format(nextInt, regTableName))
+ self.fAddLogDone.write("Wrote {} to {}\n".format(intWrote, regTableName))
self.fAddLogDone.flush()
os.fsync(self.fAddLogDone.fileno())
@@ -2137,15 +2201,16 @@ class TaskAddData(StateTransitionTask):
class ThreadStacks: # stack info for all threads
def __init__(self):
self._allStacks = {}
- allFrames = sys._current_frames()
- for th in threading.enumerate():
+ allFrames = sys._current_frames() # All current stack frames
+ for th in threading.enumerate(): # For each thread
if th.ident is None:
continue
- stack = traceback.extract_stack(allFrames[th.ident])
- self._allStacks[th.native_id] = stack
+ stack = traceback.extract_stack(allFrames[th.ident]) # Get stack for a thread
+ shortTid = th.ident % 10000
+ self._allStacks[shortTid] = stack # Was using th.native_id
def print(self, filteredEndName = None, filterInternal = False):
- for thNid, stack in self._allStacks.items(): # for each thread, stack frames top to bottom
+ for tIdent, stack in self._allStacks.items(): # for each thread, stack frames top to bottom
lastFrame = stack[-1]
if filteredEndName: # we need to filter out stacks that match this name
if lastFrame.name == filteredEndName : # end did not match
@@ -2157,7 +2222,7 @@ class ThreadStacks: # stack info for all threads
'__init__']: # the thread that extracted the stack
continue # ignore
# Now print
- print("\n<----- Thread Info for LWP/ID: {} (most recent call last) <-----".format(thNid))
+ print("\n<----- Thread Info for LWP/ID: {} (most recent call last) <-----".format(tIdent))
stackFrame = 0
for frame in stack: # was using: reversed(stack)
# print(frame)
@@ -2376,7 +2441,7 @@ class MainExec:
action='store',
default=0,
type=int,
- help='Maximum number of DBs to keep, set to disable dropping DB. (default: 0)')
+ help='Number of DBs to use, set to disable dropping DB. (default: 0)')
parser.add_argument(
'-c',
'--connector-type',
diff --git a/tests/pytest/crash_gen/service_manager.py b/tests/pytest/crash_gen/service_manager.py
index 1cd65c1dde..c6685ec469 100644
--- a/tests/pytest/crash_gen/service_manager.py
+++ b/tests/pytest/crash_gen/service_manager.py
@@ -179,7 +179,7 @@ quorum 2
def getServiceCmdLine(self): # to start the instance
if Config.getConfig().track_memory_leaks:
Logging.info("Invoking VALGRIND on service...")
- return ['exec /usr/bin/valgrind', '--leak-check=yes', self.getExecFile(), '-c', self.getCfgDir()]
+ return ['exec valgrind', '--leak-check=yes', self.getExecFile(), '-c', self.getCfgDir()]
else:
# TODO: move "exec -c" into Popen(), we can both "use shell" and NOT fork so ask to lose kill control
return ["exec " + self.getExecFile(), '-c', self.getCfgDir()] # used in subproce.Popen()
@@ -310,7 +310,7 @@ class TdeSubProcess:
# print("Starting TDengine with env: ", myEnv.items())
print("Starting TDengine: {}".format(cmdLine))
- return Popen(
+ ret = Popen(
' '.join(cmdLine), # ' '.join(cmdLine) if useShell else cmdLine,
shell=True, # Always use shell, since we need to pass ENV vars
stdout=PIPE,
@@ -318,6 +318,10 @@ class TdeSubProcess:
close_fds=ON_POSIX,
env=myEnv
) # had text=True, which interferred with reading EOF
+ time.sleep(0.01) # very brief wait, then let's check if sub process started successfully.
+ if ret.poll():
+ raise CrashGenError("Sub process failed to start with command line: {}".format(cmdLine))
+ return ret
STOP_SIGNAL = signal.SIGINT # signal.SIGKILL/SIGINT # What signal to use (in kill) to stop a taosd process?
SIG_KILL_RETCODE = 137 # ref: https://stackoverflow.com/questions/43268156/process-finished-with-exit-code-137-in-pycharm
@@ -614,7 +618,7 @@ class ServiceManager:
# Find if there's already a taosd service, and then kill it
for proc in psutil.process_iter():
- if proc.name() == 'taosd':
+ if proc.name() == 'taosd' or proc.name() == 'memcheck-amd64-': # Regular or under Valgrind
Logging.info("Killing an existing TAOSD process in 2 seconds... press CTRL-C to interrupt")
time.sleep(2.0)
proc.kill()
diff --git a/tests/pytest/crash_gen/shared/misc.py b/tests/pytest/crash_gen/shared/misc.py
index 90ad802ff1..78923bcc29 100644
--- a/tests/pytest/crash_gen/shared/misc.py
+++ b/tests/pytest/crash_gen/shared/misc.py
@@ -35,7 +35,8 @@ class LoggingFilter(logging.Filter):
class MyLoggingAdapter(logging.LoggerAdapter):
def process(self, msg, kwargs):
- return "[{:04d}] {}".format(threading.get_ident() % 10000, msg), kwargs
+ shortTid = threading.get_ident() % 10000
+ return "[{:04d}] {}".format(shortTid, msg), kwargs
# return '[%s] %s' % (self.extra['connid'], msg), kwargs
diff --git a/tests/pytest/fulltest.sh b/tests/pytest/fulltest.sh
index be2cfee04b..c5aba24867 100755
--- a/tests/pytest/fulltest.sh
+++ b/tests/pytest/fulltest.sh
@@ -31,7 +31,7 @@ python3 ./test.py -f table/column_name.py
python3 ./test.py -f table/column_num.py
python3 ./test.py -f table/db_table.py
python3 ./test.py -f table/create_sensitive.py
-#python3 ./test.py -f table/tablename-boundary.py
+python3 ./test.py -f table/tablename-boundary.py
python3 ./test.py -f table/max_table_length.py
python3 ./test.py -f table/alter_column.py
python3 ./test.py -f table/boundary.py
@@ -334,5 +334,7 @@ python3 ./test.py -f tag_lite/alter_tag.py
python3 test.py -f tools/taosdemoAllTest/taosdemoTestInsertWithJson.py
python3 test.py -f tools/taosdemoAllTest/taosdemoTestQueryWithJson.py
+python3 ./test.py -f tag_lite/drop_auto_create.py
+python3 test.py -f insert/insert_before_use_db.py
#======================p4-end===============
diff --git a/tests/pytest/import_merge/importCSV.py b/tests/pytest/import_merge/importCSV.py
index b4441949a1..24ebffd485 100644
--- a/tests/pytest/import_merge/importCSV.py
+++ b/tests/pytest/import_merge/importCSV.py
@@ -82,6 +82,8 @@ class TDTestCase:
tdSql.execute("import into tbx file \'%s\'"%(self.csvfile))
tdSql.query('select * from tbx')
tdSql.checkRows(self.rows)
+ #TD-4447 import the same csv twice
+ tdSql.execute("import into tbx file \'%s\'"%(self.csvfile))
def stop(self):
self.destroyCSVFile()
diff --git a/tests/pytest/insert/insert_before_use_db.py b/tests/pytest/insert/insert_before_use_db.py
new file mode 100644
index 0000000000..8cc02b3d4b
--- /dev/null
+++ b/tests/pytest/insert/insert_before_use_db.py
@@ -0,0 +1,39 @@
+###################################################################
+# Copyright (c) 2016 by TAOS Technologies, Inc.
+# All rights reserved.
+#
+# This file is proprietary and confidential to TAOS Technologies.
+# No part of this file may be reproduced, stored, transmitted,
+# disclosed or used in any form or by any means other than as
+# expressly provided by the written permission from Jianhui Tao
+#
+###################################################################
+
+# -*- coding: utf-8 -*-
+
+import sys
+from util.log import *
+from util.cases import *
+from util.sql import *
+
+
+class TDTestCase:
+ def init(self, conn, logSql):
+ tdLog.debug("start to execute %s" % __file__)
+ tdSql.init(conn.cursor(), logSql)
+
+ def run(self):
+ tdSql.error('insert into tb values (now + 10m, 10)')
+ tdSql.prepare()
+ tdSql.error('insert into tb values (now + 10m, 10)')
+ tdSql.execute('drop database db')
+ tdSql.error('insert into tb values (now + 10m, 10)')
+
+
+ def stop(self):
+ tdSql.close()
+ tdLog.success("%s successfully executed" % __file__)
+
+
+tdCases.addWindows(__file__, TDTestCase())
+tdCases.addLinux(__file__, TDTestCase())
diff --git a/tests/pytest/insert/nchar.py b/tests/pytest/insert/nchar.py
index 3319aa3c56..5ad52b96a1 100644
--- a/tests/pytest/insert/nchar.py
+++ b/tests/pytest/insert/nchar.py
@@ -36,6 +36,10 @@ class TDTestCase:
tdSql.checkData(1, 1, '涛思数据')
tdSql.error("insert into tb values (now, 'taosdata001')")
+
+ tdSql.error("insert into tb(now, 😀)")
+ tdSql.query("select * from tb")
+ tdSql.checkRows(2)
def stop(self):
tdSql.close()
diff --git a/tests/pytest/smoketest.sh b/tests/pytest/smoketest.sh
index 0eb850749f..7f7cb2a89e 100755
--- a/tests/pytest/smoketest.sh
+++ b/tests/pytest/smoketest.sh
@@ -35,3 +35,5 @@ python3.8 ./test.py $1 -s && sleep 1
python3.8 ./test.py $1 -f client/client.py
python3.8 ./test.py $1 -s && sleep 1
+# connector
+python3.8 ./test.py $1 -f connector/lua.py
diff --git a/tests/pytest/table/tablename-boundary.py b/tests/pytest/table/tablename-boundary.py
index 0755e75355..dc22c3343b 100644
--- a/tests/pytest/table/tablename-boundary.py
+++ b/tests/pytest/table/tablename-boundary.py
@@ -14,6 +14,13 @@ class TDTestCase:
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
+ self.ts = 1622100000000
+
+ def get_random_string(self, length):
+ letters = string.ascii_lowercase
+ result_str = ''.join(random.choice(letters) for i in range(length))
+ return result_str
+
def run(self):
tdSql.prepare()
@@ -24,19 +31,62 @@ class TDTestCase:
shell=True)) - 1
tdLog.info("table name max length is %d" % tableNameMaxLen)
chars = string.ascii_uppercase + string.ascii_lowercase
- tb_name = ''.join(random.choices(chars, k=tableNameMaxLen))
+ tb_name = ''.join(random.choices(chars, k=tableNameMaxLen + 1))
tdLog.info('tb_name length %d' % len(tb_name))
tdLog.info('create table %s (ts timestamp, value int)' % tb_name)
- tdSql.error(
- 'create table %s (ts timestamp, speed binary(4089))' %
- tb_name)
+ tdSql.error('create table %s (ts timestamp, speed binary(4089))' % tb_name)
- tb_name = ''.join(random.choices(chars, k=191))
+ tb_name = ''.join(random.choices(chars, k=tableNameMaxLen))
tdLog.info('tb_name length %d' % len(tb_name))
tdLog.info('create table %s (ts timestamp, value int)' % tb_name)
tdSql.execute(
'create table %s (ts timestamp, speed binary(4089))' %
tb_name)
+
+ db_name = self.get_random_string(33)
+ tdSql.error("create database %s" % db_name)
+
+ db_name = self.get_random_string(32)
+ tdSql.execute("create database %s" % db_name)
+ tdSql.execute("use %s" % db_name)
+
+ tb_name = self.get_random_string(193)
+ tdSql.error("create table %s(ts timestamp, val int)" % tb_name)
+
+ tb_name = self.get_random_string(192)
+ tdSql.execute("create table %s.%s(ts timestamp, val int)" % (db_name, tb_name))
+ tdSql.query("show %s.tables" % db_name)
+ tdSql.checkRows(1)
+ tdSql.checkData(0, 0, tb_name)
+
+ tdSql.execute("insert into %s.%s values(now, 1)" % (db_name, tb_name))
+ tdSql.query("select * from %s.%s" %(db_name, tb_name))
+ tdSql.checkRows(1)
+
+ db_name = self.get_random_string(32)
+ tdSql.execute("create database %s update 1" % db_name)
+
+ stb_name = self.get_random_string(192)
+ tdSql.execute("create table %s.%s(ts timestamp, val int) tags(id int)" % (db_name, stb_name))
+ tb_name1 = self.get_random_string(192)
+ tdSql.execute("insert into %s.%s using %s.%s tags(1) values(%d, 1)(%d, 2)(%d, 3)" % (db_name, tb_name1, db_name, stb_name, self.ts, self.ts + 1, self.ts + 2))
+ tb_name2 = self.get_random_string(192)
+ tdSql.execute("insert into %s.%s using %s.%s tags(2) values(%d, 1)(%d, 2)(%d, 3)" % (db_name, tb_name2, db_name, stb_name, self.ts, self.ts + 1, self.ts + 2))
+
+ tdSql.query("show %s.tables" % db_name)
+ tdSql.checkRows(2)
+
+ tdSql.query("select * from %s.%s" % (db_name, stb_name))
+ tdSql.checkRows(6)
+
+ tdSql.execute("insert into %s.%s using %s.%s tags(1) values(%d, null)" % (db_name, tb_name1, db_name, stb_name, self.ts))
+
+ tdSql.query("select * from %s.%s" % (db_name, stb_name))
+ tdSql.checkRows(6)
+
+
+
+
def stop(self):
tdSql.close()
diff --git a/tests/pytest/tag_lite/drop_auto_create.py b/tests/pytest/tag_lite/drop_auto_create.py
new file mode 100644
index 0000000000..f89b41008b
--- /dev/null
+++ b/tests/pytest/tag_lite/drop_auto_create.py
@@ -0,0 +1,47 @@
+###################################################################
+# Copyright (c) 2016 by TAOS Technologies, Inc.
+# All rights reserved.
+#
+# This file is proprietary and confidential to TAOS Technologies.
+# No part of this file may be reproduced, stored, transmitted,
+# disclosed or used in any form or by any means other than as
+# expressly provided by the written permission from Jianhui Tao
+#
+###################################################################
+
+# -*- coding: utf-8 -*-
+
+import sys
+from util.log import *
+from util.cases import *
+from util.sql import *
+
+
+class TDTestCase:
+ def init(self, conn, logSql):
+ tdLog.debug("start to execute %s" % __file__)
+ tdSql.init(conn.cursor(), logSql)
+
+ def run(self):
+ tdSql.prepare()
+
+ tdSql.execute('create table m1(ts timestamp, k int) tags(a binary(12), b int, c double);')
+ tdSql.execute('insert into tm0 using m1(b,c) tags(1, 99) values(now, 1);')
+ tdSql.execute('insert into tm1 using m1(b,c) tags(2, 100) values(now, 2);')
+ tdLog.info("2 rows inserted")
+ tdSql.query('select * from m1;')
+ tdSql.checkRows(2)
+ tdSql.query('select *,tbname from m1;')
+ tdSql.execute("drop table tm0; ")
+ tdSql.query('select * from m1')
+ tdSql.checkRows(1)
+
+
+
+ def stop(self):
+ tdSql.close()
+ tdLog.success("%s successfully executed" % __file__)
+
+
+tdCases.addWindows(__file__, TDTestCase())
+tdCases.addLinux(__file__, TDTestCase())
diff --git a/tests/script/api/batchprepare.c b/tests/script/api/batchprepare.c
index 92253be78c..55eb62d9bb 100644
--- a/tests/script/api/batchprepare.c
+++ b/tests/script/api/batchprepare.c
@@ -1046,6 +1046,7 @@ int stmt_funcb_autoctb1(TAOS_STMT *stmt) {
free(params);
free(is_null);
free(no_null);
+ free(tags);
return 0;
}
@@ -1258,6 +1259,7 @@ int stmt_funcb_autoctb2(TAOS_STMT *stmt) {
free(params);
free(is_null);
free(no_null);
+ free(tags);
return 0;
}
@@ -1446,6 +1448,7 @@ int stmt_funcb_autoctb3(TAOS_STMT *stmt) {
free(params);
free(is_null);
free(no_null);
+ free(tags);
return 0;
}
@@ -1635,6 +1638,7 @@ int stmt_funcb_autoctb_e1(TAOS_STMT *stmt) {
free(params);
free(is_null);
free(no_null);
+ free(tags);
return 0;
}
@@ -1849,6 +1853,7 @@ int stmt_funcb_autoctb_e2(TAOS_STMT *stmt) {
free(params);
free(is_null);
free(no_null);
+ free(tags);
return 0;
}
diff --git a/tests/script/api/stmtBatchTest.c b/tests/script/api/stmtBatchTest.c
index 8bd296db61..24291adfa0 100644
--- a/tests/script/api/stmtBatchTest.c
+++ b/tests/script/api/stmtBatchTest.c
@@ -1450,6 +1450,47 @@ static void prepareV_long(TAOS *taos, int schemaCase, int tableNum, int lenO
}
+static void prepareVcolumn_autoCreateTbl(TAOS *taos, int schemaCase, int tableNum, int lenOfBinaryDef, char* dbName) {
+ TAOS_RES *result;
+ int code;
+ char sqlstr[1024] = {0};
+ sprintf(sqlstr, "drop database if exists %s;", dbName);
+ result = taos_query(taos, sqlstr);
+ taos_free_result(result);
+
+ sprintf(sqlstr, "create database %s;", dbName);
+ result = taos_query(taos, sqlstr);
+ code = taos_errno(result);
+ if (code != 0) {
+ printf("failed to create database, reason:%s\n", taos_errstr(result));
+ taos_free_result(result);
+ return;
+ }
+ taos_free_result(result);
+
+ sprintf(sqlstr, "use %s;", dbName);
+ result = taos_query(taos, sqlstr);
+ taos_free_result(result);
+
+ // create table
+ char buf[1024] = {0};
+ //if (bigsize) {
+ sprintf(buf, "create stable stb1 (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, br binary(%d), nr nchar(%d), ts2 timestamp)"
+ " tags(id1 int, id2 bool, id3 tinyint, id4 smallint, id5 bigint, id6 float, id7 double, id8 binary(%d), id9 nchar(%d))", lenOfBinaryDef, lenOfBinaryDef, lenOfBinaryDef, lenOfBinaryDef) ;
+ //} else {
+ // sprintf(buf, "create stable stb1 (ts timestamp, b int) tags(id1 int, id2 bool, id3 tinyint, id4 smallint, id5 bigint, id6 float, id7 double, id8 binary(40), id9 nchar(40))") ;
+ //}
+
+ result = taos_query(taos, buf);
+ code = taos_errno(result);
+ if (code != 0) {
+ printf("failed to create table, reason:%s\n", taos_errstr(result));
+ taos_free_result(result);
+ return;
+ }
+ taos_free_result(result);
+}
+
static void prepareVcolumn(TAOS *taos, int schemaCase, int tableNum, int lenOfBinaryDef, char* dbName) {
TAOS_RES *result;
@@ -3159,12 +3200,1218 @@ static void SpecifyColumnBatchCase(TAOS *taos) {
}
+
+/*=======================*/
+/*
+test scene: insert into tb1 (ts,f1) values (?,?)
+*/
+static int stmt_specifyCol_bind_case_001_autoCreateTbl(TAOS_STMT *stmt, int tableNum, int rowsOfPerColum, int bingNum, int lenOfBinaryDef, int lenOfBinaryAct, int columnNum) {
+ sampleValue* v = (sampleValue *)calloc(1, sizeof(sampleValue));
+
+ int totalRowsPerTbl = rowsOfPerColum * bingNum;
+
+ v->ts = (int64_t *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * tableNum));
+ v->br = (char *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * lenOfBinaryDef));
+ v->nr = (char *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * lenOfBinaryDef));
+
+ int *lb = (int *)malloc(MAX_ROWS_OF_PER_COLUMN * sizeof(int));
+
+ TAOS_BIND *tags = calloc(1, sizeof(TAOS_BIND) * 9 * 1);
+ TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * (size_t)(bingNum * columnNum * (tableNum+1) * rowsOfPerColum));
+ char* is_null = malloc(sizeof(char) * MAX_ROWS_OF_PER_COLUMN);
+ char* no_null = malloc(sizeof(char) * MAX_ROWS_OF_PER_COLUMN);
+ int one_not_null = 0;
+
+ int64_t tts = 1591060628000;
+
+ for (int i = 0; i < rowsOfPerColum; ++i) {
+ lb[i] = lenOfBinaryAct;
+ no_null[i] = 0;
+ is_null[i] = (i % 10 == 2) ? 1 : 0;
+ v->b[i] = (int8_t)(i % 2);
+ v->v1[i] = (int8_t)((i+1) % 2);
+ v->v2[i] = (int16_t)i;
+ v->v4[i] = (int32_t)(i+1);
+ v->v8[i] = (int64_t)(i+2);
+ v->f4[i] = (float)(i+3);
+ v->f8[i] = (double)(i+4);
+ char tbuf[MAX_BINARY_DEF_LEN];
+ memset(tbuf, 0, MAX_BINARY_DEF_LEN);
+ sprintf(tbuf, "binary-%d-0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", i%10);
+ memcpy(v->br + i*lenOfBinaryDef, tbuf, (size_t)lenOfBinaryAct);
+ memset(tbuf, 0, MAX_BINARY_DEF_LEN);
+ sprintf(tbuf, "nchar-%d-0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", i%10);
+ memcpy(v->nr + i*lenOfBinaryDef, tbuf, (size_t)lenOfBinaryAct);
+ v->ts2[i] = tts + i;
+ }
+
+ int i = 0;
+ for (int j = 0; j < bingNum * tableNum; j++) {
+ params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP;
+ params[i+0].buffer_length = sizeof(int64_t);
+ params[i+0].buffer = &v->ts[j*rowsOfPerColum];
+ params[i+0].length = NULL;
+ params[i+0].is_null = no_null;
+ params[i+0].num = rowsOfPerColum;
+
+ params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL;
+ params[i+1].buffer_length = sizeof(int8_t);
+ params[i+1].buffer = v->b;
+ params[i+1].length = NULL;
+ params[i+1].is_null = is_null;
+ params[i+1].num = rowsOfPerColum;
+
+ params[i+2].buffer_type = TSDB_DATA_TYPE_INT;
+ params[i+2].buffer_length = sizeof(int32_t);
+ params[i+2].buffer = v->v4;
+ params[i+2].length = NULL;
+ params[i+2].is_null = is_null;
+ params[i+2].num = rowsOfPerColum;
+
+ params[i+3].buffer_type = TSDB_DATA_TYPE_FLOAT;
+ params[i+3].buffer_length = sizeof(float);
+ params[i+3].buffer = v->f4;
+ params[i+3].length = NULL;
+ params[i+3].is_null = is_null;
+ params[i+3].num = rowsOfPerColum;
+
+ params[i+4].buffer_type = TSDB_DATA_TYPE_BINARY;
+ params[i+4].buffer_length = (uintptr_t)lenOfBinaryDef;
+ params[i+4].buffer = v->br;
+ params[i+4].length = lb;
+ params[i+4].is_null = is_null;
+ params[i+4].num = rowsOfPerColum;
+
+ i+=columnNum;
+ }
+
+ //int64_t tts = 1591060628000;
+ for (int i = 0; i < totalRowsPerTbl * tableNum; ++i) {
+ v->ts[i] = tts + i;
+ }
+
+ for (int i = 0; i < 1; ++i) {
+ tags[i+0].buffer_type = TSDB_DATA_TYPE_INT;
+ tags[i+0].buffer = v->v4;
+ tags[i+0].is_null = &one_not_null;
+ tags[i+0].length = NULL;
+
+ tags[i+1].buffer_type = TSDB_DATA_TYPE_BOOL;
+ tags[i+1].buffer = v->b;
+ tags[i+1].is_null = &one_not_null;
+ tags[i+1].length = NULL;
+
+ tags[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT;
+ tags[i+2].buffer = v->v1;
+ tags[i+2].is_null = &one_not_null;
+ tags[i+2].length = NULL;
+
+ tags[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT;
+ tags[i+3].buffer = v->v2;
+ tags[i+3].is_null = &one_not_null;
+ tags[i+3].length = NULL;
+
+ tags[i+4].buffer_type = TSDB_DATA_TYPE_BIGINT;
+ tags[i+4].buffer = v->v8;
+ tags[i+4].is_null = &one_not_null;
+ tags[i+4].length = NULL;
+
+ tags[i+5].buffer_type = TSDB_DATA_TYPE_FLOAT;
+ tags[i+5].buffer = v->f4;
+ tags[i+5].is_null = &one_not_null;
+ tags[i+5].length = NULL;
+
+ tags[i+6].buffer_type = TSDB_DATA_TYPE_DOUBLE;
+ tags[i+6].buffer = v->f8;
+ tags[i+6].is_null = &one_not_null;
+ tags[i+6].length = NULL;
+
+ tags[i+7].buffer_type = TSDB_DATA_TYPE_BINARY;
+ tags[i+7].buffer = v->br;
+ tags[i+7].is_null = &one_not_null;
+ tags[i+7].length = (uintptr_t *)lb;
+
+ tags[i+8].buffer_type = TSDB_DATA_TYPE_NCHAR;
+ tags[i+8].buffer = v->nr;
+ tags[i+8].is_null = &one_not_null;
+ tags[i+8].length = (uintptr_t *)lb;
+ }
+
+
+ unsigned long long starttime = getCurrentTime();
+
+// create table m%d (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, br binary(%d), nr nchar(%d), ts2 timestamp)
+ //char *sql = "insert into ? (ts,b,v4,f4,br) using stb1 tags (?,?,?,?,?,?,?,?,?) values(?,?,?,?,?)";
+ char *sql = "insert into ? using stb1 tags (?,?,?,?,?,?,?,?,?) (ts,b,v4,f4,br) values(?,?,?,?,?)";
+
+ int code = taos_stmt_prepare(stmt, sql, 0);
+ if (code != 0){
+ printf("failed to execute taos_stmt_prepare. code:0x%x[%s]\n", code, tstrerror(code));
+ return -1;
+ }
+
+ int id = 0;
+ for (int l = 0; l < bingNum; l++) {
+ for (int zz = 0; zz < tableNum; zz++) {
+ char buf[32];
+ sprintf(buf, "m%d", zz);
+ code = taos_stmt_set_tbname_tags(stmt, buf, tags);
+ if (code != 0){
+ printf("failed to execute taos_stmt_set_tbname. code:0x%x[%s]\n", code, tstrerror(code));
+ return -1;
+ }
+
+ for (int col=0; col < columnNum; ++col) {
+ code = taos_stmt_bind_single_param_batch(stmt, params + id, col);
+ if (code != 0){
+ printf("failed to execute taos_stmt_bind_single_param_batch. code:0x%x[%s]\n", code, tstrerror(code));
+ return -1;
+ }
+ id++;
+ }
+
+ code = taos_stmt_add_batch(stmt);
+ if (code != 0) {
+ printf("failed to execute taos_stmt_add_batch. code:0x%x[%s]\n", code, tstrerror(code));
+ return -1;
+ }
+ }
+
+ code = taos_stmt_execute(stmt);
+ if (code != 0) {
+ printf("failed to execute taos_stmt_execute. code:0x%x[%s]\n", code, tstrerror(code));
+ return -1;
+ }
+ }
+
+ unsigned long long endtime = getCurrentTime();
+ unsigned long long totalRows = (uint32_t)(totalRowsPerTbl * tableNum);
+ printf("insert total %d records, used %u seconds, avg:%u useconds per record\n", totalRows, (endtime-starttime)/1000000UL, (endtime-starttime)/totalRows);
+
+ free(v->ts);
+ free(v->br);
+ free(v->nr);
+ free(v);
+ free(lb);
+ free(params);
+ free(tags);
+ free(is_null);
+ free(no_null);
+
+ return 0;
+}
+
+static int stmt_specifyCol_bind_case_002_autoCreateTbl(TAOS_STMT *stmt, int tableNum, int rowsOfPerColum, int bingNum, int lenOfBinaryDef, int lenOfBinaryAct, int columnNum) {
+ sampleValue* v = (sampleValue *)calloc(1, sizeof(sampleValue));
+
+ int totalRowsPerTbl = rowsOfPerColum * bingNum;
+
+ v->ts = (int64_t *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * tableNum));
+ v->br = (char *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * lenOfBinaryDef));
+ v->nr = (char *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * lenOfBinaryDef));
+
+ int *lb = (int *)malloc(MAX_ROWS_OF_PER_COLUMN * sizeof(int));
+
+ TAOS_BIND *tags = calloc(1, sizeof(TAOS_BIND) * 9 * 1);
+ TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * (size_t)(bingNum * columnNum * (tableNum+1) * rowsOfPerColum));
+ char* is_null = malloc(sizeof(char) * MAX_ROWS_OF_PER_COLUMN);
+ char* no_null = malloc(sizeof(char) * MAX_ROWS_OF_PER_COLUMN);
+ int one_not_null = 0;
+
+ int64_t tts = 1591060628000;
+
+ for (int i = 0; i < rowsOfPerColum; ++i) {
+ lb[i] = lenOfBinaryAct;
+ no_null[i] = 0;
+ is_null[i] = (i % 10 == 2) ? 1 : 0;
+ v->b[i] = (int8_t)(i % 2);
+ v->v1[i] = (int8_t)((i+1) % 2);
+ v->v2[i] = (int16_t)i;
+ v->v4[i] = (int32_t)(i+1);
+ v->v8[i] = (int64_t)(i+2);
+ v->f4[i] = (float)(i+3);
+ v->f8[i] = (double)(i+4);
+ char tbuf[MAX_BINARY_DEF_LEN];
+ memset(tbuf, 0, MAX_BINARY_DEF_LEN);
+ sprintf(tbuf, "binary-%d-0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", i%10);
+ memcpy(v->br + i*lenOfBinaryDef, tbuf, (size_t)lenOfBinaryAct);
+ memset(tbuf, 0, MAX_BINARY_DEF_LEN);
+ sprintf(tbuf, "nchar-%d-0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", i%10);
+ memcpy(v->nr + i*lenOfBinaryDef, tbuf, (size_t)lenOfBinaryAct);
+ v->ts2[i] = tts + i;
+ }
+
+ int i = 0;
+ for (int j = 0; j < bingNum * tableNum; j++) {
+ params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP;
+ params[i+0].buffer_length = sizeof(int64_t);
+ params[i+0].buffer = &v->ts[j*rowsOfPerColum];
+ params[i+0].length = NULL;
+ params[i+0].is_null = no_null;
+ params[i+0].num = rowsOfPerColum;
+
+ params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL;
+ params[i+1].buffer_length = sizeof(int8_t);
+ params[i+1].buffer = v->b;
+ params[i+1].length = NULL;
+ params[i+1].is_null = is_null;
+ params[i+1].num = rowsOfPerColum;
+
+ params[i+2].buffer_type = TSDB_DATA_TYPE_INT;
+ params[i+2].buffer_length = sizeof(int32_t);
+ params[i+2].buffer = v->v4;
+ params[i+2].length = NULL;
+ params[i+2].is_null = is_null;
+ params[i+2].num = rowsOfPerColum;
+
+ params[i+3].buffer_type = TSDB_DATA_TYPE_FLOAT;
+ params[i+3].buffer_length = sizeof(float);
+ params[i+3].buffer = v->f4;
+ params[i+3].length = NULL;
+ params[i+3].is_null = is_null;
+ params[i+3].num = rowsOfPerColum;
+
+ params[i+4].buffer_type = TSDB_DATA_TYPE_BINARY;
+ params[i+4].buffer_length = (uintptr_t)lenOfBinaryDef;
+ params[i+4].buffer = v->br;
+ params[i+4].length = lb;
+ params[i+4].is_null = is_null;
+ params[i+4].num = rowsOfPerColum;
+
+ i+=columnNum;
+ }
+
+ //int64_t tts = 1591060628000;
+ for (int i = 0; i < totalRowsPerTbl * tableNum; ++i) {
+ v->ts[i] = tts + i;
+ }
+
+ for (int i = 0; i < 1; ++i) {
+ //tags[i+0].buffer_type = TSDB_DATA_TYPE_INT;
+ //tags[i+0].buffer = v->v4;
+ //tags[i+0].is_null = &one_not_null;
+ //tags[i+0].length = NULL;
+
+ tags[i+0].buffer_type = TSDB_DATA_TYPE_BOOL;
+ tags[i+0].buffer = v->b;
+ tags[i+0].is_null = &one_not_null;
+ tags[i+0].length = NULL;
+
+ //tags[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT;
+ //tags[i+2].buffer = v->v1;
+ //tags[i+2].is_null = &one_not_null;
+ //tags[i+2].length = NULL;
+
+ tags[i+1].buffer_type = TSDB_DATA_TYPE_SMALLINT;
+ tags[i+1].buffer = v->v2;
+ tags[i+1].is_null = &one_not_null;
+ tags[i+1].length = NULL;
+
+ tags[i+2].buffer_type = TSDB_DATA_TYPE_BIGINT;
+ tags[i+2].buffer = v->v8;
+ tags[i+2].is_null = &one_not_null;
+ tags[i+2].length = NULL;
+
+ tags[i+3].buffer_type = TSDB_DATA_TYPE_FLOAT;
+ tags[i+3].buffer = v->f4;
+ tags[i+3].is_null = &one_not_null;
+ tags[i+3].length = NULL;
+
+ tags[i+4].buffer_type = TSDB_DATA_TYPE_DOUBLE;
+ tags[i+4].buffer = v->f8;
+ tags[i+4].is_null = &one_not_null;
+ tags[i+4].length = NULL;
+
+ tags[i+5].buffer_type = TSDB_DATA_TYPE_BINARY;
+ tags[i+5].buffer = v->br;
+ tags[i+5].is_null = &one_not_null;
+ tags[i+5].length = (uintptr_t *)lb;
+
+ tags[i+6].buffer_type = TSDB_DATA_TYPE_NCHAR;
+ tags[i+6].buffer = v->nr;
+ tags[i+6].is_null = &one_not_null;
+ tags[i+6].length = (uintptr_t *)lb;
+ }
+
+
+ unsigned long long starttime = getCurrentTime();
+
+// create table m%d (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, br binary(%d), nr nchar(%d), ts2 timestamp)
+ //char *sql = "insert into ? (ts,b,v4,f4,br) using stb1 tags (?,?,?,?,?,?,?,?,?) values(?,?,?,?,?)";
+ char *sql = "insert into ? using stb1 tags (33,?,99,?,?,?,?,?,?) (ts,b,v4,f4,br) values(?,?,?,?,?)";
+
+ int code = taos_stmt_prepare(stmt, sql, 0);
+ if (code != 0){
+ printf("failed to execute taos_stmt_prepare. code:0x%x[%s]\n", code, tstrerror(code));
+ return -1;
+ }
+
+ int id = 0;
+ for (int l = 0; l < bingNum; l++) {
+ for (int zz = 0; zz < tableNum; zz++) {
+ char buf[32];
+ sprintf(buf, "m%d", zz);
+ code = taos_stmt_set_tbname_tags(stmt, buf, tags);
+ if (code != 0){
+ printf("failed to execute taos_stmt_set_tbname. code:0x%x[%s]\n", code, tstrerror(code));
+ return -1;
+ }
+
+ for (int col=0; col < columnNum; ++col) {
+ code = taos_stmt_bind_single_param_batch(stmt, params + id, col);
+ if (code != 0){
+ printf("failed to execute taos_stmt_bind_single_param_batch. code:0x%x[%s]\n", code, tstrerror(code));
+ return -1;
+ }
+ id++;
+ }
+
+ code = taos_stmt_add_batch(stmt);
+ if (code != 0) {
+ printf("failed to execute taos_stmt_add_batch. code:0x%x[%s]\n", code, tstrerror(code));
+ return -1;
+ }
+ }
+
+ code = taos_stmt_execute(stmt);
+ if (code != 0) {
+ printf("failed to execute taos_stmt_execute. code:0x%x[%s]\n", code, tstrerror(code));
+ return -1;
+ }
+ }
+
+ unsigned long long endtime = getCurrentTime();
+ unsigned long long totalRows = (uint32_t)(totalRowsPerTbl * tableNum);
+ printf("insert total %d records, used %u seconds, avg:%u useconds per record\n", totalRows, (endtime-starttime)/1000000UL, (endtime-starttime)/totalRows);
+
+ free(v->ts);
+ free(v->br);
+ free(v->nr);
+ free(v);
+ free(lb);
+ free(params);
+ free(tags);
+ free(is_null);
+ free(no_null);
+
+ return 0;
+}
+
+// some tags are null
+static int stmt_specifyCol_bind_case_003_autoCreateTbl(TAOS_STMT *stmt, int tableNum, int rowsOfPerColum, int bingNum, int lenOfBinaryDef, int lenOfBinaryAct, int columnNum) {
+ sampleValue* v = (sampleValue *)calloc(1, sizeof(sampleValue));
+
+ int totalRowsPerTbl = rowsOfPerColum * bingNum;
+
+ v->ts = (int64_t *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * tableNum));
+ v->br = (char *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * lenOfBinaryDef));
+ v->nr = (char *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * lenOfBinaryDef));
+
+ int *lb = (int *)malloc(MAX_ROWS_OF_PER_COLUMN * sizeof(int));
+
+ TAOS_BIND *tags = calloc(1, sizeof(TAOS_BIND) * 9 * 1);
+ TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * (size_t)(bingNum * columnNum * (tableNum+1) * rowsOfPerColum));
+ char* is_null = malloc(sizeof(char) * MAX_ROWS_OF_PER_COLUMN);
+ char* no_null = malloc(sizeof(char) * MAX_ROWS_OF_PER_COLUMN);
+ int one_not_null = 0;
+ int one_is_null = 1;
+
+ int64_t tts = 1591060628000;
+
+ for (int i = 0; i < rowsOfPerColum; ++i) {
+ lb[i] = lenOfBinaryAct;
+ no_null[i] = 0;
+ is_null[i] = (i % 10 == 2) ? 1 : 0;
+ v->b[i] = (int8_t)(i % 2);
+ v->v1[i] = (int8_t)((i+1) % 2);
+ v->v2[i] = (int16_t)i;
+ v->v4[i] = (int32_t)(i+1);
+ v->v8[i] = (int64_t)(i+2);
+ v->f4[i] = (float)(i+3);
+ v->f8[i] = (double)(i+4);
+ char tbuf[MAX_BINARY_DEF_LEN];
+ memset(tbuf, 0, MAX_BINARY_DEF_LEN);
+ sprintf(tbuf, "binary-%d-0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", i%10);
+ memcpy(v->br + i*lenOfBinaryDef, tbuf, (size_t)lenOfBinaryAct);
+ memset(tbuf, 0, MAX_BINARY_DEF_LEN);
+ sprintf(tbuf, "nchar-%d-0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", i%10);
+ memcpy(v->nr + i*lenOfBinaryDef, tbuf, (size_t)lenOfBinaryAct);
+ v->ts2[i] = tts + i;
+ }
+
+ int i = 0;
+ for (int j = 0; j < bingNum * tableNum; j++) {
+ params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP;
+ params[i+0].buffer_length = sizeof(int64_t);
+ params[i+0].buffer = &v->ts[j*rowsOfPerColum];
+ params[i+0].length = NULL;
+ params[i+0].is_null = no_null;
+ params[i+0].num = rowsOfPerColum;
+
+ params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL;
+ params[i+1].buffer_length = sizeof(int8_t);
+ params[i+1].buffer = v->b;
+ params[i+1].length = NULL;
+ params[i+1].is_null = is_null;
+ params[i+1].num = rowsOfPerColum;
+
+ params[i+2].buffer_type = TSDB_DATA_TYPE_INT;
+ params[i+2].buffer_length = sizeof(int32_t);
+ params[i+2].buffer = v->v4;
+ params[i+2].length = NULL;
+ params[i+2].is_null = is_null;
+ params[i+2].num = rowsOfPerColum;
+
+ params[i+3].buffer_type = TSDB_DATA_TYPE_FLOAT;
+ params[i+3].buffer_length = sizeof(float);
+ params[i+3].buffer = v->f4;
+ params[i+3].length = NULL;
+ params[i+3].is_null = is_null;
+ params[i+3].num = rowsOfPerColum;
+
+ params[i+4].buffer_type = TSDB_DATA_TYPE_BINARY;
+ params[i+4].buffer_length = (uintptr_t)lenOfBinaryDef;
+ params[i+4].buffer = v->br;
+ params[i+4].length = lb;
+ params[i+4].is_null = is_null;
+ params[i+4].num = rowsOfPerColum;
+
+ i+=columnNum;
+ }
+
+ //int64_t tts = 1591060628000;
+ for (int i = 0; i < totalRowsPerTbl * tableNum; ++i) {
+ v->ts[i] = tts + i;
+ }
+
+ for (int i = 0; i < 1; ++i) {
+ tags[i+0].buffer_type = TSDB_DATA_TYPE_INT;
+ tags[i+0].buffer = v->v4;
+ tags[i+0].is_null = &one_not_null;
+ tags[i+0].length = NULL;
+
+ tags[i+1].buffer_type = TSDB_DATA_TYPE_BOOL;
+ tags[i+1].buffer = v->b;
+ tags[i+1].is_null = &one_is_null;
+ tags[i+1].length = NULL;
+
+ tags[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT;
+ tags[i+2].buffer = v->v1;
+ tags[i+2].is_null = &one_is_null;
+ tags[i+2].length = NULL;
+
+ tags[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT;
+ tags[i+3].buffer = v->v2;
+ tags[i+3].is_null = &one_not_null;
+ tags[i+3].length = NULL;
+
+ tags[i+4].buffer_type = TSDB_DATA_TYPE_BIGINT;
+ tags[i+4].buffer = v->v8;
+ tags[i+4].is_null = &one_not_null;
+ tags[i+4].length = NULL;
+
+ tags[i+5].buffer_type = TSDB_DATA_TYPE_FLOAT;
+ tags[i+5].buffer = v->f4;
+ tags[i+5].is_null = &one_is_null;
+ tags[i+5].length = NULL;
+
+ tags[i+6].buffer_type = TSDB_DATA_TYPE_DOUBLE;
+ tags[i+6].buffer = v->f8;
+ tags[i+6].is_null = &one_not_null;
+ tags[i+6].length = NULL;
+
+ tags[i+7].buffer_type = TSDB_DATA_TYPE_BINARY;
+ tags[i+7].buffer = v->br;
+ tags[i+7].is_null = &one_not_null;
+ tags[i+7].length = (uintptr_t *)lb;
+
+ tags[i+8].buffer_type = TSDB_DATA_TYPE_NCHAR;
+ tags[i+8].buffer = v->nr;
+ tags[i+8].is_null = &one_not_null;
+ tags[i+8].length = (uintptr_t *)lb;
+ }
+
+
+ unsigned long long starttime = getCurrentTime();
+
+// create table m%d (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, br binary(%d), nr nchar(%d), ts2 timestamp)
+ //char *sql = "insert into ? (ts,b,v4,f4,br) using stb1 tags (?,?,?,?,?,?,?,?,?) values(?,?,?,?,?)";
+ char *sql = "insert into ? using stb1 tags (?,?,?,?,?,?,?,?,?) (ts,b,v4,f4,br) values(?,?,?,?,?)";
+
+ int code = taos_stmt_prepare(stmt, sql, 0);
+ if (code != 0){
+ printf("failed to execute taos_stmt_prepare. code:0x%x[%s]\n", code, tstrerror(code));
+ return -1;
+ }
+
+ int id = 0;
+ for (int l = 0; l < bingNum; l++) {
+ for (int zz = 0; zz < tableNum; zz++) {
+ char buf[32];
+ sprintf(buf, "m%d", zz);
+ code = taos_stmt_set_tbname_tags(stmt, buf, tags);
+ if (code != 0){
+ printf("failed to execute taos_stmt_set_tbname. code:0x%x[%s]\n", code, tstrerror(code));
+ return -1;
+ }
+
+ for (int col=0; col < columnNum; ++col) {
+ code = taos_stmt_bind_single_param_batch(stmt, params + id, col);
+ if (code != 0){
+ printf("failed to execute taos_stmt_bind_single_param_batch. code:0x%x[%s]\n", code, tstrerror(code));
+ return -1;
+ }
+ id++;
+ }
+
+ code = taos_stmt_add_batch(stmt);
+ if (code != 0) {
+ printf("failed to execute taos_stmt_add_batch. code:0x%x[%s]\n", code, tstrerror(code));
+ return -1;
+ }
+ }
+
+ code = taos_stmt_execute(stmt);
+ if (code != 0) {
+ printf("failed to execute taos_stmt_execute. code:0x%x[%s]\n", code, tstrerror(code));
+ return -1;
+ }
+ }
+
+ unsigned long long endtime = getCurrentTime();
+ unsigned long long totalRows = (uint32_t)(totalRowsPerTbl * tableNum);
+ printf("insert total %d records, used %u seconds, avg:%u useconds per record\n", totalRows, (endtime-starttime)/1000000UL, (endtime-starttime)/totalRows);
+
+ free(v->ts);
+ free(v->br);
+ free(v->nr);
+ free(v);
+ free(lb);
+ free(params);
+ free(tags);
+ free(is_null);
+ free(no_null);
+
+ return 0;
+}
+
+// specify tags field, and not support , then is error case
+static int stmt_specifyCol_bind_case_004_autoCreateTbl(TAOS_STMT *stmt, int tableNum, int rowsOfPerColum, int bingNum, int lenOfBinaryDef, int lenOfBinaryAct, int columnNum) {
+ sampleValue* v = (sampleValue *)calloc(1, sizeof(sampleValue));
+
+ int totalRowsPerTbl = rowsOfPerColum * bingNum;
+
+ v->ts = (int64_t *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * tableNum));
+ v->br = (char *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * lenOfBinaryDef));
+ v->nr = (char *)malloc(sizeof(int64_t) * (size_t)(totalRowsPerTbl * lenOfBinaryDef));
+
+ int *lb = (int *)malloc(MAX_ROWS_OF_PER_COLUMN * sizeof(int));
+
+ TAOS_BIND *tags = calloc(1, sizeof(TAOS_BIND) * 9 * 1);
+ TAOS_MULTI_BIND *params = calloc(1, sizeof(TAOS_MULTI_BIND) * (size_t)(bingNum * columnNum * (tableNum+1) * rowsOfPerColum));
+ char* is_null = malloc(sizeof(char) * MAX_ROWS_OF_PER_COLUMN);
+ char* no_null = malloc(sizeof(char) * MAX_ROWS_OF_PER_COLUMN);
+ int one_not_null = 0;
+
+ int64_t tts = 1591060628000;
+
+ for (int i = 0; i < rowsOfPerColum; ++i) {
+ lb[i] = lenOfBinaryAct;
+ no_null[i] = 0;
+ is_null[i] = (i % 10 == 2) ? 1 : 0;
+ v->b[i] = (int8_t)(i % 2);
+ v->v1[i] = (int8_t)((i+1) % 2);
+ v->v2[i] = (int16_t)i;
+ v->v4[i] = (int32_t)(i+1);
+ v->v8[i] = (int64_t)(i+2);
+ v->f4[i] = (float)(i+3);
+ v->f8[i] = (double)(i+4);
+ char tbuf[MAX_BINARY_DEF_LEN];
+ memset(tbuf, 0, MAX_BINARY_DEF_LEN);
+ sprintf(tbuf, "binary-%d-0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", i%10);
+ memcpy(v->br + i*lenOfBinaryDef, tbuf, (size_t)lenOfBinaryAct);
+ memset(tbuf, 0, MAX_BINARY_DEF_LEN);
+ sprintf(tbuf, "nchar-%d-0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", i%10);
+ memcpy(v->nr + i*lenOfBinaryDef, tbuf, (size_t)lenOfBinaryAct);
+ v->ts2[i] = tts + i;
+ }
+
+ int i = 0;
+ for (int j = 0; j < bingNum * tableNum; j++) {
+ params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP;
+ params[i+0].buffer_length = sizeof(int64_t);
+ params[i+0].buffer = &v->ts[j*rowsOfPerColum];
+ params[i+0].length = NULL;
+ params[i+0].is_null = no_null;
+ params[i+0].num = rowsOfPerColum;
+
+ params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL;
+ params[i+1].buffer_length = sizeof(int8_t);
+ params[i+1].buffer = v->b;
+ params[i+1].length = NULL;
+ params[i+1].is_null = is_null;
+ params[i+1].num = rowsOfPerColum;
+
+ params[i+2].buffer_type = TSDB_DATA_TYPE_INT;
+ params[i+2].buffer_length = sizeof(int32_t);
+ params[i+2].buffer = v->v4;
+ params[i+2].length = NULL;
+ params[i+2].is_null = is_null;
+ params[i+2].num = rowsOfPerColum;
+
+ params[i+3].buffer_type = TSDB_DATA_TYPE_FLOAT;
+ params[i+3].buffer_length = sizeof(float);
+ params[i+3].buffer = v->f4;
+ params[i+3].length = NULL;
+ params[i+3].is_null = is_null;
+ params[i+3].num = rowsOfPerColum;
+
+ params[i+4].buffer_type = TSDB_DATA_TYPE_BINARY;
+ params[i+4].buffer_length = (uintptr_t)lenOfBinaryDef;
+ params[i+4].buffer = v->br;
+ params[i+4].length = lb;
+ params[i+4].is_null = is_null;
+ params[i+4].num = rowsOfPerColum;
+
+ i+=columnNum;
+ }
+
+ //int64_t tts = 1591060628000;
+ for (int i = 0; i < totalRowsPerTbl * tableNum; ++i) {
+ v->ts[i] = tts + i;
+ }
+
+ for (int i = 0; i < 1; ++i) {
+ //tags[i+0].buffer_type = TSDB_DATA_TYPE_INT;
+ //tags[i+0].buffer = v->v4;
+ //tags[i+0].is_null = &one_not_null;
+ //tags[i+0].length = NULL;
+
+ tags[i+0].buffer_type = TSDB_DATA_TYPE_BOOL;
+ tags[i+0].buffer = v->b;
+ tags[i+0].is_null = &one_not_null;
+ tags[i+0].length = NULL;
+
+ //tags[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT;
+ //tags[i+2].buffer = v->v1;
+ //tags[i+2].is_null = &one_not_null;
+ //tags[i+2].length = NULL;
+
+ tags[i+1].buffer_type = TSDB_DATA_TYPE_SMALLINT;
+ tags[i+1].buffer = v->v2;
+ tags[i+1].is_null = &one_not_null;
+ tags[i+1].length = NULL;
+
+ tags[i+2].buffer_type = TSDB_DATA_TYPE_BIGINT;
+ tags[i+2].buffer = v->v8;
+ tags[i+2].is_null = &one_not_null;
+ tags[i+2].length = NULL;
+
+ tags[i+3].buffer_type = TSDB_DATA_TYPE_FLOAT;
+ tags[i+3].buffer = v->f4;
+ tags[i+3].is_null = &one_not_null;
+ tags[i+3].length = NULL;
+
+ tags[i+4].buffer_type = TSDB_DATA_TYPE_DOUBLE;
+ tags[i+4].buffer = v->f8;
+ tags[i+4].is_null = &one_not_null;
+ tags[i+4].length = NULL;
+
+ tags[i+5].buffer_type = TSDB_DATA_TYPE_BINARY;
+ tags[i+5].buffer = v->br;
+ tags[i+5].is_null = &one_not_null;
+ tags[i+5].length = (uintptr_t *)lb;
+
+ tags[i+6].buffer_type = TSDB_DATA_TYPE_NCHAR;
+ tags[i+6].buffer = v->nr;
+ tags[i+6].is_null = &one_not_null;
+ tags[i+6].length = (uintptr_t *)lb;
+ }
+
+
+ unsigned long long starttime = getCurrentTime();
+
+// create table m%d (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, br binary(%d), nr nchar(%d), ts2 timestamp)
+ //char *sql = "insert into ? (ts,b,v4,f4,br) using stb1 tags (?,?,?,?,?,?,?,?,?) values(?,?,?,?,?)";
+ char *sql = "insert into ? using stb1 (id1, id2, id3, id4, id5, id6, id7, id8, id9) tags (33,?,99,?,?,?,?,?,?) (ts,b,v4,f4,br) values(?,?,?,?,?)";
+
+ int code = taos_stmt_prepare(stmt, sql, 0);
+ if (code != 0){
+ printf("failed to execute taos_stmt_prepare. code:0x%x[%s]\n", code, tstrerror(code));
+ return -1;
+ }
+
+ int id = 0;
+ for (int l = 0; l < bingNum; l++) {
+ for (int zz = 0; zz < tableNum; zz++) {
+ char buf[32];
+ sprintf(buf, "m%d", zz);
+ code = taos_stmt_set_tbname_tags(stmt, buf, tags);
+ if (code != 0){
+ printf("failed to execute taos_stmt_set_tbname. code:0x%x[%s]\n", code, tstrerror(code));
+ return -1;
+ }
+
+ for (int col=0; col < columnNum; ++col) {
+ code = taos_stmt_bind_single_param_batch(stmt, params + id, col);
+ if (code != 0){
+ printf("failed to execute taos_stmt_bind_single_param_batch. code:0x%x[%s]\n", code, tstrerror(code));
+ return -1;
+ }
+ id++;
+ }
+
+ code = taos_stmt_add_batch(stmt);
+ if (code != 0) {
+ printf("failed to execute taos_stmt_add_batch. code:0x%x[%s]\n", code, tstrerror(code));
+ return -1;
+ }
+ }
+
+ code = taos_stmt_execute(stmt);
+ if (code != 0) {
+ printf("failed to execute taos_stmt_execute. code:0x%x[%s]\n", code, tstrerror(code));
+ return -1;
+ }
+ }
+
+ unsigned long long endtime = getCurrentTime();
+ unsigned long long totalRows = (uint32_t)(totalRowsPerTbl * tableNum);
+ printf("insert total %d records, used %u seconds, avg:%u useconds per record\n", totalRows, (endtime-starttime)/1000000UL, (endtime-starttime)/totalRows);
+
+ free(v->ts);
+ free(v->br);
+ free(v->nr);
+ free(v);
+ free(lb);
+ free(params);
+ free(tags);
+ free(is_null);
+ free(no_null);
+
+ return 0;
+}
+
+static void SpecifyColumnBatchCase_autoCreateTbl(TAOS *taos) {
+ TAOS_STMT *stmt = NULL;
+
+ int tableNum;
+ int lenOfBinaryDef;
+ int rowsOfPerColum;
+ int bingNum;
+ int lenOfBinaryAct;
+ int columnNum;
+
+ int totalRowsPerTbl;
+
+//=======================================================================//
+//=============================== single table ==========================//
+//========== case 1: ======================//
+#if 1
+{
+ stmt = taos_stmt_init(taos);
+
+ tableNum = 1;
+ rowsOfPerColum = 1;
+ bingNum = 1;
+ lenOfBinaryDef = 40;
+ lenOfBinaryAct = 8;
+ columnNum = 5;
+
+ prepareVcolumn_autoCreateTbl(taos, 1, tableNum, lenOfBinaryDef, "db1");
+ stmt_specifyCol_bind_case_001_autoCreateTbl(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum);
+
+ totalRowsPerTbl = rowsOfPerColum * bingNum;
+ checkResult(taos, "m0", 0, totalRowsPerTbl);
+ taos_stmt_close(stmt);
+ printf("case 1 check result end\n\n");
+}
+#endif
+
+ //========== case 2: ======================//
+#if 1
+{
+ stmt = taos_stmt_init(taos);
+
+ tableNum = 1;
+ rowsOfPerColum = 5;
+ bingNum = 1;
+ lenOfBinaryDef = 1000;
+ lenOfBinaryAct = 15;
+ columnNum = 5;
+
+ prepareVcolumn_autoCreateTbl(taos, 1, tableNum, lenOfBinaryDef, "db2");
+ stmt_specifyCol_bind_case_001_autoCreateTbl(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum);
+
+ totalRowsPerTbl = rowsOfPerColum * bingNum;
+ checkResult(taos, "m0", 0, totalRowsPerTbl);
+ //checkResult(taos, "m1", 0, totalRowsPerTbl);
+ //checkResult(taos, "m2", 0, totalRowsPerTbl);
+ //checkResult(taos, "m3", 0, totalRowsPerTbl);
+ //checkResult(taos, "m4", 0, totalRowsPerTbl);
+ //checkResult(taos, "m5", 0, totalRowsPerTbl);
+ //checkResult(taos, "m6", 0, totalRowsPerTbl);
+ //checkResult(taos, "m7", 0, totalRowsPerTbl);
+ //checkResult(taos, "m8", 0, totalRowsPerTbl);
+ //checkResult(taos, "m9", 0, totalRowsPerTbl);
+ taos_stmt_close(stmt);
+ printf("case 2 check result end\n\n");
+}
+#endif
+
+ //========== case 2-1: ======================//
+#if 1
+ {
+ stmt = taos_stmt_init(taos);
+
+ tableNum = 1;
+ rowsOfPerColum = 32767;
+ bingNum = 1;
+ lenOfBinaryDef = 1000;
+ lenOfBinaryAct = 15;
+ columnNum = 5;
+
+ prepareVcolumn_autoCreateTbl(taos, 1, tableNum, lenOfBinaryDef, "db2_1");
+ stmt_specifyCol_bind_case_001_autoCreateTbl(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum);
+
+ totalRowsPerTbl = rowsOfPerColum * bingNum;
+ checkResult(taos, "m0", 0, totalRowsPerTbl);
+ //checkResult(taos, "m1", 0, totalRowsPerTbl);
+ //checkResult(taos, "m2", 0, totalRowsPerTbl);
+ //checkResult(taos, "m3", 0, totalRowsPerTbl);
+ //checkResult(taos, "m4", 0, totalRowsPerTbl);
+ //checkResult(taos, "m5", 0, totalRowsPerTbl);
+ //checkResult(taos, "m6", 0, totalRowsPerTbl);
+ //checkResult(taos, "m7", 0, totalRowsPerTbl);
+ //checkResult(taos, "m8", 0, totalRowsPerTbl);
+ //checkResult(taos, "m9", 0, totalRowsPerTbl);
+ taos_stmt_close(stmt);
+ printf("case 2-1 check result end\n\n");
+ }
+#endif
+ //========== case 2-2: ======================//
+#if 1
+ {
+ printf("====case 2-2 error test start\n");
+ stmt = taos_stmt_init(taos);
+
+ tableNum = 1;
+ rowsOfPerColum = 32768;
+ bingNum = 1;
+ lenOfBinaryDef = 1000;
+ lenOfBinaryAct = 15;
+ columnNum = 5;
+
+ prepareVcolumn_autoCreateTbl(taos, 1, tableNum, lenOfBinaryDef, "db2_2");
+ stmt_specifyCol_bind_case_001_autoCreateTbl(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum);
+
+ totalRowsPerTbl = rowsOfPerColum * bingNum;
+ checkResult(taos, "m0", 0, totalRowsPerTbl);
+ //checkResult(taos, "m1", 0, totalRowsPerTbl);
+ //checkResult(taos, "m2", 0, totalRowsPerTbl);
+ //checkResult(taos, "m3", 0, totalRowsPerTbl);
+ //checkResult(taos, "m4", 0, totalRowsPerTbl);
+ //checkResult(taos, "m5", 0, totalRowsPerTbl);
+ //checkResult(taos, "m6", 0, totalRowsPerTbl);
+ //checkResult(taos, "m7", 0, totalRowsPerTbl);
+ //checkResult(taos, "m8", 0, totalRowsPerTbl);
+ //checkResult(taos, "m9", 0, totalRowsPerTbl);
+ taos_stmt_close(stmt);
+ printf("====case 2-2 check result end\n\n");
+ }
+#endif
+
+
+ //========== case 3: ======================//
+#if 1
+ {
+ stmt = taos_stmt_init(taos);
+
+ tableNum = 1;
+ rowsOfPerColum = 1;
+ bingNum = 5;
+ lenOfBinaryDef = 1000;
+ lenOfBinaryAct = 20;
+ columnNum = 5;
+
+ prepareVcolumn_autoCreateTbl(taos, 1, tableNum, lenOfBinaryDef, "db3");
+ stmt_specifyCol_bind_case_001_autoCreateTbl(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum);
+
+ totalRowsPerTbl = rowsOfPerColum * bingNum;
+ checkResult(taos, "m0", 0, totalRowsPerTbl);
+ //checkResult(taos, "m1", 0, totalRowsPerTbl);
+ //checkResult(taos, "m2", 0, totalRowsPerTbl);
+ //checkResult(taos, "m3", 0, totalRowsPerTbl);
+ //checkResult(taos, "m4", 0, totalRowsPerTbl);
+ //checkResult(taos, "m5", 0, totalRowsPerTbl);
+ //checkResult(taos, "m6", 0, totalRowsPerTbl);
+ //checkResult(taos, "m7", 0, totalRowsPerTbl);
+ //checkResult(taos, "m8", 0, totalRowsPerTbl);
+ //checkResult(taos, "m9", 0, totalRowsPerTbl);
+ taos_stmt_close(stmt);
+ printf("case 3 check result end\n\n");
+ }
+#endif
+
+ //========== case 4: ======================//
+#if 1
+ {
+ stmt = taos_stmt_init(taos);
+
+ tableNum = 1;
+ rowsOfPerColum = 5;
+ bingNum = 5;
+ lenOfBinaryDef = 1000;
+ lenOfBinaryAct = 33;
+ columnNum = 5;
+
+ prepareVcolumn_autoCreateTbl(taos, 1, tableNum, lenOfBinaryDef, "db4");
+ stmt_specifyCol_bind_case_001_autoCreateTbl(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum);
+
+ totalRowsPerTbl = rowsOfPerColum * bingNum;
+ checkResult(taos, "m0", 0, totalRowsPerTbl);
+ //checkResult(taos, "m1", 0, totalRowsPerTbl);
+ //checkResult(taos, "m2", 0, totalRowsPerTbl);
+ //checkResult(taos, "m3", 0, totalRowsPerTbl);
+ //checkResult(taos, "m4", 0, totalRowsPerTbl);
+ //checkResult(taos, "m5", 0, totalRowsPerTbl);
+ //checkResult(taos, "m6", 0, totalRowsPerTbl);
+ //checkResult(taos, "m7", 0, totalRowsPerTbl);
+ //checkResult(taos, "m8", 0, totalRowsPerTbl);
+ //checkResult(taos, "m9", 0, totalRowsPerTbl);
+ taos_stmt_close(stmt);
+ printf("case 4 check result end\n\n");
+ }
+#endif
+
+ //=======================================================================//
+ //=============================== multi-rows to single table ==========================//
+ //========== case 5: ======================//
+#if 1
+ {
+ stmt = taos_stmt_init(taos);
+
+ tableNum = 1;
+ rowsOfPerColum = 23740;
+ bingNum = 1;
+ lenOfBinaryDef = 40;
+ lenOfBinaryAct = 8;
+ columnNum = 5;
+
+ prepareVcolumn_autoCreateTbl(taos, 1, tableNum, lenOfBinaryDef, "db5");
+ stmt_specifyCol_bind_case_001_autoCreateTbl(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum);
+
+ totalRowsPerTbl = rowsOfPerColum * bingNum;
+ checkResult(taos, "m0", 0, totalRowsPerTbl);
+ taos_stmt_close(stmt);
+ printf("case 5 check result end\n\n");
+ }
+#endif
+
+// ============== error test: 1.multi table, 2.specify some tags
+ //========== case 6: ======================//
+#if 1
+ {
+ stmt = taos_stmt_init(taos);
+
+ tableNum = 2;
+ rowsOfPerColum = 5;
+ bingNum = 1;
+ lenOfBinaryDef = 40;
+ lenOfBinaryAct = 8;
+ columnNum = 5;
+
+ prepareVcolumn_autoCreateTbl(taos, 1, tableNum, lenOfBinaryDef, "db6");
+ stmt_specifyCol_bind_case_001_autoCreateTbl(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum);
+
+ totalRowsPerTbl = rowsOfPerColum * bingNum;
+ checkResult(taos, "m0", 0, totalRowsPerTbl);
+ checkResult(taos, "m1", 0, totalRowsPerTbl);
+ taos_stmt_close(stmt);
+ printf("case 6 check result end\n\n");
+ }
+#endif
+
+ //========== case 7: ======================//
+#if 1
+ {
+ stmt = taos_stmt_init(taos);
+
+ tableNum = 200;
+ rowsOfPerColum = 60;
+ bingNum = 1;
+ lenOfBinaryDef = 40;
+ lenOfBinaryAct = 8;
+ columnNum = 5;
+
+ prepareVcolumn_autoCreateTbl(taos, 1, tableNum, lenOfBinaryDef, "db7");
+ stmt_specifyCol_bind_case_001_autoCreateTbl(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum);
+
+ totalRowsPerTbl = rowsOfPerColum * bingNum;
+ checkResult(taos, "m0", 0, totalRowsPerTbl);
+ checkResult(taos, "m1", 0, totalRowsPerTbl);
+ checkResult(taos, "m99", 0, totalRowsPerTbl);
+ checkResult(taos, "m139", 0, totalRowsPerTbl);
+ checkResult(taos, "m199", 0, totalRowsPerTbl);
+ taos_stmt_close(stmt);
+ printf("case 7 check result end\n\n");
+ }
+#endif
+
+ //========== case 8: ======================//
+#if 1
+ {
+ stmt = taos_stmt_init(taos);
+
+ tableNum = 1;
+ rowsOfPerColum = 5;
+ bingNum = 1;
+ lenOfBinaryDef = 40;
+ lenOfBinaryAct = 8;
+ columnNum = 5;
+
+ prepareVcolumn_autoCreateTbl(taos, 1, tableNum, lenOfBinaryDef, "db8");
+ stmt_specifyCol_bind_case_002_autoCreateTbl(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum);
+
+ totalRowsPerTbl = rowsOfPerColum * bingNum;
+ checkResult(taos, "m0", 0, totalRowsPerTbl);
+ taos_stmt_close(stmt);
+ printf("case 8 check result end\n\n");
+ }
+#endif
+
+ //========== case 9: ======================//
+
+#if 1
+ {
+ stmt = taos_stmt_init(taos);
+
+ tableNum = 10;
+ rowsOfPerColum = 5;
+ bingNum = 1;
+ lenOfBinaryDef = 40;
+ lenOfBinaryAct = 8;
+ columnNum = 5;
+
+ prepareVcolumn_autoCreateTbl(taos, 1, tableNum, lenOfBinaryDef, "db9");
+ stmt_specifyCol_bind_case_002_autoCreateTbl(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum);
+
+ totalRowsPerTbl = rowsOfPerColum * bingNum;
+ checkResult(taos, "m0", 0, totalRowsPerTbl);
+ checkResult(taos, "m3", 0, totalRowsPerTbl);
+ checkResult(taos, "m6", 0, totalRowsPerTbl);
+ checkResult(taos, "m9", 0, totalRowsPerTbl);
+ taos_stmt_close(stmt);
+ printf("case 9 check result end\n\n");
+ }
+#endif
+
+ //========== case 10: ======================//
+#if 1
+ {
+ stmt = taos_stmt_init(taos);
+
+ tableNum = 1;
+ rowsOfPerColum = 23740;
+ bingNum = 1;
+ lenOfBinaryDef = 40;
+ lenOfBinaryAct = 8;
+ columnNum = 5;
+
+ prepareVcolumn_autoCreateTbl(taos, 1, tableNum, lenOfBinaryDef, "db10");
+ stmt_specifyCol_bind_case_003_autoCreateTbl(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum);
+
+ totalRowsPerTbl = rowsOfPerColum * bingNum;
+ checkResult(taos, "m0", 0, totalRowsPerTbl);
+ taos_stmt_close(stmt);
+ printf("case 10 check result end\n\n");
+ }
+#endif
+
+ //========== case 11: ======================//
+#if 1
+ {
+ stmt = taos_stmt_init(taos);
+
+ tableNum = 2;
+ rowsOfPerColum = 5;
+ bingNum = 1;
+ lenOfBinaryDef = 40;
+ lenOfBinaryAct = 8;
+ columnNum = 5;
+
+ prepareVcolumn_autoCreateTbl(taos, 1, tableNum, lenOfBinaryDef, "db11");
+ stmt_specifyCol_bind_case_003_autoCreateTbl(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum);
+
+ totalRowsPerTbl = rowsOfPerColum * bingNum;
+ checkResult(taos, "m0", 0, totalRowsPerTbl);
+ checkResult(taos, "m1", 0, totalRowsPerTbl);
+ taos_stmt_close(stmt);
+ printf("case 11 check result end\n\n");
+ }
+#endif
+
+ //========== case 12: ======================//
+#if 1
+ {
+ stmt = taos_stmt_init(taos);
+
+ tableNum = 200;
+ rowsOfPerColum = 60;
+ bingNum = 1;
+ lenOfBinaryDef = 40;
+ lenOfBinaryAct = 8;
+ columnNum = 5;
+
+ prepareVcolumn_autoCreateTbl(taos, 1, tableNum, lenOfBinaryDef, "db12");
+ stmt_specifyCol_bind_case_003_autoCreateTbl(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum);
+
+ totalRowsPerTbl = rowsOfPerColum * bingNum;
+ checkResult(taos, "m0", 0, totalRowsPerTbl);
+ checkResult(taos, "m1", 0, totalRowsPerTbl);
+ checkResult(taos, "m99", 0, totalRowsPerTbl);
+ checkResult(taos, "m139", 0, totalRowsPerTbl);
+ checkResult(taos, "m199", 0, totalRowsPerTbl);
+ taos_stmt_close(stmt);
+ printf("case 12 check result end\n\n");
+ }
+#endif
+
+
+ //========== case 13: ======================//
+#if 1
+ {
+ printf("====case 13 error test start\n");
+ stmt = taos_stmt_init(taos);
+
+ tableNum = 1;
+ rowsOfPerColum = 8;
+ bingNum = 1;
+ lenOfBinaryDef = 40;
+ lenOfBinaryAct = 8;
+ columnNum = 5;
+
+ prepareVcolumn_autoCreateTbl(taos, 1, tableNum, lenOfBinaryDef, "db13");
+ stmt_specifyCol_bind_case_004_autoCreateTbl(stmt, tableNum, rowsOfPerColum, bingNum, lenOfBinaryDef, lenOfBinaryAct, columnNum);
+
+ totalRowsPerTbl = rowsOfPerColum * bingNum;
+ checkResult(taos, "m0", 0, totalRowsPerTbl);
+ taos_stmt_close(stmt);
+ printf("====case 13 check result end\n\n");
+ }
+#endif
+
+ return ;
+
+}
+
+
int main(int argc, char *argv[])
{
TAOS *taos;
char host[32] = "127.0.0.1";
char* serverIp = NULL;
- int threadNum = 1;
+ //int threadNum = 1;
// connect to server
if (argc == 1) {
@@ -3173,10 +4420,10 @@ int main(int argc, char *argv[])
serverIp = argv[1];
} else if (argc == 3) {
serverIp = argv[1];
- threadNum = atoi(argv[2]);
+ //threadNum = atoi(argv[2]);
} else if (argc == 4) {
serverIp = argv[1];
- threadNum = atoi(argv[2]);
+ //threadNum = atoi(argv[2]);
g_runTimes = atoi(argv[3]);
}
@@ -3219,12 +4466,12 @@ int main(int argc, char *argv[])
if (taos == NULL) {
printf("failed to connect to TDengine, reason:%s\n", taos_errstr(taos));
return -1;
- }
+ }
- runCase(taos);
- runCase_long(taos);
- SpecifyColumnBatchCase(taos);
-
+ //runCase(taos);
+ //runCase_long(taos);
+ //SpecifyColumnBatchCase(taos);
+ SpecifyColumnBatchCase_autoCreateTbl(taos);
return 0;
}
diff --git a/tests/script/fullGeneralSuite.sim b/tests/script/fullGeneralSuite.sim
index cde51ebdbf..2cd2236200 100644
--- a/tests/script/fullGeneralSuite.sim
+++ b/tests/script/fullGeneralSuite.sim
@@ -33,6 +33,7 @@ run general/compute/percentile.sim
run general/compute/stddev.sim
run general/compute/sum.sim
run general/compute/top.sim
+run general/compute/block_dist.sim
run general/db/alter_option.sim
run general/db/alter_tables_d2.sim
run general/db/alter_tables_v1.sim
diff --git a/tests/script/general/compute/block_dist.sim b/tests/script/general/compute/block_dist.sim
new file mode 100644
index 0000000000..51cf903654
--- /dev/null
+++ b/tests/script/general/compute/block_dist.sim
@@ -0,0 +1,94 @@
+system sh/stop_dnodes.sh
+
+system sh/deploy.sh -n dnode1 -i 1
+system sh/cfg.sh -n dnode1 -c walLevel -v 1
+system sh/exec.sh -n dnode1 -s start
+sleep 2000
+sql connect
+
+$dbPrefix = m_di_db
+$tbPrefix = m_di_tb
+$mtPrefix = m_di_mt
+$ntPrefix = m_di_nt
+$tbNum = 1
+$rowNum = 2000
+
+print =============== step1
+$i = 0
+$db = $dbPrefix . $i
+$mt = $mtPrefix . $i
+$nt = $ntPrefix . $i
+
+sql drop database $db -x step1
+step1:
+sql create database $db
+sql use $db
+sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int)
+
+$i = 0
+while $i < $tbNum
+ $tb = $tbPrefix . $i
+ sql create table $tb using $mt tags( $i )
+
+ $x = 0
+ while $x < $rowNum
+ $cc = $x * 60000
+ $ms = 1601481600000 + $cc
+ sql insert into $tb values ($ms , $x )
+ $x = $x + 1
+ endw
+
+ $i = $i + 1
+endw
+
+sql create table $nt (ts timestamp, tbcol int)
+$x = 0
+while $x < $rowNum
+ $cc = $x * 60000
+ $ms = 1601481600000 + $cc
+ sql insert into $nt values ($ms , $x )
+ $x = $x + 1
+endw
+
+sleep 100
+
+print =============== step2
+$i = 0
+$tb = $tbPrefix . $i
+
+sql select _block_dist() from $tb
+
+if $rows != 1 then
+ print expect 1, actual:$rows
+ return -1
+endi
+
+print =============== step3
+$i = 0
+$mt = $mtPrefix . $i
+sql select _block_dist() from $mt
+
+if $rows != 1 then
+ print expect 1, actual:$rows
+ return -1
+endi
+
+print =============== step4
+$i = 0
+$nt = $ntPrefix . $i
+
+sql select _block_dist() from $nt
+
+if $rows != 1 then
+ print expect 1, actual:$rows
+ return -1
+endi
+
+print =============== clear
+sql drop database $db
+sql show databases
+if $rows != 0 then
+ return -1
+endi
+
+system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
diff --git a/tests/script/general/compute/testSuite.sim b/tests/script/general/compute/testSuite.sim
index 6cd6badaee..91bf4bf0cd 100644
--- a/tests/script/general/compute/testSuite.sim
+++ b/tests/script/general/compute/testSuite.sim
@@ -14,3 +14,4 @@ run general/compute/percentile.sim
run general/compute/stddev.sim
run general/compute/sum.sim
run general/compute/top.sim
+run general/compute/block_dist.sim
diff --git a/tests/script/general/parser/function.sim b/tests/script/general/parser/function.sim
index 56ce15c36f..ee5a750c88 100644
--- a/tests/script/general/parser/function.sim
+++ b/tests/script/general/parser/function.sim
@@ -24,6 +24,9 @@ sql drop database if exists $db
sql create database $db keep 36500
sql use $db
+print =====================================> td-4481
+sql create database $db
+
print =====================================> test case for twa in single block
sql create table t1 (ts timestamp, k float);
diff --git a/tests/script/general/parser/import_file.sim b/tests/script/general/parser/import_file.sim
index a39d79af17..e9f0f1ed08 100644
--- a/tests/script/general/parser/import_file.sim
+++ b/tests/script/general/parser/import_file.sim
@@ -18,6 +18,7 @@ system general/parser/gendata.sh
sql create table tbx (ts TIMESTAMP, collect_area NCHAR(12), device_id BINARY(16), imsi BINARY(16), imei BINARY(16), mdn BINARY(10), net_type BINARY(4), mno NCHAR(4), province NCHAR(10), city NCHAR(16), alarm BINARY(2))
print ====== create tables success, starting import data
+sql import into tbx file '~/data.sql'
sql import into tbx file '~/data.sql'
sql select count(*) from tbx
diff --git a/tests/script/general/parser/nestquery.sim b/tests/script/general/parser/nestquery.sim
index 9e2736833f..3d13ff504d 100644
--- a/tests/script/general/parser/nestquery.sim
+++ b/tests/script/general/parser/nestquery.sim
@@ -9,7 +9,7 @@ sql connect
print ======================== dnode1 start
-$dbPrefix = nest_query
+$dbPrefix = nest_db
$tbPrefix = nest_tb
$mtPrefix = nest_mt
$tbNum = 10
@@ -17,7 +17,6 @@ $rowNum = 10000
$totalNum = $tbNum * $rowNum
print =============== nestquery.sim
-
$i = 0
$db = $dbPrefix . $i
$mt = $mtPrefix . $i
diff --git a/tests/script/general/parser/testSuite.sim b/tests/script/general/parser/testSuite.sim
index afb76c799e..6265fc3a02 100644
--- a/tests/script/general/parser/testSuite.sim
+++ b/tests/script/general/parser/testSuite.sim
@@ -60,4 +60,5 @@ run general/parser/slimit_alter_tags.sim
run general/parser/binary_escapeCharacter.sim
run general/parser/between_and.sim
run general/parser/last_cache.sim
+run general/parser/nestquery.sim
diff --git a/tests/script/regressionSuite.sim b/tests/script/regressionSuite.sim
index e5e2194e87..d5742cd98f 100644
--- a/tests/script/regressionSuite.sim
+++ b/tests/script/regressionSuite.sim
@@ -32,6 +32,7 @@ run general/compute/percentile.sim
run general/compute/stddev.sim
run general/compute/sum.sim
run general/compute/top.sim
+run general/compute/block_dist.sim
run general/db/alter_option.sim
run general/db/alter_tables_d2.sim
run general/db/alter_tables_v1.sim