提交 f63da34c 编写于 作者: P Ping Xiao

Merge branch 'develop' into xiaoping/add_test_case

...@@ -9,9 +9,7 @@ set -e ...@@ -9,9 +9,7 @@ set -e
script_dir=$(dirname $(readlink -f "$0")) script_dir=$(dirname $(readlink -f "$0"))
# Dynamic directory # Dynamic directory
lib_link_dir="/usr/lib" lib_link_dir="/usr/lib"
lib64_link_dir="/usr/lib64"
#install main path
install_main_dir="/usr/local/taos"
# Color setting # Color setting
RED='\033[0;31m' RED='\033[0;31m'
...@@ -25,24 +23,23 @@ if command -v sudo > /dev/null; then ...@@ -25,24 +23,23 @@ if command -v sudo > /dev/null; then
csudo="sudo" csudo="sudo"
fi fi
function clean_driver() {
${csudo} rm -f /usr/lib/libtaos.so || :
}
function install_driver() { function install_driver() {
echo -e "${GREEN}Start to install TDengine client driver ...${NC}"
#create install main dir and all sub dir
${csudo} mkdir -p ${install_main_dir}
${csudo} mkdir -p ${install_main_dir}/driver
${csudo} rm -f ${lib_link_dir}/libtaos.* || :
${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
echo echo
echo -e "\033[44;32;1mTDengine client driver is successfully installed!${NC}" if [[ -d ${lib_link_dir} && ! -e ${lib_link_dir}/libtaos.so ]]; then
echo -e "${GREEN}Start to install TDengine client driver ...${NC}"
${csudo} ln -s ${script_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 ${script_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 || :
${csudo} ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || :
fi
echo
echo -e "${GREEN}TDengine client driver is successfully installed!${NC}"
else
echo -e "${GREEN}TDengine client driver already exists, Please confirm whether the alert version matches the client driver version!${NC}"
fi
} }
install_driver install_driver
...@@ -119,7 +119,7 @@ WantedBy=multi-user.target ...@@ -119,7 +119,7 @@ WantedBy=multi-user.target
return nil return nil
} }
const version = "TDengine alert v2.0.0.1" var version = "2.0.0.1s"
func main() { func main() {
var ( var (
...@@ -133,7 +133,7 @@ func main() { ...@@ -133,7 +133,7 @@ func main() {
flag.Parse() flag.Parse()
if showVersion { if showVersion {
fmt.Println(version) fmt.Println("TDengine alert v" + version)
return return
} }
......
...@@ -6,9 +6,9 @@ set -e ...@@ -6,9 +6,9 @@ set -e
# set parameters by default value # set parameters by default value
cpuType=amd64 # [armv6l | arm64 | amd64 | 386] cpuType=amd64 # [armv6l | arm64 | amd64 | 386]
osType=linux # [linux | darwin | windows] osType=linux # [linux | darwin | windows]
version=""
declare -A archMap=(["armv6l"]="arm" ["arm64"]="arm64" ["amd64"]="x64" ["386"]="x86") declare -A archMap=(["armv6l"]="arm" ["arm64"]="arm64" ["amd64"]="x64" ["386"]="x86")
while getopts "h:c:o:" arg while getopts "h:c:o:n:" arg
do do
case $arg in case $arg in
c) c)
...@@ -19,6 +19,10 @@ do ...@@ -19,6 +19,10 @@ do
#echo "osType=$OPTARG" #echo "osType=$OPTARG"
osType=$(echo $OPTARG) osType=$(echo $OPTARG)
;; ;;
n)
#echo "version=$OPTARG"
version=$(echo $OPTARG)
;;
h) h)
echo "Usage: `basename $0` -c [armv6l | arm64 | amd64 | 386] -o [linux | darwin | windows]" echo "Usage: `basename $0` -c [armv6l | arm64 | amd64 | 386] -o [linux | darwin | windows]"
exit 0 exit 0
...@@ -30,18 +34,27 @@ do ...@@ -30,18 +34,27 @@ do
esac esac
done done
if [ "$version" == "" ]; then
echo "Please input the correct version!"
exit 1
fi
startdir=$(pwd) startdir=$(pwd)
scriptdir=$(dirname $(readlink -f $0)) scriptdir=$(dirname $(readlink -f $0))
cd ${scriptdir}/cmd/alert cd ${scriptdir}/cmd/alert
version=$(grep 'const version =' main.go | awk '{print $NF}')
version=${version%\"}
version=${version:1}
echo "cpuType=${cpuType}" echo "cpuType=${cpuType}"
echo "osType=${osType}" echo "osType=${osType}"
echo "version=${version}" echo "version=${version}"
GOOS=${osType} GOARCH=${cpuType} go build GOOS=${osType} GOARCH=${cpuType} go build -ldflags '-X main.version='${version}
mkdir -p TDengine-alert/driver
cp alert alert.cfg install_driver.sh ./TDengine-alert/.
cp ../../../debug/build/lib/libtaos.so.${version} ./TDengine-alert/driver/.
chmod 777 ./TDengine-alert/install_driver.sh
tar -I 'gzip -9' -cf ${startdir}/TDengine-alert-${version}-${osType^}-${archMap[${cpuType}]}.tar.gz TDengine-alert/
rm -rf ./TDengine-alert
tar -I 'gzip -9' -cf ${startdir}/TDengine-alert-${version}-${osType^}-${archMap[${cpuType}]}.tar.gz alert alert.cfg install_driver.sh driver/
...@@ -100,7 +100,7 @@ IF (TD_LINUX) ...@@ -100,7 +100,7 @@ IF (TD_LINUX)
ENDIF () ENDIF ()
SET(DEBUG_FLAGS "-O0 -DDEBUG") SET(DEBUG_FLAGS "-O0 -DDEBUG")
SET(RELEASE_FLAGS "-O0") SET(RELEASE_FLAGS "-O0 -Wno-unused-variable -Wunused-but-set-variable")
IF (${COVER} MATCHES "true") IF (${COVER} MATCHES "true")
MESSAGE(STATUS "Test coverage mode, add extra flags") MESSAGE(STATUS "Test coverage mode, add extra flags")
......
...@@ -78,6 +78,18 @@ taos> SELECT SUM(current) FROM meters INTERVAL(1s); ...@@ -78,6 +78,18 @@ taos> SELECT SUM(current) FROM meters INTERVAL(1s);
2018-10-03 14:38:16.000 | 36.000000000 | 2018-10-03 14:38:16.000 | 36.000000000 |
Query OK, 5 row(s) in set (0.001538s) Query OK, 5 row(s) in set (0.001538s)
``` ```
降采样操作也支持时间偏移,比如:将所有智能电表采集的电流值每秒钟求和,但要求每个时间窗口从 500 毫秒开始
```mysql
taos> SELECT SUM(current) FROM meters INTERVAL(1s, 500a);
ts | sum(current) |
======================================================
2018-10-03 14:38:04.500 | 11.189999809 |
2018-10-03 14:38:05.500 | 31.900000572 |
2018-10-03 14:38:06.500 | 11.600000000 |
2018-10-03 14:38:15.500 | 12.300000381 |
2018-10-03 14:38:16.500 | 35.000000000 |
Query OK, 5 row(s) in set (0.001521s)
```
物联网场景里,每个数据采集点采集数据的时间是难同步的,但很多分析算法(比如FFT)需要把采集的数据严格按照时间等间隔的对齐,在很多系统里,需要应用自己写程序来处理,但使用TDengine的降采样操作就轻松解决。如果一个时间间隔里,没有采集的数据,TDengine还提供插值计算的功能。 物联网场景里,每个数据采集点采集数据的时间是难同步的,但很多分析算法(比如FFT)需要把采集的数据严格按照时间等间隔的对齐,在很多系统里,需要应用自己写程序来处理,但使用TDengine的降采样操作就轻松解决。如果一个时间间隔里,没有采集的数据,TDengine还提供插值计算的功能。
......
...@@ -148,7 +148,7 @@ INSERT INTO <tb1_name> USING <stb1_name> TAGS (<tag1_value1>, ...) VALUES (<fiel ...@@ -148,7 +148,7 @@ INSERT INTO <tb1_name> USING <stb1_name> TAGS (<tag1_value1>, ...) VALUES (<fiel
SELECT function<field_name>,… SELECT function<field_name>,…
FROM <stable_name> FROM <stable_name>
WHERE <tag_name> <[=|<=|>=|<>] values..> ([AND|OR] …) WHERE <tag_name> <[=|<=|>=|<>] values..> ([AND|OR] …)
INTERVAL (<time range>) INTERVAL (<interval> [, offset])
GROUP BY <tag_name>, <tag_name>… GROUP BY <tag_name>, <tag_name>…
ORDER BY <tag_name> <asc|desc> ORDER BY <tag_name> <asc|desc>
SLIMIT <group_limit> SLIMIT <group_limit>
......
...@@ -33,8 +33,7 @@ taos> DESCRIBE meters; ...@@ -33,8 +33,7 @@ taos> DESCRIBE meters;
- 内部函数now是服务器的当前时间 - 内部函数now是服务器的当前时间
- 插入记录时,如果时间戳为now,插入数据时使用服务器当前时间 - 插入记录时,如果时间戳为now,插入数据时使用服务器当前时间
- Epoch Time: 时间戳也可以是一个长整数,表示从1970-01-01 08:00:00.000开始的毫秒数 - Epoch Time: 时间戳也可以是一个长整数,表示从1970-01-01 08:00:00.000开始的毫秒数
- 时间可以加减,比如 now-2h,表明查询时刻向前推2个小时(最近2小时)。数字后面的时间单位:a(毫秒), s(秒), m(分), h(小时), d(天),w(周), n(月), y(年)。比如select * from t1 where ts > now-2w and ts <= now-1w, 表示查询两周前整整一周的数据 - 时间可以加减,比如 now-2h,表明查询时刻向前推2个小时(最近2小时)。 数字后面的时间单位可以是 a(毫秒)、s(秒)、 m(分)、h(小时)、d(天)、w(周)。 比如select * from t1 where ts > now-2w and ts <= now-1w, 表示查询两周前整整一周的数据。 在指定降频操作(down sampling)的时间窗口(interval)时,时间单位还可以使用 n(自然月) 和 y(自然年)。
- TDengine暂不支持时间窗口按照自然年和自然月切分。Where条件中的时间窗口单位的换算关系如下:interval(1y) 等效于 interval(365d), interval(1n) 等效于 interval(30d), interval(1w) 等效于 interval(7d)
TDengine缺省的时间戳是毫秒精度,但通过修改配置参数enableMicrosecond就可支持微秒。 TDengine缺省的时间戳是毫秒精度,但通过修改配置参数enableMicrosecond就可支持微秒。
...@@ -299,7 +298,7 @@ TDengine缺省的时间戳是毫秒精度,但通过修改配置参数enableMic ...@@ -299,7 +298,7 @@ TDengine缺省的时间戳是毫秒精度,但通过修改配置参数enableMic
SELECT select_expr [, select_expr ...] SELECT select_expr [, select_expr ...]
FROM {tb_name_list} FROM {tb_name_list}
[WHERE where_condition] [WHERE where_condition]
[INTERVAL [interval_offset,] interval_val] [INTERVAL (interval_val [, interval_offset])]
[FILL fill_val] [FILL fill_val]
[SLIDING fill_val] [SLIDING fill_val]
[GROUP BY col_list] [GROUP BY col_list]
...@@ -972,17 +971,17 @@ TDengine支持按时间段进行聚合,可以将表中数据按照时间段进 ...@@ -972,17 +971,17 @@ TDengine支持按时间段进行聚合,可以将表中数据按照时间段进
```mysql ```mysql
SELECT function_list FROM tb_name SELECT function_list FROM tb_name
[WHERE where_condition] [WHERE where_condition]
INTERVAL (interval) INTERVAL (interval [, offset])
[FILL ({NONE | VALUE | PREV | NULL | LINEAR})] [FILL ({NONE | VALUE | PREV | NULL | LINEAR})]
SELECT function_list FROM stb_name SELECT function_list FROM stb_name
[WHERE where_condition] [WHERE where_condition]
INTERVAL (interval) INTERVAL (interval [, offset])
[FILL ({ VALUE | PREV | NULL | LINEAR})] [FILL ({ VALUE | PREV | NULL | LINEAR})]
[GROUP BY tags] [GROUP BY tags]
``` ```
- 聚合时间段的长度由关键词INTERVAL指定,最短时间间隔10毫秒(10a)。聚合查询中,能够同时执行的聚合和选择函数仅限于单个输出的函数:count、avg、sum 、stddev、leastsquares、percentile、min、max、first、last,不能使用具有多行输出结果的函数(例如:top、bottom、diff以及四则运算)。 - 聚合时间段的长度由关键词INTERVAL指定,最短时间间隔10毫秒(10a),并且支持偏移(偏移必须小于间隔)。聚合查询中,能够同时执行的聚合和选择函数仅限于单个输出的函数:count、avg、sum 、stddev、leastsquares、percentile、min、max、first、last,不能使用具有多行输出结果的函数(例如:top、bottom、diff以及四则运算)。
- WHERE语句可以指定查询的起止时间和其他过滤条件 - WHERE语句可以指定查询的起止时间和其他过滤条件
- FILL语句指定某一时间区间数据缺失的情况下的填充模式。填充模式包括以下几种: - FILL语句指定某一时间区间数据缺失的情况下的填充模式。填充模式包括以下几种:
1. 不进行填充:NONE(默认填充模式)。 1. 不进行填充:NONE(默认填充模式)。
......
# TDengine 集群安装、管理 # TDengine 集群安装、管理
多个taosd的运行实例可以组成一个集群,以保证TDengine的高可靠运行,并提供水平扩展能力。要了解TDengine 2.0的集群管理,需要对集群的基本概念有所了解,请看TDengine 2.0整体架构一章。而且在安装集群之前,请按照[《立即开始》](https://www.taosdata.com/cn/getting-started20/)一章安装并体验过单节点功能。 多个TDengine服务器,也就是多个taosd的运行实例可以组成一个集群,以保证TDengine的高可靠运行,并提供水平扩展能力。要了解TDengine 2.0的集群管理,需要对集群的基本概念有所了解,请看TDengine 2.0整体架构一章。而且在安装集群之前,先请按照[《立即开始》](https://www.taosdata.com/cn/getting-started20/)一章安装并体验单节点功能。
集群的每个节点是由End Point来唯一标识的,End Point是由FQDN(Fully Qualified Domain Name)外加Port组成,比如 h1.taosdata.com:6030。一般FQDN就是服务器的hostname,可通过Linux命令`hostname -f`获取,FQDN配置参考:[一篇文章说清楚TDengine的FQDN](https://www.taosdata.com/blog/2020/09/11/1824.html)。端口是这个节点对外服务的端口号,缺省是6030,但可以通过taos.cfg里配置参数serverPort进行修改。一个节点可能配置了多个hostname, TDengine会自动获取第一个,但也可以通过taos.cfg里配置参数fqdn进行指定。如果习惯IP地址直接访问,可以将参数fqdn设置为本节点的IP地址。 集群的每个数据节点是由End Point来唯一标识的,End Point是由FQDN(Fully Qualified Domain Name)外加Port组成,比如 h1.taosdata.com:6030。一般FQDN就是服务器的hostname,可通过Linux命令`hostname -f`获取,FQDN配置参考:[一篇文章说清楚TDengine的FQDN](https://www.taosdata.com/blog/2020/09/11/1824.html)。端口是这个数据节点对外服务的端口号,缺省是6030,但可以通过taos.cfg里配置参数serverPort进行修改。一个物理节点可能配置了多个hostname, TDengine会自动获取第一个,但也可以通过taos.cfg里配置参数fqdn进行指定。如果习惯IP地址直接访问,可以将参数fqdn设置为本节点的IP地址。
TDengine的集群管理极其简单,除添加和删除节点需要人工干预之外,其他全部是自动完成,最大程度的降低了运维的工作量。本章对集群管理的操作做详细的描述。 TDengine的集群管理极其简单,除添加和删除节点需要人工干预之外,其他全部是自动完成,最大程度的降低了运维的工作量。本章对集群管理的操作做详细的描述。
## 准备工作 ## 准备工作
**第一步**:如果搭建集群的节点中,存有之前的测试数据、装过1.X的版本,或者装过其他版本的TDengine,请先将其删除,并清空所有数据,具体步骤请参考博客[《TDengine多种安装包的安装和卸载》](https://www.taosdata.com/blog/2019/08/09/566.html ) **第零步**:规划集群所有物理节点的FQDN,将规划好的FQDN分别添加到每个物理节点的/etc/hostname;修改每个物理节点的/etc/hosts,将所有集群物理节点的IP与FQDN的对应添加好【如部署了DNS,请联系网络管理员在DNS上做好相关配置】;
**第一步**:如果搭建集群的物理节点中,存有之前的测试数据、装过1.X的版本,或者装过其他版本的TDengine,请先将其删除,并清空所有数据,具体步骤请参考博客[《TDengine多种安装包的安装和卸载》](https://www.taosdata.com/blog/2019/08/09/566.html )
**注意1:**因为FQDN的信息会写进文件,如果之前没有配置或者更改FQDN,且启动了TDengine。请一定在确保数据无用或者备份的前提下,清理一下之前的数据(rm -rf /var/lib/taos/); **注意1:**因为FQDN的信息会写进文件,如果之前没有配置或者更改FQDN,且启动了TDengine。请一定在确保数据无用或者备份的前提下,清理一下之前的数据(rm -rf /var/lib/taos/);
**注意2:**客户端也需要配置,确保它可以正确解析每个节点的FQDN配置,不管是通过DNS服务,还是 Host 文件。 **注意2:**客户端也需要配置,确保它可以正确解析每个节点的FQDN配置,不管是通过DNS服务,还是 Host 文件。
**第二步**:建议关闭防火墙,至少保证端口:6030 - 6042的TCP和UDP端口都是开放的。**强烈建议**先关闭防火墙,集群搭建完毕之后,再来配置端口; **第二步**:建议关闭所有物理节点的防火墙,至少保证端口:6030 - 6042的TCP和UDP端口都是开放的。**强烈建议**先关闭防火墙,集群搭建完毕之后,再来配置端口;
**第三步**:在所有节点安装TDengine,且版本必须是一致的,**但不要启动taosd** **第三步**:在所有节点安装TDengine,且版本必须是一致的,**但不要启动taosd**。安装时,提示输入是否要加入一个已经存在的TDengine集群时,第一个物理节点直接回车创建新集群,后续物理节点则输入该集群任何一个在线的物理节点的FQDN:端口号(默认6030)
**第四步**:检查、配置所有节点的FQDN **第四步**:检查所有数据节点,以及应用所在物理节点的网络设置
1. 每个节点上执行命令`hostname -f`,查看和确认所有节点的hostname是不相同的 1. 每个物理节点上执行命令`hostname -f`,查看和确认所有节点的hostname是不相同的(应用驱动所在节点无需做此项检查)
2. 每个节点上执行`ping host`, 其中host是其他节点的hostname, 看能否ping通其它节点; 如果不能ping通,需要检查网络设置, 或/etc/hosts文件,或DNS的配置。如果无法ping通,是无法组成集群的。 2. 每个物理节点上执行`ping host`, 其中host是其他物理节点的hostname, 看能否ping通其它物理节点; 如果不能ping通,需要检查网络设置, 或/etc/hosts文件(Windows系统默认路径为C:\Windows\system32\drivers\etc\hosts),或DNS的配置。如果无法ping通,是无法组成集群的;
3. 每个节点的FQDN就是输出的hostname外加端口号,比如h1.taosdata.com:6030 3. 每个数据节点的End Point就是输出的hostname外加端口号,比如h1.taosdata.com:6030
**第五步**:修改TDengine的配置文件(所有节点的文件/etc/taos/taos.cfg都需要修改)。假设准备启动的第一个节点End Point为 h1.taosdata.com:6030, 那么以下几个参数与集群相关 **第五步**:修改TDengine的配置文件(所有节点的文件/etc/taos/taos.cfg都需要修改)。假设准备启动的第一个数据节点End Point为 h1.taosdata.com:6030, 其与集群配置相关参数如下
``` ```
// firstEp 集群中所有节点的配置都是一致的,对其第一次访问后,就获得了整个集群的信息 // firstEp 是每个数据节点首次启动后连接的第一个数据节点
firstEp h1.taosdata.com:6030 firstEp h1.taosdata.com:6030
// 配置本节点的FQDN,如果本机只有一个hostname, 无需配置 // 配置本数据节点的FQDN,如果本机只有一个hostname, 无需配置
fqdn h1.taosdata.com fqdn h1.taosdata.com
// 配置本节点的端口号,缺省是6030 // 配置本数据节点的端口号,缺省是6030
serverPort 6030 serverPort 6030
// 服务端节点数为偶数的时候,需要配置,请参考《Arbitrator的使用》的部分 // 服务端节点数为偶数的时候,需要配置,请参考《Arbitrator的使用》的部分
arbitrator ha.taosdata.com:6042 arbitrator ha.taosdata.com:6042
``` ```
一定要修改的参数是firstEp, 其他参数可不做任何修改,除非你很清楚为什么要修改。 一定要修改的参数是firstEp和fqdn, 其他参数可不做任何修改,除非你很清楚为什么要修改。
**加入到集群中的数据节点dnode,涉及集群相关的下表11项参数必须完全相同,否则不能成功加入到集群中。**
| **#** | **配置参数名称** | **含义** |
| ----- | ------------------ | ---------------------------------------- |
| 1 | numOfMnodes | 系统中管理节点个数 |
| 2 | mnodeEqualVnodeNum | 一个mnode等同于vnode消耗的个数 |
| 3 | offlineThreshold | dnode离线阈值,超过该时间将导致Dnode离线 |
| 4 | statusInterval | dnode向mnode报告状态时长 |
| 5 | arbitrator | 系统中裁决器的end point |
| 6 | timezone | 时区 |
| 7 | locale | 系统区位信息及编码格式 |
| 8 | charset | 字符集编码 |
| 9 | balance | 是否启动负载均衡 |
| 10 | maxTablesPerVnode | 每个vnode中能够创建的最大表个数 |
| 11 | maxVgroupsPerDb | 每个DB中 能够使用的最大vnode个数 |
## 启动第一个节点 ## 启动第一个数据节点
按照[《立即开始》](https://www.taosdata.com/cn/getting-started20/)里的指示,启动第一个数据节点,例如h1.taosdata.com,然后执行taos, 启动taos shell,从shell里执行命令"show dnodes;",如下所示:
按照[《立即开始》](https://www.taosdata.com/cn/getting-started20/)里的指示,启动第一个节点h1.taosdata.com,然后执行taos, 启动taos shell,从shell里执行命令"show dnodes;",如下所示:
``` ```
Welcome to the TDengine shell from Linux, Client Version:2.0.0.0 Welcome to the TDengine shell from Linux, Client Version:2.0.0.0
Copyright (c) 2017 by TAOS Data, Inc. All rights reserved. Copyright (c) 2017 by TAOS Data, Inc. All rights reserved.
...@@ -55,74 +76,86 @@ Query OK, 1 row(s) in set (0.006385s) ...@@ -55,74 +76,86 @@ Query OK, 1 row(s) in set (0.006385s)
taos> taos>
``` ```
上述命令里,可以看到这个刚启动的这个节点的End Point是:h1.taos.com:6030
## 启动后续节点 上述命令里,可以看到这个刚启动的这个数据节点的End Point是:h1.taos.com:6030,就是这个新集群的firstEP。
## 启动后续数据节点
将后续的节点添加到现有集群,具体有以下几步: 将后续的数据节点添加到现有集群,具体有以下几步:
1. 按照["立即开始“](https://www.taosdata.com/cn/getting-started/)一章的方法在每个节点启动taosd。 1. 按照["立即开始“](https://www.taosdata.com/cn/getting-started/)一章的方法在每个物理节点启动taosd;
2. 在第一个节点,使用CLI程序taos, 登录进TDengine系统, 执行命令: 2. 在第一个数据节点,使用CLI程序taos, 登录进TDengine系统, 执行命令:
``` ```
CREATE DNODE "h2.taos.com:6030"; CREATE DNODE "h2.taos.com:6030";
``` ```
将新节点的End Point (准备工作中第四步获知的) 添加进集群的EP列表。**"fqdn:port"需要用双引号引起来**,否则出错。请注意将示例的“h2.taos.com:6030" 替换为这个新节点的End Point。 将新数据节点的End Point (准备工作中第四步获知的) 添加进集群的EP列表。**"fqdn:port"需要用双引号引起来**,否则出错。请注意将示例的“h2.taos.com:6030" 替换为这个新数据节点的End Point。
3. 然后执行命令 3. 然后执行命令
``` ```
SHOW DNODES; SHOW DNODES;
``` ```
查看新节点是否被成功加入。如果该被加入的节点处于离线状态,请做两个检查 查看新节点是否被成功加入。如果该被加入的数据节点处于离线状态,请做两个检查
- 查看该节点的taosd是否正常工作,如果没有正常运行,需要先检查为什么
- 查看该节点taosd日志文件taosdlog.0里前面几行日志(一般在/var/log/taos目录),看日志里输出的该节点fqdn以及端口号是否为刚添加的End Point。如果不一致,需要将正确的End Point添加进去。
按照上述步骤可以源源不断的将新的节点加入到集群。 - 查看该数据节点的taosd是否正常工作,如果没有正常运行,需要先检查为什么
- 查看该数据节点taosd日志文件taosdlog.0里前面几行日志(一般在/var/log/taos目录),看日志里输出的该数据节点fqdn以及端口号是否为刚添加的End Point。如果不一致,需要将正确的End Point添加进去。
按照上述步骤可以源源不断的将新的数据节点加入到集群。
**提示:** **提示:**
- firstEp这个参数仅仅在该节点第一次加入集群时有作用,加入集群后,该节点会保存最新的mnode的End Point列表,不再依赖这两个参数。 - 任何已经加入集群在线的数据节点,都可以作为后续待加入节点的firstEP。
- 两个没有配置firstEp参数的dnode启动后,会独立运行起来。这个时候,无法将其中一个节点加入到另外一个节点,形成集群。**无法将两个独立的集群合并成为新的集群** - firstEp这个参数仅仅在该数据节点首次加入集群时有作用,加入集群后,该数据节点会保存最新的mnode的End Point列表,不再依赖这个参数。
- 两个没有配置firstEp参数的数据节点dnode启动后,会独立运行起来。这个时候,无法将其中一个数据节点加入到另外一个数据节点,形成集群。**无法将两个独立的集群合并成为新的集群**
## 数据节点管理
## 节点管理 ### 添加数据节点
### 添加节点
执行CLI程序taos, 使用root账号登录进系统, 执行: 执行CLI程序taos, 使用root账号登录进系统, 执行:
``` ```
CREATE DNODE "fqdn:port"; CREATE DNODE "fqdn:port";
``` ```
将新节点的End Point添加进集群的EP列表。**"fqdn:port"需要用双引号引起来**,否则出错。一个节点对外服务的fqdn和port可以通过配置文件taos.cfg进行配置,缺省是自动获取。
### 删除节点 将新数据节点的End Point添加进集群的EP列表。**"fqdn:port"需要用双引号引起来**,否则出错。一个数据节点对外服务的fqdn和port可以通过配置文件taos.cfg进行配置,缺省是自动获取。【强烈不建议用自动获取方式来配置FQDN,可能导致生成的数据节点的End Point不是所期望的】
### 删除数据节点
执行CLI程序taos, 使用root账号登录进TDengine系统,执行: 执行CLI程序taos, 使用root账号登录进TDengine系统,执行:
``` ```
DROP DNODE "fqdn:port"; DROP DNODE "fqdn:port";
``` ```
其中fqdn是被删除的节点的FQDN,port是其对外服务器的端口号 其中fqdn是被删除的节点的FQDN,port是其对外服务器的端口号
### 查看节点 ### 查看数据节点
执行CLI程序taos,使用root账号登录进TDengine系统,执行: 执行CLI程序taos,使用root账号登录进TDengine系统,执行:
``` ```
SHOW DNODES; SHOW DNODES;
``` ```
它将列出集群中所有的dnode,每个dnode的fqdn:port, 状态(ready, offline等),vnode数目,还未使用的vnode数目等信息。在添加或删除一个节点后,可以使用该命令查看。
它将列出集群中所有的dnode,每个dnode的fqdn:port, 状态(ready, offline等),vnode数目,还未使用的vnode数目等信息。在添加或删除一个数据节点后,可以使用该命令查看。
### 查看虚拟节点组 ### 查看虚拟节点组
为充分利用多核技术,并提供scalability,数据需要分片处理。因此TDengine会将一个DB的数据切分成多份,存放在多个vnode里。这些vnode可能分布在多个dnode里,这样就实现了水平扩展。一个vnode仅仅属于一个DB,但一个DB可以有多个vnode。vnode的是mnode根据当前系统资源的情况,自动进行分配的,无需任何人工干预。 为充分利用多核技术,并提供scalability,数据需要分片处理。因此TDengine会将一个DB的数据切分成多份,存放在多个vnode里。这些vnode可能分布在多个数据节点dnode里,这样就实现了水平扩展。一个vnode仅仅属于一个DB,但一个DB可以有多个vnode。vnode的是mnode根据当前系统资源的情况,自动进行分配的,无需任何人工干预。
执行CLI程序taos,使用root账号登录进TDengine系统,执行: 执行CLI程序taos,使用root账号登录进TDengine系统,执行:
``` ```
SHOW VGROUPS; SHOW VGROUPS;
``` ```
## vnode的高可用性 ## vnode的高可用性
TDengine通过多副本的机制来提供系统的高可用性,包括vnode和mnode的高可用性。 TDengine通过多副本的机制来提供系统的高可用性,包括vnode和mnode的高可用性。
vnode的副本数是与DB关联的,一个集群里可以有多个DB,根据运营的需求,每个DB可以配置不同的副本数。创建数据库时,通过参数replica 指定副本数(缺省为1)。如果副本数为1,系统的可靠性无法保证,只要数据所在的节点宕机,就将无法提供服务。集群的节点数必须大于等于副本数,否则创建表时将返回错误“more dnodes are needed"。比如下面的命令将创建副本数为3的数据库demo: vnode的副本数是与DB关联的,一个集群里可以有多个DB,根据运营的需求,每个DB可以配置不同的副本数。创建数据库时,通过参数replica 指定副本数(缺省为1)。如果副本数为1,系统的可靠性无法保证,只要数据所在的节点宕机,就将无法提供服务。集群的节点数必须大于等于副本数,否则创建表时将返回错误“more dnodes are needed"。比如下面的命令将创建副本数为3的数据库demo:
...@@ -130,21 +163,25 @@ vnode的副本数是与DB关联的,一个集群里可以有多个DB,根据 ...@@ -130,21 +163,25 @@ vnode的副本数是与DB关联的,一个集群里可以有多个DB,根据
``` ```
CREATE DATABASE demo replica 3; CREATE DATABASE demo replica 3;
``` ```
一个DB里的数据会被切片分到多个vnode group,vnode group里的vnode数目就是DB的副本数,同一个vnode group里各vnode的数据是完全一致的。为保证高可用性,vnode group里的vnode一定要分布在不同的dnode里(实际部署时,需要在不同的物理机上),只要一个vgroup里超过半数的vnode处于工作状态,这个vgroup就能正常的对外服务。
一个dnode里可能有多个DB的数据,因此一个dnode离线时,可能会影响到多个DB。如果一个vnode group里的一半或一半以上的vnode不工作,那么该vnode group就无法对外服务,无法插入或读取数据,这样会影响到它所属的DB的一部分表的读写操作。 一个DB里的数据会被切片分到多个vnode group,vnode group里的vnode数目就是DB的副本数,同一个vnode group里各vnode的数据是完全一致的。为保证高可用性,vnode group里的vnode一定要分布在不同的数据节点dnode里(实际部署时,需要在不同的物理机上),只要一个vgroup里超过半数的vnode处于工作状态,这个vgroup就能正常的对外服务。
一个数据节点dnode里可能有多个DB的数据,因此一个dnode离线时,可能会影响到多个DB。如果一个vnode group里的一半或一半以上的vnode不工作,那么该vnode group就无法对外服务,无法插入或读取数据,这样会影响到它所属的DB的一部分表的读写操作。
因为vnode的引入,无法简单的给出结论:“集群中过半dnode工作,集群就应该工作”。但是对于简单的情形,很好下结论。比如副本数为3,只有三个dnode,那如果仅有一个节点不工作,整个集群还是可以正常工作的,但如果有两个节点不工作,那整个集群就无法正常工作了。 因为vnode的引入,无法简单的给出结论:“集群中过半数据节点dnode工作,集群就应该工作”。但是对于简单的情形,很好下结论。比如副本数为3,只有三个dnode,那如果仅有一个节点不工作,整个集群还是可以正常工作的,但如果有两个数据节点不工作,那整个集群就无法正常工作了。
## Mnode的高可用性 ## Mnode的高可用性
TDengine集群是由mnode (taosd的一个模块,逻辑节点) 负责管理的,为保证mnode的高可用,可以配置多个mnode副本,副本数由系统配置参数numOfMnodes决定,有效范围为1-3。为保证元数据的强一致性,mnode副本之间是通过同步的方式进行数据复制的。
一个集群有多个dnode, 但一个dnode至多运行一个mnode实例。多个dnode情况下,哪个dnode可以作为mnode呢?这是完全由系统根据整个系统资源情况,自动指定的。用户可通过CLI程序taos,在TDengine的console里,执行如下命令: TDengine集群是由mnode (taosd的一个模块,管理节点) 负责管理的,为保证mnode的高可用,可以配置多个mnode副本,副本数由系统配置参数numOfMnodes决定,有效范围为1-3。为保证元数据的强一致性,mnode副本之间是通过同步的方式进行数据复制的。
一个集群有多个数据节点dnode, 但一个dnode至多运行一个mnode实例。多个dnode情况下,哪个dnode可以作为mnode呢?这是完全由系统根据整个系统资源情况,自动指定的。用户可通过CLI程序taos,在TDengine的console里,执行如下命令:
``` ```
SHOW MNODES; SHOW MNODES;
``` ```
来查看mnode列表,该列表将列出mnode所处的dnode的End Point和角色(master, slave, unsynced 或offline)。 来查看mnode列表,该列表将列出mnode所处的dnode的End Point和角色(master, slave, unsynced 或offline)。
当集群中第一个节点启动时,该节点一定会运行一个mnode实例,否则该dnode无法正常工作,因为一个系统是必须有至少一个mnode的。如果numOfMnodes配置为2,启动第二个dnode时,该dnode也将运行一个mnode实例。 当集群中第一个数据节点启动时,该数据节点一定会运行一个mnode实例,否则该数据节点dnode无法正常工作,因为一个系统是必须有至少一个mnode的。如果numOfMnodes配置为2,启动第二个dnode时,该dnode也将运行一个mnode实例。
为保证mnode服务的高可用性,numOfMnodes必须设置为2或更大。因为mnode保存的元数据必须是强一致的,如果numOfMnodes大于2,复制参数quorum自动设为2,也就是说,至少要保证有两个副本写入数据成功,才通知客户端应用写入成功。 为保证mnode服务的高可用性,numOfMnodes必须设置为2或更大。因为mnode保存的元数据必须是强一致的,如果numOfMnodes大于2,复制参数quorum自动设为2,也就是说,至少要保证有两个副本写入数据成功,才通知客户端应用写入成功。
...@@ -154,22 +191,25 @@ SHOW MNODES; ...@@ -154,22 +191,25 @@ SHOW MNODES;
有三种情况,将触发负载均衡,而且都无需人工干预。 有三种情况,将触发负载均衡,而且都无需人工干预。
- 当一个新节点添加进集群时,系统将自动触发负载均衡,一些节点上的数据将被自动转移到新节点上,无需任何人工干预。 - 当一个新数据节点添加进集群时,系统将自动触发负载均衡,一些节点上的数据将被自动转移到新数据节点上,无需任何人工干预。
- 当一个节点从集群中移除时,系统将自动把该节点上的数据转移到其他节点,无需任何人工干预。 - 当一个数据节点从集群中移除时,系统将自动把该数据节点上的数据转移到其他数据节点,无需任何人工干预。
- 如果一个节点过热(数据量过大),系统将自动进行负载均衡,将该节点的一些vnode自动挪到其他节点。 - 如果一个数据节点过热(数据量过大),系统将自动进行负载均衡,将该数据节点的一些vnode自动挪到其他节点。
当上述三种情况发生时,系统将启动一各个数据节点的负载计算,从而决定如何挪动。
当上述三种情况发生时,系统将启动一各个节点的负载计算,从而决定如何挪动。 **【提示】负载均衡由参数balance控制,它决定是否启动自动负载均衡。**
##节点离线处理 ## 数据节点离线处理
如果一个节点离线,TDengine集群将自动检测到。有如下两种情况:
- 改节点离线超过一定时间(taos.cfg里配置参数offlineThreshold控制时长),系统将自动把该节点删除,产生系统报警信息,触发负载均衡流程。如果该被删除的节点重现上线时,它将无法加入集群,需要系统管理员重新将其添加进集群才会开始工作。 如果一个数据节点离线,TDengine集群将自动检测到。有如下两种情况:
- 该数据节点离线超过一定时间(taos.cfg里配置参数offlineThreshold控制时长),系统将自动把该数据节点删除,产生系统报警信息,触发负载均衡流程。如果该被删除的数据节点重现上线时,它将无法加入集群,需要系统管理员重新将其添加进集群才会开始工作。
- 离线后,在offlineThreshold的时长内重新上线,系统将自动启动数据恢复流程,等数据完全恢复后,该节点将开始正常工作。 - 离线后,在offlineThreshold的时长内重新上线,系统将自动启动数据恢复流程,等数据完全恢复后,该节点将开始正常工作。
**注意:**如果一个虚拟节点组(包括mnode组)里每个节点都处于离线或unsynced状态,必须等该虚拟节点组里的所有节点都上线、都能交换状态信息后,才能选出Master,该虚拟节点组才能对外提供服务。比如整个集群有3个节点,副本数为3,如果3个节点都宕机,然后2个节点重启,是无法工作的,只有等3个节点都重启成功,才能对外服务。 **注意:**如果一个虚拟节点组(包括mnode组)里所归属的每个数据节点都处于离线或unsynced状态,必须等该虚拟节点组里的所有数据节点都上线、都能交换状态信息后,才能选出Master,该虚拟节点组才能对外提供服务。比如整个集群有3个数据节点,副本数为3,如果3个数据节点都宕机,然后2个数据节点重启,是无法工作的,只有等3个数据节点都重启成功,才能对外服务。
## Arbitrator的使用 ## Arbitrator的使用
如果副本数为偶数,当一个vnode group里一半或超过一半的vnode不工作时,是无法从中选出master的。同理,一半或超过一半的mnode不工作时,是无法选出mnode的master的,因为存在“split brain”问题。为解决这个问题,TDengine引入了arbitrator的概念。Arbitrator模拟一个vnode或mnode在工作,但只简单的负责网络连接,不处理任何数据插入或访问。只要包含arbitrator在内,超过半数的vnode或mnode工作,那么该vnode group或mnode组就可以正常的提供数据插入或查询服务。比如对于副本数为2的情形,如果一个节点A离线,但另外一个节点B正常,而且能连接到arbitrator, 那么节点B就能正常工作。 如果副本数为偶数,当一个vnode group里一半或超过一半的vnode不工作时,是无法从中选出master的。同理,一半或超过一半的mnode不工作时,是无法选出mnode的master的,因为存在“split brain”问题。为解决这个问题,TDengine引入了arbitrator的概念。Arbitrator模拟一个vnode或mnode在工作,但只简单的负责网络连接,不处理任何数据插入或访问。只要包含arbitrator在内,超过半数的vnode或mnode工作,那么该vnode group或mnode组就可以正常的提供数据插入或查询服务。比如对于副本数为2的情形,如果一个节点A离线,但另外一个节点B正常,而且能连接到arbitrator, 那么节点B就能正常工作。
TDengine安装包里带有一个执行程序tarbitrator, 找任何一台Linux服务器运行它即可。该程序对系统资源几乎没有要求,只需要保证有网络连接即可。该应用的命令行参数`-p`可以指定其对外服务的端口号,缺省是6042。配置每个taosd实例时,可以在配置文件taos.cfg里将参数arbitrator设置为arbitrator的End Point。如果该参数配置了,当副本数为偶数数,系统将自动连接配置的arbitrator。 TDengine安装包里带有一个执行程序tarbitrator, 找任何一台Linux服务器运行它即可。该程序对系统资源几乎没有要求,只需要保证有网络连接即可。该应用的命令行参数`-p`可以指定其对外服务的端口号,缺省是6042。配置每个taosd实例时,可以在配置文件taos.cfg里将参数arbitrator设置为arbitrator的End Point。如果该参数配置了,当副本数为偶数数,系统将自动连接配置的arbitrator。
...@@ -69,6 +69,7 @@ typedef struct SJoinSupporter { ...@@ -69,6 +69,7 @@ typedef struct SJoinSupporter {
SSubqueryState* pState; SSubqueryState* pState;
SSqlObj* pObj; // parent SqlObj SSqlObj* pObj; // parent SqlObj
int32_t subqueryIndex; // index of sub query int32_t subqueryIndex; // index of sub query
SInterval interval;
SLimitVal limit; // limit info SLimitVal limit; // limit info
uint64_t uid; // query table uid uint64_t uid; // query table uid
SArray* colList; // previous query information, no need to use this attribute, and the corresponding attribution SArray* colList; // previous query information, no need to use this attribute, and the corresponding attribution
......
...@@ -226,12 +226,8 @@ typedef struct SQueryInfo { ...@@ -226,12 +226,8 @@ typedef struct SQueryInfo {
int16_t command; // the command may be different for each subclause, so keep it seperately. int16_t command; // the command may be different for each subclause, so keep it seperately.
uint32_t type; // query/insert type uint32_t type; // query/insert type
// TODO refactor // TODO refactor
char intervalTimeUnit;
char slidingTimeUnit;
STimeWindow window; // query time window STimeWindow window; // query time window
int64_t intervalTime; // aggregation time window range SInterval interval;
int64_t slidingTime; // sliding window in mseconds
int64_t intervalOffset;// start offset of each time window
int32_t tz; // query client timezone int32_t tz; // query client timezone
SSqlGroupbyExpr groupbyExpr; // group by tags info SSqlGroupbyExpr groupbyExpr; // group by tags info
...@@ -334,7 +330,7 @@ typedef struct STscObj { ...@@ -334,7 +330,7 @@ typedef struct STscObj {
struct SSqlStream *streamList; struct SSqlStream *streamList;
void* pDnodeConn; void* pDnodeConn;
pthread_mutex_t mutex; pthread_mutex_t mutex;
T_REF_DECLARE(); T_REF_DECLARE()
} STscObj; } STscObj;
typedef struct SSqlObj { typedef struct SSqlObj {
...@@ -370,8 +366,6 @@ typedef struct SSqlStream { ...@@ -370,8 +366,6 @@ typedef struct SSqlStream {
uint32_t streamId; uint32_t streamId;
char listed; char listed;
bool isProject; bool isProject;
char intervalTimeUnit;
char slidingTimeUnit;
int16_t precision; int16_t precision;
int64_t num; // number of computing count int64_t num; // number of computing count
...@@ -385,8 +379,7 @@ typedef struct SSqlStream { ...@@ -385,8 +379,7 @@ typedef struct SSqlStream {
int64_t ctime; // stream created time int64_t ctime; // stream created time
int64_t stime; // stream next executed time int64_t stime; // stream next executed time
int64_t etime; // stream end query time, when time is larger then etime, the stream will be closed int64_t etime; // stream end query time, when time is larger then etime, the stream will be closed
int64_t intervalTime; SInterval interval;
int64_t slidingTime;
void * pTimer; void * pTimer;
void (*fp)(); void (*fp)();
...@@ -470,7 +463,7 @@ static FORCE_INLINE void tscGetResultColumnChr(SSqlRes* pRes, SFieldInfo* pField ...@@ -470,7 +463,7 @@ static FORCE_INLINE void tscGetResultColumnChr(SSqlRes* pRes, SFieldInfo* pField
int32_t type = pInfo->pSqlExpr->resType; int32_t type = pInfo->pSqlExpr->resType;
int32_t bytes = pInfo->pSqlExpr->resBytes; int32_t bytes = pInfo->pSqlExpr->resBytes;
char* pData = pRes->data + pInfo->pSqlExpr->offset * pRes->numOfRows + bytes * pRes->row; char* pData = pRes->data + (int32_t)(pInfo->pSqlExpr->offset * pRes->numOfRows + bytes * pRes->row);
// user defined constant value output columns // user defined constant value output columns
if (TSDB_COL_IS_UD_COL(pInfo->pSqlExpr->colInfo.flag)) { if (TSDB_COL_IS_UD_COL(pInfo->pSqlExpr->colInfo.flag)) {
......
...@@ -711,13 +711,16 @@ static int32_t firstDistFuncRequired(SQLFunctionCtx *pCtx, TSKEY start, TSKEY en ...@@ -711,13 +711,16 @@ static int32_t firstDistFuncRequired(SQLFunctionCtx *pCtx, TSKEY start, TSKEY en
if (pCtx->aOutputBuf == NULL) { if (pCtx->aOutputBuf == NULL) {
return BLK_DATA_ALL_NEEDED; return BLK_DATA_ALL_NEEDED;
} }
SFirstLastInfo *pInfo = (SFirstLastInfo*) (pCtx->aOutputBuf + pCtx->inputBytes); return BLK_DATA_ALL_NEEDED;
if (pInfo->hasResult != DATA_SET_FLAG) { // TODO pCtx->aOutputBuf is the previous windowRes output buffer, not current unloaded block. so the following filter
return BLK_DATA_ALL_NEEDED; // is invalid
} else { // data in current block is not earlier than current result // SFirstLastInfo *pInfo = (SFirstLastInfo*) (pCtx->aOutputBuf + pCtx->inputBytes);
return (pInfo->ts <= start) ? BLK_DATA_NO_NEEDED : BLK_DATA_ALL_NEEDED; // if (pInfo->hasResult != DATA_SET_FLAG) {
} // return BLK_DATA_ALL_NEEDED;
// } else { // data in current block is not earlier than current result
// return (pInfo->ts <= start) ? BLK_DATA_NO_NEEDED : BLK_DATA_ALL_NEEDED;
// }
} }
static int32_t lastDistFuncRequired(SQLFunctionCtx *pCtx, TSKEY start, TSKEY end, int32_t colId) { static int32_t lastDistFuncRequired(SQLFunctionCtx *pCtx, TSKEY start, TSKEY end, int32_t colId) {
...@@ -730,12 +733,16 @@ static int32_t lastDistFuncRequired(SQLFunctionCtx *pCtx, TSKEY start, TSKEY end ...@@ -730,12 +733,16 @@ static int32_t lastDistFuncRequired(SQLFunctionCtx *pCtx, TSKEY start, TSKEY end
return BLK_DATA_ALL_NEEDED; return BLK_DATA_ALL_NEEDED;
} }
SFirstLastInfo *pInfo = (SFirstLastInfo*) (pCtx->aOutputBuf + pCtx->inputBytes); return BLK_DATA_ALL_NEEDED;
if (pInfo->hasResult != DATA_SET_FLAG) { // TODO pCtx->aOutputBuf is the previous windowRes output buffer, not current unloaded block. so the following filter
return BLK_DATA_ALL_NEEDED; // is invalid
} else {
return (pInfo->ts > end) ? BLK_DATA_NO_NEEDED : BLK_DATA_ALL_NEEDED; // SFirstLastInfo *pInfo = (SFirstLastInfo*) (pCtx->aOutputBuf + pCtx->inputBytes);
} // if (pInfo->hasResult != DATA_SET_FLAG) {
// return BLK_DATA_ALL_NEEDED;
// } else {
// return (pInfo->ts > end) ? BLK_DATA_NO_NEEDED : BLK_DATA_ALL_NEEDED;
// }
} }
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////
...@@ -2453,11 +2460,11 @@ static void percentile_function(SQLFunctionCtx *pCtx) { ...@@ -2453,11 +2460,11 @@ static void percentile_function(SQLFunctionCtx *pCtx) {
if (pInfo->stage == 0) { if (pInfo->stage == 0) {
if (pCtx->preAggVals.isSet) { if (pCtx->preAggVals.isSet) {
if (pInfo->minval > pCtx->preAggVals.statis.min) { if (pInfo->minval > pCtx->preAggVals.statis.min) {
pInfo->minval = pCtx->preAggVals.statis.min; pInfo->minval = (double)pCtx->preAggVals.statis.min;
} }
if (pInfo->maxval < pCtx->preAggVals.statis.max) { if (pInfo->maxval < pCtx->preAggVals.statis.max) {
pInfo->maxval = pCtx->preAggVals.statis.max; pInfo->maxval = (double)pCtx->preAggVals.statis.max;
} }
pInfo->numOfElems += (pCtx->size - pCtx->preAggVals.statis.numOfNull); pInfo->numOfElems += (pCtx->size - pCtx->preAggVals.statis.numOfNull);
......
...@@ -368,13 +368,12 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd ...@@ -368,13 +368,12 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
STableComInfo tinfo = tscGetTableInfo(pTableMetaInfo->pTableMeta); STableComInfo tinfo = tscGetTableInfo(pTableMetaInfo->pTableMeta);
TSKEY stime = (pQueryInfo->order.order == TSDB_ORDER_ASC)? pQueryInfo->window.skey : pQueryInfo->window.ekey; TSKEY stime = (pQueryInfo->order.order == TSDB_ORDER_ASC)? pQueryInfo->window.skey : pQueryInfo->window.ekey;
int64_t revisedSTime = int64_t revisedSTime = taosTimeTruncate(stime, &pQueryInfo->interval, tinfo.precision);
taosGetIntervalStartTimestamp(stime, pQueryInfo->slidingTime, pQueryInfo->intervalTime, pQueryInfo->slidingTimeUnit, tinfo.precision);
if (pQueryInfo->fillType != TSDB_FILL_NONE) { if (pQueryInfo->fillType != TSDB_FILL_NONE) {
SFillColInfo* pFillCol = createFillColInfo(pQueryInfo); SFillColInfo* pFillCol = createFillColInfo(pQueryInfo);
pReducer->pFillInfo = taosInitFillInfo(pQueryInfo->order.order, revisedSTime, pQueryInfo->groupbyExpr.numOfGroupCols, pReducer->pFillInfo = taosInitFillInfo(pQueryInfo->order.order, revisedSTime, pQueryInfo->groupbyExpr.numOfGroupCols,
4096, (int32_t)numOfCols, pQueryInfo->slidingTime, pQueryInfo->slidingTimeUnit, 4096, (int32_t)numOfCols, pQueryInfo->interval.sliding, pQueryInfo->interval.slidingUnit,
tinfo.precision, pQueryInfo->fillType, pFillCol); tinfo.precision, pQueryInfo->fillType, pFillCol);
} }
} }
...@@ -551,7 +550,7 @@ static int32_t createOrderDescriptor(tOrderDescriptor **pOrderDesc, SSqlCmd *pCm ...@@ -551,7 +550,7 @@ static int32_t createOrderDescriptor(tOrderDescriptor **pOrderDesc, SSqlCmd *pCm
} }
// primary timestamp column is involved in final result // primary timestamp column is involved in final result
if (pQueryInfo->intervalTime != 0 || tscOrderedProjectionQueryOnSTable(pQueryInfo, 0)) { if (pQueryInfo->interval.interval != 0 || tscOrderedProjectionQueryOnSTable(pQueryInfo, 0)) {
numOfGroupByCols++; numOfGroupByCols++;
} }
...@@ -568,7 +567,7 @@ static int32_t createOrderDescriptor(tOrderDescriptor **pOrderDesc, SSqlCmd *pCm ...@@ -568,7 +567,7 @@ static int32_t createOrderDescriptor(tOrderDescriptor **pOrderDesc, SSqlCmd *pCm
orderIdx[i] = startCols++; orderIdx[i] = startCols++;
} }
if (pQueryInfo->intervalTime != 0) { if (pQueryInfo->interval.interval != 0) {
// the first column is the timestamp, handles queries like "interval(10m) group by tags" // the first column is the timestamp, handles queries like "interval(10m) group by tags"
orderIdx[numOfGroupByCols - 1] = PRIMARYKEY_TIMESTAMP_COL_INDEX; orderIdx[numOfGroupByCols - 1] = PRIMARYKEY_TIMESTAMP_COL_INDEX;
} }
...@@ -612,12 +611,12 @@ bool isSameGroup(SSqlCmd *pCmd, SLocalReducer *pReducer, char *pPrev, tFilePage ...@@ -612,12 +611,12 @@ bool isSameGroup(SSqlCmd *pCmd, SLocalReducer *pReducer, char *pPrev, tFilePage
* super table interval query * super table interval query
* if the order columns is the primary timestamp, all result data belongs to one group * if the order columns is the primary timestamp, all result data belongs to one group
*/ */
assert(pQueryInfo->intervalTime > 0); assert(pQueryInfo->interval.interval > 0);
if (numOfCols == 1) { if (numOfCols == 1) {
return true; return true;
} }
} else { // simple group by query } else { // simple group by query
assert(pQueryInfo->intervalTime == 0); assert(pQueryInfo->interval.interval == 0);
} }
// only one row exists // only one row exists
...@@ -825,8 +824,7 @@ void savePrevRecordAndSetupFillInfo(SLocalReducer *pLocalReducer, SQueryInfo *pQ ...@@ -825,8 +824,7 @@ void savePrevRecordAndSetupFillInfo(SLocalReducer *pLocalReducer, SQueryInfo *pQ
if (pFillInfo != NULL) { if (pFillInfo != NULL) {
int64_t stime = (pQueryInfo->window.skey < pQueryInfo->window.ekey) ? pQueryInfo->window.skey : pQueryInfo->window.ekey; int64_t stime = (pQueryInfo->window.skey < pQueryInfo->window.ekey) ? pQueryInfo->window.skey : pQueryInfo->window.ekey;
int64_t revisedSTime = int64_t revisedSTime = taosTimeTruncate(stime, &pQueryInfo->interval, tinfo.precision);
taosGetIntervalStartTimestamp(stime, pQueryInfo->slidingTime, pQueryInfo->intervalTime, pQueryInfo->slidingTimeUnit, tinfo.precision);
taosResetFillInfo(pFillInfo, revisedSTime); taosResetFillInfo(pFillInfo, revisedSTime);
} }
...@@ -839,7 +837,7 @@ void savePrevRecordAndSetupFillInfo(SLocalReducer *pLocalReducer, SQueryInfo *pQ ...@@ -839,7 +837,7 @@ void savePrevRecordAndSetupFillInfo(SLocalReducer *pLocalReducer, SQueryInfo *pQ
} }
static void genFinalResWithoutFill(SSqlRes* pRes, SLocalReducer *pLocalReducer, SQueryInfo* pQueryInfo) { static void genFinalResWithoutFill(SSqlRes* pRes, SLocalReducer *pLocalReducer, SQueryInfo* pQueryInfo) {
assert(pQueryInfo->intervalTime == 0 || pQueryInfo->fillType == TSDB_FILL_NONE); assert(pQueryInfo->interval.interval == 0 || pQueryInfo->fillType == TSDB_FILL_NONE);
tFilePage * pBeforeFillData = pLocalReducer->pResultBuf; tFilePage * pBeforeFillData = pLocalReducer->pResultBuf;
...@@ -1220,7 +1218,7 @@ bool genFinalResults(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool noMoreCur ...@@ -1220,7 +1218,7 @@ bool genFinalResults(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool noMoreCur
#endif #endif
// no interval query, no fill operation // no interval query, no fill operation
if (pQueryInfo->intervalTime == 0 || pQueryInfo->fillType == TSDB_FILL_NONE) { if (pQueryInfo->interval.interval == 0 || pQueryInfo->fillType == TSDB_FILL_NONE) {
genFinalResWithoutFill(pRes, pLocalReducer, pQueryInfo); genFinalResWithoutFill(pRes, pLocalReducer, pQueryInfo);
} else { } else {
SFillInfo* pFillInfo = pLocalReducer->pFillInfo; SFillInfo* pFillInfo = pLocalReducer->pFillInfo;
...@@ -1258,13 +1256,10 @@ static void resetEnvForNewResultset(SSqlRes *pRes, SSqlCmd *pCmd, SLocalReducer ...@@ -1258,13 +1256,10 @@ static void resetEnvForNewResultset(SSqlRes *pRes, SSqlCmd *pCmd, SLocalReducer
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0); STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
STableComInfo tinfo = tscGetTableInfo(pTableMetaInfo->pTableMeta); STableComInfo tinfo = tscGetTableInfo(pTableMetaInfo->pTableMeta);
int8_t precision = tinfo.precision;
// for group result interpolation, do not return if not data is generated // for group result interpolation, do not return if not data is generated
if (pQueryInfo->fillType != TSDB_FILL_NONE) { if (pQueryInfo->fillType != TSDB_FILL_NONE) {
TSKEY skey = (pQueryInfo->order.order == TSDB_ORDER_ASC)? pQueryInfo->window.skey:pQueryInfo->window.ekey;//MIN(pQueryInfo->window.skey, pQueryInfo->window.ekey); TSKEY skey = (pQueryInfo->order.order == TSDB_ORDER_ASC)? pQueryInfo->window.skey:pQueryInfo->window.ekey;//MIN(pQueryInfo->window.skey, pQueryInfo->window.ekey);
int64_t newTime = int64_t newTime = taosTimeTruncate(skey, &pQueryInfo->interval, tinfo.precision);
taosGetIntervalStartTimestamp(skey, pQueryInfo->slidingTime, pQueryInfo->intervalTime, pQueryInfo->slidingTimeUnit, precision);
taosResetFillInfo(pLocalReducer->pFillInfo, newTime); taosResetFillInfo(pLocalReducer->pFillInfo, newTime);
} }
} }
......
...@@ -142,7 +142,7 @@ int tsParseTime(SStrToken *pToken, int64_t *time, char **next, char *error, int1 ...@@ -142,7 +142,7 @@ int tsParseTime(SStrToken *pToken, int64_t *time, char **next, char *error, int1
return tscInvalidSQLErrMsg(error, "value expected in timestamp", sToken.z); return tscInvalidSQLErrMsg(error, "value expected in timestamp", sToken.z);
} }
if (getTimestampInUsFromStr(valueToken.z, valueToken.n, &interval) != TSDB_CODE_SUCCESS) { if (parseAbsoluteDuration(valueToken.z, valueToken.n, &interval) != TSDB_CODE_SUCCESS) {
return TSDB_CODE_TSC_INVALID_SQL; return TSDB_CODE_TSC_INVALID_SQL;
} }
......
...@@ -259,11 +259,11 @@ int tscBuildQueryStreamDesc(void *pMsg, STscObj *pObj) { ...@@ -259,11 +259,11 @@ int tscBuildQueryStreamDesc(void *pMsg, STscObj *pObj) {
pSdesc->num = htobe64(pStream->num); pSdesc->num = htobe64(pStream->num);
pSdesc->useconds = htobe64(pStream->useconds); pSdesc->useconds = htobe64(pStream->useconds);
pSdesc->stime = htobe64(pStream->stime - pStream->intervalTime); pSdesc->stime = htobe64(pStream->stime - pStream->interval.interval);
pSdesc->ctime = htobe64(pStream->ctime); pSdesc->ctime = htobe64(pStream->ctime);
pSdesc->slidingTime = htobe64(pStream->slidingTime); pSdesc->slidingTime = htobe64(pStream->interval.sliding);
pSdesc->interval = htobe64(pStream->intervalTime); pSdesc->interval = htobe64(pStream->interval.interval);
pHeartbeat->numOfStreams++; pHeartbeat->numOfStreams++;
pSdesc++; pSdesc++;
......
...@@ -81,6 +81,7 @@ static void setColumnOffsetValueInResultset(SQueryInfo* pQueryInfo); ...@@ -81,6 +81,7 @@ static void setColumnOffsetValueInResultset(SQueryInfo* pQueryInfo);
static int32_t parseGroupbyClause(SQueryInfo* pQueryInfo, tVariantList* pList, SSqlCmd* pCmd); static int32_t parseGroupbyClause(SQueryInfo* pQueryInfo, tVariantList* pList, SSqlCmd* pCmd);
static int32_t parseIntervalClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql); static int32_t parseIntervalClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql);
static int32_t parseOffsetClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql);
static int32_t parseSlidingClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql); static int32_t parseSlidingClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql);
static int32_t addProjectionExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSQLExprItem* pItem); static int32_t addProjectionExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSQLExprItem* pItem);
...@@ -350,7 +351,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { ...@@ -350,7 +351,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
case TSDB_SQL_DESCRIBE_TABLE: { case TSDB_SQL_DESCRIBE_TABLE: {
SStrToken* pToken = &pInfo->pDCLInfo->a[0]; SStrToken* pToken = &pInfo->pDCLInfo->a[0];
const char* msg1 = "invalid table name"; const char* msg1 = "invalid table name";
const char* msg2 = "table name is too long"; const char* msg2 = "table name too long";
if (tscValidateName(pToken) != TSDB_CODE_SUCCESS) { if (tscValidateName(pToken) != TSDB_CODE_SUCCESS) {
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
...@@ -409,7 +410,6 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { ...@@ -409,7 +410,6 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
const char* msg3 = "name too long"; const char* msg3 = "name too long";
pCmd->command = pInfo->type; pCmd->command = pInfo->type;
// tDCLSQL* pDCL = pInfo->pDCLInfo;
SUserInfo* pUser = &pInfo->pDCLInfo->user; SUserInfo* pUser = &pInfo->pDCLInfo->user;
SStrToken* pName = &pUser->user; SStrToken* pName = &pUser->user;
...@@ -595,24 +595,28 @@ int32_t parseIntervalClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQ ...@@ -595,24 +595,28 @@ int32_t parseIntervalClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQ
// interval is not null // interval is not null
SStrToken* t = &pQuerySql->interval; SStrToken* t = &pQuerySql->interval;
if (parseDuration(t->z, t->n, &pQueryInfo->intervalTime, &pQueryInfo->intervalTimeUnit) != TSDB_CODE_SUCCESS) { if (parseNatualDuration(t->z, t->n, &pQueryInfo->interval.interval, &pQueryInfo->interval.intervalUnit) != TSDB_CODE_SUCCESS) {
return TSDB_CODE_TSC_INVALID_SQL; return TSDB_CODE_TSC_INVALID_SQL;
} }
if (pQueryInfo->intervalTimeUnit != 'n' && pQueryInfo->intervalTimeUnit != 'y') { if (pQueryInfo->interval.intervalUnit != 'n' && pQueryInfo->interval.intervalUnit != 'y') {
// if the unit of time window value is millisecond, change the value from microsecond // if the unit of time window value is millisecond, change the value from microsecond
if (tinfo.precision == TSDB_TIME_PRECISION_MILLI) { if (tinfo.precision == TSDB_TIME_PRECISION_MILLI) {
pQueryInfo->intervalTime = pQueryInfo->intervalTime / 1000; pQueryInfo->interval.interval = pQueryInfo->interval.interval / 1000;
} }
// interval cannot be less than 10 milliseconds // interval cannot be less than 10 milliseconds
if (pQueryInfo->intervalTime < tsMinIntervalTime) { if (pQueryInfo->interval.interval < tsMinIntervalTime) {
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2); return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
} }
} }
// for top/bottom + interval query, we do not add additional timestamp column in the front // for top/bottom + interval query, we do not add additional timestamp column in the front
if (isTopBottomQuery(pQueryInfo)) { if (isTopBottomQuery(pQueryInfo)) {
if (parseOffsetClause(pCmd, pQueryInfo, pQuerySql) != TSDB_CODE_SUCCESS) {
return TSDB_CODE_TSC_INVALID_SQL;
}
if (parseSlidingClause(pCmd, pQueryInfo, pQuerySql) != TSDB_CODE_SUCCESS) { if (parseSlidingClause(pCmd, pQueryInfo, pQuerySql) != TSDB_CODE_SUCCESS) {
return TSDB_CODE_TSC_INVALID_SQL; return TSDB_CODE_TSC_INVALID_SQL;
} }
...@@ -636,7 +640,7 @@ int32_t parseIntervalClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQ ...@@ -636,7 +640,7 @@ int32_t parseIntervalClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQ
* check invalid SQL: * check invalid SQL:
* select tbname, tags_fields from super_table_name interval(1s) * select tbname, tags_fields from super_table_name interval(1s)
*/ */
if (tscQueryTags(pQueryInfo) && pQueryInfo->intervalTime > 0) { if (tscQueryTags(pQueryInfo) && pQueryInfo->interval.interval > 0) {
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
} }
...@@ -662,6 +666,10 @@ int32_t parseIntervalClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQ ...@@ -662,6 +666,10 @@ int32_t parseIntervalClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQ
SColumnIndex index = {tableIndex, PRIMARYKEY_TIMESTAMP_COL_INDEX}; SColumnIndex index = {tableIndex, PRIMARYKEY_TIMESTAMP_COL_INDEX};
tscAddSpecialColumnForSelect(pQueryInfo, 0, TSDB_FUNC_TS, &index, &s, TSDB_COL_NORMAL); tscAddSpecialColumnForSelect(pQueryInfo, 0, TSDB_FUNC_TS, &index, &s, TSDB_COL_NORMAL);
if (parseOffsetClause(pCmd, pQueryInfo, pQuerySql) != TSDB_CODE_SUCCESS) {
return TSDB_CODE_TSC_INVALID_SQL;
}
if (parseSlidingClause(pCmd, pQueryInfo, pQuerySql) != TSDB_CODE_SUCCESS) { if (parseSlidingClause(pCmd, pQueryInfo, pQuerySql) != TSDB_CODE_SUCCESS) {
return TSDB_CODE_TSC_INVALID_SQL; return TSDB_CODE_TSC_INVALID_SQL;
} }
...@@ -669,6 +677,57 @@ int32_t parseIntervalClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQ ...@@ -669,6 +677,57 @@ int32_t parseIntervalClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQ
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t parseOffsetClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql) {
const char* msg1 = "interval offset cannot be negative";
const char* msg2 = "interval offset should be shorter than interval";
const char* msg3 = "cannot use 'year' as offset when interval is 'month'";
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
STableComInfo tinfo = tscGetTableInfo(pTableMetaInfo->pTableMeta);
SStrToken* t = &pQuerySql->offset;
if (t->n == 0) {
pQueryInfo->interval.offsetUnit = pQueryInfo->interval.intervalUnit;
pQueryInfo->interval.offset = 0;
return TSDB_CODE_SUCCESS;
}
if (parseNatualDuration(t->z, t->n, &pQueryInfo->interval.offset, &pQueryInfo->interval.offsetUnit) != TSDB_CODE_SUCCESS) {
return TSDB_CODE_TSC_INVALID_SQL;
}
if (pQueryInfo->interval.offset < 0) {
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
}
if (pQueryInfo->interval.offsetUnit != 'n' && pQueryInfo->interval.offsetUnit != 'y') {
// if the unit of time window value is millisecond, change the value from microsecond
if (tinfo.precision == TSDB_TIME_PRECISION_MILLI) {
pQueryInfo->interval.offset = pQueryInfo->interval.offset / 1000;
}
if (pQueryInfo->interval.intervalUnit != 'n' && pQueryInfo->interval.intervalUnit != 'y') {
if (pQueryInfo->interval.offset >= pQueryInfo->interval.interval) {
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
}
}
} else if (pQueryInfo->interval.offsetUnit == pQueryInfo->interval.intervalUnit) {
if (pQueryInfo->interval.offset >= pQueryInfo->interval.interval) {
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
}
} else if (pQueryInfo->interval.intervalUnit == 'n' && pQueryInfo->interval.offsetUnit == 'y') {
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3);
} else if (pQueryInfo->interval.intervalUnit == 'y' && pQueryInfo->interval.offsetUnit == 'n') {
if (pQueryInfo->interval.interval * 12 <= pQueryInfo->interval.offset) {
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
}
} else {
// TODO: offset should be shorter than interval, but how to check
// conflicts like 30days offset and 1 month interval
}
return TSDB_CODE_SUCCESS;
}
int32_t parseSlidingClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql) { int32_t parseSlidingClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql) {
const char* msg0 = "sliding value too small"; const char* msg0 = "sliding value too small";
const char* msg1 = "sliding value no larger than the interval value"; const char* msg1 = "sliding value no larger than the interval value";
...@@ -682,29 +741,29 @@ int32_t parseSlidingClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQu ...@@ -682,29 +741,29 @@ int32_t parseSlidingClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQu
SStrToken* pSliding = &pQuerySql->sliding; SStrToken* pSliding = &pQuerySql->sliding;
if (pSliding->n == 0) { if (pSliding->n == 0) {
pQueryInfo->slidingTimeUnit = pQueryInfo->intervalTimeUnit; pQueryInfo->interval.slidingUnit = pQueryInfo->interval.intervalUnit;
pQueryInfo->slidingTime = pQueryInfo->intervalTime; pQueryInfo->interval.sliding = pQueryInfo->interval.interval;
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
if (pQueryInfo->intervalTimeUnit == 'n' || pQueryInfo->intervalTimeUnit == 'y') { if (pQueryInfo->interval.intervalUnit == 'n' || pQueryInfo->interval.intervalUnit == 'y') {
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3); return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3);
} }
getTimestampInUsFromStr(pSliding->z, pSliding->n, &pQueryInfo->slidingTime); parseAbsoluteDuration(pSliding->z, pSliding->n, &pQueryInfo->interval.sliding);
if (tinfo.precision == TSDB_TIME_PRECISION_MILLI) { if (tinfo.precision == TSDB_TIME_PRECISION_MILLI) {
pQueryInfo->slidingTime /= 1000; pQueryInfo->interval.sliding /= 1000;
} }
if (pQueryInfo->slidingTime < tsMinSlidingTime) { if (pQueryInfo->interval.sliding < tsMinSlidingTime) {
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg0); return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg0);
} }
if (pQueryInfo->slidingTime > pQueryInfo->intervalTime) { if (pQueryInfo->interval.sliding > pQueryInfo->interval.interval) {
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
} }
if ((pQueryInfo->intervalTime != 0) && (pQueryInfo->intervalTime/pQueryInfo->slidingTime > INTERVAL_SLIDING_FACTOR)) { if ((pQueryInfo->interval.interval != 0) && (pQueryInfo->interval.interval/pQueryInfo->interval.sliding > INTERVAL_SLIDING_FACTOR)) {
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2); return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
} }
...@@ -713,7 +772,7 @@ int32_t parseSlidingClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQu ...@@ -713,7 +772,7 @@ int32_t parseSlidingClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQu
int32_t tscSetTableFullName(STableMetaInfo* pTableMetaInfo, SStrToken* pzTableName, SSqlObj* pSql) { int32_t tscSetTableFullName(STableMetaInfo* pTableMetaInfo, SStrToken* pzTableName, SSqlObj* pSql) {
const char* msg1 = "name too long"; const char* msg1 = "name too long";
const char* msg2 = "current database name is invalid"; const char* msg2 = "current database or database name invalid";
SSqlCmd* pCmd = &pSql->cmd; SSqlCmd* pCmd = &pSql->cmd;
int32_t code = TSDB_CODE_SUCCESS; int32_t code = TSDB_CODE_SUCCESS;
...@@ -4716,9 +4775,9 @@ int32_t validateSqlFunctionInStreamSql(SSqlCmd* pCmd, SQueryInfo* pQueryInfo) { ...@@ -4716,9 +4775,9 @@ int32_t validateSqlFunctionInStreamSql(SSqlCmd* pCmd, SQueryInfo* pQueryInfo) {
const char* msg0 = "sample interval can not be less than 10ms."; const char* msg0 = "sample interval can not be less than 10ms.";
const char* msg1 = "functions not allowed in select clause"; const char* msg1 = "functions not allowed in select clause";
if (pQueryInfo->intervalTime != 0 && pQueryInfo->intervalTime < 10 && if (pQueryInfo->interval.interval != 0 && pQueryInfo->interval.interval < 10 &&
pQueryInfo->intervalTimeUnit != 'n' && pQueryInfo->interval.intervalUnit != 'n' &&
pQueryInfo->intervalTimeUnit != 'y') { pQueryInfo->interval.intervalUnit != 'y') {
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg0); return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg0);
} }
...@@ -5503,7 +5562,7 @@ static int32_t doAddGroupbyColumnsOnDemand(SSqlCmd* pCmd, SQueryInfo* pQueryInfo ...@@ -5503,7 +5562,7 @@ static int32_t doAddGroupbyColumnsOnDemand(SSqlCmd* pCmd, SQueryInfo* pQueryInfo
insertResultField(pQueryInfo, (int32_t)size, &ids, bytes, (int8_t)type, name, pExpr); insertResultField(pQueryInfo, (int32_t)size, &ids, bytes, (int8_t)type, name, pExpr);
} else { } else {
// if this query is "group by" normal column, interval is not allowed // if this query is "group by" normal column, interval is not allowed
if (pQueryInfo->intervalTime > 0) { if (pQueryInfo->interval.interval > 0) {
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2); return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
} }
...@@ -5536,7 +5595,7 @@ int32_t doFunctionsCompatibleCheck(SSqlCmd* pCmd, SQueryInfo* pQueryInfo) { ...@@ -5536,7 +5595,7 @@ int32_t doFunctionsCompatibleCheck(SSqlCmd* pCmd, SQueryInfo* pQueryInfo) {
// only retrieve tags, group by is not supportted // only retrieve tags, group by is not supportted
if (tscQueryTags(pQueryInfo)) { if (tscQueryTags(pQueryInfo)) {
if (pQueryInfo->groupbyExpr.numOfGroupCols > 0 || pQueryInfo->intervalTime > 0) { if (pQueryInfo->groupbyExpr.numOfGroupCols > 0 || pQueryInfo->interval.interval > 0) {
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg4); return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg4);
} else { } else {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
...@@ -5988,7 +6047,7 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) { ...@@ -5988,7 +6047,7 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) {
if (parseIntervalClause(pCmd, pQueryInfo, pQuerySql) != TSDB_CODE_SUCCESS) { if (parseIntervalClause(pCmd, pQueryInfo, pQuerySql) != TSDB_CODE_SUCCESS) {
return TSDB_CODE_TSC_INVALID_SQL; return TSDB_CODE_TSC_INVALID_SQL;
} else { } else {
if ((pQueryInfo->intervalTime > 0) && if ((pQueryInfo->interval.interval > 0) &&
(validateFunctionsInIntervalOrGroupbyQuery(pCmd, pQueryInfo) != TSDB_CODE_SUCCESS)) { (validateFunctionsInIntervalOrGroupbyQuery(pCmd, pQueryInfo) != TSDB_CODE_SUCCESS)) {
return TSDB_CODE_TSC_INVALID_SQL; return TSDB_CODE_TSC_INVALID_SQL;
} }
...@@ -6018,7 +6077,7 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) { ...@@ -6018,7 +6077,7 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) {
* not here. * not here.
*/ */
if (pQuerySql->fillType != NULL) { if (pQuerySql->fillType != NULL) {
if (pQueryInfo->intervalTime == 0) { if (pQueryInfo->interval.interval == 0) {
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3); return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3);
} }
...@@ -6186,7 +6245,7 @@ int32_t doCheckForQuery(SSqlObj* pSql, SQuerySQL* pQuerySql, int32_t index) { ...@@ -6186,7 +6245,7 @@ int32_t doCheckForQuery(SSqlObj* pSql, SQuerySQL* pQuerySql, int32_t index) {
if (parseIntervalClause(pCmd, pQueryInfo, pQuerySql) != TSDB_CODE_SUCCESS) { if (parseIntervalClause(pCmd, pQueryInfo, pQuerySql) != TSDB_CODE_SUCCESS) {
return TSDB_CODE_TSC_INVALID_SQL; return TSDB_CODE_TSC_INVALID_SQL;
} else { } else {
if ((pQueryInfo->intervalTime > 0) && if ((pQueryInfo->interval.interval > 0) &&
(validateFunctionsInIntervalOrGroupbyQuery(pCmd, pQueryInfo) != TSDB_CODE_SUCCESS)) { (validateFunctionsInIntervalOrGroupbyQuery(pCmd, pQueryInfo) != TSDB_CODE_SUCCESS)) {
return TSDB_CODE_TSC_INVALID_SQL; return TSDB_CODE_TSC_INVALID_SQL;
} }
...@@ -6237,14 +6296,19 @@ int32_t doCheckForQuery(SSqlObj* pSql, SQuerySQL* pQuerySql, int32_t index) { ...@@ -6237,14 +6296,19 @@ int32_t doCheckForQuery(SSqlObj* pSql, SQuerySQL* pQuerySql, int32_t index) {
* the columns may be increased due to group by operation * the columns may be increased due to group by operation
*/ */
if (pQuerySql->fillType != NULL) { if (pQuerySql->fillType != NULL) {
if (pQueryInfo->intervalTime == 0 && (!tscIsPointInterpQuery(pQueryInfo))) { if (pQueryInfo->interval.interval == 0 && (!tscIsPointInterpQuery(pQueryInfo))) {
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg5); return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg5);
} }
if (pQueryInfo->intervalTime > 0 && pQueryInfo->intervalTimeUnit != 'n' && pQueryInfo->intervalTimeUnit != 'y') { if (pQueryInfo->interval.interval > 0 && pQueryInfo->interval.intervalUnit != 'n' && pQueryInfo->interval.intervalUnit != 'y') {
bool initialWindows = TSWINDOW_IS_EQUAL(pQueryInfo->window, TSWINDOW_INITIALIZER);
if (initialWindows) {
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg6);
}
int64_t timeRange = ABS(pQueryInfo->window.skey - pQueryInfo->window.ekey); int64_t timeRange = ABS(pQueryInfo->window.skey - pQueryInfo->window.ekey);
// number of result is not greater than 10,000,000 // number of result is not greater than 10,000,000
if ((timeRange == 0) || (timeRange / pQueryInfo->intervalTime) > MAX_INTERVAL_TIME_WINDOW) { if ((timeRange == 0) || (timeRange / pQueryInfo->interval.interval) > MAX_INTERVAL_TIME_WINDOW) {
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg6); return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg6);
} }
} }
...@@ -6387,4 +6451,4 @@ bool hasNormalColumnFilter(SQueryInfo* pQueryInfo) { ...@@ -6387,4 +6451,4 @@ bool hasNormalColumnFilter(SQueryInfo* pQueryInfo) {
} }
return false; return false;
} }
\ No newline at end of file
...@@ -647,8 +647,8 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) { ...@@ -647,8 +647,8 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
return TSDB_CODE_TSC_INVALID_SQL; return TSDB_CODE_TSC_INVALID_SQL;
} }
if (pQueryInfo->intervalTime < 0) { if (pQueryInfo->interval.interval < 0) {
tscError("%p illegal value of aggregation time interval in query msg: %ld", pSql, pQueryInfo->intervalTime); tscError("%p illegal value of aggregation time interval in query msg: %ld", pSql, pQueryInfo->interval.interval);
return TSDB_CODE_TSC_INVALID_SQL; return TSDB_CODE_TSC_INVALID_SQL;
} }
...@@ -675,10 +675,12 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) { ...@@ -675,10 +675,12 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pQueryMsg->limit = htobe64(pQueryInfo->limit.limit); pQueryMsg->limit = htobe64(pQueryInfo->limit.limit);
pQueryMsg->offset = htobe64(pQueryInfo->limit.offset); pQueryMsg->offset = htobe64(pQueryInfo->limit.offset);
pQueryMsg->numOfCols = htons((int16_t)taosArrayGetSize(pQueryInfo->colList)); pQueryMsg->numOfCols = htons((int16_t)taosArrayGetSize(pQueryInfo->colList));
pQueryMsg->intervalTime = htobe64(pQueryInfo->intervalTime); pQueryMsg->interval.interval = htobe64(pQueryInfo->interval.interval);
pQueryMsg->slidingTime = htobe64(pQueryInfo->slidingTime); pQueryMsg->interval.sliding = htobe64(pQueryInfo->interval.sliding);
pQueryMsg->intervalTimeUnit = pQueryInfo->intervalTimeUnit; pQueryMsg->interval.offset = htobe64(pQueryInfo->interval.offset);
pQueryMsg->slidingTimeUnit = pQueryInfo->slidingTimeUnit; pQueryMsg->interval.intervalUnit = pQueryInfo->interval.intervalUnit;
pQueryMsg->interval.slidingUnit = pQueryInfo->interval.slidingUnit;
pQueryMsg->interval.offsetUnit = pQueryInfo->interval.offsetUnit;
pQueryMsg->numOfGroupCols = htons(pQueryInfo->groupbyExpr.numOfGroupCols); pQueryMsg->numOfGroupCols = htons(pQueryInfo->groupbyExpr.numOfGroupCols);
pQueryMsg->numOfTags = htonl(numOfTags); pQueryMsg->numOfTags = htonl(numOfTags);
pQueryMsg->tagNameRelType = htons(pQueryInfo->tagCond.relType); pQueryMsg->tagNameRelType = htons(pQueryInfo->tagCond.relType);
......
...@@ -51,7 +51,7 @@ static int64_t tscGetRetryDelayTime(SSqlStream* pStream, int64_t slidingTime, in ...@@ -51,7 +51,7 @@ static int64_t tscGetRetryDelayTime(SSqlStream* pStream, int64_t slidingTime, in
int64_t retryDelta = (int64_t)(tsStreamCompRetryDelay * retryRangeFactor); int64_t retryDelta = (int64_t)(tsStreamCompRetryDelay * retryRangeFactor);
retryDelta = ((rand() % retryDelta) + tsStreamCompRetryDelay) * 1000L; retryDelta = ((rand() % retryDelta) + tsStreamCompRetryDelay) * 1000L;
if (pStream->intervalTimeUnit != 'n' && pStream->intervalTimeUnit != 'y') { if (pStream->interval.intervalUnit != 'n' && pStream->interval.intervalUnit != 'y') {
// change to ms // change to ms
if (prec == TSDB_TIME_PRECISION_MICRO) { if (prec == TSDB_TIME_PRECISION_MICRO) {
slidingTime = slidingTime / 1000; slidingTime = slidingTime / 1000;
...@@ -87,7 +87,7 @@ static void tscProcessStreamLaunchQuery(SSchedMsg *pMsg) { ...@@ -87,7 +87,7 @@ static void tscProcessStreamLaunchQuery(SSchedMsg *pMsg) {
// failed to get meter/metric meta, retry in 10sec. // failed to get meter/metric meta, retry in 10sec.
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
int64_t retryDelayTime = tscGetRetryDelayTime(pStream, pStream->slidingTime, pStream->precision); int64_t retryDelayTime = tscGetRetryDelayTime(pStream, pStream->interval.sliding, pStream->precision);
tscDebug("%p stream:%p,get metermeta failed, retry in %" PRId64 "ms", pStream->pSql, pStream, retryDelayTime); tscDebug("%p stream:%p,get metermeta failed, retry in %" PRId64 "ms", pStream->pSql, pStream, retryDelayTime);
tscSetRetryTimer(pStream, pSql, retryDelayTime); tscSetRetryTimer(pStream, pSql, retryDelayTime);
...@@ -132,15 +132,16 @@ static void tscProcessStreamTimer(void *handle, void *tmrId) { ...@@ -132,15 +132,16 @@ static void tscProcessStreamTimer(void *handle, void *tmrId) {
} }
if (etime > pStream->etime) { if (etime > pStream->etime) {
etime = pStream->etime; etime = pStream->etime;
} else if (pStream->intervalTimeUnit != 'y' && pStream->intervalTimeUnit != 'n') { } else if (pStream->interval.intervalUnit != 'y' && pStream->interval.intervalUnit != 'n') {
etime = pStream->stime + (etime - pStream->stime) / pStream->intervalTime * pStream->intervalTime; etime = pStream->stime + (etime - pStream->stime) / pStream->interval.interval * pStream->interval.interval;
} else { } else {
etime = taosGetIntervalStartTimestamp(etime, pStream->slidingTime, pStream->intervalTime, pStream->slidingTimeUnit, pStream->precision); etime = taosTimeTruncate(etime, &pStream->interval, pStream->precision);
//etime = taosGetIntervalStartTimestamp(etime, pStream->interval.sliding, pStream->interval.sliding, pStream->interval.slidingUnit, pStream->precision);
} }
pQueryInfo->window.ekey = etime; pQueryInfo->window.ekey = etime;
if (pQueryInfo->window.skey >= pQueryInfo->window.ekey) { if (pQueryInfo->window.skey >= pQueryInfo->window.ekey) {
int64_t timer = pStream->slidingTime; int64_t timer = pStream->interval.sliding;
if (pStream->intervalTimeUnit == 'y' || pStream->intervalTimeUnit == 'n') { if (pStream->interval.intervalUnit == 'y' || pStream->interval.intervalUnit == 'n') {
timer = 86400 * 1000l; timer = 86400 * 1000l;
} else if (pStream->precision == TSDB_TIME_PRECISION_MICRO) { } else if (pStream->precision == TSDB_TIME_PRECISION_MICRO) {
timer /= 1000l; timer /= 1000l;
...@@ -162,7 +163,7 @@ static void tscProcessStreamTimer(void *handle, void *tmrId) { ...@@ -162,7 +163,7 @@ static void tscProcessStreamTimer(void *handle, void *tmrId) {
static void tscProcessStreamQueryCallback(void *param, TAOS_RES *tres, int numOfRows) { static void tscProcessStreamQueryCallback(void *param, TAOS_RES *tres, int numOfRows) {
SSqlStream *pStream = (SSqlStream *)param; SSqlStream *pStream = (SSqlStream *)param;
if (tres == NULL || numOfRows < 0) { if (tres == NULL || numOfRows < 0) {
int64_t retryDelay = tscGetRetryDelayTime(pStream, pStream->slidingTime, pStream->precision); int64_t retryDelay = tscGetRetryDelayTime(pStream, pStream->interval.sliding, pStream->precision);
tscError("%p stream:%p, query data failed, code:0x%08x, retry in %" PRId64 "ms", pStream->pSql, pStream, numOfRows, tscError("%p stream:%p, query data failed, code:0x%08x, retry in %" PRId64 "ms", pStream->pSql, pStream, numOfRows,
retryDelay); retryDelay);
...@@ -223,7 +224,7 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf ...@@ -223,7 +224,7 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf
SSqlObj * pSql = (SSqlObj *)res; SSqlObj * pSql = (SSqlObj *)res;
if (pSql == NULL || numOfRows < 0) { if (pSql == NULL || numOfRows < 0) {
int64_t retryDelayTime = tscGetRetryDelayTime(pStream, pStream->slidingTime, pStream->precision); int64_t retryDelayTime = tscGetRetryDelayTime(pStream, pStream->interval.sliding, pStream->precision);
tscError("%p stream:%p, retrieve data failed, code:0x%08x, retry in %" PRId64 "ms", pSql, pStream, numOfRows, retryDelayTime); tscError("%p stream:%p, retrieve data failed, code:0x%08x, retry in %" PRId64 "ms", pSql, pStream, numOfRows, retryDelayTime);
tscSetRetryTimer(pStream, pStream->pSql, retryDelayTime); tscSetRetryTimer(pStream, pStream->pSql, retryDelayTime);
...@@ -246,11 +247,7 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf ...@@ -246,11 +247,7 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf
} }
if (!pStream->isProject) { if (!pStream->isProject) {
if (pStream->intervalTimeUnit == 'y' || pStream->intervalTimeUnit == 'n') { pStream->stime = taosTimeAdd(pStream->stime, pStream->interval.sliding, pStream->interval.slidingUnit, pStream->precision);
pStream->stime = taosAddNatualInterval(pStream->stime, pStream->slidingTime, pStream->slidingTimeUnit, pStream->precision);
} else {
pStream->stime += pStream->slidingTime;
}
} }
// actually only one row is returned. this following is not necessary // actually only one row is returned. this following is not necessary
taos_fetch_rows_a(res, tscProcessStreamRetrieveResult, pStream); taos_fetch_rows_a(res, tscProcessStreamRetrieveResult, pStream);
...@@ -310,7 +307,7 @@ static void tscSetRetryTimer(SSqlStream *pStream, SSqlObj *pSql, int64_t timer) ...@@ -310,7 +307,7 @@ static void tscSetRetryTimer(SSqlStream *pStream, SSqlObj *pSql, int64_t timer)
now + timer, timer, delay, pStream->stime, etime); now + timer, timer, delay, pStream->stime, etime);
} else { } else {
tscDebug("%p stream:%p, next start at %" PRId64 ", in %" PRId64 "ms. delay:%" PRId64 "ms qrange %" PRId64 "-%" PRId64, pStream->pSql, pStream, tscDebug("%p stream:%p, next start at %" PRId64 ", in %" PRId64 "ms. delay:%" PRId64 "ms qrange %" PRId64 "-%" PRId64, pStream->pSql, pStream,
pStream->stime, timer, delay, pStream->stime - pStream->intervalTime, pStream->stime - 1); pStream->stime, timer, delay, pStream->stime - pStream->interval.interval, pStream->stime - 1);
} }
pSql->cmd.command = TSDB_SQL_SELECT; pSql->cmd.command = TSDB_SQL_SELECT;
...@@ -324,12 +321,12 @@ static int64_t getLaunchTimeDelay(const SSqlStream* pStream) { ...@@ -324,12 +321,12 @@ static int64_t getLaunchTimeDelay(const SSqlStream* pStream) {
(pStream->precision == TSDB_TIME_PRECISION_MICRO) ? tsMaxStreamComputDelay * 1000L : tsMaxStreamComputDelay; (pStream->precision == TSDB_TIME_PRECISION_MICRO) ? tsMaxStreamComputDelay * 1000L : tsMaxStreamComputDelay;
int64_t delayDelta = maxDelay; int64_t delayDelta = maxDelay;
if (pStream->intervalTimeUnit != 'n' && pStream->intervalTimeUnit != 'y') { if (pStream->interval.intervalUnit != 'n' && pStream->interval.intervalUnit != 'y') {
delayDelta = (int64_t)(pStream->slidingTime * tsStreamComputDelayRatio); delayDelta = (int64_t)(pStream->interval.sliding * tsStreamComputDelayRatio);
if (delayDelta > maxDelay) { if (delayDelta > maxDelay) {
delayDelta = maxDelay; delayDelta = maxDelay;
} }
int64_t remainTimeWindow = pStream->slidingTime - delayDelta; int64_t remainTimeWindow = pStream->interval.sliding - delayDelta;
if (maxDelay > remainTimeWindow) { if (maxDelay > remainTimeWindow) {
maxDelay = (int64_t)(remainTimeWindow / 1.5f); maxDelay = (int64_t)(remainTimeWindow / 1.5f);
} }
...@@ -337,8 +334,8 @@ static int64_t getLaunchTimeDelay(const SSqlStream* pStream) { ...@@ -337,8 +334,8 @@ static int64_t getLaunchTimeDelay(const SSqlStream* pStream) {
int64_t currentDelay = (rand() % maxDelay); // a random number int64_t currentDelay = (rand() % maxDelay); // a random number
currentDelay += delayDelta; currentDelay += delayDelta;
if (pStream->intervalTimeUnit != 'n' && pStream->intervalTimeUnit != 'y') { if (pStream->interval.intervalUnit != 'n' && pStream->interval.intervalUnit != 'y') {
assert(currentDelay < pStream->slidingTime); assert(currentDelay < pStream->interval.sliding);
} }
return currentDelay; return currentDelay;
...@@ -353,7 +350,7 @@ static void tscSetNextLaunchTimer(SSqlStream *pStream, SSqlObj *pSql) { ...@@ -353,7 +350,7 @@ static void tscSetNextLaunchTimer(SSqlStream *pStream, SSqlObj *pSql) {
* for project query, no mater fetch data successfully or not, next launch will issue * for project query, no mater fetch data successfully or not, next launch will issue
* more than the sliding time window * more than the sliding time window
*/ */
timer = pStream->slidingTime; timer = pStream->interval.sliding;
if (pStream->stime > pStream->etime) { if (pStream->stime > pStream->etime) {
tscDebug("%p stream:%p, stime:%" PRId64 " is larger than end time: %" PRId64 ", stop the stream", pStream->pSql, pStream, tscDebug("%p stream:%p, stime:%" PRId64 " is larger than end time: %" PRId64 ", stop the stream", pStream->pSql, pStream,
pStream->stime, pStream->etime); pStream->stime, pStream->etime);
...@@ -366,7 +363,8 @@ static void tscSetNextLaunchTimer(SSqlStream *pStream, SSqlObj *pSql) { ...@@ -366,7 +363,8 @@ static void tscSetNextLaunchTimer(SSqlStream *pStream, SSqlObj *pSql) {
return; return;
} }
} else { } else {
int64_t stime = taosGetIntervalStartTimestamp(pStream->stime - 1, pStream->intervalTime, pStream->intervalTime, pStream->intervalTimeUnit, pStream->precision); int64_t stime = taosTimeTruncate(pStream->stime - 1, &pStream->interval, pStream->precision);
//int64_t stime = taosGetIntervalStartTimestamp(pStream->stime - 1, pStream->interval.interval, pStream->interval.interval, pStream->interval.intervalUnit, pStream->precision);
if (stime >= pStream->etime) { if (stime >= pStream->etime) {
tscDebug("%p stream:%p, stime:%" PRId64 " is larger than end time: %" PRId64 ", stop the stream", pStream->pSql, pStream, tscDebug("%p stream:%p, stime:%" PRId64 " is larger than end time: %" PRId64 ", stop the stream", pStream->pSql, pStream,
pStream->stime, pStream->etime); pStream->stime, pStream->etime);
...@@ -400,43 +398,43 @@ static void tscSetSlidingWindowInfo(SSqlObj *pSql, SSqlStream *pStream) { ...@@ -400,43 +398,43 @@ static void tscSetSlidingWindowInfo(SSqlObj *pSql, SSqlStream *pStream) {
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0); SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0);
if (pQueryInfo->intervalTimeUnit != 'n' && pQueryInfo->intervalTimeUnit != 'y' && pQueryInfo->intervalTime < minIntervalTime) { if (pQueryInfo->interval.intervalUnit != 'n' && pQueryInfo->interval.intervalUnit!= 'y' && pQueryInfo->interval.interval < minIntervalTime) {
tscWarn("%p stream:%p, original sample interval:%ld too small, reset to:%" PRId64, pSql, pStream, tscWarn("%p stream:%p, original sample interval:%ld too small, reset to:%" PRId64, pSql, pStream,
pQueryInfo->intervalTime, minIntervalTime); pQueryInfo->interval.interval, minIntervalTime);
pQueryInfo->intervalTime = minIntervalTime; pQueryInfo->interval.interval = minIntervalTime;
} }
pStream->intervalTimeUnit = pQueryInfo->intervalTimeUnit; pStream->interval.intervalUnit = pQueryInfo->interval.intervalUnit;
pStream->intervalTime = pQueryInfo->intervalTime; // it shall be derived from sql string pStream->interval.interval = pQueryInfo->interval.interval; // it shall be derived from sql string
if (pQueryInfo->slidingTime <= 0) { if (pQueryInfo->interval.sliding <= 0) {
pQueryInfo->slidingTime = pQueryInfo->intervalTime; pQueryInfo->interval.sliding = pQueryInfo->interval.interval;
pQueryInfo->slidingTimeUnit = pQueryInfo->intervalTimeUnit; pQueryInfo->interval.slidingUnit = pQueryInfo->interval.intervalUnit;
} }
int64_t minSlidingTime = int64_t minSlidingTime =
(pStream->precision == TSDB_TIME_PRECISION_MICRO) ? tsMinSlidingTime * 1000L : tsMinSlidingTime; (pStream->precision == TSDB_TIME_PRECISION_MICRO) ? tsMinSlidingTime * 1000L : tsMinSlidingTime;
if (pQueryInfo->intervalTimeUnit != 'n' && pQueryInfo->intervalTimeUnit != 'y' && pQueryInfo->slidingTime < minSlidingTime) { if (pQueryInfo->interval.intervalUnit != 'n' && pQueryInfo->interval.intervalUnit!= 'y' && pQueryInfo->interval.sliding < minSlidingTime) {
tscWarn("%p stream:%p, original sliding value:%" PRId64 " too small, reset to:%" PRId64, pSql, pStream, tscWarn("%p stream:%p, original sliding value:%" PRId64 " too small, reset to:%" PRId64, pSql, pStream,
pQueryInfo->slidingTime, minSlidingTime); pQueryInfo->interval.sliding, minSlidingTime);
pQueryInfo->slidingTime = minSlidingTime; pQueryInfo->interval.sliding = minSlidingTime;
} }
if (pQueryInfo->slidingTime > pQueryInfo->intervalTime) { if (pQueryInfo->interval.sliding > pQueryInfo->interval.interval) {
tscWarn("%p stream:%p, sliding value:%" PRId64 " can not be larger than interval range, reset to:%" PRId64, pSql, pStream, tscWarn("%p stream:%p, sliding value:%" PRId64 " can not be larger than interval range, reset to:%" PRId64, pSql, pStream,
pQueryInfo->slidingTime, pQueryInfo->intervalTime); pQueryInfo->interval.sliding, pQueryInfo->interval.interval);
pQueryInfo->slidingTime = pQueryInfo->intervalTime; pQueryInfo->interval.sliding = pQueryInfo->interval.interval;
} }
pStream->slidingTimeUnit = pQueryInfo->slidingTimeUnit; pStream->interval.slidingUnit = pQueryInfo->interval.slidingUnit;
pStream->slidingTime = pQueryInfo->slidingTime; pStream->interval.sliding = pQueryInfo->interval.sliding;
if (pStream->isProject) { if (pStream->isProject) {
pQueryInfo->intervalTime = 0; // clear the interval value to avoid the force time window split by query processor pQueryInfo->interval.interval = 0; // clear the interval value to avoid the force time window split by query processor
pQueryInfo->slidingTime = 0; pQueryInfo->interval.sliding = 0;
} }
} }
...@@ -445,8 +443,8 @@ static int64_t tscGetStreamStartTimestamp(SSqlObj *pSql, SSqlStream *pStream, in ...@@ -445,8 +443,8 @@ static int64_t tscGetStreamStartTimestamp(SSqlObj *pSql, SSqlStream *pStream, in
if (pStream->isProject) { if (pStream->isProject) {
// no data in table, flush all data till now to destination meter, 10sec delay // no data in table, flush all data till now to destination meter, 10sec delay
pStream->intervalTime = tsProjectExecInterval; pStream->interval.interval = tsProjectExecInterval;
pStream->slidingTime = tsProjectExecInterval; pStream->interval.sliding = tsProjectExecInterval;
if (stime != 0) { // first projection start from the latest event timestamp if (stime != 0) { // first projection start from the latest event timestamp
assert(stime >= pQueryInfo->window.skey); assert(stime >= pQueryInfo->window.skey);
...@@ -459,12 +457,15 @@ static int64_t tscGetStreamStartTimestamp(SSqlObj *pSql, SSqlStream *pStream, in ...@@ -459,12 +457,15 @@ static int64_t tscGetStreamStartTimestamp(SSqlObj *pSql, SSqlStream *pStream, in
stime = pQueryInfo->window.skey; stime = pQueryInfo->window.skey;
if (stime == INT64_MIN) { if (stime == INT64_MIN) {
stime = (int64_t)taosGetTimestamp(pStream->precision); stime = (int64_t)taosGetTimestamp(pStream->precision);
stime = taosGetIntervalStartTimestamp(stime, pStream->intervalTime, pStream->intervalTime, pStream->intervalTimeUnit, pStream->precision); stime = taosTimeTruncate(stime, &pStream->interval, pStream->precision);
stime = taosGetIntervalStartTimestamp(stime - 1, pStream->intervalTime, pStream->intervalTime, pStream->intervalTimeUnit, pStream->precision); stime = taosTimeTruncate(stime - 1, &pStream->interval, pStream->precision);
//stime = taosGetIntervalStartTimestamp(stime, pStream->interval.interval, pStream->interval.interval, pStream->interval.intervalUnit, pStream->precision);
//stime = taosGetIntervalStartTimestamp(stime - 1, pStream->interval.interval, pStream->interval.interval, pStream->interval.intervalUnit, pStream->precision);
tscWarn("%p stream:%p, last timestamp:0, reset to:%" PRId64, pSql, pStream, stime); tscWarn("%p stream:%p, last timestamp:0, reset to:%" PRId64, pSql, pStream, stime);
} }
} else { } else {
int64_t newStime = taosGetIntervalStartTimestamp(stime, pStream->intervalTime, pStream->intervalTime, pStream->intervalTimeUnit, pStream->precision); //int64_t newStime = taosGetIntervalStartTimestamp(stime, pStream->interval.interval, pStream->interval.interval, pStream->interval.intervalUnit, pStream->precision);
int64_t newStime = taosTimeTruncate(stime, &pStream->interval, pStream->precision);
if (newStime != stime) { if (newStime != stime) {
tscWarn("%p stream:%p, last timestamp:%" PRId64 ", reset to:%" PRId64, pSql, pStream, stime, newStime); tscWarn("%p stream:%p, last timestamp:%" PRId64 ", reset to:%" PRId64, pSql, pStream, stime, newStime);
stime = newStime; stime = newStime;
...@@ -534,7 +535,7 @@ static void tscCreateStream(void *param, TAOS_RES *res, int code) { ...@@ -534,7 +535,7 @@ static void tscCreateStream(void *param, TAOS_RES *res, int code) {
taosTmrReset(tscProcessStreamTimer, (int32_t)starttime, pStream, tscTmr, &pStream->pTimer); taosTmrReset(tscProcessStreamTimer, (int32_t)starttime, pStream, tscTmr, &pStream->pTimer);
tscDebug("%p stream:%p is opened, query on:%s, interval:%" PRId64 ", sliding:%" PRId64 ", first launched in:%" PRId64 ", sql:%s", pSql, tscDebug("%p stream:%p is opened, query on:%s, interval:%" PRId64 ", sliding:%" PRId64 ", first launched in:%" PRId64 ", sql:%s", pSql,
pStream, pTableMetaInfo->name, pStream->intervalTime, pStream->slidingTime, starttime, pSql->sqlstr); pStream, pTableMetaInfo->name, pStream->interval.interval, pStream->interval.sliding, starttime, pSql->sqlstr);
} }
TAOS_STREAM *taos_open_stream(TAOS *taos, const char *sqlstr, void (*fp)(void *param, TAOS_RES *, TAOS_ROW row), TAOS_STREAM *taos_open_stream(TAOS *taos, const char *sqlstr, void (*fp)(void *param, TAOS_RES *, TAOS_ROW row),
......
...@@ -92,7 +92,7 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, SJoinSupporter* pSupporter1, SJ ...@@ -92,7 +92,7 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, SJoinSupporter* pSupporter1, SJ
STSElem elem2 = tsBufGetElem(pSupporter2->pTSBuf); STSElem elem2 = tsBufGetElem(pSupporter2->pTSBuf);
#ifdef _DEBUG_VIEW #ifdef _DEBUG_VIEW
tscInfo("%" PRId64 ", tags:%d \t %" PRId64 ", tags:%d", elem1.ts, elem1.tag, elem2.ts, elem2.tag); tscInfo("%" PRId64 ", tags:%"PRId64" \t %" PRId64 ", tags:%"PRId64, elem1.ts, elem1.tag.i64Key, elem2.ts, elem2.tag.i64Key);
#endif #endif
int32_t res = tVariantCompare(&elem1.tag, &elem2.tag); int32_t res = tVariantCompare(&elem1.tag, &elem2.tag);
...@@ -113,7 +113,7 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, SJoinSupporter* pSupporter1, SJ ...@@ -113,7 +113,7 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, SJoinSupporter* pSupporter1, SJ
* in case of stable query, limit/offset is not applied here. the limit/offset is applied to the * in case of stable query, limit/offset is not applied here. the limit/offset is applied to the
* final results which is acquired after the secondry merge of in the client. * final results which is acquired after the secondry merge of in the client.
*/ */
if (pLimit->offset == 0 || pQueryInfo->intervalTime > 0 || QUERY_IS_STABLE_QUERY(pQueryInfo->type)) { if (pLimit->offset == 0 || pQueryInfo->interval.interval > 0 || QUERY_IS_STABLE_QUERY(pQueryInfo->type)) {
if (win->skey > elem1.ts) { if (win->skey > elem1.ts) {
win->skey = elem1.ts; win->skey = elem1.ts;
} }
...@@ -178,6 +178,7 @@ SJoinSupporter* tscCreateJoinSupporter(SSqlObj* pSql, SSubqueryState* pState, in ...@@ -178,6 +178,7 @@ SJoinSupporter* tscCreateJoinSupporter(SSqlObj* pSql, SSubqueryState* pState, in
pSupporter->subqueryIndex = index; pSupporter->subqueryIndex = index;
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, pSql->cmd.clauseIndex); SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, pSql->cmd.clauseIndex);
memcpy(&pSupporter->interval, &pQueryInfo->interval, sizeof(pSupporter->interval));
pSupporter->limit = pQueryInfo->limit; pSupporter->limit = pQueryInfo->limit;
STableMetaInfo* pTableMetaInfo = tscGetTableMetaInfoFromCmd(&pSql->cmd, pSql->cmd.clauseIndex, index); STableMetaInfo* pTableMetaInfo = tscGetTableMetaInfoFromCmd(&pSql->cmd, pSql->cmd.clauseIndex, index);
...@@ -297,18 +298,20 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) { ...@@ -297,18 +298,20 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) {
success = false; success = false;
break; break;
} }
tscClearSubqueryInfo(&pNew->cmd); tscClearSubqueryInfo(&pNew->cmd);
pSql->pSubs[i] = pNew; pSql->pSubs[i] = pNew;
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(&pNew->cmd, 0); SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(&pNew->cmd, 0);
pQueryInfo->tsBuf = pTSBuf; // transfer the ownership of timestamp comp-z data to the new created object pQueryInfo->tsBuf = pTSBuf; // transfer the ownership of timestamp comp-z data to the new created object
// set the second stage sub query for join process // set the second stage sub query for join process
TSDB_QUERY_SET_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_JOIN_SEC_STAGE); TSDB_QUERY_SET_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_JOIN_SEC_STAGE);
memcpy(&pQueryInfo->interval, &pSupporter->interval, sizeof(pQueryInfo->interval));
tscTagCondCopy(&pQueryInfo->tagCond, &pSupporter->tagCond); tscTagCondCopy(&pQueryInfo->tagCond, &pSupporter->tagCond);
pQueryInfo->colList = pSupporter->colList; pQueryInfo->colList = pSupporter->colList;
pQueryInfo->exprList = pSupporter->exprList; pQueryInfo->exprList = pSupporter->exprList;
pQueryInfo->fieldsInfo = pSupporter->fieldsInfo; pQueryInfo->fieldsInfo = pSupporter->fieldsInfo;
...@@ -1204,7 +1207,7 @@ int32_t tscCreateJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter ...@@ -1204,7 +1207,7 @@ int32_t tscCreateJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter
} }
pNew->cmd.numOfCols = 0; pNew->cmd.numOfCols = 0;
pNewQueryInfo->intervalTime = 0; pNewQueryInfo->interval.interval = 0;
pSupporter->limit = pNewQueryInfo->limit; pSupporter->limit = pNewQueryInfo->limit;
pNewQueryInfo->limit.limit = -1; pNewQueryInfo->limit.limit = -1;
...@@ -1950,7 +1953,7 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) { ...@@ -1950,7 +1953,7 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) {
SSqlCmd *pCmd = &pSql->cmd; SSqlCmd *pCmd = &pSql->cmd;
SSqlRes *pRes = &pSql->res; SSqlRes *pRes = &pSql->res;
pSql->numOfSubs = taosArrayGetSize(pCmd->pDataBlocks); pSql->numOfSubs = (uint16_t)taosArrayGetSize(pCmd->pDataBlocks);
assert(pSql->numOfSubs > 0); assert(pSql->numOfSubs > 0);
pRes->code = TSDB_CODE_SUCCESS; pRes->code = TSDB_CODE_SUCCESS;
...@@ -2185,7 +2188,7 @@ void **doSetResultRowData(SSqlObj *pSql, bool finalResult) { ...@@ -2185,7 +2188,7 @@ void **doSetResultRowData(SSqlObj *pSql, bool finalResult) {
} }
// primary key column cannot be null in interval query, no need to check // primary key column cannot be null in interval query, no need to check
if (i == 0 && pQueryInfo->intervalTime > 0) { if (i == 0 && pQueryInfo->interval.interval > 0) {
continue; continue;
} }
......
...@@ -1849,6 +1849,7 @@ static void doSetSqlExprAndResultFieldInfo(SQueryInfo* pQueryInfo, SQueryInfo* p ...@@ -1849,6 +1849,7 @@ static void doSetSqlExprAndResultFieldInfo(SQueryInfo* pQueryInfo, SQueryInfo* p
} }
assert(matched); assert(matched);
(void)matched;
} }
tscFieldInfoUpdateOffset(pNewQueryInfo); tscFieldInfoUpdateOffset(pNewQueryInfo);
...@@ -1899,10 +1900,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void ...@@ -1899,10 +1900,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex); SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
pNewQueryInfo->command = pQueryInfo->command; pNewQueryInfo->command = pQueryInfo->command;
pNewQueryInfo->intervalTimeUnit = pQueryInfo->intervalTimeUnit; memcpy(&pNewQueryInfo->interval, &pQueryInfo->interval, sizeof(pNewQueryInfo->interval));
pNewQueryInfo->slidingTimeUnit = pQueryInfo->slidingTimeUnit;
pNewQueryInfo->intervalTime = pQueryInfo->intervalTime;
pNewQueryInfo->slidingTime = pQueryInfo->slidingTime;
pNewQueryInfo->type = pQueryInfo->type; pNewQueryInfo->type = pQueryInfo->type;
pNewQueryInfo->window = pQueryInfo->window; pNewQueryInfo->window = pQueryInfo->window;
pNewQueryInfo->limit = pQueryInfo->limit; pNewQueryInfo->limit = pQueryInfo->limit;
......
...@@ -35,8 +35,6 @@ bool tscValidateTableNameLength(size_t len); ...@@ -35,8 +35,6 @@ bool tscValidateTableNameLength(size_t len);
SColumnFilterInfo* tscFilterInfoClone(const SColumnFilterInfo* src, int32_t numOfFilters); SColumnFilterInfo* tscFilterInfoClone(const SColumnFilterInfo* src, int32_t numOfFilters);
int64_t taosAddNatualInterval(int64_t key, int64_t intervalTime, char timeUnit, int16_t precision); // int64_t taosGetIntervalStartTimestamp(int64_t startTime, int64_t slidingTime, int64_t intervalTime, char timeUnit, int16_t precision);
int32_t taosCountNatualInterval(int64_t skey, int64_t ekey, int64_t intervalTime, char timeUnit, int16_t precision);
int64_t taosGetIntervalStartTimestamp(int64_t startTime, int64_t slidingTime, int64_t intervalTime, char timeUnit, int16_t precision);
#endif // TDENGINE_NAME_H #endif // TDENGINE_NAME_H
...@@ -99,62 +99,7 @@ SColumnFilterInfo* tscFilterInfoClone(const SColumnFilterInfo* src, int32_t numO ...@@ -99,62 +99,7 @@ SColumnFilterInfo* tscFilterInfoClone(const SColumnFilterInfo* src, int32_t numO
return pFilter; return pFilter;
} }
int64_t taosAddNatualInterval(int64_t key, int64_t intervalTime, char timeUnit, int16_t precision) { #if 0
key /= 1000;
if (precision == TSDB_TIME_PRECISION_MICRO) {
key /= 1000;
}
struct tm tm;
time_t t = (time_t)key;
localtime_r(&t, &tm);
if (timeUnit == 'y') {
intervalTime *= 12;
}
int mon = (int)(tm.tm_year * 12 + tm.tm_mon + intervalTime);
tm.tm_year = mon / 12;
tm.tm_mon = mon % 12;
key = mktime(&tm) * 1000L;
if (precision == TSDB_TIME_PRECISION_MICRO) {
key *= 1000L;
}
return key;
}
int32_t taosCountNatualInterval(int64_t skey, int64_t ekey, int64_t intervalTime, char timeUnit, int16_t precision) {
skey /= 1000;
ekey /= 1000;
if (precision == TSDB_TIME_PRECISION_MICRO) {
skey /= 1000;
ekey /= 1000;
}
if (ekey < skey) {
int64_t tmp = ekey;
ekey = skey;
skey = tmp;
}
struct tm tm;
time_t t = (time_t)skey;
localtime_r(&t, &tm);
int smon = tm.tm_year * 12 + tm.tm_mon;
t = (time_t)ekey;
localtime_r(&t, &tm);
int emon = tm.tm_year * 12 + tm.tm_mon;
if (timeUnit == 'y') {
intervalTime *= 12;
}
return (emon - smon) / (int32_t)intervalTime;
}
int64_t taosGetIntervalStartTimestamp(int64_t startTime, int64_t slidingTime, int64_t intervalTime, char timeUnit, int16_t precision) { int64_t taosGetIntervalStartTimestamp(int64_t startTime, int64_t slidingTime, int64_t intervalTime, char timeUnit, int16_t precision) {
if (slidingTime == 0) { if (slidingTime == 0) {
return startTime; return startTime;
...@@ -219,6 +164,8 @@ int64_t taosGetIntervalStartTimestamp(int64_t startTime, int64_t slidingTime, in ...@@ -219,6 +164,8 @@ int64_t taosGetIntervalStartTimestamp(int64_t startTime, int64_t slidingTime, in
return start; return start;
} }
#endif
/* /*
* tablePrefix.columnName * tablePrefix.columnName
* extract table name and save it in pTable, with only column name in pToken * extract table name and save it in pTable, with only column name in pToken
......
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.taosdata.jdbc</groupId> <groupId>com.taosdata.jdbc</groupId>
<artifactId>taos-jdbcdriver</artifactId> <artifactId>taos-jdbcdriver</artifactId>
<version>2.0.0</version> <version>2.0.0</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>JDBCDriver</name> <name>JDBCDriver</name>
<url>https://github.com/taosdata/TDengine/tree/master/src/connector/jdbc</url>
<description>TDengine JDBC Driver</description>
<licenses>
<license>
<name>GNU AFFERO GENERAL PUBLIC LICENSE Version 3</name>
<url>https://github.com/taosdata/TDengine/blob/master/LICENSE</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<connection>scm:git:git://github.com/taosdata/TDengine.git</connection>
<developerConnection>scm:git:git@github.com:taosdata/TDengine.git</developerConnection>
<url>https://github.com/taosdata/TDengine/tree/master/src/connector/jdbc</url> <url>https://github.com/taosdata/TDengine/tree/master/src/connector/jdbc</url>
<tag>HEAD</tag>
</scm> <description>TDengine JDBC Driver</description>
<developers> <licenses>
<developer> <license>
<name>taosdata</name> <name>GNU AFFERO GENERAL PUBLIC LICENSE Version 3</name>
<email>support@taosdata.com</email> <url>https://github.com/taosdata/TDengine/blob/master/LICENSE</url>
<organization>https://www.taosdata.com/</organization> <distribution>repo</distribution>
<organizationUrl>https://www.taosdata.com/</organizationUrl> </license>
</developer> </licenses>
</developers> <scm>
<properties> <connection>scm:git:git://github.com/taosdata/TDengine.git</connection>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <developerConnection>scm:git:git@github.com:taosdata/TDengine.git</developerConnection>
<java.version>1.8</java.version> <url>https://github.com/taosdata/TDengine/tree/master/src/connector/jdbc</url>
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version> <tag>HEAD</tag>
<commons-logging.version>1.1.2</commons-logging.version> </scm>
<commons-lang3.version>3.5</commons-lang3.version> <developers>
</properties> <developer>
<dependencies> <name>taosdata</name>
<dependency> <email>support@taosdata.com</email>
<groupId>commons-logging</groupId> <organization>https://www.taosdata.com/</organization>
<artifactId>commons-logging</artifactId> <organizationUrl>https://www.taosdata.com/</organizationUrl>
<version>${commons-logging.version}</version> </developer>
<exclusions> </developers>
<exclusion> <properties>
<groupId>*</groupId> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<artifactId>*</artifactId> <java.version>1.8</java.version>
</exclusion> <maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
</exclusions> <commons-logging.version>1.1.2</commons-logging.version>
</dependency> <commons-lang3.version>3.5</commons-lang3.version>
<dependency> </properties>
<groupId>junit</groupId> <dependencies>
<artifactId>junit</artifactId> <dependency>
<version>4.13</version> <groupId>commons-logging</groupId>
<scope>test</scope> <artifactId>commons-logging</artifactId>
</dependency> <version>${commons-logging.version}</version>
</dependencies> <exclusions>
<build> <exclusion>
<plugins> <groupId>*</groupId>
<plugin> <artifactId>*</artifactId>
<groupId>org.apache.maven.plugins</groupId> </exclusion>
<artifactId>maven-assembly-plugin</artifactId> </exclusions>
<version>3.0.0</version> </dependency>
<configuration> <dependency>
<descriptors> <groupId>junit</groupId>
<descriptor>src/main/assembly/assembly-jar.xml</descriptor> <artifactId>junit</artifactId>
</descriptors> <version>4.13</version>
</configuration> <scope>test</scope>
<executions> </dependency>
<execution> </dependencies>
<id>make-assembly</id> <build>
<phase>package</phase> <plugins>
<goals> <plugin>
<goal>single</goal> <groupId>org.apache.maven.plugins</groupId>
</goals> <artifactId>maven-assembly-plugin</artifactId>
</execution> <version>3.0.0</version>
</executions> <configuration>
</plugin> <descriptors>
<plugin> <descriptor>src/main/assembly/assembly-jar.xml</descriptor>
<groupId>org.apache.maven.plugins</groupId> </descriptors>
<artifactId>maven-compiler-plugin</artifactId> </configuration>
<version>${maven-compiler-plugin.version}</version> <executions>
<configuration> <execution>
<encoding>UTF-8</encoding> <id>make-assembly</id>
<source>${java.version}</source> <phase>package</phase>
<target>${java.version}</target> <goals>
<debug>true</debug> <goal>single</goal>
<showDeprecation>true</showDeprecation> </goals>
</configuration> </execution>
</plugin> </executions>
<plugin> </plugin>
<groupId>org.apache.maven.plugins</groupId> <plugin>
<artifactId>maven-surefire-plugin</artifactId> <groupId>org.apache.maven.plugins</groupId>
<version>2.12.4</version> <artifactId>maven-compiler-plugin</artifactId>
<configuration> <version>${maven-compiler-plugin.version}</version>
<testFailureIgnore>true</testFailureIgnore> <configuration>
</configuration> <encoding>UTF-8</encoding>
</plugin> <source>${java.version}</source>
</plugins> <target>${java.version}</target>
</build> <debug>true</debug>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
</plugins>
</build>
</project> </project>
...@@ -53,66 +53,12 @@ public class TSDBConnection implements Connection { ...@@ -53,66 +53,12 @@ public class TSDBConnection implements Connection {
public TSDBConnection(Properties info, TSDBDatabaseMetaData meta) throws SQLException { public TSDBConnection(Properties info, TSDBDatabaseMetaData meta) throws SQLException {
this.dbMetaData = meta; this.dbMetaData = meta;
//load taos.cfg start
File cfgDir = loadConfigDir(info.getProperty(TSDBDriver.PROPERTY_KEY_CONFIG_DIR));
File cfgFile = cfgDir.listFiles((dir, name) -> "taos.cfg".equalsIgnoreCase(name))[0];
List<String> endpoints = loadConfigEndpoints(cfgFile);
if (!endpoints.isEmpty()) {
info.setProperty(TSDBDriver.PROPERTY_KEY_HOST, endpoints.get(0).split(":")[0]);
info.setProperty(TSDBDriver.PROPERTY_KEY_PORT, endpoints.get(0).split(":")[1]);
}
//load taos.cfg end
connect(info.getProperty(TSDBDriver.PROPERTY_KEY_HOST), connect(info.getProperty(TSDBDriver.PROPERTY_KEY_HOST),
Integer.parseInt(info.getProperty(TSDBDriver.PROPERTY_KEY_PORT, "0")), Integer.parseInt(info.getProperty(TSDBDriver.PROPERTY_KEY_PORT, "0")),
info.getProperty(TSDBDriver.PROPERTY_KEY_DBNAME), info.getProperty(TSDBDriver.PROPERTY_KEY_USER), info.getProperty(TSDBDriver.PROPERTY_KEY_DBNAME), info.getProperty(TSDBDriver.PROPERTY_KEY_USER),
info.getProperty(TSDBDriver.PROPERTY_KEY_PASSWORD)); info.getProperty(TSDBDriver.PROPERTY_KEY_PASSWORD));
} }
private List<String> loadConfigEndpoints(File cfgFile) {
List<String> endpoints = new ArrayList<>();
try (BufferedReader reader = new BufferedReader(new FileReader(cfgFile))) {
String line = null;
while ((line = reader.readLine()) != null) {
if (line.trim().startsWith("firstEp") || line.trim().startsWith("secondEp")) {
endpoints.add(line.substring(line.indexOf('p') + 1).trim());
}
if (endpoints.size() > 1)
break;
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return endpoints;
}
/**
* @param cfgDirPath
* @return return the config dir
**/
private File loadConfigDir(String cfgDirPath) {
if (cfgDirPath == null)
return loadDefaultConfigDir();
File cfgDir = new File(cfgDirPath);
if (!cfgDir.exists())
return loadDefaultConfigDir();
return cfgDir;
}
/**
* @return search the default config dir, if the config dir is not exist will return null
*/
private File loadDefaultConfigDir() {
File cfgDir;
File cfgDir_linux = new File("/etc/taos");
cfgDir = cfgDir_linux.exists() ? cfgDir_linux : null;
File cfgDir_windows = new File("C:\\TDengine\\cfg");
cfgDir = (cfgDir == null && cfgDir_windows.exists()) ? cfgDir_windows : cfgDir;
return cfgDir;
}
private void connect(String host, int port, String dbName, String user, String password) throws SQLException { private void connect(String host, int port, String dbName, String user, String password) throws SQLException {
this.connector = new TSDBJNIConnector(); this.connector = new TSDBJNIConnector();
this.connector.connect(host, port, dbName, user, password); this.connector.connect(host, port, dbName, user, password);
......
...@@ -68,15 +68,15 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData { ...@@ -68,15 +68,15 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData {
} }
public boolean nullsAreSortedLow() throws SQLException { public boolean nullsAreSortedLow() throws SQLException {
return false; return !nullsAreSortedHigh();
} }
public boolean nullsAreSortedAtStart() throws SQLException { public boolean nullsAreSortedAtStart() throws SQLException {
return false; return true;
} }
public boolean nullsAreSortedAtEnd() throws SQLException { public boolean nullsAreSortedAtEnd() throws SQLException {
return false; return !nullsAreSortedAtStart();
} }
public String getDatabaseProductName() throws SQLException { public String getDatabaseProductName() throws SQLException {
......
...@@ -14,24 +14,29 @@ ...@@ -14,24 +14,29 @@
*****************************************************************************/ *****************************************************************************/
package com.taosdata.jdbc; package com.taosdata.jdbc;
import java.io.*;
import java.sql.*; import java.sql.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Logger; import java.util.logging.Logger;
/** /**
* The Java SQL framework allows for multiple database drivers. Each driver * The Java SQL framework allows for multiple database drivers. Each driver
* should supply a class that implements the Driver interface * should supply a class that implements the Driver interface
* *
* <p> * <p>
* The DriverManager will try to load as many drivers as it can find and then * The DriverManager will try to load as many drivers as it can find and then
* for any given connection request, it will ask each driver in turn to try to * for any given connection request, it will ask each driver in turn to try to
* connect to the target URL. * connect to the target URL.
* *
* <p> * <p>
* It is strongly recommended that each Driver class should be small and stand * It is strongly recommended that each Driver class should be small and stand
* alone so that the Driver class can be loaded and queried without bringing in * alone so that the Driver class can be loaded and queried without bringing in
* vast quantities of supporting code. * vast quantities of supporting code.
* *
* <p> * <p>
* When a Driver class is loaded, it should create an instance of itself and * When a Driver class is loaded, it should create an instance of itself and
* register it with the DriverManager. This means that a user can load and * register it with the DriverManager. This means that a user can load and
...@@ -39,38 +44,41 @@ import java.util.logging.Logger; ...@@ -39,38 +44,41 @@ import java.util.logging.Logger;
*/ */
public class TSDBDriver implements java.sql.Driver { public class TSDBDriver implements java.sql.Driver {
@Deprecated
private static final String URL_PREFIX1 = "jdbc:tsdb://"; @Deprecated
private static final String URL_PREFIX = "jdbc:taos://"; private static final String URL_PREFIX1 = "jdbc:TSDB://";
/** private static final String URL_PREFIX = "jdbc:TAOS://";
* Key used to retrieve the database value from the properties instance passed
* to the driver. /**
*/ * Key used to retrieve the database value from the properties instance passed
public static final String PROPERTY_KEY_DBNAME = "dbname"; * to the driver.
*/
/** public static final String PROPERTY_KEY_DBNAME = "dbname";
* Key used to retrieve the host value from the properties instance passed to
* the driver. /**
*/ * Key used to retrieve the host value from the properties instance passed to
public static final String PROPERTY_KEY_HOST = "host"; * the driver.
/** */
* Key used to retrieve the password value from the properties instance passed public static final String PROPERTY_KEY_HOST = "host";
* to the driver. /**
*/ * Key used to retrieve the password value from the properties instance passed
public static final String PROPERTY_KEY_PASSWORD = "password"; * to the driver.
*/
/** public static final String PROPERTY_KEY_PASSWORD = "password";
* Key used to retrieve the port number value from the properties instance
* passed to the driver. /**
*/ * Key used to retrieve the port number value from the properties instance
public static final String PROPERTY_KEY_PORT = "port"; * passed to the driver.
*/
/** public static final String PROPERTY_KEY_PORT = "port";
* Key used to retrieve the user value from the properties instance passed to
* the driver. /**
*/ * Key used to retrieve the user value from the properties instance passed to
public static final String PROPERTY_KEY_USER = "user"; * the driver.
*/
public static final String PROPERTY_KEY_USER = "user";
/** /**
* Key for the configuration file directory of TSDB client in properties instance * Key for the configuration file directory of TSDB client in properties instance
...@@ -95,278 +103,320 @@ public class TSDBDriver implements java.sql.Driver { ...@@ -95,278 +103,320 @@ public class TSDBDriver implements java.sql.Driver {
public static final String PROPERTY_KEY_PROTOCOL = "protocol"; public static final String PROPERTY_KEY_PROTOCOL = "protocol";
/**
* Index for port coming out of parseHostPortPair(). /**
*/ * Index for port coming out of parseHostPortPair().
public final static int PORT_NUMBER_INDEX = 1; */
public final static int PORT_NUMBER_INDEX = 1;
/**
* Index for host coming out of parseHostPortPair(). /**
*/ * Index for host coming out of parseHostPortPair().
public final static int HOST_NAME_INDEX = 0; */
public final static int HOST_NAME_INDEX = 0;
private TSDBDatabaseMetaData dbMetaData = null;
private TSDBDatabaseMetaData dbMetaData = null;
static {
try { static {
java.sql.DriverManager.registerDriver(new TSDBDriver()); try {
} catch (SQLException E) { java.sql.DriverManager.registerDriver(new TSDBDriver());
throw new RuntimeException(TSDBConstants.WrapErrMsg("can't register tdengine jdbc driver!")); } catch (SQLException E) {
} throw new RuntimeException(TSDBConstants.WrapErrMsg("can't register tdengine jdbc driver!"));
} }
}
public Connection connect(String url, Properties info) throws SQLException {
if (url == null) { private List<String> loadConfigEndpoints(File cfgFile) {
throw new SQLException(TSDBConstants.WrapErrMsg("url is not set!")); List<String> endpoints = new ArrayList<>();
} try (BufferedReader reader = new BufferedReader(new FileReader(cfgFile))) {
String line = null;
Properties props = null; while ((line = reader.readLine()) != null) {
if (line.trim().startsWith("firstEp") || line.trim().startsWith("secondEp")) {
if ((props = parseURL(url, info)) == null) { endpoints.add(line.substring(line.indexOf('p') + 1).trim());
return null; }
} if (endpoints.size() > 1)
break;
try { }
TSDBJNIConnector.init((String) props.get(PROPERTY_KEY_CONFIG_DIR), (String) props.get(PROPERTY_KEY_LOCALE), (String) props.get(PROPERTY_KEY_CHARSET), } catch (FileNotFoundException e) {
(String) props.get(PROPERTY_KEY_TIME_ZONE)); e.printStackTrace();
Connection newConn = new TSDBConnection(props, this.dbMetaData); } catch (IOException e) {
return newConn; e.printStackTrace();
} catch (SQLWarning sqlWarning) { }
sqlWarning.printStackTrace(); return endpoints;
Connection newConn = new TSDBConnection(props, this.dbMetaData); }
return newConn;
} catch (SQLException sqlEx) { /**
throw sqlEx; * @param cfgDirPath
} catch (Exception ex) { * @return return the config dir
SQLException sqlEx = new SQLException("SQLException:" + ex.toString()); **/
sqlEx.initCause(ex); private File loadConfigDir(String cfgDirPath) {
throw sqlEx; if (cfgDirPath == null)
} return loadDefaultConfigDir();
} File cfgDir = new File(cfgDirPath);
if (!cfgDir.exists())
/** return loadDefaultConfigDir();
* Parses hostPortPair in the form of [host][:port] into an array, with the return cfgDir;
* element of index HOST_NAME_INDEX being the host (or null if not specified), }
* and the element of index PORT_NUMBER_INDEX being the port (or null if not
* specified). /**
* * @return search the default config dir, if the config dir is not exist will return null
* @param hostPortPair */
* host and port in form of of [host][:port] private File loadDefaultConfigDir() {
* File cfgDir;
* @return array containing host and port as Strings File cfgDir_linux = new File("/etc/taos");
* cfgDir = cfgDir_linux.exists() ? cfgDir_linux : null;
* @throws SQLException File cfgDir_windows = new File("C:\\TDengine\\cfg");
* if a parse error occurs cfgDir = (cfgDir == null && cfgDir_windows.exists()) ? cfgDir_windows : cfgDir;
*/ return cfgDir;
protected static String[] parseHostPortPair(String hostPortPair) throws SQLException { }
String[] splitValues = new String[2];
public Connection connect(String url, Properties info) throws SQLException {
int portIndex = hostPortPair.indexOf(":"); if (url == null) {
throw new SQLException(TSDBConstants.WrapErrMsg("url is not set!"));
String hostname = null; }
if (portIndex != -1) { Properties props = null;
if ((portIndex + 1) < hostPortPair.length()) { if ((props = parseURL(url, info)) == null) {
String portAsString = hostPortPair.substring(portIndex + 1); return null;
hostname = hostPortPair.substring(0, portIndex); }
splitValues[HOST_NAME_INDEX] = hostname; //load taos.cfg start
if (info.getProperty(TSDBDriver.PROPERTY_KEY_HOST) == null && info.getProperty(TSDBDriver.PROPERTY_KEY_PORT) == null){
splitValues[PORT_NUMBER_INDEX] = portAsString; File cfgDir = loadConfigDir(info.getProperty(TSDBDriver.PROPERTY_KEY_CONFIG_DIR));
} else { File cfgFile = cfgDir.listFiles((dir, name) -> "taos.cfg".equalsIgnoreCase(name))[0];
throw new SQLException(TSDBConstants.WrapErrMsg("port is not proper!")); List<String> endpoints = loadConfigEndpoints(cfgFile);
} if (!endpoints.isEmpty()) {
} else { info.setProperty(TSDBDriver.PROPERTY_KEY_HOST, endpoints.get(0).split(":")[0]);
splitValues[HOST_NAME_INDEX] = hostPortPair; info.setProperty(TSDBDriver.PROPERTY_KEY_PORT, endpoints.get(0).split(":")[1]);
splitValues[PORT_NUMBER_INDEX] = null; }
} }
return splitValues; try {
} TSDBJNIConnector.init((String) props.get(PROPERTY_KEY_CONFIG_DIR), (String) props.get(PROPERTY_KEY_LOCALE), (String) props.get(PROPERTY_KEY_CHARSET),
(String) props.get(PROPERTY_KEY_TIME_ZONE));
public boolean acceptsURL(String url) throws SQLException { Connection newConn = new TSDBConnection(props, this.dbMetaData);
return (url != null && url.length() > 0 && url.trim().length() > 0) && url.toLowerCase().startsWith(URL_PREFIX); return newConn;
} } catch (SQLWarning sqlWarning) {
sqlWarning.printStackTrace();
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException { Connection newConn = new TSDBConnection(props, this.dbMetaData);
if (info == null) { return newConn;
info = new Properties(); } catch (SQLException sqlEx) {
} throw sqlEx;
} catch (Exception ex) {
if ((url != null) && (url.startsWith(URL_PREFIX) || url.startsWith(URL_PREFIX1))) { SQLException sqlEx = new SQLException("SQLException:" + ex.toString());
info = parseURL(url, info); sqlEx.initCause(ex);
} throw sqlEx;
}
DriverPropertyInfo hostProp = new DriverPropertyInfo(PROPERTY_KEY_HOST, info.getProperty(PROPERTY_KEY_HOST)); }
hostProp.required = true;
/**
DriverPropertyInfo portProp = new DriverPropertyInfo(PROPERTY_KEY_PORT, * Parses hostPortPair in the form of [host][:port] into an array, with the
info.getProperty(PROPERTY_KEY_PORT, TSDBConstants.DEFAULT_PORT)); * element of index HOST_NAME_INDEX being the host (or null if not specified),
portProp.required = false; * and the element of index PORT_NUMBER_INDEX being the port (or null if not
* specified).
DriverPropertyInfo dbProp = new DriverPropertyInfo(PROPERTY_KEY_DBNAME, info.getProperty(PROPERTY_KEY_DBNAME)); *
dbProp.required = false; * @param hostPortPair host and port in form of of [host][:port]
dbProp.description = "Database name"; * @return array containing host and port as Strings
* @throws SQLException if a parse error occurs
DriverPropertyInfo userProp = new DriverPropertyInfo(PROPERTY_KEY_USER, info.getProperty(PROPERTY_KEY_USER)); */
userProp.required = true; protected static String[] parseHostPortPair(String hostPortPair) throws SQLException {
String[] splitValues = new String[2];
DriverPropertyInfo passwordProp = new DriverPropertyInfo(PROPERTY_KEY_PASSWORD,
info.getProperty(PROPERTY_KEY_PASSWORD)); int portIndex = hostPortPair.indexOf(":");
passwordProp.required = true;
String hostname = null;
DriverPropertyInfo[] propertyInfo = new DriverPropertyInfo[5];
propertyInfo[0] = hostProp; if (portIndex != -1) {
propertyInfo[1] = portProp; if ((portIndex + 1) < hostPortPair.length()) {
propertyInfo[2] = dbProp; String portAsString = hostPortPair.substring(portIndex + 1);
propertyInfo[3] = userProp; hostname = hostPortPair.substring(0, portIndex);
propertyInfo[4] = passwordProp;
splitValues[HOST_NAME_INDEX] = hostname;
return propertyInfo;
} splitValues[PORT_NUMBER_INDEX] = portAsString;
} else {
/** throw new SQLException(TSDBConstants.WrapErrMsg("port is not proper!"));
* example: jdbc:TSDB://127.0.0.1:0/db?user=root&password=your_password }
*/ } else {
splitValues[HOST_NAME_INDEX] = hostPortPair;
public Properties parseURL(String url, Properties defaults) throws java.sql.SQLException { splitValues[PORT_NUMBER_INDEX] = null;
Properties urlProps = (defaults != null) ? defaults : new Properties(); }
if (url == null) {
return null; return splitValues;
} }
public boolean acceptsURL(String url) throws SQLException {
return (url != null && url.length() > 0 && url.trim().length() > 0) && url.toLowerCase().startsWith(URL_PREFIX);
}
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
if (info == null) {
info = new Properties();
}
if ((url != null) && (url.startsWith(URL_PREFIX) || url.startsWith(URL_PREFIX1))) {
info = parseURL(url, info);
}
DriverPropertyInfo hostProp = new DriverPropertyInfo(PROPERTY_KEY_HOST, info.getProperty(PROPERTY_KEY_HOST));
hostProp.required = true;
DriverPropertyInfo portProp = new DriverPropertyInfo(PROPERTY_KEY_PORT, info.getProperty(PROPERTY_KEY_PORT, TSDBConstants.DEFAULT_PORT));
portProp.required = false;
DriverPropertyInfo dbProp = new DriverPropertyInfo(PROPERTY_KEY_DBNAME, info.getProperty(PROPERTY_KEY_DBNAME));
dbProp.required = false;
dbProp.description = "Database name";
DriverPropertyInfo userProp = new DriverPropertyInfo(PROPERTY_KEY_USER, info.getProperty(PROPERTY_KEY_USER));
userProp.required = true;
DriverPropertyInfo passwordProp = new DriverPropertyInfo(PROPERTY_KEY_PASSWORD, info.getProperty(PROPERTY_KEY_PASSWORD));
passwordProp.required = true;
DriverPropertyInfo[] propertyInfo = new DriverPropertyInfo[5];
propertyInfo[0] = hostProp;
propertyInfo[1] = portProp;
propertyInfo[2] = dbProp;
propertyInfo[3] = userProp;
propertyInfo[4] = passwordProp;
return propertyInfo;
}
/**
* example: jdbc:TSDB://127.0.0.1:0/db?user=root&password=your_password
*/
public Properties parseURL(String url, Properties defaults) throws java.sql.SQLException {
Properties urlProps = (defaults != null) ? defaults : new Properties();
if (url == null) {
return null;
}
String lowerUrl = url.toLowerCase(); String lowerUrl = url.toLowerCase();
if (!lowerUrl.startsWith(URL_PREFIX) && !lowerUrl.startsWith(URL_PREFIX1)) { if (!lowerUrl.startsWith(URL_PREFIX) && !lowerUrl.startsWith(URL_PREFIX1)) {
return null; return null;
} }
String urlForMeta = url; String urlForMeta = url;
String dbProductName = url.substring(url.indexOf(":") + 1); String dbProductName = url.substring(url.indexOf(":") + 1);
dbProductName = dbProductName.substring(0, dbProductName.indexOf(":")); dbProductName = dbProductName.substring(0, dbProductName.indexOf(":"));
int beginningOfSlashes = url.indexOf("//"); int beginningOfSlashes = url.indexOf("//");
url = url.substring(beginningOfSlashes + 2); url = url.substring(beginningOfSlashes + 2);
String host = url.substring(0, url.indexOf(":")); String host = url.substring(0, url.indexOf(":"));
url = url.substring(url.indexOf(":") + 1); url = url.substring(url.indexOf(":") + 1);
urlProps.setProperty(PROPERTY_KEY_HOST, host); urlProps.setProperty(PROPERTY_KEY_HOST, host);
String port = url.substring(0, url.indexOf("/")); String port = url.substring(0, url.indexOf("/"));
urlProps.setProperty(PROPERTY_KEY_PORT, port); urlProps.setProperty(PROPERTY_KEY_PORT, port);
url = url.substring(url.indexOf("/") + 1); url = url.substring(url.indexOf("/") + 1);
if (url.indexOf("?") != -1) { if (url.indexOf("?") != -1) {
String dbName = url.substring(0, url.indexOf("?")); String dbName = url.substring(0, url.indexOf("?"));
urlProps.setProperty(PROPERTY_KEY_DBNAME, dbName); urlProps.setProperty(PROPERTY_KEY_DBNAME, dbName);
url = url.trim().substring(url.indexOf("?") + 1); url = url.trim().substring(url.indexOf("?") + 1);
} else { } else {
// without user & password so return // without user & password so return
if(!url.trim().isEmpty()) { if (!url.trim().isEmpty()) {
String dbName = url.trim(); String dbName = url.trim();
urlProps.setProperty(PROPERTY_KEY_DBNAME, dbName); urlProps.setProperty(PROPERTY_KEY_DBNAME, dbName);
} }
this.dbMetaData = new TSDBDatabaseMetaData(dbProductName, urlForMeta, urlProps.getProperty("user")); this.dbMetaData = new TSDBDatabaseMetaData(dbProductName, urlForMeta, urlProps.getProperty("user"));
return urlProps; return urlProps;
} }
String user = ""; String user = "";
if (url.indexOf("&") == -1) { if (url.indexOf("&") == -1) {
String[] kvPair = url.trim().split("="); String[] kvPair = url.trim().split("=");
if (kvPair.length == 2) { if (kvPair.length == 2) {
setPropertyValue(urlProps, kvPair); setPropertyValue(urlProps, kvPair);
return urlProps; return urlProps;
} }
} }
String[] queryStrings = url.trim().split("&"); String[] queryStrings = url.trim().split("&");
for (String queryStr : queryStrings) { for (String queryStr : queryStrings) {
String[] kvPair = queryStr.trim().split("="); String[] kvPair = queryStr.trim().split("=");
if (kvPair.length < 2){ if (kvPair.length < 2) {
continue; continue;
} }
setPropertyValue(urlProps, kvPair); setPropertyValue(urlProps, kvPair);
} }
user = urlProps.getProperty(PROPERTY_KEY_USER).toString(); user = urlProps.getProperty(PROPERTY_KEY_USER).toString();
this.dbMetaData = new TSDBDatabaseMetaData(dbProductName, urlForMeta, user); this.dbMetaData = new TSDBDatabaseMetaData(dbProductName, urlForMeta, user);
return urlProps; return urlProps;
} }
public void setPropertyValue(Properties property, String[] keyValuePair) { public void setPropertyValue(Properties property, String[] keyValuePair) {
switch (keyValuePair[0].toLowerCase()) { switch (keyValuePair[0].toLowerCase()) {
case PROPERTY_KEY_USER: case PROPERTY_KEY_USER:
property.setProperty(PROPERTY_KEY_USER, keyValuePair[1]); property.setProperty(PROPERTY_KEY_USER, keyValuePair[1]);
break; break;
case PROPERTY_KEY_PASSWORD: case PROPERTY_KEY_PASSWORD:
property.setProperty(PROPERTY_KEY_PASSWORD, keyValuePair[1]); property.setProperty(PROPERTY_KEY_PASSWORD, keyValuePair[1]);
break; break;
case PROPERTY_KEY_TIME_ZONE: case PROPERTY_KEY_TIME_ZONE:
property.setProperty(PROPERTY_KEY_TIME_ZONE, keyValuePair[1]); property.setProperty(PROPERTY_KEY_TIME_ZONE, keyValuePair[1]);
break; break;
case PROPERTY_KEY_LOCALE: case PROPERTY_KEY_LOCALE:
property.setProperty(PROPERTY_KEY_LOCALE, keyValuePair[1]); property.setProperty(PROPERTY_KEY_LOCALE, keyValuePair[1]);
break; break;
case PROPERTY_KEY_CHARSET: case PROPERTY_KEY_CHARSET:
property.setProperty(PROPERTY_KEY_CHARSET, keyValuePair[1]); property.setProperty(PROPERTY_KEY_CHARSET, keyValuePair[1]);
break; break;
case PROPERTY_KEY_CONFIG_DIR: case PROPERTY_KEY_CONFIG_DIR:
property.setProperty(PROPERTY_KEY_CONFIG_DIR, keyValuePair[1]); property.setProperty(PROPERTY_KEY_CONFIG_DIR, keyValuePair[1]);
break; break;
} }
} }
public int getMajorVersion() { public int getMajorVersion() {
return 1; return 1;
} }
public int getMinorVersion() { public int getMinorVersion() {
return 1; return 1;
} }
public boolean jdbcCompliant() { public boolean jdbcCompliant() {
return false; return false;
} }
public Logger getParentLogger() throws SQLFeatureNotSupportedException { public Logger getParentLogger() throws SQLFeatureNotSupportedException {
return null; return null;
} }
/** /**
* Returns the host property * Returns the host property
* *
* @param props * @param props the java.util.Properties instance to retrieve the hostname from.
* the java.util.Properties instance to retrieve the hostname from. * @return the host
* */
* @return the host public String host(Properties props) {
*/ return props.getProperty(PROPERTY_KEY_HOST, "localhost");
public String host(Properties props) { }
return props.getProperty(PROPERTY_KEY_HOST, "localhost");
} /**
* Returns the port number property
/** *
* Returns the port number property * @param props the properties to get the port number from
* * @return the port number
* @param props */
* the properties to get the port number from public int port(Properties props) {
* return Integer.parseInt(props.getProperty(PROPERTY_KEY_PORT, TSDBConstants.DEFAULT_PORT));
* @return the port number }
*/
public int port(Properties props) { /**
return Integer.parseInt(props.getProperty(PROPERTY_KEY_PORT, TSDBConstants.DEFAULT_PORT)); * Returns the database property from <code>props</code>
} *
* @param props the Properties to look for the database property.
/** * @return the database name.
* Returns the database property from <code>props</code> */
* public String database(Properties props) {
* @param props return props.getProperty(PROPERTY_KEY_DBNAME);
* the Properties to look for the database property. }
*
* @return the database name.
*/
public String database(Properties props) {
return props.getProperty(PROPERTY_KEY_DBNAME);
}
} }
...@@ -242,7 +242,7 @@ public class TSDBStatement implements Statement { ...@@ -242,7 +242,7 @@ public class TSDBStatement implements Statement {
public void addBatch(String sql) throws SQLException { public void addBatch(String sql) throws SQLException {
if (batchedArgs == null) { if (batchedArgs == null) {
batchedArgs = new ArrayList<String>(); batchedArgs = new ArrayList<>();
} }
batchedArgs.add(sql); batchedArgs.add(sql);
} }
......
...@@ -101,6 +101,7 @@ extern const int32_t TYPE_BYTES[11]; ...@@ -101,6 +101,7 @@ extern const int32_t TYPE_BYTES[11];
#define TSDB_TIME_PRECISION_MILLI 0 #define TSDB_TIME_PRECISION_MILLI 0
#define TSDB_TIME_PRECISION_MICRO 1 #define TSDB_TIME_PRECISION_MICRO 1
#define TSDB_TIME_PRECISION_NANO 2 #define TSDB_TIME_PRECISION_NANO 2
#define TSDB_TICK_PER_SECOND(precision) ((precision)==TSDB_TIME_PRECISION_MILLI ? 1e3L : ((precision)==TSDB_TIME_PRECISION_MICRO ? 1e6L : 1e9L))
#define TSDB_TIME_PRECISION_MILLI_STR "ms" #define TSDB_TIME_PRECISION_MILLI_STR "ms"
#define TSDB_TIME_PRECISION_MICRO_STR "us" #define TSDB_TIME_PRECISION_MICRO_STR "us"
...@@ -244,7 +245,7 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size, void* buf ...@@ -244,7 +245,7 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size, void* buf
#define TSDB_MAX_SAVED_SQL_LEN TSDB_MAX_COLUMNS * 64 #define TSDB_MAX_SAVED_SQL_LEN TSDB_MAX_COLUMNS * 64
#define TSDB_MAX_SQL_LEN TSDB_PAYLOAD_SIZE #define TSDB_MAX_SQL_LEN TSDB_PAYLOAD_SIZE
#define TSDB_MAX_SQL_SHOW_LEN 256 #define TSDB_MAX_SQL_SHOW_LEN 256
#define TSDB_MAX_ALLOWED_SQL_LEN (8*1024*1024U) // sql length should be less than 8mb #define TSDB_MAX_ALLOWED_SQL_LEN (1*1024*1024U) // sql length should be less than 8mb
#define TSDB_MAX_BYTES_PER_ROW 16384 #define TSDB_MAX_BYTES_PER_ROW 16384
#define TSDB_MAX_TAGS_LEN 16384 #define TSDB_MAX_TAGS_LEN 16384
......
...@@ -460,11 +460,7 @@ typedef struct { ...@@ -460,11 +460,7 @@ typedef struct {
int16_t order; int16_t order;
int16_t orderColId; int16_t orderColId;
int16_t numOfCols; // the number of columns will be load from vnode int16_t numOfCols; // the number of columns will be load from vnode
int64_t intervalTime; // time interval for aggregation, in million second SInterval interval;
int64_t intervalOffset; // start offset for interval query
int64_t slidingTime; // value for sliding window
char intervalTimeUnit;
char slidingTimeUnit; // time interval type, for revisement of interval(1d)
uint16_t tagCondLen; // tag length in current query uint16_t tagCondLen; // tag length in current query
int16_t numOfGroupCols; // num of group by columns int16_t numOfGroupCols; // num of group by columns
int16_t orderByIdx; int16_t orderByIdx;
......
...@@ -30,8 +30,6 @@ extern "C" { ...@@ -30,8 +30,6 @@ extern "C" {
#define MILLISECOND_PER_HOUR (MILLISECOND_PER_MINUTE * 60) #define MILLISECOND_PER_HOUR (MILLISECOND_PER_MINUTE * 60)
#define MILLISECOND_PER_DAY (MILLISECOND_PER_HOUR * 24) #define MILLISECOND_PER_DAY (MILLISECOND_PER_HOUR * 24)
#define MILLISECOND_PER_WEEK (MILLISECOND_PER_DAY * 7) #define MILLISECOND_PER_WEEK (MILLISECOND_PER_DAY * 7)
#define MILLISECOND_PER_MONTH (MILLISECOND_PER_DAY * 30)
#define MILLISECOND_PER_YEAR (MILLISECOND_PER_DAY * 365)
//@return timestamp in second //@return timestamp in second
int32_t taosGetTimestampSec(); int32_t taosGetTimestampSec();
...@@ -63,8 +61,22 @@ static FORCE_INLINE int64_t taosGetTimestamp(int32_t precision) { ...@@ -63,8 +61,22 @@ static FORCE_INLINE int64_t taosGetTimestamp(int32_t precision) {
} }
} }
int32_t getTimestampInUsFromStr(char* token, int32_t tokenlen, int64_t* ts);
int32_t parseDuration(const char* token, int32_t tokenLen, int64_t* duration, char* unit); typedef struct SInterval {
char intervalUnit;
char slidingUnit;
char offsetUnit;
int64_t interval;
int64_t sliding;
int64_t offset;
} SInterval;
int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision);
int64_t taosTimeTruncate(int64_t t, const SInterval* pInterval, int32_t precision);
int32_t taosTimeCountInterval(int64_t skey, int64_t ekey, int64_t interval, char unit, int32_t precision);
int32_t parseAbsoluteDuration(char* token, int32_t tokenlen, int64_t* ts);
int32_t parseNatualDuration(const char* token, int32_t tokenLen, int64_t* duration, char* unit);
int32_t taosParseTime(char* timestr, int64_t* time, int32_t len, int32_t timePrec, int8_t dayligth); int32_t taosParseTime(char* timestr, int64_t* time, int32_t len, int32_t timePrec, int8_t dayligth);
void deltaToUtcInitOnce(); void deltaToUtcInitOnce();
......
...@@ -321,7 +321,7 @@ int32_t parseLocaltimeWithDst(char* timestr, int64_t* time, int32_t timePrec) { ...@@ -321,7 +321,7 @@ int32_t parseLocaltimeWithDst(char* timestr, int64_t* time, int32_t timePrec) {
} }
static int32_t getTimestampInUsFromStrImpl(int64_t val, char unit, int64_t* result) { static int32_t getDurationInUs(int64_t val, char unit, int64_t* result) {
*result = val; *result = val;
int64_t factor = 1000L; int64_t factor = 1000L;
...@@ -342,19 +342,12 @@ static int32_t getTimestampInUsFromStrImpl(int64_t val, char unit, int64_t* resu ...@@ -342,19 +342,12 @@ static int32_t getTimestampInUsFromStrImpl(int64_t val, char unit, int64_t* resu
case 'w': case 'w':
(*result) *= MILLISECOND_PER_WEEK*factor; (*result) *= MILLISECOND_PER_WEEK*factor;
break; break;
case 'n':
(*result) *= MILLISECOND_PER_MONTH*factor;
break;
case 'y':
(*result) *= MILLISECOND_PER_YEAR*factor;
break;
case 'a': case 'a':
(*result) *= factor; (*result) *= factor;
break; break;
case 'u': case 'u':
break; break;
default: { default: {
;
return -1; return -1;
} }
} }
...@@ -373,7 +366,7 @@ static int32_t getTimestampInUsFromStrImpl(int64_t val, char unit, int64_t* resu ...@@ -373,7 +366,7 @@ static int32_t getTimestampInUsFromStrImpl(int64_t val, char unit, int64_t* resu
* n - Months (30 days) * n - Months (30 days)
* y - Years (365 days) * y - Years (365 days)
*/ */
int32_t getTimestampInUsFromStr(char* token, int32_t tokenlen, int64_t* ts) { int32_t parseAbsoluteDuration(char* token, int32_t tokenlen, int64_t* duration) {
errno = 0; errno = 0;
char* endPtr = NULL; char* endPtr = NULL;
...@@ -383,10 +376,16 @@ int32_t getTimestampInUsFromStr(char* token, int32_t tokenlen, int64_t* ts) { ...@@ -383,10 +376,16 @@ int32_t getTimestampInUsFromStr(char* token, int32_t tokenlen, int64_t* ts) {
return -1; return -1;
} }
return getTimestampInUsFromStrImpl(timestamp, token[tokenlen - 1], ts); /* natual month/year are not allowed in absolute duration */
char unit = token[tokenlen - 1];
if (unit == 'n' || unit == 'y') {
return -1;
}
return getDurationInUs(timestamp, unit, duration);
} }
int32_t parseDuration(const char* token, int32_t tokenLen, int64_t* duration, char* unit) { int32_t parseNatualDuration(const char* token, int32_t tokenLen, int64_t* duration, char* unit) {
errno = 0; errno = 0;
/* get the basic numeric value */ /* get the basic numeric value */
...@@ -400,7 +399,121 @@ int32_t parseDuration(const char* token, int32_t tokenLen, int64_t* duration, ch ...@@ -400,7 +399,121 @@ int32_t parseDuration(const char* token, int32_t tokenLen, int64_t* duration, ch
return 0; return 0;
} }
return getTimestampInUsFromStrImpl(*duration, *unit, duration); return getDurationInUs(*duration, *unit, duration);
}
int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision) {
if (duration == 0) {
return t;
}
if (unit == 'y') {
duration *= 12;
} else if (unit != 'n') {
return t + duration;
}
struct tm tm;
time_t tt = (time_t)(t / TSDB_TICK_PER_SECOND(precision));
localtime_r(&tt, &tm);
int mon = tm.tm_year * 12 + tm.tm_mon + (int)duration;
tm.tm_year = mon / 12;
tm.tm_mon = mon % 12;
return (int64_t)(mktime(&tm) * TSDB_TICK_PER_SECOND(precision));
}
int32_t taosTimeCountInterval(int64_t skey, int64_t ekey, int64_t interval, char unit, int32_t precision) {
if (ekey < skey) {
int64_t tmp = ekey;
ekey = skey;
skey = tmp;
}
if (unit != 'n' && unit != 'y') {
return (int32_t)((ekey - skey) / interval);
}
skey /= (int64_t)(TSDB_TICK_PER_SECOND(precision));
ekey /= (int64_t)(TSDB_TICK_PER_SECOND(precision));
struct tm tm;
time_t t = (time_t)skey;
localtime_r(&t, &tm);
int smon = tm.tm_year * 12 + tm.tm_mon;
t = (time_t)ekey;
localtime_r(&t, &tm);
int emon = tm.tm_year * 12 + tm.tm_mon;
if (unit == 'y') {
interval *= 12;
}
return (emon - smon) / (int32_t)interval;
}
int64_t taosTimeTruncate(int64_t t, const SInterval* pInterval, int32_t precision) {
if (pInterval->sliding == 0) {
assert(pInterval->interval == 0);
return t;
}
int64_t start = t;
if (pInterval->slidingUnit == 'n' || pInterval->slidingUnit == 'y') {
start /= (int64_t)(TSDB_TICK_PER_SECOND(precision));
struct tm tm;
time_t tt = (time_t)start;
localtime_r(&tt, &tm);
tm.tm_sec = 0;
tm.tm_min = 0;
tm.tm_hour = 0;
tm.tm_mday = 1;
if (pInterval->slidingUnit == 'y') {
tm.tm_mon = 0;
tm.tm_year = (int)(tm.tm_year / pInterval->sliding * pInterval->sliding);
} else {
int mon = tm.tm_year * 12 + tm.tm_mon;
mon = (int)(mon / pInterval->sliding * pInterval->sliding);
tm.tm_year = mon / 12;
tm.tm_mon = mon % 12;
}
start = (int64_t)(mktime(&tm) * TSDB_TICK_PER_SECOND(precision));
} else {
int64_t delta = t - pInterval->interval;
int32_t factor = delta > 0 ? 1 : -1;
start = (delta / pInterval->sliding + factor) * pInterval->sliding;
if (pInterval->intervalUnit == 'd' || pInterval->intervalUnit == 'w') {
/*
* here we revised the start time of day according to the local time zone,
* but in case of DST, the start time of one day need to be dynamically decided.
*/
// todo refactor to extract function that is available for Linux/Windows/Mac platform
#if defined(WINDOWS) && _MSC_VER >= 1900
// see https://docs.microsoft.com/en-us/cpp/c-runtime-library/daylight-dstbias-timezone-and-tzname?view=vs-2019
int64_t timezone = _timezone;
int32_t daylight = _daylight;
char** tzname = _tzname;
#endif
start += (int64_t)(timezone * TSDB_TICK_PER_SECOND(precision));
}
int64_t end = start + pInterval->interval - 1;
if (end < t) {
start += pInterval->sliding;
}
}
if (pInterval->offset > 0) {
start = taosTimeAdd(start, pInterval->offset, pInterval->offsetUnit, precision);
if (start > t) {
start = taosTimeAdd(start, -pInterval->interval, pInterval->intervalUnit, precision);
}
}
return start;
} }
// internal function, when program is paused in debugger, // internal function, when program is paused in debugger,
...@@ -411,24 +524,38 @@ int32_t parseDuration(const char* token, int32_t tokenLen, int64_t* duration, ch ...@@ -411,24 +524,38 @@ int32_t parseDuration(const char* token, int32_t tokenLen, int64_t* duration, ch
// 2020-07-03 17:48:42 // 2020-07-03 17:48:42
// and the parameter can also be a variable. // and the parameter can also be a variable.
const char* fmtts(int64_t ts) { const char* fmtts(int64_t ts) {
static char buf[32]; static char buf[96];
size_t pos = 0;
struct tm tm;
time_t tt;
if (ts > -62135625943 && ts < 32503651200) { if (ts > -62135625943 && ts < 32503651200) {
tt = ts; time_t t = (time_t)ts;
} else if (ts > -62135625943000 && ts < 32503651200000) { localtime_r(&t, &tm);
tt = ts / 1000; pos += strftime(buf + pos, sizeof(buf), "s=%Y-%m-%d %H:%M:%S", &tm);
} else {
tt = ts / 1000000;
} }
struct tm* ptm = localtime(&tt); if (ts > -62135625943000 && ts < 32503651200000) {
size_t pos = strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", ptm); time_t t = (time_t)(ts / 1000);
localtime_r(&t, &tm);
if (pos > 0) {
buf[pos++] = ' ';
buf[pos++] = '|';
buf[pos++] = ' ';
}
pos += strftime(buf + pos, sizeof(buf), "ms=%Y-%m-%d %H:%M:%S", &tm);
pos += sprintf(buf + pos, ".%03d", (int)(ts % 1000));
}
if (ts <= -62135625943000 || ts >= 32503651200000) { {
sprintf(buf + pos, ".%06d", (int)(ts % 1000000)); time_t t = (time_t)(ts / 1000000);
} else if (ts <= -62135625943 || ts >= 32503651200) { localtime_r(&t, &tm);
sprintf(buf + pos, ".%03d", (int)(ts % 1000)); if (pos > 0) {
buf[pos++] = ' ';
buf[pos++] = '|';
buf[pos++] = ' ';
}
pos += strftime(buf + pos, sizeof(buf), "us=%Y-%m-%d %H:%M:%S", &tm);
pos += sprintf(buf + pos, ".%06d", (int)(ts % 1000000));
} }
return buf; return buf;
......
...@@ -230,4 +230,5 @@ void httpCloseContextByServer(HttpContext *pContext) { ...@@ -230,4 +230,5 @@ void httpCloseContextByServer(HttpContext *pContext) {
pContext->parsed = false; pContext->parsed = false;
httpRemoveContextFromEpoll(pContext); httpRemoveContextFromEpoll(pContext);
httpReleaseContext(pContext, true);
} }
...@@ -132,12 +132,9 @@ typedef struct SQueryCostInfo { ...@@ -132,12 +132,9 @@ typedef struct SQueryCostInfo {
typedef struct SQuery { typedef struct SQuery {
int16_t numOfCols; int16_t numOfCols;
int16_t numOfTags; int16_t numOfTags;
char intervalTimeUnit;
char slidingTimeUnit; // interval data type, used for daytime revise
SOrderVal order; SOrderVal order;
STimeWindow window; STimeWindow window;
int64_t intervalTime; SInterval interval;
int64_t slidingTime; // sliding time for sliding window query
int16_t precision; int16_t precision;
int16_t numOfOutput; int16_t numOfOutput;
int16_t fillType; int16_t fillType;
......
...@@ -51,12 +51,11 @@ typedef struct SFillInfo { ...@@ -51,12 +51,11 @@ typedef struct SFillInfo {
int32_t rowSize; // size of each row int32_t rowSize; // size of each row
// char ** pTags; // tags value for current interpolation // char ** pTags; // tags value for current interpolation
SFillTagColInfo* pTags; // tags value for filling gap SFillTagColInfo* pTags; // tags value for filling gap
int64_t slidingTime; // sliding value to determine the number of result for a given time window SInterval interval;
char * prevValues; // previous row of data, to generate the interpolation results char * prevValues; // previous row of data, to generate the interpolation results
char * nextValues; // next row of data char * nextValues; // next row of data
char** pData; // original result data block involved in filling data char** pData; // original result data block involved in filling data
int32_t capacityInRows; // data buffer size in rows int32_t capacityInRows; // data buffer size in rows
int8_t slidingUnit; // sliding time unit
int8_t precision; // time resoluation int8_t precision; // time resoluation
SFillColInfo* pFillCol; // column info for fill operations SFillColInfo* pFillCol; // column info for fill operations
} SFillInfo; } SFillInfo;
......
...@@ -73,12 +73,11 @@ typedef struct SDiskbasedResultBuf { ...@@ -73,12 +73,11 @@ typedef struct SDiskbasedResultBuf {
bool comp; // compressed before flushed to disk bool comp; // compressed before flushed to disk
int32_t nextPos; // next page flush position int32_t nextPos; // next page flush position
const void* handle; // for debug purpose const void* handle; // for debug purpose
SResultBufStatis statis; SResultBufStatis statis;
} SDiskbasedResultBuf; } SDiskbasedResultBuf;
#define DEFAULT_INTERN_BUF_PAGE_SIZE (4096L) #define DEFAULT_INTERN_BUF_PAGE_SIZE (256L) // in bytes
#define DEFAULT_INMEM_BUF_PAGES 10
#define PAGE_INFO_INITIALIZER (SPageDiskInfo){-1, -1} #define PAGE_INFO_INITIALIZER (SPageDiskInfo){-1, -1}
/** /**
......
...@@ -65,6 +65,11 @@ typedef struct tVariantList { ...@@ -65,6 +65,11 @@ typedef struct tVariantList {
tVariantListItem *a; /* One entry for each expression */ tVariantListItem *a; /* One entry for each expression */
} tVariantList; } tVariantList;
typedef struct SIntervalVal {
SStrToken interval;
SStrToken offset;
} SIntervalVal;
typedef struct SQuerySQL { typedef struct SQuerySQL {
struct tSQLExprList *pSelection; // select clause struct tSQLExprList *pSelection; // select clause
tVariantList * from; // from clause tVariantList * from; // from clause
...@@ -72,6 +77,7 @@ typedef struct SQuerySQL { ...@@ -72,6 +77,7 @@ typedef struct SQuerySQL {
tVariantList * pGroupby; // groupby clause, only for tags[optional] tVariantList * pGroupby; // groupby clause, only for tags[optional]
tVariantList * pSortOrder; // orderby [optional] tVariantList * pSortOrder; // orderby [optional]
SStrToken interval; // interval [optional] SStrToken interval; // interval [optional]
SStrToken offset; // offset window [optional]
SStrToken sliding; // sliding window [optional] SStrToken sliding; // sliding window [optional]
SLimitVal limit; // limit offset [optional] SLimitVal limit; // limit offset [optional]
SLimitVal slimit; // group limit offset [optional] SLimitVal slimit; // group limit offset [optional]
...@@ -259,7 +265,7 @@ tSQLExprList *tSQLExprListAppend(tSQLExprList *pList, tSQLExpr *pNode, SStrToken ...@@ -259,7 +265,7 @@ tSQLExprList *tSQLExprListAppend(tSQLExprList *pList, tSQLExpr *pNode, SStrToken
void tSQLExprListDestroy(tSQLExprList *pList); void tSQLExprListDestroy(tSQLExprList *pList);
SQuerySQL *tSetQuerySQLElems(SStrToken *pSelectToken, tSQLExprList *pSelection, tVariantList *pFrom, tSQLExpr *pWhere, SQuerySQL *tSetQuerySQLElems(SStrToken *pSelectToken, tSQLExprList *pSelection, tVariantList *pFrom, tSQLExpr *pWhere,
tVariantList *pGroupby, tVariantList *pSortOrder, SStrToken *pInterval, tVariantList *pGroupby, tVariantList *pSortOrder, SIntervalVal *pInterval,
SStrToken *pSliding, tVariantList *pFill, SLimitVal *pLimit, SLimitVal *pGLimit); SStrToken *pSliding, tVariantList *pFill, SLimitVal *pLimit, SLimitVal *pGLimit);
SCreateTableSQL *tSetCreateSQLElems(tFieldList *pCols, tFieldList *pTags, SStrToken *pMetricName, SCreateTableSQL *tSetCreateSQLElems(tFieldList *pCols, tFieldList *pTags, SStrToken *pMetricName,
......
...@@ -39,7 +39,6 @@ static FORCE_INLINE SWindowResult *getWindowResult(SWindowResInfo *pWindowResInf ...@@ -39,7 +39,6 @@ static FORCE_INLINE SWindowResult *getWindowResult(SWindowResInfo *pWindowResInf
} }
#define curTimeWindowIndex(_winres) ((_winres)->curIndex) #define curTimeWindowIndex(_winres) ((_winres)->curIndex)
#define GET_TIMEWINDOW(_winresInfo, _win) (STimeWindow) {(_win)->skey, ((_win)->skey + (_winresInfo)->interval - 1)}
#define GET_ROW_PARAM_FOR_MULTIOUTPUT(_q, tbq, sq) (((tbq) && (!sq))? (_q)->pSelectExpr[1].base.arg->argValue.i64:1) #define GET_ROW_PARAM_FOR_MULTIOUTPUT(_q, tbq, sq) (((tbq) && (!sq))? (_q)->pSelectExpr[1].base.arg->argValue.i64:1)
bool isWindowResClosed(SWindowResInfo *pWindowResInfo, int32_t slot); bool isWindowResClosed(SWindowResInfo *pWindowResInfo, int32_t slot);
......
...@@ -458,9 +458,10 @@ tablelist(A) ::= tablelist(Y) COMMA ids(X) cpxName(Z) ids(F). { ...@@ -458,9 +458,10 @@ tablelist(A) ::= tablelist(Y) COMMA ids(X) cpxName(Z) ids(F). {
%type tmvar {SStrToken} %type tmvar {SStrToken}
tmvar(A) ::= VARIABLE(X). {A = X;} tmvar(A) ::= VARIABLE(X). {A = X;}
%type interval_opt {SStrToken} %type interval_opt {SIntervalVal}
interval_opt(N) ::= INTERVAL LP tmvar(E) RP. {N = E; } interval_opt(N) ::= INTERVAL LP tmvar(E) RP. {N.interval = E; N.offset.n = 0; N.offset.z = NULL; N.offset.type = 0;}
interval_opt(N) ::= . {N.n = 0; N.z = NULL; N.type = 0; } interval_opt(N) ::= INTERVAL LP tmvar(E) COMMA tmvar(O) RP. {N.interval = E; N.offset = O;}
interval_opt(N) ::= . {memset(&N, 0, sizeof(N));}
%type fill_opt {tVariantList*} %type fill_opt {tVariantList*}
%destructor fill_opt {tVariantListDestroy($$);} %destructor fill_opt {tVariantListDestroy($$);}
......
...@@ -108,7 +108,7 @@ extern "C" { ...@@ -108,7 +108,7 @@ extern "C" {
#define GET_FORWARD_DIRECTION_FACTOR(ord) (((ord) == TSDB_ORDER_ASC) ? QUERY_ASC_FORWARD_STEP : QUERY_DESC_FORWARD_STEP) #define GET_FORWARD_DIRECTION_FACTOR(ord) (((ord) == TSDB_ORDER_ASC) ? QUERY_ASC_FORWARD_STEP : QUERY_DESC_FORWARD_STEP)
#define MAX_INTERVAL_TIME_WINDOW 10000000 #define MAX_INTERVAL_TIME_WINDOW 1000000 // maximum allowed time windows in final results
#define TOP_BOTTOM_QUERY_LIMIT 100 #define TOP_BOTTOM_QUERY_LIMIT 100
enum { enum {
......
...@@ -131,21 +131,21 @@ static UNUSED_FUNC void* u_realloc(void* p, size_t __size) { ...@@ -131,21 +131,21 @@ static UNUSED_FUNC void* u_realloc(void* p, size_t __size) {
static void setQueryStatus(SQuery *pQuery, int8_t status); static void setQueryStatus(SQuery *pQuery, int8_t status);
static void finalizeQueryResult(SQueryRuntimeEnv *pRuntimeEnv); static void finalizeQueryResult(SQueryRuntimeEnv *pRuntimeEnv);
#define QUERY_IS_INTERVAL_QUERY(_q) ((_q)->intervalTime > 0) #define QUERY_IS_INTERVAL_QUERY(_q) ((_q)->interval.interval > 0)
static void getNextTimeWindow(SQuery* pQuery, STimeWindow* tw) { static void getNextTimeWindow(SQuery* pQuery, STimeWindow* tw) {
int32_t factor = GET_FORWARD_DIRECTION_FACTOR(pQuery->order.order); int32_t factor = GET_FORWARD_DIRECTION_FACTOR(pQuery->order.order);
if (pQuery->intervalTimeUnit != 'n' && pQuery->intervalTimeUnit != 'y') { if (pQuery->interval.intervalUnit != 'n' && pQuery->interval.intervalUnit != 'y') {
tw->skey += pQuery->slidingTime * factor; tw->skey += pQuery->interval.sliding * factor;
tw->ekey = tw->skey + pQuery->intervalTime - 1; tw->ekey = tw->skey + pQuery->interval.interval - 1;
return; return;
} }
int64_t key = tw->skey / 1000, interval = pQuery->intervalTime; int64_t key = tw->skey / 1000, interval = pQuery->interval.interval;
if (pQuery->precision == TSDB_TIME_PRECISION_MICRO) { if (pQuery->precision == TSDB_TIME_PRECISION_MICRO) {
key /= 1000; key /= 1000;
} }
if (pQuery->intervalTimeUnit == 'y') { if (pQuery->interval.intervalUnit == 'y') {
interval *= 12; interval *= 12;
} }
...@@ -187,7 +187,7 @@ static void setExecParams(SQuery *pQuery, SQLFunctionCtx *pCtx, void* inputData, ...@@ -187,7 +187,7 @@ static void setExecParams(SQuery *pQuery, SQLFunctionCtx *pCtx, void* inputData,
SDataStatis *pStatis, void *param, int32_t colIndex); SDataStatis *pStatis, void *param, int32_t colIndex);
static void initCtxOutputBuf(SQueryRuntimeEnv *pRuntimeEnv); static void initCtxOutputBuf(SQueryRuntimeEnv *pRuntimeEnv);
static void destroyTableQueryInfo(STableQueryInfo *pTableQueryInfo); static void destroyTableQueryInfoImpl(STableQueryInfo *pTableQueryInfo);
static void resetCtxOutputBuf(SQueryRuntimeEnv *pRuntimeEnv); static void resetCtxOutputBuf(SQueryRuntimeEnv *pRuntimeEnv);
static bool hasMainOutput(SQuery *pQuery); static bool hasMainOutput(SQuery *pQuery);
static void buildTagQueryResult(SQInfo *pQInfo); static void buildTagQueryResult(SQInfo *pQInfo);
...@@ -510,10 +510,10 @@ static STimeWindow getActiveTimeWindow(SWindowResInfo *pWindowResInfo, int64_t t ...@@ -510,10 +510,10 @@ static STimeWindow getActiveTimeWindow(SWindowResInfo *pWindowResInfo, int64_t t
if (pWindowResInfo->curIndex == -1) { // the first window, from the previous stored value if (pWindowResInfo->curIndex == -1) { // the first window, from the previous stored value
w.skey = pWindowResInfo->prevSKey; w.skey = pWindowResInfo->prevSKey;
if (pQuery->intervalTimeUnit == 'n' || pQuery->intervalTimeUnit == 'y') { if (pQuery->interval.intervalUnit == 'n' || pQuery->interval.intervalUnit == 'y') {
w.ekey = taosAddNatualInterval(w.skey, pQuery->intervalTime, pQuery->intervalTimeUnit, pQuery->precision) - 1; w.ekey = taosTimeAdd(w.skey, pQuery->interval.interval, pQuery->interval.intervalUnit, pQuery->precision);
} else { } else {
w.ekey = w.skey + pQuery->intervalTime - 1; w.ekey = w.skey + pQuery->interval.interval - 1;
} }
} else { } else {
int32_t slot = curTimeWindowIndex(pWindowResInfo); int32_t slot = curTimeWindowIndex(pWindowResInfo);
...@@ -522,23 +522,23 @@ static STimeWindow getActiveTimeWindow(SWindowResInfo *pWindowResInfo, int64_t t ...@@ -522,23 +522,23 @@ static STimeWindow getActiveTimeWindow(SWindowResInfo *pWindowResInfo, int64_t t
} }
if (w.skey > ts || w.ekey < ts) { if (w.skey > ts || w.ekey < ts) {
if (pQuery->intervalTimeUnit == 'n' || pQuery->intervalTimeUnit == 'y') { if (pQuery->interval.intervalUnit == 'n' || pQuery->interval.intervalUnit == 'y') {
w.skey = taosGetIntervalStartTimestamp(ts, pQuery->slidingTime, pQuery->intervalTime, pQuery->intervalTimeUnit, pQuery->precision); w.skey = taosTimeTruncate(ts, &pQuery->interval, pQuery->precision);
w.ekey = taosAddNatualInterval(w.skey, pQuery->intervalTime, pQuery->intervalTimeUnit, pQuery->precision) - 1; w.ekey = taosTimeAdd(w.skey, pQuery->interval.interval, pQuery->interval.intervalUnit, pQuery->precision) - 1;
} else { } else {
int64_t st = w.skey; int64_t st = w.skey;
if (st > ts) { if (st > ts) {
st -= ((st - ts + pQuery->slidingTime - 1) / pQuery->slidingTime) * pQuery->slidingTime; st -= ((st - ts + pQuery->interval.sliding - 1) / pQuery->interval.sliding) * pQuery->interval.sliding;
} }
int64_t et = st + pQuery->intervalTime - 1; int64_t et = st + pQuery->interval.interval - 1;
if (et < ts) { if (et < ts) {
st += ((ts - et + pQuery->slidingTime - 1) / pQuery->slidingTime) * pQuery->slidingTime; st += ((ts - et + pQuery->interval.sliding - 1) / pQuery->interval.sliding) * pQuery->interval.sliding;
} }
w.skey = st; w.skey = st;
w.ekey = w.skey + pQuery->intervalTime - 1; w.ekey = w.skey + pQuery->interval.interval - 1;
} }
} }
...@@ -550,8 +550,6 @@ static STimeWindow getActiveTimeWindow(SWindowResInfo *pWindowResInfo, int64_t t ...@@ -550,8 +550,6 @@ static STimeWindow getActiveTimeWindow(SWindowResInfo *pWindowResInfo, int64_t t
w.ekey = pQuery->window.ekey; w.ekey = pQuery->window.ekey;
} }
assert(ts >= w.skey && ts <= w.ekey);
return w; return w;
} }
...@@ -784,6 +782,8 @@ static void doBlockwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, bool closed ...@@ -784,6 +782,8 @@ static void doBlockwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, bool closed
SQuery * pQuery = pRuntimeEnv->pQuery; SQuery * pQuery = pRuntimeEnv->pQuery;
SQLFunctionCtx *pCtx = pRuntimeEnv->pCtx; SQLFunctionCtx *pCtx = pRuntimeEnv->pCtx;
bool hasPrev = pCtx[0].preAggVals.isSet;
if (IS_MASTER_SCAN(pRuntimeEnv) || closed) { if (IS_MASTER_SCAN(pRuntimeEnv) || closed) {
for (int32_t k = 0; k < pQuery->numOfOutput; ++k) { for (int32_t k = 0; k < pQuery->numOfOutput; ++k) {
pCtx[k].nStartQueryTimestamp = pWin->skey; pCtx[k].nStartQueryTimestamp = pWin->skey;
...@@ -796,11 +796,17 @@ static void doBlockwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, bool closed ...@@ -796,11 +796,17 @@ static void doBlockwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, bool closed
} }
// not a whole block involved in query processing, statistics data can not be used // not a whole block involved in query processing, statistics data can not be used
pCtx[k].preAggVals.isSet = (forwardStep == numOfTotal); // NOTE: the original value of isSet have been changed here
if (pCtx[k].preAggVals.isSet && forwardStep < numOfTotal) {
pCtx[k].preAggVals.isSet = false;
}
if (functionNeedToExecute(pRuntimeEnv, &pCtx[k], functionId)) { if (functionNeedToExecute(pRuntimeEnv, &pCtx[k], functionId)) {
aAggs[functionId].xFunction(&pCtx[k]); aAggs[functionId].xFunction(&pCtx[k]);
} }
// restore it
pCtx[k].preAggVals.isSet = hasPrev;
} }
} }
} }
...@@ -848,7 +854,7 @@ static int32_t getNextQualifiedWindow(SQueryRuntimeEnv *pRuntimeEnv, STimeWindow ...@@ -848,7 +854,7 @@ static int32_t getNextQualifiedWindow(SQueryRuntimeEnv *pRuntimeEnv, STimeWindow
int32_t startPos = 0; int32_t startPos = 0;
// tumbling time window query, a special case of sliding time window query // tumbling time window query, a special case of sliding time window query
if (pQuery->slidingTime == pQuery->intervalTime && prevPosition != -1) { if (pQuery->interval.sliding == pQuery->interval.interval && prevPosition != -1) {
int32_t factor = GET_FORWARD_DIRECTION_FACTOR(pQuery->order.order); int32_t factor = GET_FORWARD_DIRECTION_FACTOR(pQuery->order.order);
startPos = prevPosition + factor; startPos = prevPosition + factor;
} else { } else {
...@@ -861,21 +867,21 @@ static int32_t getNextQualifiedWindow(SQueryRuntimeEnv *pRuntimeEnv, STimeWindow ...@@ -861,21 +867,21 @@ static int32_t getNextQualifiedWindow(SQueryRuntimeEnv *pRuntimeEnv, STimeWindow
*/ */
if (QUERY_IS_ASC_QUERY(pQuery) && primaryKeys[startPos] > pNext->ekey) { if (QUERY_IS_ASC_QUERY(pQuery) && primaryKeys[startPos] > pNext->ekey) {
TSKEY next = primaryKeys[startPos]; TSKEY next = primaryKeys[startPos];
if (pQuery->intervalTimeUnit == 'n' || pQuery->intervalTimeUnit == 'y') { if (pQuery->interval.intervalUnit == 'n' || pQuery->interval.intervalUnit == 'y') {
pNext->skey = taosGetIntervalStartTimestamp(next, pQuery->slidingTime, pQuery->intervalTime, pQuery->intervalTimeUnit, pQuery->precision); pNext->skey = taosTimeTruncate(next, &pQuery->interval, pQuery->precision);
pNext->ekey = taosAddNatualInterval(pNext->skey, pQuery->intervalTime, pQuery->intervalTimeUnit, pQuery->precision) - 1; pNext->ekey = taosTimeAdd(pNext->skey, pQuery->interval.interval, pQuery->interval.intervalUnit, pQuery->precision) - 1;
} else { } else {
pNext->ekey += ((next - pNext->ekey + pQuery->slidingTime - 1)/pQuery->slidingTime) * pQuery->slidingTime; pNext->ekey += ((next - pNext->ekey + pQuery->interval.sliding - 1)/pQuery->interval.sliding) * pQuery->interval.sliding;
pNext->skey = pNext->ekey - pQuery->intervalTime + 1; pNext->skey = pNext->ekey - pQuery->interval.interval + 1;
} }
} else if ((!QUERY_IS_ASC_QUERY(pQuery)) && primaryKeys[startPos] < pNext->skey) { } else if ((!QUERY_IS_ASC_QUERY(pQuery)) && primaryKeys[startPos] < pNext->skey) {
TSKEY next = primaryKeys[startPos]; TSKEY next = primaryKeys[startPos];
if (pQuery->intervalTimeUnit == 'n' || pQuery->intervalTimeUnit == 'y') { if (pQuery->interval.intervalUnit == 'n' || pQuery->interval.intervalUnit == 'y') {
pNext->skey = taosGetIntervalStartTimestamp(next, pQuery->slidingTime, pQuery->intervalTime, pQuery->intervalTimeUnit, pQuery->precision); pNext->skey = taosTimeTruncate(next, &pQuery->interval, pQuery->precision);
pNext->ekey = taosAddNatualInterval(pNext->skey, pQuery->intervalTime, pQuery->intervalTimeUnit, pQuery->precision) - 1; pNext->ekey = taosTimeAdd(pNext->skey, pQuery->interval.interval, pQuery->interval.intervalUnit, pQuery->precision) - 1;
} else { } else {
pNext->skey -= ((pNext->skey - next + pQuery->slidingTime - 1) / pQuery->slidingTime) * pQuery->slidingTime; pNext->skey -= ((pNext->skey - next + pQuery->interval.sliding - 1) / pQuery->interval.sliding) * pQuery->interval.sliding;
pNext->ekey = pNext->skey + pQuery->intervalTime - 1; pNext->ekey = pNext->skey + pQuery->interval.interval - 1;
} }
} }
...@@ -1871,20 +1877,20 @@ static bool onlyQueryTags(SQuery* pQuery) { ...@@ -1871,20 +1877,20 @@ static bool onlyQueryTags(SQuery* pQuery) {
///////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////
void getAlignQueryTimeWindow(SQuery *pQuery, int64_t key, int64_t keyFirst, int64_t keyLast, STimeWindow *win) { void getAlignQueryTimeWindow(SQuery *pQuery, int64_t key, int64_t keyFirst, int64_t keyLast, STimeWindow *win) {
assert(key >= keyFirst && key <= keyLast && pQuery->slidingTime <= pQuery->intervalTime); assert(key >= keyFirst && key <= keyLast && pQuery->interval.sliding <= pQuery->interval.interval);
win->skey = taosGetIntervalStartTimestamp(key, pQuery->slidingTime, pQuery->intervalTime, pQuery->slidingTimeUnit, pQuery->precision); win->skey = taosTimeTruncate(key, &pQuery->interval, pQuery->precision);
/* /*
* if the realSkey > INT64_MAX - pQuery->intervalTime, the query duration between * if the realSkey > INT64_MAX - pQuery->interval.interval, the query duration between
* realSkey and realEkey must be less than one interval.Therefore, no need to adjust the query ranges. * realSkey and realEkey must be less than one interval.Therefore, no need to adjust the query ranges.
*/ */
if (keyFirst > (INT64_MAX - pQuery->intervalTime)) { if (keyFirst > (INT64_MAX - pQuery->interval.interval)) {
assert(keyLast - keyFirst < pQuery->intervalTime); assert(keyLast - keyFirst < pQuery->interval.interval);
win->ekey = INT64_MAX; win->ekey = INT64_MAX;
} else if (pQuery->intervalTimeUnit == 'n' || pQuery->intervalTimeUnit == 'y') { } else if (pQuery->interval.intervalUnit == 'n' || pQuery->interval.intervalUnit == 'y') {
win->ekey = taosAddNatualInterval(win->skey, pQuery->intervalTime, pQuery->intervalTimeUnit, pQuery->precision) - 1; win->ekey = taosTimeAdd(win->skey, pQuery->interval.interval, pQuery->interval.intervalUnit, pQuery->precision) - 1;
} else { } else {
win->ekey = win->skey + pQuery->intervalTime - 1; win->ekey = win->skey + pQuery->interval.interval - 1;
} }
} }
...@@ -1977,8 +1983,7 @@ static void changeExecuteScanOrder(SQInfo *pQInfo, SQueryTableMsg* pQueryMsg, bo ...@@ -1977,8 +1983,7 @@ static void changeExecuteScanOrder(SQInfo *pQInfo, SQueryTableMsg* pQueryMsg, bo
// todo handle the case the the order irrelevant query type mixed up with order critical query type // todo handle the case the the order irrelevant query type mixed up with order critical query type
// descending order query for last_row query // descending order query for last_row query
if (isFirstLastRowQuery(pQuery)) { if (isFirstLastRowQuery(pQuery)) {
qDebug("QInfo:%p scan order changed for last_row query, old:%d, new:%d", GET_QINFO_ADDR(pQuery), qDebug("QInfo:%p scan order changed for last_row query, old:%d, new:%d", pQInfo, pQuery->order.order, TSDB_ORDER_ASC);
pQuery->order.order, TSDB_ORDER_ASC);
pQuery->order.order = TSDB_ORDER_ASC; pQuery->order.order = TSDB_ORDER_ASC;
if (pQuery->window.skey > pQuery->window.ekey) { if (pQuery->window.skey > pQuery->window.ekey) {
...@@ -1998,7 +2003,7 @@ static void changeExecuteScanOrder(SQInfo *pQInfo, SQueryTableMsg* pQueryMsg, bo ...@@ -1998,7 +2003,7 @@ static void changeExecuteScanOrder(SQInfo *pQInfo, SQueryTableMsg* pQueryMsg, bo
return; return;
} }
if (isPointInterpoQuery(pQuery) && pQuery->intervalTime == 0) { if (isPointInterpoQuery(pQuery) && pQuery->interval.interval == 0) {
if (!QUERY_IS_ASC_QUERY(pQuery)) { if (!QUERY_IS_ASC_QUERY(pQuery)) {
qDebug(msg, GET_QINFO_ADDR(pQuery), "interp", pQuery->order.order, TSDB_ORDER_ASC, pQuery->window.skey, qDebug(msg, GET_QINFO_ADDR(pQuery), "interp", pQuery->order.order, TSDB_ORDER_ASC, pQuery->window.skey,
pQuery->window.ekey, pQuery->window.ekey, pQuery->window.skey); pQuery->window.ekey, pQuery->window.ekey, pQuery->window.skey);
...@@ -2009,7 +2014,7 @@ static void changeExecuteScanOrder(SQInfo *pQInfo, SQueryTableMsg* pQueryMsg, bo ...@@ -2009,7 +2014,7 @@ static void changeExecuteScanOrder(SQInfo *pQInfo, SQueryTableMsg* pQueryMsg, bo
return; return;
} }
if (pQuery->intervalTime == 0) { if (pQuery->interval.interval == 0) {
if (onlyFirstQuery(pQuery)) { if (onlyFirstQuery(pQuery)) {
if (!QUERY_IS_ASC_QUERY(pQuery)) { if (!QUERY_IS_ASC_QUERY(pQuery)) {
qDebug(msg, GET_QINFO_ADDR(pQuery), "only-first", pQuery->order.order, TSDB_ORDER_ASC, pQuery->window.skey, qDebug(msg, GET_QINFO_ADDR(pQuery), "only-first", pQuery->order.order, TSDB_ORDER_ASC, pQuery->window.skey,
...@@ -2080,13 +2085,14 @@ static int32_t getInitialPageNum(SQInfo *pQInfo) { ...@@ -2080,13 +2085,14 @@ static int32_t getInitialPageNum(SQInfo *pQInfo) {
static void getIntermediateBufInfo(SQueryRuntimeEnv* pRuntimeEnv, int32_t* ps, int32_t* rowsize) { static void getIntermediateBufInfo(SQueryRuntimeEnv* pRuntimeEnv, int32_t* ps, int32_t* rowsize) {
SQuery* pQuery = pRuntimeEnv->pQuery; SQuery* pQuery = pRuntimeEnv->pQuery;
int32_t MIN_ROWS_PER_PAGE = 4;
*rowsize = (int32_t)(pQuery->rowSize * GET_ROW_PARAM_FOR_MULTIOUTPUT(pQuery, pRuntimeEnv->topBotQuery, pRuntimeEnv->stableQuery)); *rowsize = (int32_t)(pQuery->rowSize * GET_ROW_PARAM_FOR_MULTIOUTPUT(pQuery, pRuntimeEnv->topBotQuery, pRuntimeEnv->stableQuery));
int32_t overhead = sizeof(tFilePage); int32_t overhead = sizeof(tFilePage);
// one page contains at least two rows // one page contains at least two rows
*ps = DEFAULT_INTERN_BUF_PAGE_SIZE; *ps = DEFAULT_INTERN_BUF_PAGE_SIZE;
while(((*rowsize) * 2) > (*ps) - overhead) { while(((*rowsize) * MIN_ROWS_PER_PAGE) > (*ps) - overhead) {
*ps = (*ps << 1u); *ps = (*ps << 1u);
} }
...@@ -2836,6 +2842,7 @@ void copyResToQueryResultBuf(SQInfo *pQInfo, SQuery *pQuery) { ...@@ -2836,6 +2842,7 @@ void copyResToQueryResultBuf(SQInfo *pQInfo, SQuery *pQuery) {
// all results have been return to client, try next group // all results have been return to client, try next group
if (pGroupResInfo->pos.pageId == pGroupResInfo->numOfDataPages) { if (pGroupResInfo->pos.pageId == pGroupResInfo->numOfDataPages) {
pGroupResInfo->numOfDataPages = 0; pGroupResInfo->numOfDataPages = 0;
pGroupResInfo->pos.pageId = 0;
pGroupResInfo->pos.rowId = 0; pGroupResInfo->pos.rowId = 0;
// current results of group has been sent to client, try next group // current results of group has been sent to client, try next group
...@@ -3708,7 +3715,7 @@ static STableQueryInfo *createTableQueryInfo(SQueryRuntimeEnv *pRuntimeEnv, void ...@@ -3708,7 +3715,7 @@ static STableQueryInfo *createTableQueryInfo(SQueryRuntimeEnv *pRuntimeEnv, void
return pTableQueryInfo; return pTableQueryInfo;
} }
void destroyTableQueryInfo(STableQueryInfo *pTableQueryInfo) { void destroyTableQueryInfoImpl(STableQueryInfo *pTableQueryInfo) {
if (pTableQueryInfo == NULL) { if (pTableQueryInfo == NULL) {
return; return;
} }
...@@ -4268,8 +4275,8 @@ static bool skipTimeInterval(SQueryRuntimeEnv *pRuntimeEnv, TSKEY* start) { ...@@ -4268,8 +4275,8 @@ static bool skipTimeInterval(SQueryRuntimeEnv *pRuntimeEnv, TSKEY* start) {
} }
/* /*
* 1. for interval without interpolation query we forward pQuery->intervalTime at a time for * 1. for interval without interpolation query we forward pQuery->interval.interval at a time for
* pQuery->limit.offset times. Since hole exists, pQuery->intervalTime*pQuery->limit.offset value is * pQuery->limit.offset times. Since hole exists, pQuery->interval.interval*pQuery->limit.offset value is
* not valid. otherwise, we only forward pQuery->limit.offset number of points * not valid. otherwise, we only forward pQuery->limit.offset number of points
*/ */
assert(pRuntimeEnv->windowResInfo.prevSKey == TSKEY_INITIAL_VAL); assert(pRuntimeEnv->windowResInfo.prevSKey == TSKEY_INITIAL_VAL);
...@@ -4384,6 +4391,8 @@ static bool skipTimeInterval(SQueryRuntimeEnv *pRuntimeEnv, TSKEY* start) { ...@@ -4384,6 +4391,8 @@ static bool skipTimeInterval(SQueryRuntimeEnv *pRuntimeEnv, TSKEY* start) {
return true; return true;
} }
static void doDestroyTableQueryInfo(STableGroupInfo* pTableqinfoGroupInfo);
static int32_t setupQueryHandle(void* tsdb, SQInfo* pQInfo, bool isSTableQuery) { static int32_t setupQueryHandle(void* tsdb, SQInfo* pQInfo, bool isSTableQuery) {
SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->runtimeEnv; SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->runtimeEnv;
SQuery *pQuery = pQInfo->runtimeEnv.pQuery; SQuery *pQuery = pQInfo->runtimeEnv.pQuery;
...@@ -4423,16 +4432,20 @@ static int32_t setupQueryHandle(void* tsdb, SQInfo* pQInfo, bool isSTableQuery) ...@@ -4423,16 +4432,20 @@ static int32_t setupQueryHandle(void* tsdb, SQInfo* pQInfo, bool isSTableQuery)
// update the query time window // update the query time window
pQuery->window = cond.twindow; pQuery->window = cond.twindow;
size_t numOfGroups = GET_NUM_OF_TABLEGROUP(pQInfo); if (pQInfo->tableGroupInfo.numOfTables == 0) {
for(int32_t i = 0; i < numOfGroups; ++i) { pQInfo->tableqinfoGroupInfo.numOfTables = 0;
SArray *group = GET_TABLEGROUP(pQInfo, i); } else {
size_t numOfGroups = GET_NUM_OF_TABLEGROUP(pQInfo);
for(int32_t i = 0; i < numOfGroups; ++i) {
SArray *group = GET_TABLEGROUP(pQInfo, i);
size_t t = taosArrayGetSize(group); size_t t = taosArrayGetSize(group);
for (int32_t j = 0; j < t; ++j) { for (int32_t j = 0; j < t; ++j) {
STableQueryInfo *pCheckInfo = taosArrayGetP(group, j); STableQueryInfo *pCheckInfo = taosArrayGetP(group, j);
pCheckInfo->win = pQuery->window; pCheckInfo->win = pQuery->window;
pCheckInfo->lastKey = pCheckInfo->win.skey; pCheckInfo->lastKey = pCheckInfo->win.skey;
}
} }
} }
} else if (isPointInterpoQuery(pQuery)) { } else if (isPointInterpoQuery(pQuery)) {
...@@ -4568,7 +4581,7 @@ int32_t doInitQInfo(SQInfo *pQInfo, STSBuf *pTsBuf, void *tsdb, int32_t vgId, bo ...@@ -4568,7 +4581,7 @@ int32_t doInitQInfo(SQInfo *pQInfo, STSBuf *pTsBuf, void *tsdb, int32_t vgId, bo
getAlignQueryTimeWindow(pQuery, pQuery->window.skey, sk, ek, &w); getAlignQueryTimeWindow(pQuery, pQuery->window.skey, sk, ek, &w);
pRuntimeEnv->pFillInfo = taosInitFillInfo(pQuery->order.order, w.skey, 0, (int32_t)pQuery->rec.capacity, pQuery->numOfOutput, pRuntimeEnv->pFillInfo = taosInitFillInfo(pQuery->order.order, w.skey, 0, (int32_t)pQuery->rec.capacity, pQuery->numOfOutput,
pQuery->slidingTime, pQuery->slidingTimeUnit, (int8_t)pQuery->precision, pQuery->interval.sliding, pQuery->interval.slidingUnit, (int8_t)pQuery->precision,
pQuery->fillType, pColInfo); pQuery->fillType, pColInfo);
} }
...@@ -5429,7 +5442,7 @@ static void stableQueryImpl(SQInfo *pQInfo) { ...@@ -5429,7 +5442,7 @@ static void stableQueryImpl(SQInfo *pQInfo) {
(isFixedOutputQuery(pRuntimeEnv) && (!isPointInterpoQuery(pQuery)) && (!pRuntimeEnv->groupbyNormalCol))) { (isFixedOutputQuery(pRuntimeEnv) && (!isPointInterpoQuery(pQuery)) && (!pRuntimeEnv->groupbyNormalCol))) {
multiTableQueryProcess(pQInfo); multiTableQueryProcess(pQInfo);
} else { } else {
assert((pQuery->checkBuffer == 1 && pQuery->intervalTime == 0) || isPointInterpoQuery(pQuery) || assert((pQuery->checkBuffer == 1 && pQuery->interval.interval == 0) || isPointInterpoQuery(pQuery) ||
isFirstLastRowQuery(pQuery) || pRuntimeEnv->groupbyNormalCol); isFirstLastRowQuery(pQuery) || pRuntimeEnv->groupbyNormalCol);
sequentialTableProcess(pQInfo); sequentialTableProcess(pQInfo);
...@@ -5467,6 +5480,7 @@ static int32_t getColumnIndexInSource(SQueryTableMsg *pQueryMsg, SSqlFuncMsg *pE ...@@ -5467,6 +5480,7 @@ static int32_t getColumnIndexInSource(SQueryTableMsg *pQueryMsg, SSqlFuncMsg *pE
} }
} }
assert(0); assert(0);
return -1;
} }
bool validateExprColumnInfo(SQueryTableMsg *pQueryMsg, SSqlFuncMsg *pExprMsg, SColumnInfo* pTagCols) { bool validateExprColumnInfo(SQueryTableMsg *pQueryMsg, SSqlFuncMsg *pExprMsg, SColumnInfo* pTagCols) {
...@@ -5475,8 +5489,8 @@ bool validateExprColumnInfo(SQueryTableMsg *pQueryMsg, SSqlFuncMsg *pExprMsg, SC ...@@ -5475,8 +5489,8 @@ bool validateExprColumnInfo(SQueryTableMsg *pQueryMsg, SSqlFuncMsg *pExprMsg, SC
} }
static bool validateQueryMsg(SQueryTableMsg *pQueryMsg) { static bool validateQueryMsg(SQueryTableMsg *pQueryMsg) {
if (pQueryMsg->intervalTime < 0) { if (pQueryMsg->interval.interval < 0) {
qError("qmsg:%p illegal value of interval time %" PRId64, pQueryMsg, pQueryMsg->intervalTime); qError("qmsg:%p illegal value of interval time %" PRId64, pQueryMsg, pQueryMsg->interval.interval);
return false; return false;
} }
...@@ -5555,8 +5569,12 @@ static int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SArray **pTableIdList, ...@@ -5555,8 +5569,12 @@ static int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SArray **pTableIdList,
pQueryMsg->window.skey = htobe64(pQueryMsg->window.skey); pQueryMsg->window.skey = htobe64(pQueryMsg->window.skey);
pQueryMsg->window.ekey = htobe64(pQueryMsg->window.ekey); pQueryMsg->window.ekey = htobe64(pQueryMsg->window.ekey);
pQueryMsg->intervalTime = htobe64(pQueryMsg->intervalTime); pQueryMsg->interval.interval = htobe64(pQueryMsg->interval.interval);
pQueryMsg->slidingTime = htobe64(pQueryMsg->slidingTime); pQueryMsg->interval.sliding = htobe64(pQueryMsg->interval.sliding);
pQueryMsg->interval.offset = htobe64(pQueryMsg->interval.offset);
pQueryMsg->interval.intervalUnit = pQueryMsg->interval.intervalUnit;
pQueryMsg->interval.slidingUnit = pQueryMsg->interval.slidingUnit;
pQueryMsg->interval.offsetUnit = pQueryMsg->interval.offsetUnit;
pQueryMsg->limit = htobe64(pQueryMsg->limit); pQueryMsg->limit = htobe64(pQueryMsg->limit);
pQueryMsg->offset = htobe64(pQueryMsg->offset); pQueryMsg->offset = htobe64(pQueryMsg->offset);
...@@ -5769,7 +5787,7 @@ static int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SArray **pTableIdList, ...@@ -5769,7 +5787,7 @@ static int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SArray **pTableIdList,
qDebug("qmsg:%p query %d tables, type:%d, qrange:%" PRId64 "-%" PRId64 ", numOfGroupbyTagCols:%d, order:%d, " qDebug("qmsg:%p query %d tables, type:%d, qrange:%" PRId64 "-%" PRId64 ", numOfGroupbyTagCols:%d, order:%d, "
"outputCols:%d, numOfCols:%d, interval:%" PRId64 ", fillType:%d, comptsLen:%d, compNumOfBlocks:%d, limit:%" PRId64 ", offset:%" PRId64, "outputCols:%d, numOfCols:%d, interval:%" PRId64 ", fillType:%d, comptsLen:%d, compNumOfBlocks:%d, limit:%" PRId64 ", offset:%" PRId64,
pQueryMsg, pQueryMsg->numOfTables, pQueryMsg->queryType, pQueryMsg->window.skey, pQueryMsg->window.ekey, pQueryMsg->numOfGroupCols, pQueryMsg, pQueryMsg->numOfTables, pQueryMsg->queryType, pQueryMsg->window.skey, pQueryMsg->window.ekey, pQueryMsg->numOfGroupCols,
pQueryMsg->order, pQueryMsg->numOfOutput, pQueryMsg->numOfCols, pQueryMsg->intervalTime, pQueryMsg->order, pQueryMsg->numOfOutput, pQueryMsg->numOfCols, pQueryMsg->interval.interval,
pQueryMsg->fillType, pQueryMsg->tsLen, pQueryMsg->tsNumOfBlocks, pQueryMsg->limit, pQueryMsg->offset); pQueryMsg->fillType, pQueryMsg->tsLen, pQueryMsg->tsNumOfBlocks, pQueryMsg->limit, pQueryMsg->offset);
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
...@@ -6108,10 +6126,7 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SSqlGroupbyExpr *pGrou ...@@ -6108,10 +6126,7 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SSqlGroupbyExpr *pGrou
pQuery->order.orderColId = pQueryMsg->orderColId; pQuery->order.orderColId = pQueryMsg->orderColId;
pQuery->pSelectExpr = pExprs; pQuery->pSelectExpr = pExprs;
pQuery->pGroupbyExpr = pGroupbyExpr; pQuery->pGroupbyExpr = pGroupbyExpr;
pQuery->intervalTime = pQueryMsg->intervalTime; memcpy(&pQuery->interval, &pQueryMsg->interval, sizeof(pQuery->interval));
pQuery->slidingTime = pQueryMsg->slidingTime;
pQuery->intervalTimeUnit = pQueryMsg->intervalTimeUnit;
pQuery->slidingTimeUnit = pQueryMsg->slidingTimeUnit;
pQuery->fillType = pQueryMsg->fillType; pQuery->fillType = pQueryMsg->fillType;
pQuery->numOfTags = pQueryMsg->numOfTags; pQuery->numOfTags = pQueryMsg->numOfTags;
pQuery->tagColList = pTagCols; pQuery->tagColList = pTagCols;
...@@ -6316,17 +6331,43 @@ _error: ...@@ -6316,17 +6331,43 @@ _error:
} }
static void freeColumnFilterInfo(SColumnFilterInfo* pFilter, int32_t numOfFilters) { static void freeColumnFilterInfo(SColumnFilterInfo* pFilter, int32_t numOfFilters) {
if (pFilter == NULL) { if (pFilter == NULL || numOfFilters == 0) {
return; return;
} }
for (int32_t i = 0; i < numOfFilters; i++) { for (int32_t i = 0; i < numOfFilters; i++) {
if (pFilter[i].filterstr) { if (pFilter[i].filterstr) {
free((void*)(pFilter[i].pz)); free((void*)(pFilter[i].pz));
} }
} }
free(pFilter); free(pFilter);
} }
static void doDestroyTableQueryInfo(STableGroupInfo* pTableqinfoGroupInfo) {
if (pTableqinfoGroupInfo->pGroupList != NULL) {
int32_t numOfGroups = (int32_t) taosArrayGetSize(pTableqinfoGroupInfo->pGroupList);
for (int32_t i = 0; i < numOfGroups; ++i) {
SArray *p = taosArrayGetP(pTableqinfoGroupInfo->pGroupList, i);
size_t num = taosArrayGetSize(p);
for(int32_t j = 0; j < num; ++j) {
STableQueryInfo* item = taosArrayGetP(p, j);
destroyTableQueryInfoImpl(item);
}
taosArrayDestroy(p);
}
}
taosArrayDestroy(pTableqinfoGroupInfo->pGroupList);
taosHashCleanup(pTableqinfoGroupInfo->map);
pTableqinfoGroupInfo->pGroupList = NULL;
pTableqinfoGroupInfo->map = NULL;
pTableqinfoGroupInfo->numOfTables = 0;
}
static void freeQInfo(SQInfo *pQInfo) { static void freeQInfo(SQInfo *pQInfo) {
if (!isValidQInfo(pQInfo)) { if (!isValidQInfo(pQInfo)) {
return; return;
...@@ -6387,25 +6428,9 @@ static void freeQInfo(SQInfo *pQInfo) { ...@@ -6387,25 +6428,9 @@ static void freeQInfo(SQInfo *pQInfo) {
taosTFree(pQuery); taosTFree(pQuery);
} }
// todo refactor, extract method to destroytableDataInfo doDestroyTableQueryInfo(&pQInfo->tableqinfoGroupInfo);
if (pQInfo->tableqinfoGroupInfo.pGroupList != NULL) {
int32_t numOfGroups = (int32_t)(GET_NUM_OF_TABLEGROUP(pQInfo));
for (int32_t i = 0; i < numOfGroups; ++i) {
SArray *p = GET_TABLEGROUP(pQInfo, i);
size_t num = taosArrayGetSize(p);
for(int32_t j = 0; j < num; ++j) {
STableQueryInfo* item = taosArrayGetP(p, j);
destroyTableQueryInfo(item);
}
taosArrayDestroy(p);
}
}
taosTFree(pQInfo->pBuf); taosTFree(pQInfo->pBuf);
taosArrayDestroy(pQInfo->tableqinfoGroupInfo.pGroupList);
taosHashCleanup(pQInfo->tableqinfoGroupInfo.map);
tsdbDestroyTableGroup(&pQInfo->tableGroupInfo); tsdbDestroyTableGroup(&pQInfo->tableGroupInfo);
taosArrayDestroy(pQInfo->arrTableIdInfo); taosArrayDestroy(pQInfo->arrTableIdInfo);
......
...@@ -38,8 +38,11 @@ SFillInfo* taosInitFillInfo(int32_t order, TSKEY skey, int32_t numOfTags, int32_ ...@@ -38,8 +38,11 @@ SFillInfo* taosInitFillInfo(int32_t order, TSKEY skey, int32_t numOfTags, int32_
pFillInfo->numOfTags = numOfTags; pFillInfo->numOfTags = numOfTags;
pFillInfo->numOfCols = numOfCols; pFillInfo->numOfCols = numOfCols;
pFillInfo->precision = precision; pFillInfo->precision = precision;
pFillInfo->slidingTime = slidingTime;
pFillInfo->slidingUnit = slidingUnit; pFillInfo->interval.interval = slidingTime;
pFillInfo->interval.intervalUnit = slidingUnit;
pFillInfo->interval.sliding = slidingTime;
pFillInfo->interval.slidingUnit = slidingUnit;
pFillInfo->pData = malloc(POINTER_BYTES * numOfCols); pFillInfo->pData = malloc(POINTER_BYTES * numOfCols);
if (numOfTags > 0) { if (numOfTags > 0) {
...@@ -108,21 +111,15 @@ void* taosDestoryFillInfo(SFillInfo* pFillInfo) { ...@@ -108,21 +111,15 @@ void* taosDestoryFillInfo(SFillInfo* pFillInfo) {
return NULL; return NULL;
} }
static TSKEY taosGetRevisedEndKey(TSKEY ekey, int32_t order, int64_t timeInterval, int8_t slidingTimeUnit, int8_t precision) {
if (order == TSDB_ORDER_ASC) {
return ekey;
} else {
return taosGetIntervalStartTimestamp(ekey, timeInterval, timeInterval, slidingTimeUnit, precision);
}
}
void taosFillSetStartInfo(SFillInfo* pFillInfo, int32_t numOfRows, TSKEY endKey) { void taosFillSetStartInfo(SFillInfo* pFillInfo, int32_t numOfRows, TSKEY endKey) {
if (pFillInfo->fillType == TSDB_FILL_NONE) { if (pFillInfo->fillType == TSDB_FILL_NONE) {
return; return;
} }
pFillInfo->endKey = taosGetRevisedEndKey(endKey, pFillInfo->order, pFillInfo->slidingTime, pFillInfo->slidingUnit, pFillInfo->endKey = endKey;
pFillInfo->precision); if (pFillInfo->order != TSDB_ORDER_ASC) {
pFillInfo->endKey = taosTimeTruncate(endKey, &pFillInfo->interval, pFillInfo->precision);
}
pFillInfo->rowIdx = 0; pFillInfo->rowIdx = 0;
pFillInfo->numOfRows = numOfRows; pFillInfo->numOfRows = numOfRows;
...@@ -172,30 +169,34 @@ int64_t getFilledNumOfRes(SFillInfo* pFillInfo, TSKEY ekey, int32_t maxNumOfRows ...@@ -172,30 +169,34 @@ int64_t getFilledNumOfRes(SFillInfo* pFillInfo, TSKEY ekey, int32_t maxNumOfRows
int32_t numOfRows = taosNumOfRemainRows(pFillInfo); int32_t numOfRows = taosNumOfRemainRows(pFillInfo);
TSKEY ekey1 = taosGetRevisedEndKey(ekey, pFillInfo->order, pFillInfo->slidingTime, pFillInfo->slidingUnit, TSKEY ekey1 = ekey;
pFillInfo->precision); if (pFillInfo->order != TSDB_ORDER_ASC) {
pFillInfo->endKey = taosTimeTruncate(ekey, &pFillInfo->interval, pFillInfo->precision);
}
int64_t numOfRes = -1; int64_t numOfRes = -1;
if (numOfRows > 0) { // still fill gap within current data block, not generating data after the result set. if (numOfRows > 0) { // still fill gap within current data block, not generating data after the result set.
TSKEY lastKey = tsList[pFillInfo->numOfRows - 1]; TSKEY lastKey = tsList[pFillInfo->numOfRows - 1];
numOfRes = taosTimeCountInterval(
if (pFillInfo->slidingUnit != 'y' && pFillInfo->slidingUnit != 'n') { lastKey,
numOfRes = (int64_t)(ABS(lastKey - pFillInfo->start) / pFillInfo->slidingTime) + 1; pFillInfo->start,
} else { pFillInfo->interval.sliding,
numOfRes = taosCountNatualInterval(lastKey, pFillInfo->start, pFillInfo->slidingTime, pFillInfo->slidingUnit, pFillInfo->precision) + 1; pFillInfo->interval.slidingUnit,
} pFillInfo->precision);
numOfRes += 1;
assert(numOfRes >= numOfRows); assert(numOfRes >= numOfRows);
} else { // reach the end of data } else { // reach the end of data
if ((ekey1 < pFillInfo->start && FILL_IS_ASC_FILL(pFillInfo)) || if ((ekey1 < pFillInfo->start && FILL_IS_ASC_FILL(pFillInfo)) ||
(ekey1 > pFillInfo->start && !FILL_IS_ASC_FILL(pFillInfo))) { (ekey1 > pFillInfo->start && !FILL_IS_ASC_FILL(pFillInfo))) {
return 0; return 0;
} }
// the numOfRes rows are all filled with specified policy numOfRes = taosTimeCountInterval(
if (pFillInfo->slidingUnit != 'y' && pFillInfo->slidingUnit != 'n') { ekey1,
numOfRes = (ABS(ekey1 - pFillInfo->start) / pFillInfo->slidingTime) + 1; pFillInfo->start,
} else { pFillInfo->interval.sliding,
numOfRes = taosCountNatualInterval(ekey1, pFillInfo->start, pFillInfo->slidingTime, pFillInfo->slidingUnit, pFillInfo->precision) + 1; pFillInfo->interval.slidingUnit,
} pFillInfo->precision);
numOfRes += 1;
} }
return (numOfRes > maxNumOfRows) ? maxNumOfRows : numOfRes; return (numOfRes > maxNumOfRows) ? maxNumOfRows : numOfRes;
...@@ -374,12 +375,7 @@ static void doFillResultImpl(SFillInfo* pFillInfo, tFilePage** data, int32_t* nu ...@@ -374,12 +375,7 @@ static void doFillResultImpl(SFillInfo* pFillInfo, tFilePage** data, int32_t* nu
setTagsValue(pFillInfo, data, *num); setTagsValue(pFillInfo, data, *num);
} }
// TODO natual sliding time pFillInfo->start = taosTimeAdd(pFillInfo->start, pFillInfo->interval.sliding * step, pFillInfo->interval.slidingUnit, pFillInfo->precision);
if (pFillInfo->slidingUnit != 'n' && pFillInfo->slidingUnit != 'y') {
pFillInfo->start += (pFillInfo->slidingTime * step);
} else {
pFillInfo->start = taosAddNatualInterval(pFillInfo->start, pFillInfo->slidingTime*step, pFillInfo->slidingUnit, pFillInfo->precision);
}
pFillInfo->numOfCurrent++; pFillInfo->numOfCurrent++;
(*num) += 1; (*num) += 1;
...@@ -486,12 +482,7 @@ int32_t generateDataBlockImpl(SFillInfo* pFillInfo, tFilePage** data, int32_t nu ...@@ -486,12 +482,7 @@ int32_t generateDataBlockImpl(SFillInfo* pFillInfo, tFilePage** data, int32_t nu
// set the tag value for final result // set the tag value for final result
setTagsValue(pFillInfo, data, num); setTagsValue(pFillInfo, data, num);
// TODO natual sliding time pFillInfo->start = taosTimeAdd(pFillInfo->start, pFillInfo->interval.sliding*step, pFillInfo->interval.slidingUnit, pFillInfo->precision);
if (pFillInfo->slidingUnit != 'n' && pFillInfo->slidingUnit != 'y') {
pFillInfo->start += (pFillInfo->slidingTime * step);
} else {
pFillInfo->start = taosAddNatualInterval(pFillInfo->start, pFillInfo->slidingTime*step, pFillInfo->slidingUnit, pFillInfo->precision);
}
pFillInfo->rowIdx += 1; pFillInfo->rowIdx += 1;
pFillInfo->numOfCurrent +=1; pFillInfo->numOfCurrent +=1;
......
...@@ -135,7 +135,7 @@ tSQLExpr *tSQLExprIdValueCreate(SStrToken *pToken, int32_t optrType) { ...@@ -135,7 +135,7 @@ tSQLExpr *tSQLExprIdValueCreate(SStrToken *pToken, int32_t optrType) {
pSQLExpr->val.nType = TSDB_DATA_TYPE_BIGINT; pSQLExpr->val.nType = TSDB_DATA_TYPE_BIGINT;
pSQLExpr->nSQLOptr = TK_TIMESTAMP; // TK_TIMESTAMP used to denote the time value is in microsecond pSQLExpr->nSQLOptr = TK_TIMESTAMP; // TK_TIMESTAMP used to denote the time value is in microsecond
} else if (optrType == TK_VARIABLE) { } else if (optrType == TK_VARIABLE) {
int32_t ret = getTimestampInUsFromStr(pToken->z, pToken->n, &pSQLExpr->val.i64Key); int32_t ret = parseAbsoluteDuration(pToken->z, pToken->n, &pSQLExpr->val.i64Key);
UNUSED(ret); UNUSED(ret);
pSQLExpr->val.nType = TSDB_DATA_TYPE_BIGINT; pSQLExpr->val.nType = TSDB_DATA_TYPE_BIGINT;
...@@ -443,44 +443,6 @@ void setDBName(SStrToken *pCpxName, SStrToken *pDB) { ...@@ -443,44 +443,6 @@ void setDBName(SStrToken *pCpxName, SStrToken *pDB) {
pCpxName->n = pDB->n; pCpxName->n = pDB->n;
} }
int32_t getTimestampInUsFromStrImpl(int64_t val, char unit, int64_t *result) {
*result = val;
switch (unit) {
case 's':
(*result) *= MILLISECOND_PER_SECOND;
break;
case 'm':
(*result) *= MILLISECOND_PER_MINUTE;
break;
case 'h':
(*result) *= MILLISECOND_PER_HOUR;
break;
case 'd':
(*result) *= MILLISECOND_PER_DAY;
break;
case 'w':
(*result) *= MILLISECOND_PER_WEEK;
break;
case 'n':
(*result) *= MILLISECOND_PER_MONTH;
break;
case 'y':
(*result) *= MILLISECOND_PER_YEAR;
break;
case 'a':
break;
default: {
;
return -1;
}
}
/* get the value in microsecond */
(*result) *= 1000L;
return 0;
}
void tSQLSetColumnInfo(TAOS_FIELD *pField, SStrToken *pName, TAOS_FIELD *pType) { void tSQLSetColumnInfo(TAOS_FIELD *pField, SStrToken *pName, TAOS_FIELD *pType) {
int32_t maxLen = sizeof(pField->name) / sizeof(pField->name[0]); int32_t maxLen = sizeof(pField->name) / sizeof(pField->name[0]);
...@@ -535,7 +497,7 @@ void tSQLSetColumnType(TAOS_FIELD *pField, SStrToken *type) { ...@@ -535,7 +497,7 @@ void tSQLSetColumnType(TAOS_FIELD *pField, SStrToken *type) {
* extract the select info out of sql string * extract the select info out of sql string
*/ */
SQuerySQL *tSetQuerySQLElems(SStrToken *pSelectToken, tSQLExprList *pSelection, tVariantList *pFrom, tSQLExpr *pWhere, SQuerySQL *tSetQuerySQLElems(SStrToken *pSelectToken, tSQLExprList *pSelection, tVariantList *pFrom, tSQLExpr *pWhere,
tVariantList *pGroupby, tVariantList *pSortOrder, SStrToken *pInterval, tVariantList *pGroupby, tVariantList *pSortOrder, SIntervalVal *pInterval,
SStrToken *pSliding, tVariantList *pFill, SLimitVal *pLimit, SLimitVal *pGLimit) { SStrToken *pSliding, tVariantList *pFill, SLimitVal *pLimit, SLimitVal *pGLimit) {
assert(pSelection != NULL); assert(pSelection != NULL);
...@@ -558,7 +520,8 @@ SQuerySQL *tSetQuerySQLElems(SStrToken *pSelectToken, tSQLExprList *pSelection, ...@@ -558,7 +520,8 @@ SQuerySQL *tSetQuerySQLElems(SStrToken *pSelectToken, tSQLExprList *pSelection,
} }
if (pInterval != NULL) { if (pInterval != NULL) {
pQuery->interval = *pInterval; pQuery->interval = pInterval->interval;
pQuery->offset = pInterval->offset;
} }
if (pSliding != NULL) { if (pSliding != NULL) {
......
...@@ -54,7 +54,7 @@ int32_t initWindowResInfo(SWindowResInfo *pWindowResInfo, SQueryRuntimeEnv *pRun ...@@ -54,7 +54,7 @@ int32_t initWindowResInfo(SWindowResInfo *pWindowResInfo, SQueryRuntimeEnv *pRun
return TSDB_CODE_QRY_OUT_OF_MEMORY; return TSDB_CODE_QRY_OUT_OF_MEMORY;
} }
pWindowResInfo->interval = pRuntimeEnv->pQuery->intervalTime; pWindowResInfo->interval = pRuntimeEnv->pQuery->interval.interval;
pSummary->internalSupSize += sizeof(SWindowResult) * threshold; pSummary->internalSupSize += sizeof(SWindowResult) * threshold;
pSummary->internalSupSize += (pRuntimeEnv->pQuery->numOfOutput * sizeof(SResultInfo) + pRuntimeEnv->interBufSize) * pWindowResInfo->capacity; pSummary->internalSupSize += (pRuntimeEnv->pQuery->numOfOutput * sizeof(SResultInfo) + pRuntimeEnv->interBufSize) * pWindowResInfo->capacity;
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
** input grammar file: ** input grammar file:
*/ */
#include <stdio.h> #include <stdio.h>
#include <assert.h>
/************ Begin %include sections from the grammar ************************/ /************ Begin %include sections from the grammar ************************/
#include <stdio.h> #include <stdio.h>
...@@ -76,8 +77,10 @@ ...@@ -76,8 +77,10 @@
** zero the stack is dynamically sized using realloc() ** zero the stack is dynamically sized using realloc()
** ParseARG_SDECL A static variable declaration for the %extra_argument ** ParseARG_SDECL A static variable declaration for the %extra_argument
** ParseARG_PDECL A parameter declaration for the %extra_argument ** ParseARG_PDECL A parameter declaration for the %extra_argument
** ParseARG_PARAM Code to pass %extra_argument as a subroutine parameter
** ParseARG_STORE Code to store %extra_argument into yypParser ** ParseARG_STORE Code to store %extra_argument into yypParser
** ParseARG_FETCH Code to extract %extra_argument from yypParser ** ParseARG_FETCH Code to extract %extra_argument from yypParser
** ParseCTX_* As ParseARG_ except for %extra_context
** YYERRORSYMBOL is the code number of the error symbol. If not ** YYERRORSYMBOL is the code number of the error symbol. If not
** defined, then do no error processing. ** defined, then do no error processing.
** YYNSTATE the combined number of states. ** YYNSTATE the combined number of states.
...@@ -97,47 +100,56 @@ ...@@ -97,47 +100,56 @@
#endif #endif
/************* Begin control #defines *****************************************/ /************* Begin control #defines *****************************************/
#define YYCODETYPE unsigned short int #define YYCODETYPE unsigned short int
#define YYNOCODE 272 #define YYNOCODE 270
#define YYACTIONTYPE unsigned short int #define YYACTIONTYPE unsigned short int
#define ParseTOKENTYPE SStrToken #define ParseTOKENTYPE SStrToken
typedef union { typedef union {
int yyinit; int yyinit;
ParseTOKENTYPE yy0; ParseTOKENTYPE yy0;
SSubclauseInfo* yy25; int yy112;
tSQLExpr* yy66; SCreateDBInfo yy118;
SCreateAcctSQL yy73; tVariantList* yy156;
int yy82; tSQLExprList* yy158;
SQuerySQL* yy150; tSQLExpr* yy190;
SCreateDBInfo yy158; SSubclauseInfo* yy333;
TAOS_FIELD yy181; SIntervalVal yy340;
SLimitVal yy188; TAOS_FIELD yy343;
tSQLExprList* yy224; int64_t yy369;
int64_t yy271; SCreateTableSQL* yy398;
tVariant yy312; SLimitVal yy414;
SCreateTableSQL* yy374; SQuerySQL* yy444;
tFieldList* yy449; SCreateAcctSQL yy479;
tVariantList* yy494; tVariant yy506;
tFieldList* yy511;
} YYMINORTYPE; } YYMINORTYPE;
#ifndef YYSTACKDEPTH #ifndef YYSTACKDEPTH
#define YYSTACKDEPTH 100 #define YYSTACKDEPTH 100
#endif #endif
#define ParseARG_SDECL SSqlInfo* pInfo; #define ParseARG_SDECL SSqlInfo* pInfo;
#define ParseARG_PDECL ,SSqlInfo* pInfo #define ParseARG_PDECL ,SSqlInfo* pInfo
#define ParseARG_FETCH SSqlInfo* pInfo = yypParser->pInfo #define ParseARG_PARAM ,pInfo
#define ParseARG_STORE yypParser->pInfo = pInfo #define ParseARG_FETCH SSqlInfo* pInfo=yypParser->pInfo;
#define ParseARG_STORE yypParser->pInfo=pInfo;
#define ParseCTX_SDECL
#define ParseCTX_PDECL
#define ParseCTX_PARAM
#define ParseCTX_FETCH
#define ParseCTX_STORE
#define YYFALLBACK 1 #define YYFALLBACK 1
#define YYNSTATE 246 #define YYNSTATE 248
#define YYNRULE 227 #define YYNRULE 228
#define YYNRULE_WITH_ACTION 228
#define YYNTOKEN 206 #define YYNTOKEN 206
#define YY_MAX_SHIFT 245 #define YY_MAX_SHIFT 247
#define YY_MIN_SHIFTREDUCE 407 #define YY_MIN_SHIFTREDUCE 410
#define YY_MAX_SHIFTREDUCE 633 #define YY_MAX_SHIFTREDUCE 637
#define YY_ERROR_ACTION 634 #define YY_ERROR_ACTION 638
#define YY_ACCEPT_ACTION 635 #define YY_ACCEPT_ACTION 639
#define YY_NO_ACTION 636 #define YY_NO_ACTION 640
#define YY_MIN_REDUCE 637 #define YY_MIN_REDUCE 641
#define YY_MAX_REDUCE 863 #define YY_MAX_REDUCE 868
/************* End control #defines *******************************************/ /************* End control #defines *******************************************/
#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
/* Define the yytestcase() macro to be a no-op if is not already defined /* Define the yytestcase() macro to be a no-op if is not already defined
** otherwise. ** otherwise.
...@@ -202,151 +214,151 @@ typedef union { ...@@ -202,151 +214,151 @@ typedef union {
** yy_default[] Default action for each state. ** yy_default[] Default action for each state.
** **
*********** Begin parsing tables **********************************************/ *********** Begin parsing tables **********************************************/
#define YY_ACTTAB_COUNT (556) #define YY_ACTTAB_COUNT (560)
static const YYACTIONTYPE yy_action[] = { static const YYACTIONTYPE yy_action[] = {
/* 0 */ 737, 448, 11, 735, 736, 635, 245, 448, 738, 449, /* 0 */ 741, 451, 11, 739, 740, 639, 247, 451, 742, 452,
/* 10 */ 740, 741, 739, 35, 36, 449, 37, 38, 155, 243, /* 10 */ 744, 745, 743, 35, 36, 452, 37, 38, 156, 245,
/* 20 */ 165, 29, 137, 136, 200, 41, 39, 43, 40, 105, /* 20 */ 167, 29, 138, 137, 202, 41, 39, 43, 40, 106,
/* 30 */ 514, 160, 851, 34, 33, 778, 137, 32, 31, 30, /* 30 */ 517, 162, 856, 34, 33, 782, 138, 32, 31, 30,
/* 40 */ 35, 36, 767, 37, 38, 159, 851, 165, 29, 767, /* 40 */ 35, 36, 771, 37, 38, 161, 856, 167, 29, 771,
/* 50 */ 105, 200, 41, 39, 43, 40, 185, 157, 221, 220, /* 50 */ 106, 202, 41, 39, 43, 40, 187, 159, 223, 222,
/* 60 */ 34, 33, 137, 156, 32, 31, 30, 35, 36, 448, /* 60 */ 34, 33, 138, 157, 32, 31, 30, 35, 36, 451,
/* 70 */ 37, 38, 850, 141, 165, 29, 756, 449, 200, 41, /* 70 */ 37, 38, 855, 142, 167, 29, 760, 452, 202, 41,
/* 80 */ 39, 43, 40, 197, 78, 60, 775, 34, 33, 232, /* 80 */ 39, 43, 40, 199, 78, 60, 779, 34, 33, 234,
/* 90 */ 232, 32, 31, 30, 21, 41, 39, 43, 40, 32, /* 90 */ 234, 32, 31, 30, 21, 41, 39, 43, 40, 32,
/* 100 */ 31, 30, 56, 34, 33, 847, 803, 32, 31, 30, /* 100 */ 31, 30, 56, 34, 33, 852, 808, 32, 31, 30,
/* 110 */ 21, 21, 105, 408, 409, 410, 411, 412, 413, 414, /* 110 */ 21, 21, 106, 411, 412, 413, 414, 415, 416, 417,
/* 120 */ 415, 416, 417, 418, 419, 244, 587, 169, 36, 753, /* 120 */ 418, 419, 420, 421, 422, 246, 591, 171, 36, 757,
/* 130 */ 37, 38, 223, 50, 165, 29, 21, 62, 200, 41, /* 130 */ 37, 38, 225, 50, 167, 29, 21, 62, 202, 41,
/* 140 */ 39, 43, 40, 170, 219, 753, 753, 34, 33, 27, /* 140 */ 39, 43, 40, 172, 221, 757, 757, 34, 33, 27,
/* 150 */ 51, 32, 31, 30, 8, 37, 38, 63, 115, 165, /* 150 */ 51, 32, 31, 30, 8, 37, 38, 63, 116, 167,
/* 160 */ 29, 101, 754, 200, 41, 39, 43, 40, 804, 224, /* 160 */ 29, 101, 758, 202, 41, 39, 43, 40, 809, 226,
/* 170 */ 195, 753, 34, 33, 168, 846, 32, 31, 30, 16, /* 170 */ 197, 757, 34, 33, 170, 851, 32, 31, 30, 16,
/* 180 */ 212, 238, 237, 211, 210, 209, 236, 208, 235, 234, /* 180 */ 214, 240, 239, 213, 212, 211, 238, 210, 237, 236,
/* 190 */ 233, 207, 733, 756, 721, 722, 723, 724, 725, 726, /* 190 */ 235, 209, 737, 760, 725, 726, 727, 728, 729, 730,
/* 200 */ 727, 728, 729, 730, 731, 732, 164, 600, 12, 239, /* 200 */ 731, 732, 733, 734, 735, 736, 166, 604, 12, 241,
/* 210 */ 591, 17, 594, 188, 597, 105, 164, 600, 26, 559, /* 210 */ 595, 17, 598, 190, 601, 559, 166, 604, 26, 103,
/* 220 */ 591, 845, 594, 46, 597, 34, 33, 150, 756, 32, /* 220 */ 595, 597, 598, 600, 601, 34, 33, 151, 760, 32,
/* 230 */ 31, 30, 21, 90, 89, 144, 568, 569, 161, 162, /* 230 */ 31, 30, 21, 90, 89, 145, 572, 573, 163, 164,
/* 240 */ 171, 149, 199, 76, 80, 85, 88, 79, 161, 162, /* 240 */ 173, 150, 201, 76, 80, 85, 88, 79, 163, 164,
/* 250 */ 164, 600, 546, 82, 591, 589, 594, 100, 597, 242, /* 250 */ 166, 604, 549, 82, 595, 106, 598, 100, 601, 244,
/* 260 */ 241, 97, 17, 16, 26, 238, 237, 752, 201, 26, /* 260 */ 243, 97, 17, 16, 26, 240, 239, 756, 680, 26,
/* 270 */ 236, 61, 235, 234, 233, 118, 119, 70, 66, 69, /* 270 */ 238, 129, 237, 236, 235, 119, 120, 70, 66, 69,
/* 280 */ 538, 676, 161, 162, 128, 530, 178, 187, 527, 184, /* 280 */ 203, 165, 163, 164, 689, 533, 180, 129, 530, 186,
/* 290 */ 528, 590, 529, 182, 181, 593, 152, 596, 132, 130, /* 290 */ 531, 850, 532, 184, 183, 596, 153, 599, 133, 131,
/* 300 */ 93, 92, 91, 42, 172, 543, 685, 218, 217, 128, /* 300 */ 93, 92, 91, 42, 174, 546, 681, 220, 219, 129,
/* 310 */ 18, 163, 677, 42, 599, 128, 173, 174, 560, 619, /* 310 */ 18, 61, 541, 42, 603, 593, 175, 176, 563, 189,
/* 320 */ 153, 47, 14, 13, 599, 592, 601, 595, 520, 598, /* 320 */ 3, 47, 46, 537, 603, 538, 564, 623, 605, 602,
/* 330 */ 13, 519, 46, 154, 205, 22, 75, 74, 22, 598, /* 330 */ 14, 13, 13, 154, 523, 75, 74, 522, 46, 602,
/* 340 */ 48, 10, 9, 534, 532, 535, 533, 42, 87, 86, /* 340 */ 48, 22, 207, 535, 155, 536, 22, 42, 10, 9,
/* 350 */ 3, 139, 860, 140, 755, 142, 143, 603, 599, 147, /* 350 */ 140, 594, 87, 86, 141, 143, 144, 148, 603, 149,
/* 360 */ 148, 146, 135, 145, 138, 814, 813, 166, 810, 809, /* 360 */ 147, 136, 146, 139, 865, 759, 819, 818, 168, 607,
/* 370 */ 167, 777, 747, 598, 222, 769, 782, 784, 102, 796, /* 370 */ 815, 814, 169, 602, 751, 224, 781, 773, 786, 788,
/* 380 */ 114, 116, 795, 117, 687, 206, 133, 531, 186, 26, /* 380 */ 102, 801, 117, 800, 115, 118, 26, 534, 188, 691,
/* 390 */ 24, 95, 215, 684, 216, 859, 72, 858, 856, 120, /* 390 */ 208, 134, 24, 217, 688, 218, 864, 72, 863, 861,
/* 400 */ 705, 25, 555, 23, 134, 674, 81, 672, 83, 189, /* 400 */ 121, 95, 709, 25, 23, 135, 678, 81, 558, 676,
/* 410 */ 84, 670, 193, 669, 175, 52, 129, 667, 49, 666, /* 410 */ 83, 191, 84, 674, 158, 673, 195, 177, 130, 671,
/* 420 */ 665, 106, 664, 44, 663, 107, 655, 131, 198, 766, /* 420 */ 52, 670, 770, 669, 49, 44, 668, 107, 108, 200,
/* 430 */ 196, 661, 659, 657, 194, 57, 58, 797, 192, 190, /* 430 */ 667, 194, 659, 132, 665, 663, 198, 196, 192, 661,
/* 440 */ 28, 214, 77, 225, 226, 227, 228, 229, 230, 203, /* 440 */ 28, 57, 58, 802, 216, 77, 227, 228, 229, 230,
/* 450 */ 53, 231, 240, 633, 151, 177, 64, 67, 176, 668, /* 450 */ 231, 232, 205, 233, 242, 53, 637, 178, 179, 636,
/* 460 */ 632, 179, 180, 631, 624, 187, 123, 183, 122, 706, /* 460 */ 152, 64, 67, 182, 181, 672, 635, 628, 94, 96,
/* 470 */ 121, 125, 124, 94, 127, 662, 126, 96, 1, 2, /* 470 */ 185, 666, 124, 55, 123, 710, 122, 125, 126, 128,
/* 480 */ 540, 112, 108, 109, 751, 110, 113, 111, 59, 55, /* 480 */ 127, 1, 2, 189, 755, 543, 59, 560, 111, 109,
/* 490 */ 556, 103, 158, 19, 191, 20, 561, 104, 5, 602, /* 490 */ 112, 110, 104, 113, 114, 160, 19, 193, 5, 565,
/* 500 */ 6, 4, 604, 15, 202, 7, 204, 65, 489, 485, /* 500 */ 105, 6, 606, 4, 20, 15, 204, 7, 608, 65,
/* 510 */ 483, 482, 481, 478, 452, 213, 68, 45, 71, 22, /* 510 */ 206, 492, 488, 486, 485, 484, 481, 455, 215, 68,
/* 520 */ 516, 515, 513, 54, 473, 471, 463, 469, 465, 467, /* 520 */ 45, 71, 22, 519, 73, 518, 516, 54, 476, 474,
/* 530 */ 73, 461, 459, 488, 487, 486, 484, 480, 479, 46, /* 530 */ 466, 472, 468, 470, 464, 462, 491, 490, 489, 487,
/* 540 */ 450, 423, 421, 637, 636, 636, 98, 636, 636, 636, /* 540 */ 483, 482, 46, 453, 426, 424, 641, 640, 640, 640,
/* 550 */ 636, 636, 636, 636, 636, 99, /* 550 */ 640, 640, 640, 640, 640, 640, 640, 640, 98, 99,
}; };
static const YYCODETYPE yy_lookahead[] = { static const YYCODETYPE yy_lookahead[] = {
/* 0 */ 226, 1, 260, 229, 230, 207, 208, 1, 234, 9, /* 0 */ 225, 1, 259, 228, 229, 206, 207, 1, 233, 9,
/* 10 */ 236, 237, 238, 13, 14, 9, 16, 17, 209, 210, /* 10 */ 235, 236, 237, 13, 14, 9, 16, 17, 208, 209,
/* 20 */ 20, 21, 260, 260, 24, 25, 26, 27, 28, 210, /* 20 */ 20, 21, 259, 259, 24, 25, 26, 27, 28, 209,
/* 30 */ 5, 269, 270, 33, 34, 210, 260, 37, 38, 39, /* 30 */ 5, 268, 269, 33, 34, 209, 259, 37, 38, 39,
/* 40 */ 13, 14, 244, 16, 17, 269, 270, 20, 21, 244, /* 40 */ 13, 14, 243, 16, 17, 268, 269, 20, 21, 243,
/* 50 */ 210, 24, 25, 26, 27, 28, 258, 227, 33, 34, /* 50 */ 209, 24, 25, 26, 27, 28, 257, 226, 33, 34,
/* 60 */ 33, 34, 260, 258, 37, 38, 39, 13, 14, 1, /* 60 */ 33, 34, 259, 257, 37, 38, 39, 13, 14, 1,
/* 70 */ 16, 17, 270, 260, 20, 21, 246, 9, 24, 25, /* 70 */ 16, 17, 269, 259, 20, 21, 245, 9, 24, 25,
/* 80 */ 26, 27, 28, 264, 72, 266, 261, 33, 34, 78, /* 80 */ 26, 27, 28, 263, 72, 265, 260, 33, 34, 78,
/* 90 */ 78, 37, 38, 39, 210, 25, 26, 27, 28, 37, /* 90 */ 78, 37, 38, 39, 209, 25, 26, 27, 28, 37,
/* 100 */ 38, 39, 102, 33, 34, 260, 266, 37, 38, 39, /* 100 */ 38, 39, 102, 33, 34, 259, 265, 37, 38, 39,
/* 110 */ 210, 210, 210, 45, 46, 47, 48, 49, 50, 51, /* 110 */ 209, 209, 209, 45, 46, 47, 48, 49, 50, 51,
/* 120 */ 52, 53, 54, 55, 56, 57, 99, 243, 14, 245, /* 120 */ 52, 53, 54, 55, 56, 57, 99, 242, 14, 244,
/* 130 */ 16, 17, 210, 103, 20, 21, 210, 247, 24, 25, /* 130 */ 16, 17, 209, 103, 20, 21, 209, 246, 24, 25,
/* 140 */ 26, 27, 28, 243, 243, 245, 245, 33, 34, 259, /* 140 */ 26, 27, 28, 242, 242, 244, 244, 33, 34, 258,
/* 150 */ 120, 37, 38, 39, 98, 16, 17, 101, 102, 20, /* 150 */ 120, 37, 38, 39, 98, 16, 17, 101, 102, 20,
/* 160 */ 21, 210, 240, 24, 25, 26, 27, 28, 266, 243, /* 160 */ 21, 209, 239, 24, 25, 26, 27, 28, 265, 242,
/* 170 */ 268, 245, 33, 34, 227, 260, 37, 38, 39, 85, /* 170 */ 267, 244, 33, 34, 226, 259, 37, 38, 39, 85,
/* 180 */ 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, /* 180 */ 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
/* 190 */ 96, 97, 226, 246, 228, 229, 230, 231, 232, 233, /* 190 */ 96, 97, 225, 245, 227, 228, 229, 230, 231, 232,
/* 200 */ 234, 235, 236, 237, 238, 239, 1, 2, 44, 227, /* 200 */ 233, 234, 235, 236, 237, 238, 1, 2, 44, 226,
/* 210 */ 5, 98, 7, 262, 9, 210, 1, 2, 105, 99, /* 210 */ 5, 98, 7, 261, 9, 99, 1, 2, 105, 103,
/* 220 */ 5, 260, 7, 103, 9, 33, 34, 63, 246, 37, /* 220 */ 5, 5, 7, 7, 9, 33, 34, 63, 245, 37,
/* 230 */ 38, 39, 210, 69, 70, 71, 115, 116, 33, 34, /* 230 */ 38, 39, 209, 69, 70, 71, 115, 116, 33, 34,
/* 240 */ 63, 77, 37, 64, 65, 66, 67, 68, 33, 34, /* 240 */ 63, 77, 37, 64, 65, 66, 67, 68, 33, 34,
/* 250 */ 1, 2, 37, 74, 5, 1, 7, 98, 9, 60, /* 250 */ 1, 2, 37, 74, 5, 209, 7, 98, 9, 60,
/* 260 */ 61, 62, 98, 85, 105, 87, 88, 245, 15, 105, /* 260 */ 61, 62, 98, 85, 105, 87, 88, 244, 213, 105,
/* 270 */ 92, 266, 94, 95, 96, 64, 65, 66, 67, 68, /* 270 */ 92, 216, 94, 95, 96, 64, 65, 66, 67, 68,
/* 280 */ 99, 214, 33, 34, 217, 2, 126, 106, 5, 125, /* 280 */ 15, 59, 33, 34, 213, 2, 126, 216, 5, 125,
/* 290 */ 7, 37, 9, 133, 134, 5, 132, 7, 64, 65, /* 290 */ 7, 259, 9, 133, 134, 5, 132, 7, 64, 65,
/* 300 */ 66, 67, 68, 98, 127, 103, 214, 130, 131, 217, /* 300 */ 66, 67, 68, 98, 127, 103, 213, 130, 131, 216,
/* 310 */ 108, 59, 214, 98, 109, 217, 33, 34, 99, 99, /* 310 */ 108, 265, 99, 98, 109, 1, 33, 34, 99, 106,
/* 320 */ 260, 103, 103, 103, 109, 5, 99, 7, 99, 124, /* 320 */ 98, 103, 103, 5, 109, 7, 99, 99, 99, 124,
/* 330 */ 103, 99, 103, 260, 99, 103, 128, 129, 103, 124, /* 330 */ 103, 103, 103, 259, 99, 128, 129, 99, 103, 124,
/* 340 */ 122, 128, 129, 5, 5, 7, 7, 98, 72, 73, /* 340 */ 122, 103, 99, 5, 259, 7, 103, 98, 128, 129,
/* 350 */ 98, 260, 246, 260, 246, 260, 260, 104, 109, 260, /* 350 */ 259, 37, 72, 73, 259, 259, 259, 259, 109, 259,
/* 360 */ 260, 260, 260, 260, 260, 241, 241, 241, 241, 241, /* 360 */ 259, 259, 259, 259, 245, 245, 240, 240, 240, 104,
/* 370 */ 241, 210, 242, 124, 241, 244, 210, 210, 210, 267, /* 370 */ 240, 240, 240, 124, 241, 240, 209, 243, 209, 209,
/* 380 */ 248, 210, 267, 210, 210, 210, 210, 104, 244, 105, /* 380 */ 209, 266, 209, 266, 247, 209, 105, 104, 243, 209,
/* 390 */ 210, 59, 210, 210, 210, 210, 210, 210, 210, 210, /* 390 */ 209, 209, 209, 209, 209, 209, 209, 209, 209, 209,
/* 400 */ 210, 210, 109, 210, 210, 210, 210, 210, 210, 263, /* 400 */ 209, 59, 209, 209, 209, 209, 209, 209, 109, 209,
/* 410 */ 210, 210, 263, 210, 210, 119, 210, 210, 121, 210, /* 410 */ 209, 262, 209, 209, 262, 209, 262, 209, 209, 209,
/* 420 */ 210, 256, 210, 118, 210, 255, 210, 210, 113, 257, /* 420 */ 119, 209, 256, 209, 121, 118, 209, 255, 254, 113,
/* 430 */ 117, 210, 210, 210, 112, 211, 211, 211, 111, 110, /* 430 */ 209, 111, 209, 209, 209, 209, 117, 112, 110, 209,
/* 440 */ 123, 75, 84, 83, 49, 80, 82, 53, 81, 211, /* 440 */ 123, 210, 210, 210, 75, 84, 83, 49, 80, 82,
/* 450 */ 211, 79, 75, 5, 211, 5, 215, 215, 135, 211, /* 450 */ 53, 81, 210, 79, 75, 210, 5, 135, 5, 5,
/* 460 */ 5, 135, 5, 5, 86, 106, 219, 126, 223, 225, /* 460 */ 210, 214, 214, 5, 135, 210, 5, 86, 211, 211,
/* 470 */ 224, 220, 222, 212, 218, 211, 221, 212, 216, 213, /* 470 */ 126, 210, 218, 107, 222, 224, 223, 221, 219, 217,
/* 480 */ 99, 250, 254, 253, 244, 252, 249, 251, 103, 107, /* 480 */ 220, 215, 212, 106, 243, 99, 103, 99, 251, 253,
/* 490 */ 99, 98, 1, 103, 98, 103, 99, 98, 114, 99, /* 490 */ 250, 252, 98, 249, 248, 1, 103, 98, 114, 99,
/* 500 */ 114, 98, 104, 98, 100, 98, 100, 72, 9, 5, /* 500 */ 98, 114, 99, 98, 103, 98, 100, 98, 104, 72,
/* 510 */ 5, 5, 5, 5, 76, 15, 72, 16, 129, 103, /* 510 */ 100, 9, 5, 5, 5, 5, 5, 76, 15, 72,
/* 520 */ 5, 5, 99, 98, 5, 5, 5, 5, 5, 5, /* 520 */ 16, 129, 103, 5, 129, 5, 99, 98, 5, 5,
/* 530 */ 129, 5, 5, 5, 5, 5, 5, 5, 5, 103, /* 530 */ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
/* 540 */ 76, 59, 58, 0, 271, 271, 21, 271, 271, 271, /* 540 */ 5, 5, 103, 76, 59, 58, 0, 270, 270, 270,
/* 550 */ 271, 271, 271, 271, 271, 21, 271, 271, 271, 271, /* 550 */ 270, 270, 270, 270, 270, 270, 270, 270, 21, 21,
/* 560 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, /* 560 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270,
/* 570 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, /* 570 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270,
/* 580 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, /* 580 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270,
/* 590 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, /* 590 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270,
/* 600 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, /* 600 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270,
/* 610 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, /* 610 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270,
/* 620 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, /* 620 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270,
/* 630 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, /* 630 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270,
/* 640 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, /* 640 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270,
/* 650 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, /* 650 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270,
/* 660 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, /* 660 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270,
/* 670 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, /* 670 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270,
/* 680 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, /* 680 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270,
/* 690 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, /* 690 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270,
/* 700 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, /* 700 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270,
/* 710 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, /* 710 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270,
/* 720 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, /* 720 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270,
/* 730 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, /* 730 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270,
/* 740 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, /* 740 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270,
/* 750 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, /* 750 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270,
/* 760 */ 271, 271, /* 760 */ 270, 270, 270, 270, 270, 270,
}; };
#define YY_SHIFT_COUNT (245) #define YY_SHIFT_COUNT (247)
#define YY_SHIFT_MIN (0) #define YY_SHIFT_MIN (0)
#define YY_SHIFT_MAX (543) #define YY_SHIFT_MAX (546)
static const unsigned short int yy_shift_ofst[] = { static const unsigned short int yy_shift_ofst[] = {
/* 0 */ 164, 94, 178, 205, 249, 6, 6, 6, 6, 6, /* 0 */ 164, 94, 178, 205, 249, 6, 6, 6, 6, 6,
/* 10 */ 6, 0, 68, 249, 283, 283, 283, 113, 6, 6, /* 10 */ 6, 0, 68, 249, 283, 283, 283, 113, 6, 6,
/* 20 */ 6, 6, 6, 12, 11, 11, 556, 215, 249, 249, /* 20 */ 6, 6, 6, 12, 11, 11, 560, 215, 249, 249,
/* 30 */ 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, /* 30 */ 249, 249, 249, 249, 249, 249, 249, 249, 249, 249,
/* 40 */ 249, 249, 249, 249, 249, 283, 283, 25, 25, 25, /* 40 */ 249, 249, 249, 249, 249, 283, 283, 25, 25, 25,
/* 50 */ 25, 25, 25, 56, 25, 159, 6, 6, 6, 6, /* 50 */ 25, 25, 25, 56, 25, 159, 6, 6, 6, 6,
...@@ -354,67 +366,67 @@ static const unsigned short int yy_shift_ofst[] = { ...@@ -354,67 +366,67 @@ static const unsigned short int yy_shift_ofst[] = {
/* 70 */ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, /* 70 */ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
/* 80 */ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, /* 80 */ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
/* 90 */ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, /* 90 */ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
/* 100 */ 284, 332, 332, 293, 293, 332, 296, 297, 305, 315, /* 100 */ 281, 342, 342, 299, 299, 299, 342, 301, 303, 307,
/* 110 */ 313, 322, 327, 329, 317, 284, 332, 332, 366, 366, /* 110 */ 316, 319, 325, 320, 328, 317, 281, 342, 342, 369,
/* 120 */ 332, 358, 360, 395, 365, 364, 394, 367, 372, 332, /* 120 */ 369, 342, 361, 363, 398, 368, 367, 397, 370, 374,
/* 130 */ 377, 332, 377, 556, 556, 27, 54, 54, 54, 114, /* 130 */ 342, 379, 342, 379, 560, 560, 27, 54, 54, 54,
/* 140 */ 139, 70, 70, 70, 179, 192, 192, 192, 192, 211, /* 140 */ 114, 139, 70, 70, 70, 179, 192, 192, 192, 192,
/* 150 */ 234, 177, 160, 62, 62, 199, 181, 120, 219, 220, /* 150 */ 211, 234, 177, 160, 62, 62, 199, 213, 116, 219,
/* 160 */ 227, 290, 320, 254, 252, 253, 218, 30, 229, 232, /* 160 */ 227, 228, 229, 216, 290, 314, 222, 265, 218, 30,
/* 170 */ 235, 208, 213, 338, 339, 276, 448, 323, 450, 455, /* 170 */ 235, 238, 243, 207, 220, 318, 338, 280, 451, 322,
/* 180 */ 326, 457, 458, 378, 341, 359, 381, 382, 385, 391, /* 180 */ 453, 454, 329, 458, 461, 381, 344, 377, 386, 366,
/* 190 */ 393, 491, 396, 397, 399, 390, 384, 392, 386, 400, /* 190 */ 383, 388, 394, 494, 399, 400, 402, 393, 384, 401,
/* 200 */ 403, 398, 405, 404, 407, 406, 435, 499, 504, 505, /* 200 */ 387, 403, 405, 404, 407, 406, 409, 410, 437, 502,
/* 210 */ 506, 507, 508, 438, 500, 444, 501, 389, 401, 416, /* 210 */ 507, 508, 509, 510, 511, 441, 503, 447, 504, 392,
/* 220 */ 515, 516, 423, 425, 416, 519, 520, 521, 522, 523, /* 220 */ 395, 419, 518, 520, 427, 429, 419, 523, 524, 525,
/* 230 */ 524, 526, 527, 528, 529, 530, 531, 532, 533, 436, /* 230 */ 526, 527, 528, 529, 530, 531, 532, 533, 534, 535,
/* 240 */ 464, 525, 534, 482, 484, 543, /* 240 */ 536, 439, 467, 537, 538, 485, 487, 546,
}; };
#define YY_REDUCE_COUNT (134) #define YY_REDUCE_COUNT (135)
#define YY_REDUCE_MIN (-258) #define YY_REDUCE_MIN (-257)
#define YY_REDUCE_MAX (266) #define YY_REDUCE_MAX (270)
static const short yy_reduce_ofst[] = { static const short yy_reduce_ofst[] = {
/* 0 */ -202, -34, -226, -238, -224, -98, -181, -116, -100, -99, /* 0 */ -201, -33, -225, -237, -223, -97, -180, -115, -99, -98,
/* 10 */ -74, -175, -191, -198, -170, -53, -18, -195, -49, -160, /* 10 */ -73, -174, -190, -197, -169, -52, -17, -194, -48, -159,
/* 20 */ 5, -78, 22, 67, 92, 98, -110, -258, -237, -187, /* 20 */ 46, -77, 23, 55, 71, 93, -109, -257, -236, -186,
/* 30 */ -155, -85, -39, 60, 73, 91, 93, 95, 96, 99, /* 30 */ -154, -84, 32, 74, 85, 91, 95, 96, 97, 98,
/* 40 */ 100, 101, 102, 103, 104, 106, 108, 124, 125, 126, /* 40 */ 100, 101, 102, 103, 104, 119, 120, 126, 127, 128,
/* 50 */ 127, 128, 129, 130, 133, 131, 161, 166, 167, 168, /* 50 */ 130, 131, 132, 133, 135, 134, 167, 169, 170, 171,
/* 60 */ 112, 115, 132, 171, 173, 174, 175, 176, 180, 182, /* 60 */ 115, 117, 137, 173, 176, 180, 181, 182, 183, 184,
/* 70 */ 183, 184, 185, 186, 187, 188, 189, 190, 191, 193, /* 70 */ 185, 186, 187, 188, 189, 190, 191, 193, 194, 195,
/* 80 */ 194, 195, 196, 197, 198, 200, 201, 203, 204, 206, /* 80 */ 196, 197, 198, 200, 201, 203, 204, 206, 208, 209,
/* 90 */ 207, 209, 210, 212, 214, 216, 217, 221, 222, 223, /* 90 */ 210, 212, 214, 217, 221, 223, 224, 225, 226, 230,
/* 100 */ 144, 224, 225, 146, 149, 226, 172, 165, 170, 228, /* 100 */ 145, 231, 232, 149, 152, 154, 233, 166, 172, 174,
/* 110 */ 230, 233, 236, 231, 237, 240, 238, 239, 241, 242, /* 110 */ 236, 239, 237, 240, 244, 246, 241, 242, 245, 247,
/* 120 */ 243, 244, 246, 245, 247, 250, 251, 255, 256, 248, /* 120 */ 248, 250, 251, 253, 252, 254, 256, 259, 260, 262,
/* 130 */ 261, 264, 265, 262, 266, /* 130 */ 255, 257, 261, 258, 266, 270,
}; };
static const YYACTIONTYPE yy_default[] = { static const YYACTIONTYPE yy_default[] = {
/* 0 */ 634, 686, 675, 853, 853, 634, 634, 634, 634, 634, /* 0 */ 638, 690, 679, 858, 858, 638, 638, 638, 638, 638,
/* 10 */ 634, 779, 652, 853, 634, 634, 634, 634, 634, 634, /* 10 */ 638, 783, 656, 858, 638, 638, 638, 638, 638, 638,
/* 20 */ 634, 634, 634, 688, 688, 688, 774, 634, 634, 634, /* 20 */ 638, 638, 638, 692, 692, 692, 778, 638, 638, 638,
/* 30 */ 634, 634, 634, 634, 634, 634, 634, 634, 634, 634, /* 30 */ 638, 638, 638, 638, 638, 638, 638, 638, 638, 638,
/* 40 */ 634, 634, 634, 634, 634, 634, 634, 634, 634, 634, /* 40 */ 638, 638, 638, 638, 638, 638, 638, 638, 638, 638,
/* 50 */ 634, 634, 634, 634, 634, 634, 634, 781, 783, 634, /* 50 */ 638, 638, 638, 638, 638, 638, 638, 785, 787, 638,
/* 60 */ 800, 800, 772, 634, 634, 634, 634, 634, 634, 634, /* 60 */ 805, 805, 776, 638, 638, 638, 638, 638, 638, 638,
/* 70 */ 634, 634, 634, 634, 634, 634, 634, 634, 634, 634, /* 70 */ 638, 638, 638, 638, 638, 638, 638, 638, 638, 638,
/* 80 */ 634, 673, 634, 671, 634, 634, 634, 634, 634, 634, /* 80 */ 638, 677, 638, 675, 638, 638, 638, 638, 638, 638,
/* 90 */ 634, 634, 634, 634, 634, 634, 634, 660, 634, 634, /* 90 */ 638, 638, 638, 638, 638, 638, 638, 664, 638, 638,
/* 100 */ 634, 654, 654, 634, 634, 654, 807, 811, 805, 793, /* 100 */ 638, 658, 658, 638, 638, 638, 658, 812, 816, 810,
/* 110 */ 801, 792, 788, 787, 815, 634, 654, 654, 683, 683, /* 110 */ 798, 806, 797, 793, 792, 820, 638, 658, 658, 687,
/* 120 */ 654, 704, 702, 700, 692, 698, 694, 696, 690, 654, /* 120 */ 687, 658, 708, 706, 704, 696, 702, 698, 700, 694,
/* 130 */ 681, 654, 681, 720, 734, 634, 816, 852, 806, 842, /* 130 */ 658, 685, 658, 685, 724, 738, 638, 821, 857, 811,
/* 140 */ 841, 848, 840, 839, 634, 835, 836, 838, 837, 634, /* 140 */ 847, 846, 853, 845, 844, 638, 840, 841, 843, 842,
/* 150 */ 634, 634, 634, 844, 843, 634, 634, 634, 634, 634, /* 150 */ 638, 638, 638, 638, 849, 848, 638, 638, 638, 638,
/* 160 */ 634, 634, 634, 634, 818, 634, 812, 808, 634, 634, /* 160 */ 638, 638, 638, 638, 638, 638, 823, 638, 817, 813,
/* 170 */ 634, 634, 634, 634, 634, 634, 634, 634, 634, 634, /* 170 */ 638, 638, 638, 638, 638, 638, 638, 638, 638, 638,
/* 180 */ 634, 634, 634, 634, 634, 771, 634, 634, 780, 634, /* 180 */ 638, 638, 638, 638, 638, 638, 638, 775, 638, 638,
/* 190 */ 634, 634, 634, 634, 634, 802, 634, 794, 634, 634, /* 190 */ 784, 638, 638, 638, 638, 638, 638, 807, 638, 799,
/* 200 */ 634, 634, 634, 634, 634, 748, 634, 634, 634, 634, /* 200 */ 638, 638, 638, 638, 638, 638, 638, 752, 638, 638,
/* 210 */ 634, 634, 634, 634, 634, 634, 634, 634, 634, 857, /* 210 */ 638, 638, 638, 638, 638, 638, 638, 638, 638, 638,
/* 220 */ 634, 634, 634, 742, 855, 634, 634, 634, 634, 634, /* 220 */ 638, 862, 638, 638, 638, 746, 860, 638, 638, 638,
/* 230 */ 634, 634, 634, 634, 634, 634, 634, 634, 634, 707, /* 230 */ 638, 638, 638, 638, 638, 638, 638, 638, 638, 638,
/* 240 */ 634, 658, 656, 634, 650, 634, /* 240 */ 638, 711, 638, 662, 660, 638, 654, 638,
}; };
/********** End of lemon-generated parsing tables *****************************/ /********** End of lemon-generated parsing tables *****************************/
...@@ -679,6 +691,7 @@ struct yyParser { ...@@ -679,6 +691,7 @@ struct yyParser {
int yyerrcnt; /* Shifts left before out of the error */ int yyerrcnt; /* Shifts left before out of the error */
#endif #endif
ParseARG_SDECL /* A place to hold %extra_argument */ ParseARG_SDECL /* A place to hold %extra_argument */
ParseCTX_SDECL /* A place to hold %extra_context */
#if YYSTACKDEPTH<=0 #if YYSTACKDEPTH<=0
int yystksz; /* Current side of the stack */ int yystksz; /* Current side of the stack */
yyStackEntry *yystack; /* The parser's stack */ yyStackEntry *yystack; /* The parser's stack */
...@@ -932,71 +945,70 @@ static const char *const yyTokenName[] = { ...@@ -932,71 +945,70 @@ static const char *const yyTokenName[] = {
/* 203 */ "INSERT", /* 203 */ "INSERT",
/* 204 */ "INTO", /* 204 */ "INTO",
/* 205 */ "VALUES", /* 205 */ "VALUES",
/* 206 */ "error", /* 206 */ "program",
/* 207 */ "program", /* 207 */ "cmd",
/* 208 */ "cmd", /* 208 */ "dbPrefix",
/* 209 */ "dbPrefix", /* 209 */ "ids",
/* 210 */ "ids", /* 210 */ "cpxName",
/* 211 */ "cpxName", /* 211 */ "ifexists",
/* 212 */ "ifexists", /* 212 */ "alter_db_optr",
/* 213 */ "alter_db_optr", /* 213 */ "acct_optr",
/* 214 */ "acct_optr", /* 214 */ "ifnotexists",
/* 215 */ "ifnotexists", /* 215 */ "db_optr",
/* 216 */ "db_optr", /* 216 */ "pps",
/* 217 */ "pps", /* 217 */ "tseries",
/* 218 */ "tseries", /* 218 */ "dbs",
/* 219 */ "dbs", /* 219 */ "streams",
/* 220 */ "streams", /* 220 */ "storage",
/* 221 */ "storage", /* 221 */ "qtime",
/* 222 */ "qtime", /* 222 */ "users",
/* 223 */ "users", /* 223 */ "conns",
/* 224 */ "conns", /* 224 */ "state",
/* 225 */ "state", /* 225 */ "keep",
/* 226 */ "keep", /* 226 */ "tagitemlist",
/* 227 */ "tagitemlist", /* 227 */ "cache",
/* 228 */ "cache", /* 228 */ "replica",
/* 229 */ "replica", /* 229 */ "quorum",
/* 230 */ "quorum", /* 230 */ "days",
/* 231 */ "days", /* 231 */ "minrows",
/* 232 */ "minrows", /* 232 */ "maxrows",
/* 233 */ "maxrows", /* 233 */ "blocks",
/* 234 */ "blocks", /* 234 */ "ctime",
/* 235 */ "ctime", /* 235 */ "wal",
/* 236 */ "wal", /* 236 */ "fsync",
/* 237 */ "fsync", /* 237 */ "comp",
/* 238 */ "comp", /* 238 */ "prec",
/* 239 */ "prec", /* 239 */ "typename",
/* 240 */ "typename", /* 240 */ "signed",
/* 241 */ "signed", /* 241 */ "create_table_args",
/* 242 */ "create_table_args", /* 242 */ "columnlist",
/* 243 */ "columnlist", /* 243 */ "select",
/* 244 */ "select", /* 244 */ "column",
/* 245 */ "column", /* 245 */ "tagitem",
/* 246 */ "tagitem", /* 246 */ "selcollist",
/* 247 */ "selcollist", /* 247 */ "from",
/* 248 */ "from", /* 248 */ "where_opt",
/* 249 */ "where_opt", /* 249 */ "interval_opt",
/* 250 */ "interval_opt", /* 250 */ "fill_opt",
/* 251 */ "fill_opt", /* 251 */ "sliding_opt",
/* 252 */ "sliding_opt", /* 252 */ "groupby_opt",
/* 253 */ "groupby_opt", /* 253 */ "orderby_opt",
/* 254 */ "orderby_opt", /* 254 */ "having_opt",
/* 255 */ "having_opt", /* 255 */ "slimit_opt",
/* 256 */ "slimit_opt", /* 256 */ "limit_opt",
/* 257 */ "limit_opt", /* 257 */ "union",
/* 258 */ "union", /* 258 */ "sclp",
/* 259 */ "sclp", /* 259 */ "expr",
/* 260 */ "expr", /* 260 */ "as",
/* 261 */ "as", /* 261 */ "tablelist",
/* 262 */ "tablelist", /* 262 */ "tmvar",
/* 263 */ "tmvar", /* 263 */ "sortlist",
/* 264 */ "sortlist", /* 264 */ "sortitem",
/* 265 */ "sortitem", /* 265 */ "item",
/* 266 */ "item", /* 266 */ "sortorder",
/* 267 */ "sortorder", /* 267 */ "grouplist",
/* 268 */ "grouplist", /* 268 */ "exprlist",
/* 269 */ "exprlist", /* 269 */ "expritem",
/* 270 */ "expritem",
}; };
#endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */
...@@ -1154,83 +1166,84 @@ static const char *const yyRuleName[] = { ...@@ -1154,83 +1166,84 @@ static const char *const yyRuleName[] = {
/* 147 */ "tablelist ::= tablelist COMMA ids cpxName ids", /* 147 */ "tablelist ::= tablelist COMMA ids cpxName ids",
/* 148 */ "tmvar ::= VARIABLE", /* 148 */ "tmvar ::= VARIABLE",
/* 149 */ "interval_opt ::= INTERVAL LP tmvar RP", /* 149 */ "interval_opt ::= INTERVAL LP tmvar RP",
/* 150 */ "interval_opt ::=", /* 150 */ "interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP",
/* 151 */ "fill_opt ::=", /* 151 */ "interval_opt ::=",
/* 152 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP", /* 152 */ "fill_opt ::=",
/* 153 */ "fill_opt ::= FILL LP ID RP", /* 153 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP",
/* 154 */ "sliding_opt ::= SLIDING LP tmvar RP", /* 154 */ "fill_opt ::= FILL LP ID RP",
/* 155 */ "sliding_opt ::=", /* 155 */ "sliding_opt ::= SLIDING LP tmvar RP",
/* 156 */ "orderby_opt ::=", /* 156 */ "sliding_opt ::=",
/* 157 */ "orderby_opt ::= ORDER BY sortlist", /* 157 */ "orderby_opt ::=",
/* 158 */ "sortlist ::= sortlist COMMA item sortorder", /* 158 */ "orderby_opt ::= ORDER BY sortlist",
/* 159 */ "sortlist ::= item sortorder", /* 159 */ "sortlist ::= sortlist COMMA item sortorder",
/* 160 */ "item ::= ids cpxName", /* 160 */ "sortlist ::= item sortorder",
/* 161 */ "sortorder ::= ASC", /* 161 */ "item ::= ids cpxName",
/* 162 */ "sortorder ::= DESC", /* 162 */ "sortorder ::= ASC",
/* 163 */ "sortorder ::=", /* 163 */ "sortorder ::= DESC",
/* 164 */ "groupby_opt ::=", /* 164 */ "sortorder ::=",
/* 165 */ "groupby_opt ::= GROUP BY grouplist", /* 165 */ "groupby_opt ::=",
/* 166 */ "grouplist ::= grouplist COMMA item", /* 166 */ "groupby_opt ::= GROUP BY grouplist",
/* 167 */ "grouplist ::= item", /* 167 */ "grouplist ::= grouplist COMMA item",
/* 168 */ "having_opt ::=", /* 168 */ "grouplist ::= item",
/* 169 */ "having_opt ::= HAVING expr", /* 169 */ "having_opt ::=",
/* 170 */ "limit_opt ::=", /* 170 */ "having_opt ::= HAVING expr",
/* 171 */ "limit_opt ::= LIMIT signed", /* 171 */ "limit_opt ::=",
/* 172 */ "limit_opt ::= LIMIT signed OFFSET signed", /* 172 */ "limit_opt ::= LIMIT signed",
/* 173 */ "limit_opt ::= LIMIT signed COMMA signed", /* 173 */ "limit_opt ::= LIMIT signed OFFSET signed",
/* 174 */ "slimit_opt ::=", /* 174 */ "limit_opt ::= LIMIT signed COMMA signed",
/* 175 */ "slimit_opt ::= SLIMIT signed", /* 175 */ "slimit_opt ::=",
/* 176 */ "slimit_opt ::= SLIMIT signed SOFFSET signed", /* 176 */ "slimit_opt ::= SLIMIT signed",
/* 177 */ "slimit_opt ::= SLIMIT signed COMMA signed", /* 177 */ "slimit_opt ::= SLIMIT signed SOFFSET signed",
/* 178 */ "where_opt ::=", /* 178 */ "slimit_opt ::= SLIMIT signed COMMA signed",
/* 179 */ "where_opt ::= WHERE expr", /* 179 */ "where_opt ::=",
/* 180 */ "expr ::= LP expr RP", /* 180 */ "where_opt ::= WHERE expr",
/* 181 */ "expr ::= ID", /* 181 */ "expr ::= LP expr RP",
/* 182 */ "expr ::= ID DOT ID", /* 182 */ "expr ::= ID",
/* 183 */ "expr ::= ID DOT STAR", /* 183 */ "expr ::= ID DOT ID",
/* 184 */ "expr ::= INTEGER", /* 184 */ "expr ::= ID DOT STAR",
/* 185 */ "expr ::= MINUS INTEGER", /* 185 */ "expr ::= INTEGER",
/* 186 */ "expr ::= PLUS INTEGER", /* 186 */ "expr ::= MINUS INTEGER",
/* 187 */ "expr ::= FLOAT", /* 187 */ "expr ::= PLUS INTEGER",
/* 188 */ "expr ::= MINUS FLOAT", /* 188 */ "expr ::= FLOAT",
/* 189 */ "expr ::= PLUS FLOAT", /* 189 */ "expr ::= MINUS FLOAT",
/* 190 */ "expr ::= STRING", /* 190 */ "expr ::= PLUS FLOAT",
/* 191 */ "expr ::= NOW", /* 191 */ "expr ::= STRING",
/* 192 */ "expr ::= VARIABLE", /* 192 */ "expr ::= NOW",
/* 193 */ "expr ::= BOOL", /* 193 */ "expr ::= VARIABLE",
/* 194 */ "expr ::= ID LP exprlist RP", /* 194 */ "expr ::= BOOL",
/* 195 */ "expr ::= ID LP STAR RP", /* 195 */ "expr ::= ID LP exprlist RP",
/* 196 */ "expr ::= expr IS NULL", /* 196 */ "expr ::= ID LP STAR RP",
/* 197 */ "expr ::= expr IS NOT NULL", /* 197 */ "expr ::= expr IS NULL",
/* 198 */ "expr ::= expr LT expr", /* 198 */ "expr ::= expr IS NOT NULL",
/* 199 */ "expr ::= expr GT expr", /* 199 */ "expr ::= expr LT expr",
/* 200 */ "expr ::= expr LE expr", /* 200 */ "expr ::= expr GT expr",
/* 201 */ "expr ::= expr GE expr", /* 201 */ "expr ::= expr LE expr",
/* 202 */ "expr ::= expr NE expr", /* 202 */ "expr ::= expr GE expr",
/* 203 */ "expr ::= expr EQ expr", /* 203 */ "expr ::= expr NE expr",
/* 204 */ "expr ::= expr AND expr", /* 204 */ "expr ::= expr EQ expr",
/* 205 */ "expr ::= expr OR expr", /* 205 */ "expr ::= expr AND expr",
/* 206 */ "expr ::= expr PLUS expr", /* 206 */ "expr ::= expr OR expr",
/* 207 */ "expr ::= expr MINUS expr", /* 207 */ "expr ::= expr PLUS expr",
/* 208 */ "expr ::= expr STAR expr", /* 208 */ "expr ::= expr MINUS expr",
/* 209 */ "expr ::= expr SLASH expr", /* 209 */ "expr ::= expr STAR expr",
/* 210 */ "expr ::= expr REM expr", /* 210 */ "expr ::= expr SLASH expr",
/* 211 */ "expr ::= expr LIKE expr", /* 211 */ "expr ::= expr REM expr",
/* 212 */ "expr ::= expr IN LP exprlist RP", /* 212 */ "expr ::= expr LIKE expr",
/* 213 */ "exprlist ::= exprlist COMMA expritem", /* 213 */ "expr ::= expr IN LP exprlist RP",
/* 214 */ "exprlist ::= expritem", /* 214 */ "exprlist ::= exprlist COMMA expritem",
/* 215 */ "expritem ::= expr", /* 215 */ "exprlist ::= expritem",
/* 216 */ "expritem ::=", /* 216 */ "expritem ::= expr",
/* 217 */ "cmd ::= RESET QUERY CACHE", /* 217 */ "expritem ::=",
/* 218 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist", /* 218 */ "cmd ::= RESET QUERY CACHE",
/* 219 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids", /* 219 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist",
/* 220 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist", /* 220 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids",
/* 221 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids", /* 221 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist",
/* 222 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids", /* 222 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids",
/* 223 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem", /* 223 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids",
/* 224 */ "cmd ::= KILL CONNECTION INTEGER", /* 224 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem",
/* 225 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER", /* 225 */ "cmd ::= KILL CONNECTION INTEGER",
/* 226 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER", /* 226 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER",
/* 227 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER",
}; };
#endif /* NDEBUG */ #endif /* NDEBUG */
...@@ -1279,28 +1292,29 @@ static int yyGrowStack(yyParser *p){ ...@@ -1279,28 +1292,29 @@ static int yyGrowStack(yyParser *p){
/* Initialize a new parser that has already been allocated. /* Initialize a new parser that has already been allocated.
*/ */
void ParseInit(void *yypParser){ void ParseInit(void *yypRawParser ParseCTX_PDECL){
yyParser *pParser = (yyParser*)yypParser; yyParser *yypParser = (yyParser*)yypRawParser;
ParseCTX_STORE
#ifdef YYTRACKMAXSTACKDEPTH #ifdef YYTRACKMAXSTACKDEPTH
pParser->yyhwm = 0; yypParser->yyhwm = 0;
#endif #endif
#if YYSTACKDEPTH<=0 #if YYSTACKDEPTH<=0
pParser->yytos = NULL; yypParser->yytos = NULL;
pParser->yystack = NULL; yypParser->yystack = NULL;
pParser->yystksz = 0; yypParser->yystksz = 0;
if( yyGrowStack(pParser) ){ if( yyGrowStack(yypParser) ){
pParser->yystack = &pParser->yystk0; yypParser->yystack = &yypParser->yystk0;
pParser->yystksz = 1; yypParser->yystksz = 1;
} }
#endif #endif
#ifndef YYNOERRORRECOVERY #ifndef YYNOERRORRECOVERY
pParser->yyerrcnt = -1; yypParser->yyerrcnt = -1;
#endif #endif
pParser->yytos = pParser->yystack; yypParser->yytos = yypParser->yystack;
pParser->yystack[0].stateno = 0; yypParser->yystack[0].stateno = 0;
pParser->yystack[0].major = 0; yypParser->yystack[0].major = 0;
#if YYSTACKDEPTH>0 #if YYSTACKDEPTH>0
pParser->yystackEnd = &pParser->yystack[YYSTACKDEPTH-1]; yypParser->yystackEnd = &yypParser->yystack[YYSTACKDEPTH-1];
#endif #endif
} }
...@@ -1317,11 +1331,14 @@ void ParseInit(void *yypParser){ ...@@ -1317,11 +1331,14 @@ void ParseInit(void *yypParser){
** A pointer to a parser. This pointer is used in subsequent calls ** A pointer to a parser. This pointer is used in subsequent calls
** to Parse and ParseFree. ** to Parse and ParseFree.
*/ */
void *ParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE)){ void *ParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE) ParseCTX_PDECL){
yyParser *pParser; yyParser *yypParser;
pParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) ); yypParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) );
if( pParser ) ParseInit(pParser); if( yypParser ){
return pParser; ParseCTX_STORE
ParseInit(yypParser ParseCTX_PARAM);
}
return (void*)yypParser;
} }
#endif /* Parse_ENGINEALWAYSONSTACK */ #endif /* Parse_ENGINEALWAYSONSTACK */
...@@ -1338,7 +1355,8 @@ static void yy_destructor( ...@@ -1338,7 +1355,8 @@ static void yy_destructor(
YYCODETYPE yymajor, /* Type code for object to destroy */ YYCODETYPE yymajor, /* Type code for object to destroy */
YYMINORTYPE *yypminor /* The object to be destroyed */ YYMINORTYPE *yypminor /* The object to be destroyed */
){ ){
ParseARG_FETCH; ParseARG_FETCH
ParseCTX_FETCH
switch( yymajor ){ switch( yymajor ){
/* Here is inserted the actions which take place when a /* Here is inserted the actions which take place when a
** terminal or non-terminal is destroyed. This can happen ** terminal or non-terminal is destroyed. This can happen
...@@ -1351,50 +1369,50 @@ static void yy_destructor( ...@@ -1351,50 +1369,50 @@ static void yy_destructor(
** inside the C code. ** inside the C code.
*/ */
/********* Begin destructor definitions ***************************************/ /********* Begin destructor definitions ***************************************/
case 226: /* keep */ case 225: /* keep */
case 227: /* tagitemlist */ case 226: /* tagitemlist */
case 251: /* fill_opt */ case 250: /* fill_opt */
case 253: /* groupby_opt */ case 252: /* groupby_opt */
case 254: /* orderby_opt */ case 253: /* orderby_opt */
case 264: /* sortlist */ case 263: /* sortlist */
case 268: /* grouplist */ case 267: /* grouplist */
{ {
tVariantListDestroy((yypminor->yy494)); tVariantListDestroy((yypminor->yy156));
} }
break; break;
case 243: /* columnlist */ case 242: /* columnlist */
{ {
tFieldListDestroy((yypminor->yy449)); tFieldListDestroy((yypminor->yy511));
} }
break; break;
case 244: /* select */ case 243: /* select */
{ {
doDestroyQuerySql((yypminor->yy150)); doDestroyQuerySql((yypminor->yy444));
} }
break; break;
case 247: /* selcollist */ case 246: /* selcollist */
case 259: /* sclp */ case 258: /* sclp */
case 269: /* exprlist */ case 268: /* exprlist */
{ {
tSQLExprListDestroy((yypminor->yy224)); tSQLExprListDestroy((yypminor->yy158));
} }
break; break;
case 249: /* where_opt */ case 248: /* where_opt */
case 255: /* having_opt */ case 254: /* having_opt */
case 260: /* expr */ case 259: /* expr */
case 270: /* expritem */ case 269: /* expritem */
{ {
tSQLExprDestroy((yypminor->yy66)); tSQLExprDestroy((yypminor->yy190));
} }
break; break;
case 258: /* union */ case 257: /* union */
{ {
destroyAllSelectClause((yypminor->yy25)); destroyAllSelectClause((yypminor->yy333));
} }
break; break;
case 265: /* sortitem */ case 264: /* sortitem */
{ {
tVariantDestroy(&(yypminor->yy312)); tVariantDestroy(&(yypminor->yy506));
} }
break; break;
/********* End destructor definitions *****************************************/ /********* End destructor definitions *****************************************/
...@@ -1506,13 +1524,12 @@ int ParseCoverage(FILE *out){ ...@@ -1506,13 +1524,12 @@ int ParseCoverage(FILE *out){
** Find the appropriate action for a parser given the terminal ** Find the appropriate action for a parser given the terminal
** look-ahead token iLookAhead. ** look-ahead token iLookAhead.
*/ */
static unsigned int yy_find_shift_action( static YYACTIONTYPE yy_find_shift_action(
yyParser *pParser, /* The parser */ YYCODETYPE iLookAhead, /* The look-ahead token */
YYCODETYPE iLookAhead /* The look-ahead token */ YYACTIONTYPE stateno /* Current state number */
){ ){
int i; int i;
int stateno = pParser->yytos->stateno;
if( stateno>YY_MAX_SHIFT ) return stateno; if( stateno>YY_MAX_SHIFT ) return stateno;
assert( stateno <= YY_SHIFT_COUNT ); assert( stateno <= YY_SHIFT_COUNT );
#if defined(YYCOVERAGE) #if defined(YYCOVERAGE)
...@@ -1520,15 +1537,19 @@ static unsigned int yy_find_shift_action( ...@@ -1520,15 +1537,19 @@ static unsigned int yy_find_shift_action(
#endif #endif
do{ do{
i = yy_shift_ofst[stateno]; i = yy_shift_ofst[stateno];
assert( i>=0 && i+YYNTOKEN<=sizeof(yy_lookahead)/sizeof(yy_lookahead[0]) ); assert( i>=0 );
assert( i<=YY_ACTTAB_COUNT );
assert( i+YYNTOKEN<=(int)YY_NLOOKAHEAD );
assert( iLookAhead!=YYNOCODE ); assert( iLookAhead!=YYNOCODE );
assert( iLookAhead < YYNTOKEN ); assert( iLookAhead < YYNTOKEN );
i += iLookAhead; i += iLookAhead;
assert( i<(int)YY_NLOOKAHEAD );
if( yy_lookahead[i]!=iLookAhead ){ if( yy_lookahead[i]!=iLookAhead ){
#ifdef YYFALLBACK #ifdef YYFALLBACK
YYCODETYPE iFallback; /* Fallback token */ YYCODETYPE iFallback; /* Fallback token */
if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0]) assert( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0]) );
&& (iFallback = yyFallback[iLookAhead])!=0 ){ iFallback = yyFallback[iLookAhead];
if( iFallback!=0 ){
#ifndef NDEBUG #ifndef NDEBUG
if( yyTraceFILE ){ if( yyTraceFILE ){
fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n", fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n",
...@@ -1543,15 +1564,8 @@ static unsigned int yy_find_shift_action( ...@@ -1543,15 +1564,8 @@ static unsigned int yy_find_shift_action(
#ifdef YYWILDCARD #ifdef YYWILDCARD
{ {
int j = i - iLookAhead + YYWILDCARD; int j = i - iLookAhead + YYWILDCARD;
if( assert( j<(int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])) );
#if YY_SHIFT_MIN+YYWILDCARD<0 if( yy_lookahead[j]==YYWILDCARD && iLookAhead>0 ){
j>=0 &&
#endif
#if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT
j<YY_ACTTAB_COUNT &&
#endif
yy_lookahead[j]==YYWILDCARD && iLookAhead>0
){
#ifndef NDEBUG #ifndef NDEBUG
if( yyTraceFILE ){ if( yyTraceFILE ){
fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n", fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n",
...@@ -1565,6 +1579,7 @@ static unsigned int yy_find_shift_action( ...@@ -1565,6 +1579,7 @@ static unsigned int yy_find_shift_action(
#endif /* YYWILDCARD */ #endif /* YYWILDCARD */
return yy_default[stateno]; return yy_default[stateno];
}else{ }else{
assert( i>=0 && i<sizeof(yy_action)/sizeof(yy_action[0]) );
return yy_action[i]; return yy_action[i];
} }
}while(1); }while(1);
...@@ -1574,8 +1589,8 @@ static unsigned int yy_find_shift_action( ...@@ -1574,8 +1589,8 @@ static unsigned int yy_find_shift_action(
** Find the appropriate action for a parser given the non-terminal ** Find the appropriate action for a parser given the non-terminal
** look-ahead token iLookAhead. ** look-ahead token iLookAhead.
*/ */
static int yy_find_reduce_action( static YYACTIONTYPE yy_find_reduce_action(
int stateno, /* Current state number */ YYACTIONTYPE stateno, /* Current state number */
YYCODETYPE iLookAhead /* The look-ahead token */ YYCODETYPE iLookAhead /* The look-ahead token */
){ ){
int i; int i;
...@@ -1604,7 +1619,8 @@ static int yy_find_reduce_action( ...@@ -1604,7 +1619,8 @@ static int yy_find_reduce_action(
** The following routine is called if the stack overflows. ** The following routine is called if the stack overflows.
*/ */
static void yyStackOverflow(yyParser *yypParser){ static void yyStackOverflow(yyParser *yypParser){
ParseARG_FETCH; ParseARG_FETCH
ParseCTX_FETCH
#ifndef NDEBUG #ifndef NDEBUG
if( yyTraceFILE ){ if( yyTraceFILE ){
fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt); fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt);
...@@ -1615,7 +1631,8 @@ static void yyStackOverflow(yyParser *yypParser){ ...@@ -1615,7 +1631,8 @@ static void yyStackOverflow(yyParser *yypParser){
** stack every overflows */ ** stack every overflows */
/******** Begin %stack_overflow code ******************************************/ /******** Begin %stack_overflow code ******************************************/
/******** End %stack_overflow code ********************************************/ /******** End %stack_overflow code ********************************************/
ParseARG_STORE; /* Suppress warning about unused %extra_argument var */ ParseARG_STORE /* Suppress warning about unused %extra_argument var */
ParseCTX_STORE
} }
/* /*
...@@ -1644,8 +1661,8 @@ static void yyTraceShift(yyParser *yypParser, int yyNewState, const char *zTag){ ...@@ -1644,8 +1661,8 @@ static void yyTraceShift(yyParser *yypParser, int yyNewState, const char *zTag){
*/ */
static void yy_shift( static void yy_shift(
yyParser *yypParser, /* The parser to be shifted */ yyParser *yypParser, /* The parser to be shifted */
int yyNewState, /* The new state to shift in */ YYACTIONTYPE yyNewState, /* The new state to shift in */
int yyMajor, /* The major token to shift in */ YYCODETYPE yyMajor, /* The major token to shift in */
ParseTOKENTYPE yyMinor /* The minor token to shift in */ ParseTOKENTYPE yyMinor /* The minor token to shift in */
){ ){
yyStackEntry *yytos; yyStackEntry *yytos;
...@@ -1675,246 +1692,476 @@ static void yy_shift( ...@@ -1675,246 +1692,476 @@ static void yy_shift(
yyNewState += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE; yyNewState += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
} }
yytos = yypParser->yytos; yytos = yypParser->yytos;
yytos->stateno = (YYACTIONTYPE)yyNewState; yytos->stateno = yyNewState;
yytos->major = (YYCODETYPE)yyMajor; yytos->major = yyMajor;
yytos->minor.yy0 = yyMinor; yytos->minor.yy0 = yyMinor;
yyTraceShift(yypParser, yyNewState, "Shift"); yyTraceShift(yypParser, yyNewState, "Shift");
} }
/* The following table contains information about every rule that /* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side
** is used during the reduce. ** of that rule */
*/ static const YYCODETYPE yyRuleInfoLhs[] = {
static const struct { 206, /* (0) program ::= cmd */
YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ 207, /* (1) cmd ::= SHOW DATABASES */
signed char nrhs; /* Negative of the number of RHS symbols in the rule */ 207, /* (2) cmd ::= SHOW MNODES */
} yyRuleInfo[] = { 207, /* (3) cmd ::= SHOW DNODES */
{ 207, -1 }, /* (0) program ::= cmd */ 207, /* (4) cmd ::= SHOW ACCOUNTS */
{ 208, -2 }, /* (1) cmd ::= SHOW DATABASES */ 207, /* (5) cmd ::= SHOW USERS */
{ 208, -2 }, /* (2) cmd ::= SHOW MNODES */ 207, /* (6) cmd ::= SHOW MODULES */
{ 208, -2 }, /* (3) cmd ::= SHOW DNODES */ 207, /* (7) cmd ::= SHOW QUERIES */
{ 208, -2 }, /* (4) cmd ::= SHOW ACCOUNTS */ 207, /* (8) cmd ::= SHOW CONNECTIONS */
{ 208, -2 }, /* (5) cmd ::= SHOW USERS */ 207, /* (9) cmd ::= SHOW STREAMS */
{ 208, -2 }, /* (6) cmd ::= SHOW MODULES */ 207, /* (10) cmd ::= SHOW VARIABLES */
{ 208, -2 }, /* (7) cmd ::= SHOW QUERIES */ 207, /* (11) cmd ::= SHOW SCORES */
{ 208, -2 }, /* (8) cmd ::= SHOW CONNECTIONS */ 207, /* (12) cmd ::= SHOW GRANTS */
{ 208, -2 }, /* (9) cmd ::= SHOW STREAMS */ 207, /* (13) cmd ::= SHOW VNODES */
{ 208, -2 }, /* (10) cmd ::= SHOW VARIABLES */ 207, /* (14) cmd ::= SHOW VNODES IPTOKEN */
{ 208, -2 }, /* (11) cmd ::= SHOW SCORES */ 208, /* (15) dbPrefix ::= */
{ 208, -2 }, /* (12) cmd ::= SHOW GRANTS */ 208, /* (16) dbPrefix ::= ids DOT */
{ 208, -2 }, /* (13) cmd ::= SHOW VNODES */ 210, /* (17) cpxName ::= */
{ 208, -3 }, /* (14) cmd ::= SHOW VNODES IPTOKEN */ 210, /* (18) cpxName ::= DOT ids */
{ 209, 0 }, /* (15) dbPrefix ::= */ 207, /* (19) cmd ::= SHOW dbPrefix TABLES */
{ 209, -2 }, /* (16) dbPrefix ::= ids DOT */ 207, /* (20) cmd ::= SHOW dbPrefix TABLES LIKE ids */
{ 211, 0 }, /* (17) cpxName ::= */ 207, /* (21) cmd ::= SHOW dbPrefix STABLES */
{ 211, -2 }, /* (18) cpxName ::= DOT ids */ 207, /* (22) cmd ::= SHOW dbPrefix STABLES LIKE ids */
{ 208, -3 }, /* (19) cmd ::= SHOW dbPrefix TABLES */ 207, /* (23) cmd ::= SHOW dbPrefix VGROUPS */
{ 208, -5 }, /* (20) cmd ::= SHOW dbPrefix TABLES LIKE ids */ 207, /* (24) cmd ::= SHOW dbPrefix VGROUPS ids */
{ 208, -3 }, /* (21) cmd ::= SHOW dbPrefix STABLES */ 207, /* (25) cmd ::= DROP TABLE ifexists ids cpxName */
{ 208, -5 }, /* (22) cmd ::= SHOW dbPrefix STABLES LIKE ids */ 207, /* (26) cmd ::= DROP DATABASE ifexists ids */
{ 208, -3 }, /* (23) cmd ::= SHOW dbPrefix VGROUPS */ 207, /* (27) cmd ::= DROP DNODE ids */
{ 208, -4 }, /* (24) cmd ::= SHOW dbPrefix VGROUPS ids */ 207, /* (28) cmd ::= DROP USER ids */
{ 208, -5 }, /* (25) cmd ::= DROP TABLE ifexists ids cpxName */ 207, /* (29) cmd ::= DROP ACCOUNT ids */
{ 208, -4 }, /* (26) cmd ::= DROP DATABASE ifexists ids */ 207, /* (30) cmd ::= USE ids */
{ 208, -3 }, /* (27) cmd ::= DROP DNODE ids */ 207, /* (31) cmd ::= DESCRIBE ids cpxName */
{ 208, -3 }, /* (28) cmd ::= DROP USER ids */ 207, /* (32) cmd ::= ALTER USER ids PASS ids */
{ 208, -3 }, /* (29) cmd ::= DROP ACCOUNT ids */ 207, /* (33) cmd ::= ALTER USER ids PRIVILEGE ids */
{ 208, -2 }, /* (30) cmd ::= USE ids */ 207, /* (34) cmd ::= ALTER DNODE ids ids */
{ 208, -3 }, /* (31) cmd ::= DESCRIBE ids cpxName */ 207, /* (35) cmd ::= ALTER DNODE ids ids ids */
{ 208, -5 }, /* (32) cmd ::= ALTER USER ids PASS ids */ 207, /* (36) cmd ::= ALTER LOCAL ids */
{ 208, -5 }, /* (33) cmd ::= ALTER USER ids PRIVILEGE ids */ 207, /* (37) cmd ::= ALTER LOCAL ids ids */
{ 208, -4 }, /* (34) cmd ::= ALTER DNODE ids ids */ 207, /* (38) cmd ::= ALTER DATABASE ids alter_db_optr */
{ 208, -5 }, /* (35) cmd ::= ALTER DNODE ids ids ids */ 207, /* (39) cmd ::= ALTER ACCOUNT ids acct_optr */
{ 208, -3 }, /* (36) cmd ::= ALTER LOCAL ids */ 207, /* (40) cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */
{ 208, -4 }, /* (37) cmd ::= ALTER LOCAL ids ids */ 209, /* (41) ids ::= ID */
{ 208, -4 }, /* (38) cmd ::= ALTER DATABASE ids alter_db_optr */ 209, /* (42) ids ::= STRING */
{ 208, -4 }, /* (39) cmd ::= ALTER ACCOUNT ids acct_optr */ 211, /* (43) ifexists ::= IF EXISTS */
{ 208, -6 }, /* (40) cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ 211, /* (44) ifexists ::= */
{ 210, -1 }, /* (41) ids ::= ID */ 214, /* (45) ifnotexists ::= IF NOT EXISTS */
{ 210, -1 }, /* (42) ids ::= STRING */ 214, /* (46) ifnotexists ::= */
{ 212, -2 }, /* (43) ifexists ::= IF EXISTS */ 207, /* (47) cmd ::= CREATE DNODE ids */
{ 212, 0 }, /* (44) ifexists ::= */ 207, /* (48) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */
{ 215, -3 }, /* (45) ifnotexists ::= IF NOT EXISTS */ 207, /* (49) cmd ::= CREATE DATABASE ifnotexists ids db_optr */
{ 215, 0 }, /* (46) ifnotexists ::= */ 207, /* (50) cmd ::= CREATE USER ids PASS ids */
{ 208, -3 }, /* (47) cmd ::= CREATE DNODE ids */ 216, /* (51) pps ::= */
{ 208, -6 }, /* (48) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ 216, /* (52) pps ::= PPS INTEGER */
{ 208, -5 }, /* (49) cmd ::= CREATE DATABASE ifnotexists ids db_optr */ 217, /* (53) tseries ::= */
{ 208, -5 }, /* (50) cmd ::= CREATE USER ids PASS ids */ 217, /* (54) tseries ::= TSERIES INTEGER */
{ 217, 0 }, /* (51) pps ::= */ 218, /* (55) dbs ::= */
{ 217, -2 }, /* (52) pps ::= PPS INTEGER */ 218, /* (56) dbs ::= DBS INTEGER */
{ 218, 0 }, /* (53) tseries ::= */ 219, /* (57) streams ::= */
{ 218, -2 }, /* (54) tseries ::= TSERIES INTEGER */ 219, /* (58) streams ::= STREAMS INTEGER */
{ 219, 0 }, /* (55) dbs ::= */ 220, /* (59) storage ::= */
{ 219, -2 }, /* (56) dbs ::= DBS INTEGER */ 220, /* (60) storage ::= STORAGE INTEGER */
{ 220, 0 }, /* (57) streams ::= */ 221, /* (61) qtime ::= */
{ 220, -2 }, /* (58) streams ::= STREAMS INTEGER */ 221, /* (62) qtime ::= QTIME INTEGER */
{ 221, 0 }, /* (59) storage ::= */ 222, /* (63) users ::= */
{ 221, -2 }, /* (60) storage ::= STORAGE INTEGER */ 222, /* (64) users ::= USERS INTEGER */
{ 222, 0 }, /* (61) qtime ::= */ 223, /* (65) conns ::= */
{ 222, -2 }, /* (62) qtime ::= QTIME INTEGER */ 223, /* (66) conns ::= CONNS INTEGER */
{ 223, 0 }, /* (63) users ::= */ 224, /* (67) state ::= */
{ 223, -2 }, /* (64) users ::= USERS INTEGER */ 224, /* (68) state ::= STATE ids */
{ 224, 0 }, /* (65) conns ::= */ 213, /* (69) acct_optr ::= pps tseries storage streams qtime dbs users conns state */
{ 224, -2 }, /* (66) conns ::= CONNS INTEGER */ 225, /* (70) keep ::= KEEP tagitemlist */
{ 225, 0 }, /* (67) state ::= */ 227, /* (71) cache ::= CACHE INTEGER */
{ 225, -2 }, /* (68) state ::= STATE ids */ 228, /* (72) replica ::= REPLICA INTEGER */
{ 214, -9 }, /* (69) acct_optr ::= pps tseries storage streams qtime dbs users conns state */ 229, /* (73) quorum ::= QUORUM INTEGER */
{ 226, -2 }, /* (70) keep ::= KEEP tagitemlist */ 230, /* (74) days ::= DAYS INTEGER */
{ 228, -2 }, /* (71) cache ::= CACHE INTEGER */ 231, /* (75) minrows ::= MINROWS INTEGER */
{ 229, -2 }, /* (72) replica ::= REPLICA INTEGER */ 232, /* (76) maxrows ::= MAXROWS INTEGER */
{ 230, -2 }, /* (73) quorum ::= QUORUM INTEGER */ 233, /* (77) blocks ::= BLOCKS INTEGER */
{ 231, -2 }, /* (74) days ::= DAYS INTEGER */ 234, /* (78) ctime ::= CTIME INTEGER */
{ 232, -2 }, /* (75) minrows ::= MINROWS INTEGER */ 235, /* (79) wal ::= WAL INTEGER */
{ 233, -2 }, /* (76) maxrows ::= MAXROWS INTEGER */ 236, /* (80) fsync ::= FSYNC INTEGER */
{ 234, -2 }, /* (77) blocks ::= BLOCKS INTEGER */ 237, /* (81) comp ::= COMP INTEGER */
{ 235, -2 }, /* (78) ctime ::= CTIME INTEGER */ 238, /* (82) prec ::= PRECISION STRING */
{ 236, -2 }, /* (79) wal ::= WAL INTEGER */ 215, /* (83) db_optr ::= */
{ 237, -2 }, /* (80) fsync ::= FSYNC INTEGER */ 215, /* (84) db_optr ::= db_optr cache */
{ 238, -2 }, /* (81) comp ::= COMP INTEGER */ 215, /* (85) db_optr ::= db_optr replica */
{ 239, -2 }, /* (82) prec ::= PRECISION STRING */ 215, /* (86) db_optr ::= db_optr quorum */
{ 216, 0 }, /* (83) db_optr ::= */ 215, /* (87) db_optr ::= db_optr days */
{ 216, -2 }, /* (84) db_optr ::= db_optr cache */ 215, /* (88) db_optr ::= db_optr minrows */
{ 216, -2 }, /* (85) db_optr ::= db_optr replica */ 215, /* (89) db_optr ::= db_optr maxrows */
{ 216, -2 }, /* (86) db_optr ::= db_optr quorum */ 215, /* (90) db_optr ::= db_optr blocks */
{ 216, -2 }, /* (87) db_optr ::= db_optr days */ 215, /* (91) db_optr ::= db_optr ctime */
{ 216, -2 }, /* (88) db_optr ::= db_optr minrows */ 215, /* (92) db_optr ::= db_optr wal */
{ 216, -2 }, /* (89) db_optr ::= db_optr maxrows */ 215, /* (93) db_optr ::= db_optr fsync */
{ 216, -2 }, /* (90) db_optr ::= db_optr blocks */ 215, /* (94) db_optr ::= db_optr comp */
{ 216, -2 }, /* (91) db_optr ::= db_optr ctime */ 215, /* (95) db_optr ::= db_optr prec */
{ 216, -2 }, /* (92) db_optr ::= db_optr wal */ 215, /* (96) db_optr ::= db_optr keep */
{ 216, -2 }, /* (93) db_optr ::= db_optr fsync */ 212, /* (97) alter_db_optr ::= */
{ 216, -2 }, /* (94) db_optr ::= db_optr comp */ 212, /* (98) alter_db_optr ::= alter_db_optr replica */
{ 216, -2 }, /* (95) db_optr ::= db_optr prec */ 212, /* (99) alter_db_optr ::= alter_db_optr quorum */
{ 216, -2 }, /* (96) db_optr ::= db_optr keep */ 212, /* (100) alter_db_optr ::= alter_db_optr keep */
{ 213, 0 }, /* (97) alter_db_optr ::= */ 212, /* (101) alter_db_optr ::= alter_db_optr blocks */
{ 213, -2 }, /* (98) alter_db_optr ::= alter_db_optr replica */ 212, /* (102) alter_db_optr ::= alter_db_optr comp */
{ 213, -2 }, /* (99) alter_db_optr ::= alter_db_optr quorum */ 212, /* (103) alter_db_optr ::= alter_db_optr wal */
{ 213, -2 }, /* (100) alter_db_optr ::= alter_db_optr keep */ 212, /* (104) alter_db_optr ::= alter_db_optr fsync */
{ 213, -2 }, /* (101) alter_db_optr ::= alter_db_optr blocks */ 239, /* (105) typename ::= ids */
{ 213, -2 }, /* (102) alter_db_optr ::= alter_db_optr comp */ 239, /* (106) typename ::= ids LP signed RP */
{ 213, -2 }, /* (103) alter_db_optr ::= alter_db_optr wal */ 240, /* (107) signed ::= INTEGER */
{ 213, -2 }, /* (104) alter_db_optr ::= alter_db_optr fsync */ 240, /* (108) signed ::= PLUS INTEGER */
{ 240, -1 }, /* (105) typename ::= ids */ 240, /* (109) signed ::= MINUS INTEGER */
{ 240, -4 }, /* (106) typename ::= ids LP signed RP */ 207, /* (110) cmd ::= CREATE TABLE ifnotexists ids cpxName create_table_args */
{ 241, -1 }, /* (107) signed ::= INTEGER */ 241, /* (111) create_table_args ::= LP columnlist RP */
{ 241, -2 }, /* (108) signed ::= PLUS INTEGER */ 241, /* (112) create_table_args ::= LP columnlist RP TAGS LP columnlist RP */
{ 241, -2 }, /* (109) signed ::= MINUS INTEGER */ 241, /* (113) create_table_args ::= USING ids cpxName TAGS LP tagitemlist RP */
{ 208, -6 }, /* (110) cmd ::= CREATE TABLE ifnotexists ids cpxName create_table_args */ 241, /* (114) create_table_args ::= AS select */
{ 242, -3 }, /* (111) create_table_args ::= LP columnlist RP */ 242, /* (115) columnlist ::= columnlist COMMA column */
{ 242, -7 }, /* (112) create_table_args ::= LP columnlist RP TAGS LP columnlist RP */ 242, /* (116) columnlist ::= column */
{ 242, -7 }, /* (113) create_table_args ::= USING ids cpxName TAGS LP tagitemlist RP */ 244, /* (117) column ::= ids typename */
{ 242, -2 }, /* (114) create_table_args ::= AS select */ 226, /* (118) tagitemlist ::= tagitemlist COMMA tagitem */
{ 243, -3 }, /* (115) columnlist ::= columnlist COMMA column */ 226, /* (119) tagitemlist ::= tagitem */
{ 243, -1 }, /* (116) columnlist ::= column */ 245, /* (120) tagitem ::= INTEGER */
{ 245, -2 }, /* (117) column ::= ids typename */ 245, /* (121) tagitem ::= FLOAT */
{ 227, -3 }, /* (118) tagitemlist ::= tagitemlist COMMA tagitem */ 245, /* (122) tagitem ::= STRING */
{ 227, -1 }, /* (119) tagitemlist ::= tagitem */ 245, /* (123) tagitem ::= BOOL */
{ 246, -1 }, /* (120) tagitem ::= INTEGER */ 245, /* (124) tagitem ::= NULL */
{ 246, -1 }, /* (121) tagitem ::= FLOAT */ 245, /* (125) tagitem ::= MINUS INTEGER */
{ 246, -1 }, /* (122) tagitem ::= STRING */ 245, /* (126) tagitem ::= MINUS FLOAT */
{ 246, -1 }, /* (123) tagitem ::= BOOL */ 245, /* (127) tagitem ::= PLUS INTEGER */
{ 246, -1 }, /* (124) tagitem ::= NULL */ 245, /* (128) tagitem ::= PLUS FLOAT */
{ 246, -2 }, /* (125) tagitem ::= MINUS INTEGER */ 243, /* (129) select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */
{ 246, -2 }, /* (126) tagitem ::= MINUS FLOAT */ 257, /* (130) union ::= select */
{ 246, -2 }, /* (127) tagitem ::= PLUS INTEGER */ 257, /* (131) union ::= LP union RP */
{ 246, -2 }, /* (128) tagitem ::= PLUS FLOAT */ 257, /* (132) union ::= union UNION ALL select */
{ 244, -12 }, /* (129) select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */ 257, /* (133) union ::= union UNION ALL LP select RP */
{ 258, -1 }, /* (130) union ::= select */ 207, /* (134) cmd ::= union */
{ 258, -3 }, /* (131) union ::= LP union RP */ 243, /* (135) select ::= SELECT selcollist */
{ 258, -4 }, /* (132) union ::= union UNION ALL select */ 258, /* (136) sclp ::= selcollist COMMA */
{ 258, -6 }, /* (133) union ::= union UNION ALL LP select RP */ 258, /* (137) sclp ::= */
{ 208, -1 }, /* (134) cmd ::= union */ 246, /* (138) selcollist ::= sclp expr as */
{ 244, -2 }, /* (135) select ::= SELECT selcollist */ 246, /* (139) selcollist ::= sclp STAR */
{ 259, -2 }, /* (136) sclp ::= selcollist COMMA */ 260, /* (140) as ::= AS ids */
{ 259, 0 }, /* (137) sclp ::= */ 260, /* (141) as ::= ids */
{ 247, -3 }, /* (138) selcollist ::= sclp expr as */ 260, /* (142) as ::= */
{ 247, -2 }, /* (139) selcollist ::= sclp STAR */ 247, /* (143) from ::= FROM tablelist */
{ 261, -2 }, /* (140) as ::= AS ids */ 261, /* (144) tablelist ::= ids cpxName */
{ 261, -1 }, /* (141) as ::= ids */ 261, /* (145) tablelist ::= ids cpxName ids */
{ 261, 0 }, /* (142) as ::= */ 261, /* (146) tablelist ::= tablelist COMMA ids cpxName */
{ 248, -2 }, /* (143) from ::= FROM tablelist */ 261, /* (147) tablelist ::= tablelist COMMA ids cpxName ids */
{ 262, -2 }, /* (144) tablelist ::= ids cpxName */ 262, /* (148) tmvar ::= VARIABLE */
{ 262, -3 }, /* (145) tablelist ::= ids cpxName ids */ 249, /* (149) interval_opt ::= INTERVAL LP tmvar RP */
{ 262, -4 }, /* (146) tablelist ::= tablelist COMMA ids cpxName */ 249, /* (150) interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */
{ 262, -5 }, /* (147) tablelist ::= tablelist COMMA ids cpxName ids */ 249, /* (151) interval_opt ::= */
{ 263, -1 }, /* (148) tmvar ::= VARIABLE */ 250, /* (152) fill_opt ::= */
{ 250, -4 }, /* (149) interval_opt ::= INTERVAL LP tmvar RP */ 250, /* (153) fill_opt ::= FILL LP ID COMMA tagitemlist RP */
{ 250, 0 }, /* (150) interval_opt ::= */ 250, /* (154) fill_opt ::= FILL LP ID RP */
{ 251, 0 }, /* (151) fill_opt ::= */ 251, /* (155) sliding_opt ::= SLIDING LP tmvar RP */
{ 251, -6 }, /* (152) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ 251, /* (156) sliding_opt ::= */
{ 251, -4 }, /* (153) fill_opt ::= FILL LP ID RP */ 253, /* (157) orderby_opt ::= */
{ 252, -4 }, /* (154) sliding_opt ::= SLIDING LP tmvar RP */ 253, /* (158) orderby_opt ::= ORDER BY sortlist */
{ 252, 0 }, /* (155) sliding_opt ::= */ 263, /* (159) sortlist ::= sortlist COMMA item sortorder */
{ 254, 0 }, /* (156) orderby_opt ::= */ 263, /* (160) sortlist ::= item sortorder */
{ 254, -3 }, /* (157) orderby_opt ::= ORDER BY sortlist */ 265, /* (161) item ::= ids cpxName */
{ 264, -4 }, /* (158) sortlist ::= sortlist COMMA item sortorder */ 266, /* (162) sortorder ::= ASC */
{ 264, -2 }, /* (159) sortlist ::= item sortorder */ 266, /* (163) sortorder ::= DESC */
{ 266, -2 }, /* (160) item ::= ids cpxName */ 266, /* (164) sortorder ::= */
{ 267, -1 }, /* (161) sortorder ::= ASC */ 252, /* (165) groupby_opt ::= */
{ 267, -1 }, /* (162) sortorder ::= DESC */ 252, /* (166) groupby_opt ::= GROUP BY grouplist */
{ 267, 0 }, /* (163) sortorder ::= */ 267, /* (167) grouplist ::= grouplist COMMA item */
{ 253, 0 }, /* (164) groupby_opt ::= */ 267, /* (168) grouplist ::= item */
{ 253, -3 }, /* (165) groupby_opt ::= GROUP BY grouplist */ 254, /* (169) having_opt ::= */
{ 268, -3 }, /* (166) grouplist ::= grouplist COMMA item */ 254, /* (170) having_opt ::= HAVING expr */
{ 268, -1 }, /* (167) grouplist ::= item */ 256, /* (171) limit_opt ::= */
{ 255, 0 }, /* (168) having_opt ::= */ 256, /* (172) limit_opt ::= LIMIT signed */
{ 255, -2 }, /* (169) having_opt ::= HAVING expr */ 256, /* (173) limit_opt ::= LIMIT signed OFFSET signed */
{ 257, 0 }, /* (170) limit_opt ::= */ 256, /* (174) limit_opt ::= LIMIT signed COMMA signed */
{ 257, -2 }, /* (171) limit_opt ::= LIMIT signed */ 255, /* (175) slimit_opt ::= */
{ 257, -4 }, /* (172) limit_opt ::= LIMIT signed OFFSET signed */ 255, /* (176) slimit_opt ::= SLIMIT signed */
{ 257, -4 }, /* (173) limit_opt ::= LIMIT signed COMMA signed */ 255, /* (177) slimit_opt ::= SLIMIT signed SOFFSET signed */
{ 256, 0 }, /* (174) slimit_opt ::= */ 255, /* (178) slimit_opt ::= SLIMIT signed COMMA signed */
{ 256, -2 }, /* (175) slimit_opt ::= SLIMIT signed */ 248, /* (179) where_opt ::= */
{ 256, -4 }, /* (176) slimit_opt ::= SLIMIT signed SOFFSET signed */ 248, /* (180) where_opt ::= WHERE expr */
{ 256, -4 }, /* (177) slimit_opt ::= SLIMIT signed COMMA signed */ 259, /* (181) expr ::= LP expr RP */
{ 249, 0 }, /* (178) where_opt ::= */ 259, /* (182) expr ::= ID */
{ 249, -2 }, /* (179) where_opt ::= WHERE expr */ 259, /* (183) expr ::= ID DOT ID */
{ 260, -3 }, /* (180) expr ::= LP expr RP */ 259, /* (184) expr ::= ID DOT STAR */
{ 260, -1 }, /* (181) expr ::= ID */ 259, /* (185) expr ::= INTEGER */
{ 260, -3 }, /* (182) expr ::= ID DOT ID */ 259, /* (186) expr ::= MINUS INTEGER */
{ 260, -3 }, /* (183) expr ::= ID DOT STAR */ 259, /* (187) expr ::= PLUS INTEGER */
{ 260, -1 }, /* (184) expr ::= INTEGER */ 259, /* (188) expr ::= FLOAT */
{ 260, -2 }, /* (185) expr ::= MINUS INTEGER */ 259, /* (189) expr ::= MINUS FLOAT */
{ 260, -2 }, /* (186) expr ::= PLUS INTEGER */ 259, /* (190) expr ::= PLUS FLOAT */
{ 260, -1 }, /* (187) expr ::= FLOAT */ 259, /* (191) expr ::= STRING */
{ 260, -2 }, /* (188) expr ::= MINUS FLOAT */ 259, /* (192) expr ::= NOW */
{ 260, -2 }, /* (189) expr ::= PLUS FLOAT */ 259, /* (193) expr ::= VARIABLE */
{ 260, -1 }, /* (190) expr ::= STRING */ 259, /* (194) expr ::= BOOL */
{ 260, -1 }, /* (191) expr ::= NOW */ 259, /* (195) expr ::= ID LP exprlist RP */
{ 260, -1 }, /* (192) expr ::= VARIABLE */ 259, /* (196) expr ::= ID LP STAR RP */
{ 260, -1 }, /* (193) expr ::= BOOL */ 259, /* (197) expr ::= expr IS NULL */
{ 260, -4 }, /* (194) expr ::= ID LP exprlist RP */ 259, /* (198) expr ::= expr IS NOT NULL */
{ 260, -4 }, /* (195) expr ::= ID LP STAR RP */ 259, /* (199) expr ::= expr LT expr */
{ 260, -3 }, /* (196) expr ::= expr IS NULL */ 259, /* (200) expr ::= expr GT expr */
{ 260, -4 }, /* (197) expr ::= expr IS NOT NULL */ 259, /* (201) expr ::= expr LE expr */
{ 260, -3 }, /* (198) expr ::= expr LT expr */ 259, /* (202) expr ::= expr GE expr */
{ 260, -3 }, /* (199) expr ::= expr GT expr */ 259, /* (203) expr ::= expr NE expr */
{ 260, -3 }, /* (200) expr ::= expr LE expr */ 259, /* (204) expr ::= expr EQ expr */
{ 260, -3 }, /* (201) expr ::= expr GE expr */ 259, /* (205) expr ::= expr AND expr */
{ 260, -3 }, /* (202) expr ::= expr NE expr */ 259, /* (206) expr ::= expr OR expr */
{ 260, -3 }, /* (203) expr ::= expr EQ expr */ 259, /* (207) expr ::= expr PLUS expr */
{ 260, -3 }, /* (204) expr ::= expr AND expr */ 259, /* (208) expr ::= expr MINUS expr */
{ 260, -3 }, /* (205) expr ::= expr OR expr */ 259, /* (209) expr ::= expr STAR expr */
{ 260, -3 }, /* (206) expr ::= expr PLUS expr */ 259, /* (210) expr ::= expr SLASH expr */
{ 260, -3 }, /* (207) expr ::= expr MINUS expr */ 259, /* (211) expr ::= expr REM expr */
{ 260, -3 }, /* (208) expr ::= expr STAR expr */ 259, /* (212) expr ::= expr LIKE expr */
{ 260, -3 }, /* (209) expr ::= expr SLASH expr */ 259, /* (213) expr ::= expr IN LP exprlist RP */
{ 260, -3 }, /* (210) expr ::= expr REM expr */ 268, /* (214) exprlist ::= exprlist COMMA expritem */
{ 260, -3 }, /* (211) expr ::= expr LIKE expr */ 268, /* (215) exprlist ::= expritem */
{ 260, -5 }, /* (212) expr ::= expr IN LP exprlist RP */ 269, /* (216) expritem ::= expr */
{ 269, -3 }, /* (213) exprlist ::= exprlist COMMA expritem */ 269, /* (217) expritem ::= */
{ 269, -1 }, /* (214) exprlist ::= expritem */ 207, /* (218) cmd ::= RESET QUERY CACHE */
{ 270, -1 }, /* (215) expritem ::= expr */ 207, /* (219) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */
{ 270, 0 }, /* (216) expritem ::= */ 207, /* (220) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */
{ 208, -3 }, /* (217) cmd ::= RESET QUERY CACHE */ 207, /* (221) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */
{ 208, -7 }, /* (218) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ 207, /* (222) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */
{ 208, -7 }, /* (219) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ 207, /* (223) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */
{ 208, -7 }, /* (220) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ 207, /* (224) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */
{ 208, -7 }, /* (221) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ 207, /* (225) cmd ::= KILL CONNECTION INTEGER */
{ 208, -8 }, /* (222) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ 207, /* (226) cmd ::= KILL STREAM INTEGER COLON INTEGER */
{ 208, -9 }, /* (223) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ 207, /* (227) cmd ::= KILL QUERY INTEGER COLON INTEGER */
{ 208, -3 }, /* (224) cmd ::= KILL CONNECTION INTEGER */ };
{ 208, -5 }, /* (225) cmd ::= KILL STREAM INTEGER COLON INTEGER */
{ 208, -5 }, /* (226) cmd ::= KILL QUERY INTEGER COLON INTEGER */ /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number
** of symbols on the right-hand side of that rule. */
static const signed char yyRuleInfoNRhs[] = {
-1, /* (0) program ::= cmd */
-2, /* (1) cmd ::= SHOW DATABASES */
-2, /* (2) cmd ::= SHOW MNODES */
-2, /* (3) cmd ::= SHOW DNODES */
-2, /* (4) cmd ::= SHOW ACCOUNTS */
-2, /* (5) cmd ::= SHOW USERS */
-2, /* (6) cmd ::= SHOW MODULES */
-2, /* (7) cmd ::= SHOW QUERIES */
-2, /* (8) cmd ::= SHOW CONNECTIONS */
-2, /* (9) cmd ::= SHOW STREAMS */
-2, /* (10) cmd ::= SHOW VARIABLES */
-2, /* (11) cmd ::= SHOW SCORES */
-2, /* (12) cmd ::= SHOW GRANTS */
-2, /* (13) cmd ::= SHOW VNODES */
-3, /* (14) cmd ::= SHOW VNODES IPTOKEN */
0, /* (15) dbPrefix ::= */
-2, /* (16) dbPrefix ::= ids DOT */
0, /* (17) cpxName ::= */
-2, /* (18) cpxName ::= DOT ids */
-3, /* (19) cmd ::= SHOW dbPrefix TABLES */
-5, /* (20) cmd ::= SHOW dbPrefix TABLES LIKE ids */
-3, /* (21) cmd ::= SHOW dbPrefix STABLES */
-5, /* (22) cmd ::= SHOW dbPrefix STABLES LIKE ids */
-3, /* (23) cmd ::= SHOW dbPrefix VGROUPS */
-4, /* (24) cmd ::= SHOW dbPrefix VGROUPS ids */
-5, /* (25) cmd ::= DROP TABLE ifexists ids cpxName */
-4, /* (26) cmd ::= DROP DATABASE ifexists ids */
-3, /* (27) cmd ::= DROP DNODE ids */
-3, /* (28) cmd ::= DROP USER ids */
-3, /* (29) cmd ::= DROP ACCOUNT ids */
-2, /* (30) cmd ::= USE ids */
-3, /* (31) cmd ::= DESCRIBE ids cpxName */
-5, /* (32) cmd ::= ALTER USER ids PASS ids */
-5, /* (33) cmd ::= ALTER USER ids PRIVILEGE ids */
-4, /* (34) cmd ::= ALTER DNODE ids ids */
-5, /* (35) cmd ::= ALTER DNODE ids ids ids */
-3, /* (36) cmd ::= ALTER LOCAL ids */
-4, /* (37) cmd ::= ALTER LOCAL ids ids */
-4, /* (38) cmd ::= ALTER DATABASE ids alter_db_optr */
-4, /* (39) cmd ::= ALTER ACCOUNT ids acct_optr */
-6, /* (40) cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */
-1, /* (41) ids ::= ID */
-1, /* (42) ids ::= STRING */
-2, /* (43) ifexists ::= IF EXISTS */
0, /* (44) ifexists ::= */
-3, /* (45) ifnotexists ::= IF NOT EXISTS */
0, /* (46) ifnotexists ::= */
-3, /* (47) cmd ::= CREATE DNODE ids */
-6, /* (48) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */
-5, /* (49) cmd ::= CREATE DATABASE ifnotexists ids db_optr */
-5, /* (50) cmd ::= CREATE USER ids PASS ids */
0, /* (51) pps ::= */
-2, /* (52) pps ::= PPS INTEGER */
0, /* (53) tseries ::= */
-2, /* (54) tseries ::= TSERIES INTEGER */
0, /* (55) dbs ::= */
-2, /* (56) dbs ::= DBS INTEGER */
0, /* (57) streams ::= */
-2, /* (58) streams ::= STREAMS INTEGER */
0, /* (59) storage ::= */
-2, /* (60) storage ::= STORAGE INTEGER */
0, /* (61) qtime ::= */
-2, /* (62) qtime ::= QTIME INTEGER */
0, /* (63) users ::= */
-2, /* (64) users ::= USERS INTEGER */
0, /* (65) conns ::= */
-2, /* (66) conns ::= CONNS INTEGER */
0, /* (67) state ::= */
-2, /* (68) state ::= STATE ids */
-9, /* (69) acct_optr ::= pps tseries storage streams qtime dbs users conns state */
-2, /* (70) keep ::= KEEP tagitemlist */
-2, /* (71) cache ::= CACHE INTEGER */
-2, /* (72) replica ::= REPLICA INTEGER */
-2, /* (73) quorum ::= QUORUM INTEGER */
-2, /* (74) days ::= DAYS INTEGER */
-2, /* (75) minrows ::= MINROWS INTEGER */
-2, /* (76) maxrows ::= MAXROWS INTEGER */
-2, /* (77) blocks ::= BLOCKS INTEGER */
-2, /* (78) ctime ::= CTIME INTEGER */
-2, /* (79) wal ::= WAL INTEGER */
-2, /* (80) fsync ::= FSYNC INTEGER */
-2, /* (81) comp ::= COMP INTEGER */
-2, /* (82) prec ::= PRECISION STRING */
0, /* (83) db_optr ::= */
-2, /* (84) db_optr ::= db_optr cache */
-2, /* (85) db_optr ::= db_optr replica */
-2, /* (86) db_optr ::= db_optr quorum */
-2, /* (87) db_optr ::= db_optr days */
-2, /* (88) db_optr ::= db_optr minrows */
-2, /* (89) db_optr ::= db_optr maxrows */
-2, /* (90) db_optr ::= db_optr blocks */
-2, /* (91) db_optr ::= db_optr ctime */
-2, /* (92) db_optr ::= db_optr wal */
-2, /* (93) db_optr ::= db_optr fsync */
-2, /* (94) db_optr ::= db_optr comp */
-2, /* (95) db_optr ::= db_optr prec */
-2, /* (96) db_optr ::= db_optr keep */
0, /* (97) alter_db_optr ::= */
-2, /* (98) alter_db_optr ::= alter_db_optr replica */
-2, /* (99) alter_db_optr ::= alter_db_optr quorum */
-2, /* (100) alter_db_optr ::= alter_db_optr keep */
-2, /* (101) alter_db_optr ::= alter_db_optr blocks */
-2, /* (102) alter_db_optr ::= alter_db_optr comp */
-2, /* (103) alter_db_optr ::= alter_db_optr wal */
-2, /* (104) alter_db_optr ::= alter_db_optr fsync */
-1, /* (105) typename ::= ids */
-4, /* (106) typename ::= ids LP signed RP */
-1, /* (107) signed ::= INTEGER */
-2, /* (108) signed ::= PLUS INTEGER */
-2, /* (109) signed ::= MINUS INTEGER */
-6, /* (110) cmd ::= CREATE TABLE ifnotexists ids cpxName create_table_args */
-3, /* (111) create_table_args ::= LP columnlist RP */
-7, /* (112) create_table_args ::= LP columnlist RP TAGS LP columnlist RP */
-7, /* (113) create_table_args ::= USING ids cpxName TAGS LP tagitemlist RP */
-2, /* (114) create_table_args ::= AS select */
-3, /* (115) columnlist ::= columnlist COMMA column */
-1, /* (116) columnlist ::= column */
-2, /* (117) column ::= ids typename */
-3, /* (118) tagitemlist ::= tagitemlist COMMA tagitem */
-1, /* (119) tagitemlist ::= tagitem */
-1, /* (120) tagitem ::= INTEGER */
-1, /* (121) tagitem ::= FLOAT */
-1, /* (122) tagitem ::= STRING */
-1, /* (123) tagitem ::= BOOL */
-1, /* (124) tagitem ::= NULL */
-2, /* (125) tagitem ::= MINUS INTEGER */
-2, /* (126) tagitem ::= MINUS FLOAT */
-2, /* (127) tagitem ::= PLUS INTEGER */
-2, /* (128) tagitem ::= PLUS FLOAT */
-12, /* (129) select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */
-1, /* (130) union ::= select */
-3, /* (131) union ::= LP union RP */
-4, /* (132) union ::= union UNION ALL select */
-6, /* (133) union ::= union UNION ALL LP select RP */
-1, /* (134) cmd ::= union */
-2, /* (135) select ::= SELECT selcollist */
-2, /* (136) sclp ::= selcollist COMMA */
0, /* (137) sclp ::= */
-3, /* (138) selcollist ::= sclp expr as */
-2, /* (139) selcollist ::= sclp STAR */
-2, /* (140) as ::= AS ids */
-1, /* (141) as ::= ids */
0, /* (142) as ::= */
-2, /* (143) from ::= FROM tablelist */
-2, /* (144) tablelist ::= ids cpxName */
-3, /* (145) tablelist ::= ids cpxName ids */
-4, /* (146) tablelist ::= tablelist COMMA ids cpxName */
-5, /* (147) tablelist ::= tablelist COMMA ids cpxName ids */
-1, /* (148) tmvar ::= VARIABLE */
-4, /* (149) interval_opt ::= INTERVAL LP tmvar RP */
-6, /* (150) interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */
0, /* (151) interval_opt ::= */
0, /* (152) fill_opt ::= */
-6, /* (153) fill_opt ::= FILL LP ID COMMA tagitemlist RP */
-4, /* (154) fill_opt ::= FILL LP ID RP */
-4, /* (155) sliding_opt ::= SLIDING LP tmvar RP */
0, /* (156) sliding_opt ::= */
0, /* (157) orderby_opt ::= */
-3, /* (158) orderby_opt ::= ORDER BY sortlist */
-4, /* (159) sortlist ::= sortlist COMMA item sortorder */
-2, /* (160) sortlist ::= item sortorder */
-2, /* (161) item ::= ids cpxName */
-1, /* (162) sortorder ::= ASC */
-1, /* (163) sortorder ::= DESC */
0, /* (164) sortorder ::= */
0, /* (165) groupby_opt ::= */
-3, /* (166) groupby_opt ::= GROUP BY grouplist */
-3, /* (167) grouplist ::= grouplist COMMA item */
-1, /* (168) grouplist ::= item */
0, /* (169) having_opt ::= */
-2, /* (170) having_opt ::= HAVING expr */
0, /* (171) limit_opt ::= */
-2, /* (172) limit_opt ::= LIMIT signed */
-4, /* (173) limit_opt ::= LIMIT signed OFFSET signed */
-4, /* (174) limit_opt ::= LIMIT signed COMMA signed */
0, /* (175) slimit_opt ::= */
-2, /* (176) slimit_opt ::= SLIMIT signed */
-4, /* (177) slimit_opt ::= SLIMIT signed SOFFSET signed */
-4, /* (178) slimit_opt ::= SLIMIT signed COMMA signed */
0, /* (179) where_opt ::= */
-2, /* (180) where_opt ::= WHERE expr */
-3, /* (181) expr ::= LP expr RP */
-1, /* (182) expr ::= ID */
-3, /* (183) expr ::= ID DOT ID */
-3, /* (184) expr ::= ID DOT STAR */
-1, /* (185) expr ::= INTEGER */
-2, /* (186) expr ::= MINUS INTEGER */
-2, /* (187) expr ::= PLUS INTEGER */
-1, /* (188) expr ::= FLOAT */
-2, /* (189) expr ::= MINUS FLOAT */
-2, /* (190) expr ::= PLUS FLOAT */
-1, /* (191) expr ::= STRING */
-1, /* (192) expr ::= NOW */
-1, /* (193) expr ::= VARIABLE */
-1, /* (194) expr ::= BOOL */
-4, /* (195) expr ::= ID LP exprlist RP */
-4, /* (196) expr ::= ID LP STAR RP */
-3, /* (197) expr ::= expr IS NULL */
-4, /* (198) expr ::= expr IS NOT NULL */
-3, /* (199) expr ::= expr LT expr */
-3, /* (200) expr ::= expr GT expr */
-3, /* (201) expr ::= expr LE expr */
-3, /* (202) expr ::= expr GE expr */
-3, /* (203) expr ::= expr NE expr */
-3, /* (204) expr ::= expr EQ expr */
-3, /* (205) expr ::= expr AND expr */
-3, /* (206) expr ::= expr OR expr */
-3, /* (207) expr ::= expr PLUS expr */
-3, /* (208) expr ::= expr MINUS expr */
-3, /* (209) expr ::= expr STAR expr */
-3, /* (210) expr ::= expr SLASH expr */
-3, /* (211) expr ::= expr REM expr */
-3, /* (212) expr ::= expr LIKE expr */
-5, /* (213) expr ::= expr IN LP exprlist RP */
-3, /* (214) exprlist ::= exprlist COMMA expritem */
-1, /* (215) exprlist ::= expritem */
-1, /* (216) expritem ::= expr */
0, /* (217) expritem ::= */
-3, /* (218) cmd ::= RESET QUERY CACHE */
-7, /* (219) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */
-7, /* (220) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */
-7, /* (221) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */
-7, /* (222) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */
-8, /* (223) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */
-9, /* (224) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */
-3, /* (225) cmd ::= KILL CONNECTION INTEGER */
-5, /* (226) cmd ::= KILL STREAM INTEGER COLON INTEGER */
-5, /* (227) cmd ::= KILL QUERY INTEGER COLON INTEGER */
}; };
static void yy_accept(yyParser*); /* Forward Declaration */ static void yy_accept(yyParser*); /* Forward Declaration */
...@@ -1929,30 +2176,34 @@ static void yy_accept(yyParser*); /* Forward Declaration */ ...@@ -1929,30 +2176,34 @@ static void yy_accept(yyParser*); /* Forward Declaration */
** only called from one place, optimizing compilers will in-line it, which ** only called from one place, optimizing compilers will in-line it, which
** means that the extra parameters have no performance impact. ** means that the extra parameters have no performance impact.
*/ */
static void yy_reduce( static YYACTIONTYPE yy_reduce(
yyParser *yypParser, /* The parser */ yyParser *yypParser, /* The parser */
unsigned int yyruleno, /* Number of the rule by which to reduce */ unsigned int yyruleno, /* Number of the rule by which to reduce */
int yyLookahead, /* Lookahead token, or YYNOCODE if none */ int yyLookahead, /* Lookahead token, or YYNOCODE if none */
ParseTOKENTYPE yyLookaheadToken /* Value of the lookahead token */ ParseTOKENTYPE yyLookaheadToken /* Value of the lookahead token */
ParseCTX_PDECL /* %extra_context */
){ ){
int yygoto; /* The next state */ int yygoto; /* The next state */
int yyact; /* The next action */ YYACTIONTYPE yyact; /* The next action */
yyStackEntry *yymsp; /* The top of the parser's stack */ yyStackEntry *yymsp; /* The top of the parser's stack */
int yysize; /* Amount to pop the stack */ int yysize; /* Amount to pop the stack */
ParseARG_FETCH; ParseARG_FETCH
(void)yyLookahead; (void)yyLookahead;
(void)yyLookaheadToken; (void)yyLookaheadToken;
yymsp = yypParser->yytos; yymsp = yypParser->yytos;
#ifndef NDEBUG #ifndef NDEBUG
if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
yysize = yyRuleInfo[yyruleno].nrhs; yysize = yyRuleInfoNRhs[yyruleno];
if( yysize ){ if( yysize ){
fprintf(yyTraceFILE, "%sReduce %d [%s], go to state %d.\n", fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n",
yyTracePrompt, yyTracePrompt,
yyruleno, yyRuleName[yyruleno], yymsp[yysize].stateno); yyruleno, yyRuleName[yyruleno],
yyruleno<YYNRULE_WITH_ACTION ? "" : " without external action",
yymsp[yysize].stateno);
}else{ }else{
fprintf(yyTraceFILE, "%sReduce %d [%s].\n", fprintf(yyTraceFILE, "%sReduce %d [%s]%s.\n",
yyTracePrompt, yyruleno, yyRuleName[yyruleno]); yyTracePrompt, yyruleno, yyRuleName[yyruleno],
yyruleno<YYNRULE_WITH_ACTION ? "" : " without external action");
} }
} }
#endif /* NDEBUG */ #endif /* NDEBUG */
...@@ -1960,7 +2211,7 @@ static void yy_reduce( ...@@ -1960,7 +2211,7 @@ static void yy_reduce(
/* Check that the stack is large enough to grow by a single entry /* Check that the stack is large enough to grow by a single entry
** if the RHS of the rule is empty. This ensures that there is room ** if the RHS of the rule is empty. This ensures that there is room
** enough on the stack to push the LHS value */ ** enough on the stack to push the LHS value */
if( yyRuleInfo[yyruleno].nrhs==0 ){ if( yyRuleInfoNRhs[yyruleno]==0 ){
#ifdef YYTRACKMAXSTACKDEPTH #ifdef YYTRACKMAXSTACKDEPTH
if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){ if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){
yypParser->yyhwm++; yypParser->yyhwm++;
...@@ -1970,13 +2221,19 @@ static void yy_reduce( ...@@ -1970,13 +2221,19 @@ static void yy_reduce(
#if YYSTACKDEPTH>0 #if YYSTACKDEPTH>0
if( yypParser->yytos>=yypParser->yystackEnd ){ if( yypParser->yytos>=yypParser->yystackEnd ){
yyStackOverflow(yypParser); yyStackOverflow(yypParser);
return; /* The call to yyStackOverflow() above pops the stack until it is
** empty, causing the main parser loop to exit. So the return value
** is never used and does not matter. */
return 0;
} }
#else #else
if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){ if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){
if( yyGrowStack(yypParser) ){ if( yyGrowStack(yypParser) ){
yyStackOverflow(yypParser); yyStackOverflow(yypParser);
return; /* The call to yyStackOverflow() above pops the stack until it is
** empty, causing the main parser loop to exit. So the return value
** is never used and does not matter. */
return 0;
} }
yymsp = yypParser->yytos; yymsp = yypParser->yytos;
} }
...@@ -2134,13 +2391,13 @@ static void yy_reduce( ...@@ -2134,13 +2391,13 @@ static void yy_reduce(
{ setDCLSQLElems(pInfo, TSDB_SQL_CFG_LOCAL, 2, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } { setDCLSQLElems(pInfo, TSDB_SQL_CFG_LOCAL, 2, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); }
break; break;
case 38: /* cmd ::= ALTER DATABASE ids alter_db_optr */ case 38: /* cmd ::= ALTER DATABASE ids alter_db_optr */
{ SStrToken t = {0}; setCreateDBSQL(pInfo, TSDB_SQL_ALTER_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy158, &t);} { SStrToken t = {0}; setCreateDBSQL(pInfo, TSDB_SQL_ALTER_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy118, &t);}
break; break;
case 39: /* cmd ::= ALTER ACCOUNT ids acct_optr */ case 39: /* cmd ::= ALTER ACCOUNT ids acct_optr */
{ setCreateAcctSQL(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-1].minor.yy0, NULL, &yymsp[0].minor.yy73);} { setCreateAcctSQL(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-1].minor.yy0, NULL, &yymsp[0].minor.yy479);}
break; break;
case 40: /* cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ case 40: /* 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.yy73);} { setCreateAcctSQL(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy479);}
break; break;
case 41: /* ids ::= ID */ case 41: /* ids ::= ID */
case 42: /* ids ::= STRING */ yytestcase(yyruleno==42); case 42: /* ids ::= STRING */ yytestcase(yyruleno==42);
...@@ -2161,10 +2418,10 @@ static void yy_reduce( ...@@ -2161,10 +2418,10 @@ static void yy_reduce(
{ setDCLSQLElems(pInfo, TSDB_SQL_CREATE_DNODE, 1, &yymsp[0].minor.yy0);} { setDCLSQLElems(pInfo, TSDB_SQL_CREATE_DNODE, 1, &yymsp[0].minor.yy0);}
break; break;
case 48: /* cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ case 48: /* 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.yy73);} { setCreateAcctSQL(pInfo, TSDB_SQL_CREATE_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy479);}
break; break;
case 49: /* cmd ::= CREATE DATABASE ifnotexists ids db_optr */ case 49: /* cmd ::= CREATE DATABASE ifnotexists ids db_optr */
{ setCreateDBSQL(pInfo, TSDB_SQL_CREATE_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy158, &yymsp[-2].minor.yy0);} { setCreateDBSQL(pInfo, TSDB_SQL_CREATE_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy118, &yymsp[-2].minor.yy0);}
break; break;
case 50: /* cmd ::= CREATE USER ids PASS ids */ case 50: /* cmd ::= CREATE USER ids PASS ids */
{ setCreateUserSQL(pInfo, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);} { setCreateUserSQL(pInfo, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);}
...@@ -2193,20 +2450,20 @@ static void yy_reduce( ...@@ -2193,20 +2450,20 @@ static void yy_reduce(
break; break;
case 69: /* acct_optr ::= pps tseries storage streams qtime dbs users conns state */ case 69: /* acct_optr ::= pps tseries storage streams qtime dbs users conns state */
{ {
yylhsminor.yy73.maxUsers = (yymsp[-2].minor.yy0.n>0)?atoi(yymsp[-2].minor.yy0.z):-1; yylhsminor.yy479.maxUsers = (yymsp[-2].minor.yy0.n>0)?atoi(yymsp[-2].minor.yy0.z):-1;
yylhsminor.yy73.maxDbs = (yymsp[-3].minor.yy0.n>0)?atoi(yymsp[-3].minor.yy0.z):-1; yylhsminor.yy479.maxDbs = (yymsp[-3].minor.yy0.n>0)?atoi(yymsp[-3].minor.yy0.z):-1;
yylhsminor.yy73.maxTimeSeries = (yymsp[-7].minor.yy0.n>0)?atoi(yymsp[-7].minor.yy0.z):-1; yylhsminor.yy479.maxTimeSeries = (yymsp[-7].minor.yy0.n>0)?atoi(yymsp[-7].minor.yy0.z):-1;
yylhsminor.yy73.maxStreams = (yymsp[-5].minor.yy0.n>0)?atoi(yymsp[-5].minor.yy0.z):-1; yylhsminor.yy479.maxStreams = (yymsp[-5].minor.yy0.n>0)?atoi(yymsp[-5].minor.yy0.z):-1;
yylhsminor.yy73.maxPointsPerSecond = (yymsp[-8].minor.yy0.n>0)?atoi(yymsp[-8].minor.yy0.z):-1; yylhsminor.yy479.maxPointsPerSecond = (yymsp[-8].minor.yy0.n>0)?atoi(yymsp[-8].minor.yy0.z):-1;
yylhsminor.yy73.maxStorage = (yymsp[-6].minor.yy0.n>0)?strtoll(yymsp[-6].minor.yy0.z, NULL, 10):-1; yylhsminor.yy479.maxStorage = (yymsp[-6].minor.yy0.n>0)?strtoll(yymsp[-6].minor.yy0.z, NULL, 10):-1;
yylhsminor.yy73.maxQueryTime = (yymsp[-4].minor.yy0.n>0)?strtoll(yymsp[-4].minor.yy0.z, NULL, 10):-1; yylhsminor.yy479.maxQueryTime = (yymsp[-4].minor.yy0.n>0)?strtoll(yymsp[-4].minor.yy0.z, NULL, 10):-1;
yylhsminor.yy73.maxConnections = (yymsp[-1].minor.yy0.n>0)?atoi(yymsp[-1].minor.yy0.z):-1; yylhsminor.yy479.maxConnections = (yymsp[-1].minor.yy0.n>0)?atoi(yymsp[-1].minor.yy0.z):-1;
yylhsminor.yy73.stat = yymsp[0].minor.yy0; yylhsminor.yy479.stat = yymsp[0].minor.yy0;
} }
yymsp[-8].minor.yy73 = yylhsminor.yy73; yymsp[-8].minor.yy479 = yylhsminor.yy479;
break; break;
case 70: /* keep ::= KEEP tagitemlist */ case 70: /* keep ::= KEEP tagitemlist */
{ yymsp[-1].minor.yy494 = yymsp[0].minor.yy494; } { yymsp[-1].minor.yy156 = yymsp[0].minor.yy156; }
break; break;
case 71: /* cache ::= CACHE INTEGER */ case 71: /* cache ::= CACHE INTEGER */
case 72: /* replica ::= REPLICA INTEGER */ yytestcase(yyruleno==72); case 72: /* replica ::= REPLICA INTEGER */ yytestcase(yyruleno==72);
...@@ -2223,98 +2480,98 @@ static void yy_reduce( ...@@ -2223,98 +2480,98 @@ static void yy_reduce(
{ yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; }
break; break;
case 83: /* db_optr ::= */ case 83: /* db_optr ::= */
{setDefaultCreateDbOption(&yymsp[1].minor.yy158);} {setDefaultCreateDbOption(&yymsp[1].minor.yy118);}
break; break;
case 84: /* db_optr ::= db_optr cache */ case 84: /* db_optr ::= db_optr cache */
{ yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy118 = yymsp[-1].minor.yy118; yylhsminor.yy118.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy158 = yylhsminor.yy158; yymsp[-1].minor.yy118 = yylhsminor.yy118;
break; break;
case 85: /* db_optr ::= db_optr replica */ case 85: /* db_optr ::= db_optr replica */
case 98: /* alter_db_optr ::= alter_db_optr replica */ yytestcase(yyruleno==98); case 98: /* alter_db_optr ::= alter_db_optr replica */ yytestcase(yyruleno==98);
{ yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy118 = yymsp[-1].minor.yy118; yylhsminor.yy118.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy158 = yylhsminor.yy158; yymsp[-1].minor.yy118 = yylhsminor.yy118;
break; break;
case 86: /* db_optr ::= db_optr quorum */ case 86: /* db_optr ::= db_optr quorum */
case 99: /* alter_db_optr ::= alter_db_optr quorum */ yytestcase(yyruleno==99); case 99: /* alter_db_optr ::= alter_db_optr quorum */ yytestcase(yyruleno==99);
{ yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.quorum = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy118 = yymsp[-1].minor.yy118; yylhsminor.yy118.quorum = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy158 = yylhsminor.yy158; yymsp[-1].minor.yy118 = yylhsminor.yy118;
break; break;
case 87: /* db_optr ::= db_optr days */ case 87: /* db_optr ::= db_optr days */
{ yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy118 = yymsp[-1].minor.yy118; yylhsminor.yy118.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy158 = yylhsminor.yy158; yymsp[-1].minor.yy118 = yylhsminor.yy118;
break; break;
case 88: /* db_optr ::= db_optr minrows */ case 88: /* db_optr ::= db_optr minrows */
{ yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.minRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } { yylhsminor.yy118 = yymsp[-1].minor.yy118; yylhsminor.yy118.minRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); }
yymsp[-1].minor.yy158 = yylhsminor.yy158; yymsp[-1].minor.yy118 = yylhsminor.yy118;
break; break;
case 89: /* db_optr ::= db_optr maxrows */ case 89: /* db_optr ::= db_optr maxrows */
{ yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.maxRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } { yylhsminor.yy118 = yymsp[-1].minor.yy118; yylhsminor.yy118.maxRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); }
yymsp[-1].minor.yy158 = yylhsminor.yy158; yymsp[-1].minor.yy118 = yylhsminor.yy118;
break; break;
case 90: /* db_optr ::= db_optr blocks */ case 90: /* db_optr ::= db_optr blocks */
case 101: /* alter_db_optr ::= alter_db_optr blocks */ yytestcase(yyruleno==101); case 101: /* alter_db_optr ::= alter_db_optr blocks */ yytestcase(yyruleno==101);
{ yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.numOfBlocks = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy118 = yymsp[-1].minor.yy118; yylhsminor.yy118.numOfBlocks = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy158 = yylhsminor.yy158; yymsp[-1].minor.yy118 = yylhsminor.yy118;
break; break;
case 91: /* db_optr ::= db_optr ctime */ case 91: /* db_optr ::= db_optr ctime */
{ yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy118 = yymsp[-1].minor.yy118; yylhsminor.yy118.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy158 = yylhsminor.yy158; yymsp[-1].minor.yy118 = yylhsminor.yy118;
break; break;
case 92: /* db_optr ::= db_optr wal */ case 92: /* db_optr ::= db_optr wal */
case 103: /* alter_db_optr ::= alter_db_optr wal */ yytestcase(yyruleno==103); case 103: /* alter_db_optr ::= alter_db_optr wal */ yytestcase(yyruleno==103);
{ yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.walLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy118 = yymsp[-1].minor.yy118; yylhsminor.yy118.walLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy158 = yylhsminor.yy158; yymsp[-1].minor.yy118 = yylhsminor.yy118;
break; break;
case 93: /* db_optr ::= db_optr fsync */ case 93: /* db_optr ::= db_optr fsync */
case 104: /* alter_db_optr ::= alter_db_optr fsync */ yytestcase(yyruleno==104); case 104: /* alter_db_optr ::= alter_db_optr fsync */ yytestcase(yyruleno==104);
{ yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy118 = yymsp[-1].minor.yy118; yylhsminor.yy118.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy158 = yylhsminor.yy158; yymsp[-1].minor.yy118 = yylhsminor.yy118;
break; break;
case 94: /* db_optr ::= db_optr comp */ case 94: /* db_optr ::= db_optr comp */
case 102: /* alter_db_optr ::= alter_db_optr comp */ yytestcase(yyruleno==102); case 102: /* alter_db_optr ::= alter_db_optr comp */ yytestcase(yyruleno==102);
{ yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy118 = yymsp[-1].minor.yy118; yylhsminor.yy118.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy158 = yylhsminor.yy158; yymsp[-1].minor.yy118 = yylhsminor.yy118;
break; break;
case 95: /* db_optr ::= db_optr prec */ case 95: /* db_optr ::= db_optr prec */
{ yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.precision = yymsp[0].minor.yy0; } { yylhsminor.yy118 = yymsp[-1].minor.yy118; yylhsminor.yy118.precision = yymsp[0].minor.yy0; }
yymsp[-1].minor.yy158 = yylhsminor.yy158; yymsp[-1].minor.yy118 = yylhsminor.yy118;
break; break;
case 96: /* db_optr ::= db_optr keep */ case 96: /* db_optr ::= db_optr keep */
case 100: /* alter_db_optr ::= alter_db_optr keep */ yytestcase(yyruleno==100); case 100: /* alter_db_optr ::= alter_db_optr keep */ yytestcase(yyruleno==100);
{ yylhsminor.yy158 = yymsp[-1].minor.yy158; yylhsminor.yy158.keep = yymsp[0].minor.yy494; } { yylhsminor.yy118 = yymsp[-1].minor.yy118; yylhsminor.yy118.keep = yymsp[0].minor.yy156; }
yymsp[-1].minor.yy158 = yylhsminor.yy158; yymsp[-1].minor.yy118 = yylhsminor.yy118;
break; break;
case 97: /* alter_db_optr ::= */ case 97: /* alter_db_optr ::= */
{ setDefaultCreateDbOption(&yymsp[1].minor.yy158);} { setDefaultCreateDbOption(&yymsp[1].minor.yy118);}
break; break;
case 105: /* typename ::= ids */ case 105: /* typename ::= ids */
{ {
yymsp[0].minor.yy0.type = 0; yymsp[0].minor.yy0.type = 0;
tSQLSetColumnType (&yylhsminor.yy181, &yymsp[0].minor.yy0); tSQLSetColumnType (&yylhsminor.yy343, &yymsp[0].minor.yy0);
} }
yymsp[0].minor.yy181 = yylhsminor.yy181; yymsp[0].minor.yy343 = yylhsminor.yy343;
break; break;
case 106: /* typename ::= ids LP signed RP */ case 106: /* typename ::= ids LP signed RP */
{ {
if (yymsp[-1].minor.yy271 <= 0) { if (yymsp[-1].minor.yy369 <= 0) {
yymsp[-3].minor.yy0.type = 0; yymsp[-3].minor.yy0.type = 0;
tSQLSetColumnType(&yylhsminor.yy181, &yymsp[-3].minor.yy0); tSQLSetColumnType(&yylhsminor.yy343, &yymsp[-3].minor.yy0);
} else { } else {
yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy271; // negative value of name length yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy369; // negative value of name length
tSQLSetColumnType(&yylhsminor.yy181, &yymsp[-3].minor.yy0); tSQLSetColumnType(&yylhsminor.yy343, &yymsp[-3].minor.yy0);
} }
} }
yymsp[-3].minor.yy181 = yylhsminor.yy181; yymsp[-3].minor.yy343 = yylhsminor.yy343;
break; break;
case 107: /* signed ::= INTEGER */ case 107: /* signed ::= INTEGER */
{ yylhsminor.yy271 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy369 = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[0].minor.yy271 = yylhsminor.yy271; yymsp[0].minor.yy369 = yylhsminor.yy369;
break; break;
case 108: /* signed ::= PLUS INTEGER */ case 108: /* signed ::= PLUS INTEGER */
{ yymsp[-1].minor.yy271 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yymsp[-1].minor.yy369 = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
break; break;
case 109: /* signed ::= MINUS INTEGER */ case 109: /* signed ::= MINUS INTEGER */
{ yymsp[-1].minor.yy271 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);} { yymsp[-1].minor.yy369 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);}
break; break;
case 110: /* cmd ::= CREATE TABLE ifnotexists ids cpxName create_table_args */ case 110: /* cmd ::= CREATE TABLE ifnotexists ids cpxName create_table_args */
{ {
...@@ -2324,61 +2581,61 @@ static void yy_reduce( ...@@ -2324,61 +2581,61 @@ static void yy_reduce(
break; break;
case 111: /* create_table_args ::= LP columnlist RP */ case 111: /* create_table_args ::= LP columnlist RP */
{ {
yymsp[-2].minor.yy374 = tSetCreateSQLElems(yymsp[-1].minor.yy449, NULL, NULL, NULL, NULL, TSQL_CREATE_TABLE); yymsp[-2].minor.yy398 = tSetCreateSQLElems(yymsp[-1].minor.yy511, NULL, NULL, NULL, NULL, TSQL_CREATE_TABLE);
setSQLInfo(pInfo, yymsp[-2].minor.yy374, NULL, TSDB_SQL_CREATE_TABLE); setSQLInfo(pInfo, yymsp[-2].minor.yy398, NULL, TSDB_SQL_CREATE_TABLE);
} }
break; break;
case 112: /* create_table_args ::= LP columnlist RP TAGS LP columnlist RP */ case 112: /* create_table_args ::= LP columnlist RP TAGS LP columnlist RP */
{ {
yymsp[-6].minor.yy374 = tSetCreateSQLElems(yymsp[-5].minor.yy449, yymsp[-1].minor.yy449, NULL, NULL, NULL, TSQL_CREATE_STABLE); yymsp[-6].minor.yy398 = tSetCreateSQLElems(yymsp[-5].minor.yy511, yymsp[-1].minor.yy511, NULL, NULL, NULL, TSQL_CREATE_STABLE);
setSQLInfo(pInfo, yymsp[-6].minor.yy374, NULL, TSDB_SQL_CREATE_TABLE); setSQLInfo(pInfo, yymsp[-6].minor.yy398, NULL, TSDB_SQL_CREATE_TABLE);
} }
break; break;
case 113: /* create_table_args ::= USING ids cpxName TAGS LP tagitemlist RP */ case 113: /* create_table_args ::= USING ids cpxName TAGS LP tagitemlist RP */
{ {
yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n;
yymsp[-6].minor.yy374 = tSetCreateSQLElems(NULL, NULL, &yymsp[-5].minor.yy0, yymsp[-1].minor.yy494, NULL, TSQL_CREATE_TABLE_FROM_STABLE); yymsp[-6].minor.yy398 = tSetCreateSQLElems(NULL, NULL, &yymsp[-5].minor.yy0, yymsp[-1].minor.yy156, NULL, TSQL_CREATE_TABLE_FROM_STABLE);
setSQLInfo(pInfo, yymsp[-6].minor.yy374, NULL, TSDB_SQL_CREATE_TABLE); setSQLInfo(pInfo, yymsp[-6].minor.yy398, NULL, TSDB_SQL_CREATE_TABLE);
} }
break; break;
case 114: /* create_table_args ::= AS select */ case 114: /* create_table_args ::= AS select */
{ {
yymsp[-1].minor.yy374 = tSetCreateSQLElems(NULL, NULL, NULL, NULL, yymsp[0].minor.yy150, TSQL_CREATE_STREAM); yymsp[-1].minor.yy398 = tSetCreateSQLElems(NULL, NULL, NULL, NULL, yymsp[0].minor.yy444, TSQL_CREATE_STREAM);
setSQLInfo(pInfo, yymsp[-1].minor.yy374, NULL, TSDB_SQL_CREATE_TABLE); setSQLInfo(pInfo, yymsp[-1].minor.yy398, NULL, TSDB_SQL_CREATE_TABLE);
} }
break; break;
case 115: /* columnlist ::= columnlist COMMA column */ case 115: /* columnlist ::= columnlist COMMA column */
{yylhsminor.yy449 = tFieldListAppend(yymsp[-2].minor.yy449, &yymsp[0].minor.yy181); } {yylhsminor.yy511 = tFieldListAppend(yymsp[-2].minor.yy511, &yymsp[0].minor.yy343); }
yymsp[-2].minor.yy449 = yylhsminor.yy449; yymsp[-2].minor.yy511 = yylhsminor.yy511;
break; break;
case 116: /* columnlist ::= column */ case 116: /* columnlist ::= column */
{yylhsminor.yy449 = tFieldListAppend(NULL, &yymsp[0].minor.yy181);} {yylhsminor.yy511 = tFieldListAppend(NULL, &yymsp[0].minor.yy343);}
yymsp[0].minor.yy449 = yylhsminor.yy449; yymsp[0].minor.yy511 = yylhsminor.yy511;
break; break;
case 117: /* column ::= ids typename */ case 117: /* column ::= ids typename */
{ {
tSQLSetColumnInfo(&yylhsminor.yy181, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy181); tSQLSetColumnInfo(&yylhsminor.yy343, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy343);
} }
yymsp[-1].minor.yy181 = yylhsminor.yy181; yymsp[-1].minor.yy343 = yylhsminor.yy343;
break; break;
case 118: /* tagitemlist ::= tagitemlist COMMA tagitem */ case 118: /* tagitemlist ::= tagitemlist COMMA tagitem */
{ yylhsminor.yy494 = tVariantListAppend(yymsp[-2].minor.yy494, &yymsp[0].minor.yy312, -1); } { yylhsminor.yy156 = tVariantListAppend(yymsp[-2].minor.yy156, &yymsp[0].minor.yy506, -1); }
yymsp[-2].minor.yy494 = yylhsminor.yy494; yymsp[-2].minor.yy156 = yylhsminor.yy156;
break; break;
case 119: /* tagitemlist ::= tagitem */ case 119: /* tagitemlist ::= tagitem */
{ yylhsminor.yy494 = tVariantListAppend(NULL, &yymsp[0].minor.yy312, -1); } { yylhsminor.yy156 = tVariantListAppend(NULL, &yymsp[0].minor.yy506, -1); }
yymsp[0].minor.yy494 = yylhsminor.yy494; yymsp[0].minor.yy156 = yylhsminor.yy156;
break; break;
case 120: /* tagitem ::= INTEGER */ case 120: /* tagitem ::= INTEGER */
case 121: /* tagitem ::= FLOAT */ yytestcase(yyruleno==121); case 121: /* tagitem ::= FLOAT */ yytestcase(yyruleno==121);
case 122: /* tagitem ::= STRING */ yytestcase(yyruleno==122); case 122: /* tagitem ::= STRING */ yytestcase(yyruleno==122);
case 123: /* tagitem ::= BOOL */ yytestcase(yyruleno==123); case 123: /* tagitem ::= BOOL */ yytestcase(yyruleno==123);
{toTSDBType(yymsp[0].minor.yy0.type); tVariantCreate(&yylhsminor.yy312, &yymsp[0].minor.yy0); } {toTSDBType(yymsp[0].minor.yy0.type); tVariantCreate(&yylhsminor.yy506, &yymsp[0].minor.yy0); }
yymsp[0].minor.yy312 = yylhsminor.yy312; yymsp[0].minor.yy506 = yylhsminor.yy506;
break; break;
case 124: /* tagitem ::= NULL */ case 124: /* tagitem ::= NULL */
{ yymsp[0].minor.yy0.type = 0; tVariantCreate(&yylhsminor.yy312, &yymsp[0].minor.yy0); } { yymsp[0].minor.yy0.type = 0; tVariantCreate(&yylhsminor.yy506, &yymsp[0].minor.yy0); }
yymsp[0].minor.yy312 = yylhsminor.yy312; yymsp[0].minor.yy506 = yylhsminor.yy506;
break; break;
case 125: /* tagitem ::= MINUS INTEGER */ case 125: /* tagitem ::= MINUS INTEGER */
case 126: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==126); case 126: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==126);
...@@ -2388,59 +2645,59 @@ static void yy_reduce( ...@@ -2388,59 +2645,59 @@ static void yy_reduce(
yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n;
yymsp[-1].minor.yy0.type = yymsp[0].minor.yy0.type; yymsp[-1].minor.yy0.type = yymsp[0].minor.yy0.type;
toTSDBType(yymsp[-1].minor.yy0.type); toTSDBType(yymsp[-1].minor.yy0.type);
tVariantCreate(&yylhsminor.yy312, &yymsp[-1].minor.yy0); tVariantCreate(&yylhsminor.yy506, &yymsp[-1].minor.yy0);
} }
yymsp[-1].minor.yy312 = yylhsminor.yy312; yymsp[-1].minor.yy506 = yylhsminor.yy506;
break; break;
case 129: /* select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */ case 129: /* select ::= SELECT selcollist from where_opt interval_opt fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */
{ {
yylhsminor.yy150 = tSetQuerySQLElems(&yymsp[-11].minor.yy0, yymsp[-10].minor.yy224, yymsp[-9].minor.yy494, yymsp[-8].minor.yy66, yymsp[-4].minor.yy494, yymsp[-3].minor.yy494, &yymsp[-7].minor.yy0, &yymsp[-5].minor.yy0, yymsp[-6].minor.yy494, &yymsp[0].minor.yy188, &yymsp[-1].minor.yy188); yylhsminor.yy444 = tSetQuerySQLElems(&yymsp[-11].minor.yy0, yymsp[-10].minor.yy158, yymsp[-9].minor.yy156, yymsp[-8].minor.yy190, yymsp[-4].minor.yy156, yymsp[-3].minor.yy156, &yymsp[-7].minor.yy340, &yymsp[-5].minor.yy0, yymsp[-6].minor.yy156, &yymsp[0].minor.yy414, &yymsp[-1].minor.yy414);
} }
yymsp[-11].minor.yy150 = yylhsminor.yy150; yymsp[-11].minor.yy444 = yylhsminor.yy444;
break; break;
case 130: /* union ::= select */ case 130: /* union ::= select */
{ yylhsminor.yy25 = setSubclause(NULL, yymsp[0].minor.yy150); } { yylhsminor.yy333 = setSubclause(NULL, yymsp[0].minor.yy444); }
yymsp[0].minor.yy25 = yylhsminor.yy25; yymsp[0].minor.yy333 = yylhsminor.yy333;
break; break;
case 131: /* union ::= LP union RP */ case 131: /* union ::= LP union RP */
{ yymsp[-2].minor.yy25 = yymsp[-1].minor.yy25; } { yymsp[-2].minor.yy333 = yymsp[-1].minor.yy333; }
break; break;
case 132: /* union ::= union UNION ALL select */ case 132: /* union ::= union UNION ALL select */
{ yylhsminor.yy25 = appendSelectClause(yymsp[-3].minor.yy25, yymsp[0].minor.yy150); } { yylhsminor.yy333 = appendSelectClause(yymsp[-3].minor.yy333, yymsp[0].minor.yy444); }
yymsp[-3].minor.yy25 = yylhsminor.yy25; yymsp[-3].minor.yy333 = yylhsminor.yy333;
break; break;
case 133: /* union ::= union UNION ALL LP select RP */ case 133: /* union ::= union UNION ALL LP select RP */
{ yylhsminor.yy25 = appendSelectClause(yymsp[-5].minor.yy25, yymsp[-1].minor.yy150); } { yylhsminor.yy333 = appendSelectClause(yymsp[-5].minor.yy333, yymsp[-1].minor.yy444); }
yymsp[-5].minor.yy25 = yylhsminor.yy25; yymsp[-5].minor.yy333 = yylhsminor.yy333;
break; break;
case 134: /* cmd ::= union */ case 134: /* cmd ::= union */
{ setSQLInfo(pInfo, yymsp[0].minor.yy25, NULL, TSDB_SQL_SELECT); } { setSQLInfo(pInfo, yymsp[0].minor.yy333, NULL, TSDB_SQL_SELECT); }
break; break;
case 135: /* select ::= SELECT selcollist */ case 135: /* select ::= SELECT selcollist */
{ {
yylhsminor.yy150 = tSetQuerySQLElems(&yymsp[-1].minor.yy0, yymsp[0].minor.yy224, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); yylhsminor.yy444 = tSetQuerySQLElems(&yymsp[-1].minor.yy0, yymsp[0].minor.yy158, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
} }
yymsp[-1].minor.yy150 = yylhsminor.yy150; yymsp[-1].minor.yy444 = yylhsminor.yy444;
break; break;
case 136: /* sclp ::= selcollist COMMA */ case 136: /* sclp ::= selcollist COMMA */
{yylhsminor.yy224 = yymsp[-1].minor.yy224;} {yylhsminor.yy158 = yymsp[-1].minor.yy158;}
yymsp[-1].minor.yy224 = yylhsminor.yy224; yymsp[-1].minor.yy158 = yylhsminor.yy158;
break; break;
case 137: /* sclp ::= */ case 137: /* sclp ::= */
{yymsp[1].minor.yy224 = 0;} {yymsp[1].minor.yy158 = 0;}
break; break;
case 138: /* selcollist ::= sclp expr as */ case 138: /* selcollist ::= sclp expr as */
{ {
yylhsminor.yy224 = tSQLExprListAppend(yymsp[-2].minor.yy224, yymsp[-1].minor.yy66, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0); yylhsminor.yy158 = tSQLExprListAppend(yymsp[-2].minor.yy158, yymsp[-1].minor.yy190, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0);
} }
yymsp[-2].minor.yy224 = yylhsminor.yy224; yymsp[-2].minor.yy158 = yylhsminor.yy158;
break; break;
case 139: /* selcollist ::= sclp STAR */ case 139: /* selcollist ::= sclp STAR */
{ {
tSQLExpr *pNode = tSQLExprIdValueCreate(NULL, TK_ALL); tSQLExpr *pNode = tSQLExprIdValueCreate(NULL, TK_ALL);
yylhsminor.yy224 = tSQLExprListAppend(yymsp[-1].minor.yy224, pNode, 0); yylhsminor.yy158 = tSQLExprListAppend(yymsp[-1].minor.yy158, pNode, 0);
} }
yymsp[-1].minor.yy224 = yylhsminor.yy224; yymsp[-1].minor.yy158 = yylhsminor.yy158;
break; break;
case 140: /* as ::= AS ids */ case 140: /* as ::= AS ids */
{ yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; }
...@@ -2453,300 +2710,307 @@ static void yy_reduce( ...@@ -2453,300 +2710,307 @@ static void yy_reduce(
{ yymsp[1].minor.yy0.n = 0; } { yymsp[1].minor.yy0.n = 0; }
break; break;
case 143: /* from ::= FROM tablelist */ case 143: /* from ::= FROM tablelist */
{yymsp[-1].minor.yy494 = yymsp[0].minor.yy494;} {yymsp[-1].minor.yy156 = yymsp[0].minor.yy156;}
break; break;
case 144: /* tablelist ::= ids cpxName */ case 144: /* tablelist ::= ids cpxName */
{ {
toTSDBType(yymsp[-1].minor.yy0.type); toTSDBType(yymsp[-1].minor.yy0.type);
yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n;
yylhsminor.yy494 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1); yylhsminor.yy156 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1);
yylhsminor.yy494 = tVariantListAppendToken(yylhsminor.yy494, &yymsp[-1].minor.yy0, -1); // table alias name yylhsminor.yy156 = tVariantListAppendToken(yylhsminor.yy156, &yymsp[-1].minor.yy0, -1); // table alias name
} }
yymsp[-1].minor.yy494 = yylhsminor.yy494; yymsp[-1].minor.yy156 = yylhsminor.yy156;
break; break;
case 145: /* tablelist ::= ids cpxName ids */ case 145: /* tablelist ::= ids cpxName ids */
{ {
toTSDBType(yymsp[-2].minor.yy0.type); toTSDBType(yymsp[-2].minor.yy0.type);
toTSDBType(yymsp[0].minor.yy0.type); toTSDBType(yymsp[0].minor.yy0.type);
yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n;
yylhsminor.yy494 = tVariantListAppendToken(NULL, &yymsp[-2].minor.yy0, -1); yylhsminor.yy156 = tVariantListAppendToken(NULL, &yymsp[-2].minor.yy0, -1);
yylhsminor.yy494 = tVariantListAppendToken(yylhsminor.yy494, &yymsp[0].minor.yy0, -1); yylhsminor.yy156 = tVariantListAppendToken(yylhsminor.yy156, &yymsp[0].minor.yy0, -1);
} }
yymsp[-2].minor.yy494 = yylhsminor.yy494; yymsp[-2].minor.yy156 = yylhsminor.yy156;
break; break;
case 146: /* tablelist ::= tablelist COMMA ids cpxName */ case 146: /* tablelist ::= tablelist COMMA ids cpxName */
{ {
toTSDBType(yymsp[-1].minor.yy0.type); toTSDBType(yymsp[-1].minor.yy0.type);
yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n;
yylhsminor.yy494 = tVariantListAppendToken(yymsp[-3].minor.yy494, &yymsp[-1].minor.yy0, -1); yylhsminor.yy156 = tVariantListAppendToken(yymsp[-3].minor.yy156, &yymsp[-1].minor.yy0, -1);
yylhsminor.yy494 = tVariantListAppendToken(yylhsminor.yy494, &yymsp[-1].minor.yy0, -1); yylhsminor.yy156 = tVariantListAppendToken(yylhsminor.yy156, &yymsp[-1].minor.yy0, -1);
} }
yymsp[-3].minor.yy494 = yylhsminor.yy494; yymsp[-3].minor.yy156 = yylhsminor.yy156;
break; break;
case 147: /* tablelist ::= tablelist COMMA ids cpxName ids */ case 147: /* tablelist ::= tablelist COMMA ids cpxName ids */
{ {
toTSDBType(yymsp[-2].minor.yy0.type); toTSDBType(yymsp[-2].minor.yy0.type);
toTSDBType(yymsp[0].minor.yy0.type); toTSDBType(yymsp[0].minor.yy0.type);
yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n;
yylhsminor.yy494 = tVariantListAppendToken(yymsp[-4].minor.yy494, &yymsp[-2].minor.yy0, -1); yylhsminor.yy156 = tVariantListAppendToken(yymsp[-4].minor.yy156, &yymsp[-2].minor.yy0, -1);
yylhsminor.yy494 = tVariantListAppendToken(yylhsminor.yy494, &yymsp[0].minor.yy0, -1); yylhsminor.yy156 = tVariantListAppendToken(yylhsminor.yy156, &yymsp[0].minor.yy0, -1);
} }
yymsp[-4].minor.yy494 = yylhsminor.yy494; yymsp[-4].minor.yy156 = yylhsminor.yy156;
break; break;
case 148: /* tmvar ::= VARIABLE */ case 148: /* tmvar ::= VARIABLE */
{yylhsminor.yy0 = yymsp[0].minor.yy0;} {yylhsminor.yy0 = yymsp[0].minor.yy0;}
yymsp[0].minor.yy0 = yylhsminor.yy0; yymsp[0].minor.yy0 = yylhsminor.yy0;
break; break;
case 149: /* interval_opt ::= INTERVAL LP tmvar RP */ case 149: /* interval_opt ::= INTERVAL LP tmvar RP */
case 154: /* sliding_opt ::= SLIDING LP tmvar RP */ yytestcase(yyruleno==154); {yymsp[-3].minor.yy340.interval = yymsp[-1].minor.yy0; yymsp[-3].minor.yy340.offset.n = 0; yymsp[-3].minor.yy340.offset.z = NULL; yymsp[-3].minor.yy340.offset.type = 0;}
{yymsp[-3].minor.yy0 = yymsp[-1].minor.yy0; }
break; break;
case 150: /* interval_opt ::= */ case 150: /* interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */
case 155: /* sliding_opt ::= */ yytestcase(yyruleno==155); {yymsp[-5].minor.yy340.interval = yymsp[-3].minor.yy0; yymsp[-5].minor.yy340.offset = yymsp[-1].minor.yy0;}
{yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = NULL; yymsp[1].minor.yy0.type = 0; } break;
case 151: /* interval_opt ::= */
{memset(&yymsp[1].minor.yy340, 0, sizeof(yymsp[1].minor.yy340));}
break; break;
case 151: /* fill_opt ::= */ case 152: /* fill_opt ::= */
{yymsp[1].minor.yy494 = 0; } {yymsp[1].minor.yy156 = 0; }
break; break;
case 152: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */ case 153: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */
{ {
tVariant A = {0}; tVariant A = {0};
toTSDBType(yymsp[-3].minor.yy0.type); toTSDBType(yymsp[-3].minor.yy0.type);
tVariantCreate(&A, &yymsp[-3].minor.yy0); tVariantCreate(&A, &yymsp[-3].minor.yy0);
tVariantListInsert(yymsp[-1].minor.yy494, &A, -1, 0); tVariantListInsert(yymsp[-1].minor.yy156, &A, -1, 0);
yymsp[-5].minor.yy494 = yymsp[-1].minor.yy494; yymsp[-5].minor.yy156 = yymsp[-1].minor.yy156;
} }
break; break;
case 153: /* fill_opt ::= FILL LP ID RP */ case 154: /* fill_opt ::= FILL LP ID RP */
{ {
toTSDBType(yymsp[-1].minor.yy0.type); toTSDBType(yymsp[-1].minor.yy0.type);
yymsp[-3].minor.yy494 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1); yymsp[-3].minor.yy156 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1);
} }
break; break;
case 156: /* orderby_opt ::= */ case 155: /* sliding_opt ::= SLIDING LP tmvar RP */
case 164: /* groupby_opt ::= */ yytestcase(yyruleno==164); {yymsp[-3].minor.yy0 = yymsp[-1].minor.yy0; }
{yymsp[1].minor.yy494 = 0;} break;
case 156: /* sliding_opt ::= */
{yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = NULL; yymsp[1].minor.yy0.type = 0; }
break;
case 157: /* orderby_opt ::= */
case 165: /* groupby_opt ::= */ yytestcase(yyruleno==165);
{yymsp[1].minor.yy156 = 0;}
break; break;
case 157: /* orderby_opt ::= ORDER BY sortlist */ case 158: /* orderby_opt ::= ORDER BY sortlist */
case 165: /* groupby_opt ::= GROUP BY grouplist */ yytestcase(yyruleno==165); case 166: /* groupby_opt ::= GROUP BY grouplist */ yytestcase(yyruleno==166);
{yymsp[-2].minor.yy494 = yymsp[0].minor.yy494;} {yymsp[-2].minor.yy156 = yymsp[0].minor.yy156;}
break; break;
case 158: /* sortlist ::= sortlist COMMA item sortorder */ case 159: /* sortlist ::= sortlist COMMA item sortorder */
{ {
yylhsminor.yy494 = tVariantListAppend(yymsp[-3].minor.yy494, &yymsp[-1].minor.yy312, yymsp[0].minor.yy82); yylhsminor.yy156 = tVariantListAppend(yymsp[-3].minor.yy156, &yymsp[-1].minor.yy506, yymsp[0].minor.yy112);
} }
yymsp[-3].minor.yy494 = yylhsminor.yy494; yymsp[-3].minor.yy156 = yylhsminor.yy156;
break; break;
case 159: /* sortlist ::= item sortorder */ case 160: /* sortlist ::= item sortorder */
{ {
yylhsminor.yy494 = tVariantListAppend(NULL, &yymsp[-1].minor.yy312, yymsp[0].minor.yy82); yylhsminor.yy156 = tVariantListAppend(NULL, &yymsp[-1].minor.yy506, yymsp[0].minor.yy112);
} }
yymsp[-1].minor.yy494 = yylhsminor.yy494; yymsp[-1].minor.yy156 = yylhsminor.yy156;
break; break;
case 160: /* item ::= ids cpxName */ case 161: /* item ::= ids cpxName */
{ {
toTSDBType(yymsp[-1].minor.yy0.type); toTSDBType(yymsp[-1].minor.yy0.type);
yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n;
tVariantCreate(&yylhsminor.yy312, &yymsp[-1].minor.yy0); tVariantCreate(&yylhsminor.yy506, &yymsp[-1].minor.yy0);
} }
yymsp[-1].minor.yy312 = yylhsminor.yy312; yymsp[-1].minor.yy506 = yylhsminor.yy506;
break; break;
case 161: /* sortorder ::= ASC */ case 162: /* sortorder ::= ASC */
{yymsp[0].minor.yy82 = TSDB_ORDER_ASC; } {yymsp[0].minor.yy112 = TSDB_ORDER_ASC; }
break; break;
case 162: /* sortorder ::= DESC */ case 163: /* sortorder ::= DESC */
{yymsp[0].minor.yy82 = TSDB_ORDER_DESC;} {yymsp[0].minor.yy112 = TSDB_ORDER_DESC;}
break; break;
case 163: /* sortorder ::= */ case 164: /* sortorder ::= */
{yymsp[1].minor.yy82 = TSDB_ORDER_ASC;} {yymsp[1].minor.yy112 = TSDB_ORDER_ASC;}
break; break;
case 166: /* grouplist ::= grouplist COMMA item */ case 167: /* grouplist ::= grouplist COMMA item */
{ {
yylhsminor.yy494 = tVariantListAppend(yymsp[-2].minor.yy494, &yymsp[0].minor.yy312, -1); yylhsminor.yy156 = tVariantListAppend(yymsp[-2].minor.yy156, &yymsp[0].minor.yy506, -1);
} }
yymsp[-2].minor.yy494 = yylhsminor.yy494; yymsp[-2].minor.yy156 = yylhsminor.yy156;
break; break;
case 167: /* grouplist ::= item */ case 168: /* grouplist ::= item */
{ {
yylhsminor.yy494 = tVariantListAppend(NULL, &yymsp[0].minor.yy312, -1); yylhsminor.yy156 = tVariantListAppend(NULL, &yymsp[0].minor.yy506, -1);
} }
yymsp[0].minor.yy494 = yylhsminor.yy494; yymsp[0].minor.yy156 = yylhsminor.yy156;
break; break;
case 168: /* having_opt ::= */ case 169: /* having_opt ::= */
case 178: /* where_opt ::= */ yytestcase(yyruleno==178); case 179: /* where_opt ::= */ yytestcase(yyruleno==179);
case 216: /* expritem ::= */ yytestcase(yyruleno==216); case 217: /* expritem ::= */ yytestcase(yyruleno==217);
{yymsp[1].minor.yy66 = 0;} {yymsp[1].minor.yy190 = 0;}
break; break;
case 169: /* having_opt ::= HAVING expr */ case 170: /* having_opt ::= HAVING expr */
case 179: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==179); case 180: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==180);
{yymsp[-1].minor.yy66 = yymsp[0].minor.yy66;} {yymsp[-1].minor.yy190 = yymsp[0].minor.yy190;}
break; break;
case 170: /* limit_opt ::= */ case 171: /* limit_opt ::= */
case 174: /* slimit_opt ::= */ yytestcase(yyruleno==174); case 175: /* slimit_opt ::= */ yytestcase(yyruleno==175);
{yymsp[1].minor.yy188.limit = -1; yymsp[1].minor.yy188.offset = 0;} {yymsp[1].minor.yy414.limit = -1; yymsp[1].minor.yy414.offset = 0;}
break; break;
case 171: /* limit_opt ::= LIMIT signed */ case 172: /* limit_opt ::= LIMIT signed */
case 175: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==175); case 176: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==176);
{yymsp[-1].minor.yy188.limit = yymsp[0].minor.yy271; yymsp[-1].minor.yy188.offset = 0;} {yymsp[-1].minor.yy414.limit = yymsp[0].minor.yy369; yymsp[-1].minor.yy414.offset = 0;}
break; break;
case 172: /* limit_opt ::= LIMIT signed OFFSET signed */ case 173: /* limit_opt ::= LIMIT signed OFFSET signed */
case 176: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ yytestcase(yyruleno==176); case 177: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ yytestcase(yyruleno==177);
{yymsp[-3].minor.yy188.limit = yymsp[-2].minor.yy271; yymsp[-3].minor.yy188.offset = yymsp[0].minor.yy271;} {yymsp[-3].minor.yy414.limit = yymsp[-2].minor.yy369; yymsp[-3].minor.yy414.offset = yymsp[0].minor.yy369;}
break; break;
case 173: /* limit_opt ::= LIMIT signed COMMA signed */ case 174: /* limit_opt ::= LIMIT signed COMMA signed */
case 177: /* slimit_opt ::= SLIMIT signed COMMA signed */ yytestcase(yyruleno==177); case 178: /* slimit_opt ::= SLIMIT signed COMMA signed */ yytestcase(yyruleno==178);
{yymsp[-3].minor.yy188.limit = yymsp[0].minor.yy271; yymsp[-3].minor.yy188.offset = yymsp[-2].minor.yy271;} {yymsp[-3].minor.yy414.limit = yymsp[0].minor.yy369; yymsp[-3].minor.yy414.offset = yymsp[-2].minor.yy369;}
break; break;
case 180: /* expr ::= LP expr RP */ case 181: /* expr ::= LP expr RP */
{yymsp[-2].minor.yy66 = yymsp[-1].minor.yy66; } {yymsp[-2].minor.yy190 = yymsp[-1].minor.yy190; }
break; break;
case 181: /* expr ::= ID */ case 182: /* expr ::= ID */
{yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_ID);} {yylhsminor.yy190 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_ID);}
yymsp[0].minor.yy66 = yylhsminor.yy66; yymsp[0].minor.yy190 = yylhsminor.yy190;
break; break;
case 182: /* expr ::= ID DOT ID */ case 183: /* expr ::= ID DOT ID */
{yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[-2].minor.yy0, TK_ID);} {yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy190 = tSQLExprIdValueCreate(&yymsp[-2].minor.yy0, TK_ID);}
yymsp[-2].minor.yy66 = yylhsminor.yy66; yymsp[-2].minor.yy190 = yylhsminor.yy190;
break; break;
case 183: /* expr ::= ID DOT STAR */ case 184: /* expr ::= ID DOT STAR */
{yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[-2].minor.yy0, TK_ALL);} {yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy190 = tSQLExprIdValueCreate(&yymsp[-2].minor.yy0, TK_ALL);}
yymsp[-2].minor.yy66 = yylhsminor.yy66; yymsp[-2].minor.yy190 = yylhsminor.yy190;
break; break;
case 184: /* expr ::= INTEGER */ case 185: /* expr ::= INTEGER */
{yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_INTEGER);} {yylhsminor.yy190 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_INTEGER);}
yymsp[0].minor.yy66 = yylhsminor.yy66; yymsp[0].minor.yy190 = yylhsminor.yy190;
break; break;
case 185: /* expr ::= MINUS INTEGER */ case 186: /* expr ::= MINUS INTEGER */
case 186: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==186); case 187: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==187);
{yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[-1].minor.yy0, TK_INTEGER);} {yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy190 = tSQLExprIdValueCreate(&yymsp[-1].minor.yy0, TK_INTEGER);}
yymsp[-1].minor.yy66 = yylhsminor.yy66; yymsp[-1].minor.yy190 = yylhsminor.yy190;
break; break;
case 187: /* expr ::= FLOAT */ case 188: /* expr ::= FLOAT */
{yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_FLOAT);} {yylhsminor.yy190 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_FLOAT);}
yymsp[0].minor.yy66 = yylhsminor.yy66; yymsp[0].minor.yy190 = yylhsminor.yy190;
break; break;
case 188: /* expr ::= MINUS FLOAT */ case 189: /* expr ::= MINUS FLOAT */
case 189: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==189); case 190: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==190);
{yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[-1].minor.yy0, TK_FLOAT);} {yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy190 = tSQLExprIdValueCreate(&yymsp[-1].minor.yy0, TK_FLOAT);}
yymsp[-1].minor.yy66 = yylhsminor.yy66; yymsp[-1].minor.yy190 = yylhsminor.yy190;
break; break;
case 190: /* expr ::= STRING */ case 191: /* expr ::= STRING */
{yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_STRING);} {yylhsminor.yy190 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_STRING);}
yymsp[0].minor.yy66 = yylhsminor.yy66; yymsp[0].minor.yy190 = yylhsminor.yy190;
break; break;
case 191: /* expr ::= NOW */ case 192: /* expr ::= NOW */
{yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_NOW); } {yylhsminor.yy190 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_NOW); }
yymsp[0].minor.yy66 = yylhsminor.yy66; yymsp[0].minor.yy190 = yylhsminor.yy190;
break; break;
case 192: /* expr ::= VARIABLE */ case 193: /* expr ::= VARIABLE */
{yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_VARIABLE);} {yylhsminor.yy190 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_VARIABLE);}
yymsp[0].minor.yy66 = yylhsminor.yy66; yymsp[0].minor.yy190 = yylhsminor.yy190;
break; break;
case 193: /* expr ::= BOOL */ case 194: /* expr ::= BOOL */
{yylhsminor.yy66 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_BOOL);} {yylhsminor.yy190 = tSQLExprIdValueCreate(&yymsp[0].minor.yy0, TK_BOOL);}
yymsp[0].minor.yy66 = yylhsminor.yy66; yymsp[0].minor.yy190 = yylhsminor.yy190;
break; break;
case 194: /* expr ::= ID LP exprlist RP */ case 195: /* expr ::= ID LP exprlist RP */
{ yylhsminor.yy66 = tSQLExprCreateFunction(yymsp[-1].minor.yy224, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } { yylhsminor.yy190 = tSQLExprCreateFunction(yymsp[-1].minor.yy158, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); }
yymsp[-3].minor.yy66 = yylhsminor.yy66; yymsp[-3].minor.yy190 = yylhsminor.yy190;
break; break;
case 195: /* expr ::= ID LP STAR RP */ case 196: /* expr ::= ID LP STAR RP */
{ yylhsminor.yy66 = tSQLExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } { yylhsminor.yy190 = tSQLExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); }
yymsp[-3].minor.yy66 = yylhsminor.yy66; yymsp[-3].minor.yy190 = yylhsminor.yy190;
break; break;
case 196: /* expr ::= expr IS NULL */ case 197: /* expr ::= expr IS NULL */
{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, NULL, TK_ISNULL);} {yylhsminor.yy190 = tSQLExprCreate(yymsp[-2].minor.yy190, NULL, TK_ISNULL);}
yymsp[-2].minor.yy66 = yylhsminor.yy66; yymsp[-2].minor.yy190 = yylhsminor.yy190;
break; break;
case 197: /* expr ::= expr IS NOT NULL */ case 198: /* expr ::= expr IS NOT NULL */
{yylhsminor.yy66 = tSQLExprCreate(yymsp[-3].minor.yy66, NULL, TK_NOTNULL);} {yylhsminor.yy190 = tSQLExprCreate(yymsp[-3].minor.yy190, NULL, TK_NOTNULL);}
yymsp[-3].minor.yy66 = yylhsminor.yy66; yymsp[-3].minor.yy190 = yylhsminor.yy190;
break; break;
case 198: /* expr ::= expr LT expr */ case 199: /* expr ::= expr LT expr */
{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_LT);} {yylhsminor.yy190 = tSQLExprCreate(yymsp[-2].minor.yy190, yymsp[0].minor.yy190, TK_LT);}
yymsp[-2].minor.yy66 = yylhsminor.yy66; yymsp[-2].minor.yy190 = yylhsminor.yy190;
break; break;
case 199: /* expr ::= expr GT expr */ case 200: /* expr ::= expr GT expr */
{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_GT);} {yylhsminor.yy190 = tSQLExprCreate(yymsp[-2].minor.yy190, yymsp[0].minor.yy190, TK_GT);}
yymsp[-2].minor.yy66 = yylhsminor.yy66; yymsp[-2].minor.yy190 = yylhsminor.yy190;
break; break;
case 200: /* expr ::= expr LE expr */ case 201: /* expr ::= expr LE expr */
{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_LE);} {yylhsminor.yy190 = tSQLExprCreate(yymsp[-2].minor.yy190, yymsp[0].minor.yy190, TK_LE);}
yymsp[-2].minor.yy66 = yylhsminor.yy66; yymsp[-2].minor.yy190 = yylhsminor.yy190;
break; break;
case 201: /* expr ::= expr GE expr */ case 202: /* expr ::= expr GE expr */
{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_GE);} {yylhsminor.yy190 = tSQLExprCreate(yymsp[-2].minor.yy190, yymsp[0].minor.yy190, TK_GE);}
yymsp[-2].minor.yy66 = yylhsminor.yy66; yymsp[-2].minor.yy190 = yylhsminor.yy190;
break; break;
case 202: /* expr ::= expr NE expr */ case 203: /* expr ::= expr NE expr */
{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_NE);} {yylhsminor.yy190 = tSQLExprCreate(yymsp[-2].minor.yy190, yymsp[0].minor.yy190, TK_NE);}
yymsp[-2].minor.yy66 = yylhsminor.yy66; yymsp[-2].minor.yy190 = yylhsminor.yy190;
break; break;
case 203: /* expr ::= expr EQ expr */ case 204: /* expr ::= expr EQ expr */
{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_EQ);} {yylhsminor.yy190 = tSQLExprCreate(yymsp[-2].minor.yy190, yymsp[0].minor.yy190, TK_EQ);}
yymsp[-2].minor.yy66 = yylhsminor.yy66; yymsp[-2].minor.yy190 = yylhsminor.yy190;
break; break;
case 204: /* expr ::= expr AND expr */ case 205: /* expr ::= expr AND expr */
{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_AND);} {yylhsminor.yy190 = tSQLExprCreate(yymsp[-2].minor.yy190, yymsp[0].minor.yy190, TK_AND);}
yymsp[-2].minor.yy66 = yylhsminor.yy66; yymsp[-2].minor.yy190 = yylhsminor.yy190;
break; break;
case 205: /* expr ::= expr OR expr */ case 206: /* expr ::= expr OR expr */
{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_OR); } {yylhsminor.yy190 = tSQLExprCreate(yymsp[-2].minor.yy190, yymsp[0].minor.yy190, TK_OR); }
yymsp[-2].minor.yy66 = yylhsminor.yy66; yymsp[-2].minor.yy190 = yylhsminor.yy190;
break; break;
case 206: /* expr ::= expr PLUS expr */ case 207: /* expr ::= expr PLUS expr */
{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_PLUS); } {yylhsminor.yy190 = tSQLExprCreate(yymsp[-2].minor.yy190, yymsp[0].minor.yy190, TK_PLUS); }
yymsp[-2].minor.yy66 = yylhsminor.yy66; yymsp[-2].minor.yy190 = yylhsminor.yy190;
break; break;
case 207: /* expr ::= expr MINUS expr */ case 208: /* expr ::= expr MINUS expr */
{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_MINUS); } {yylhsminor.yy190 = tSQLExprCreate(yymsp[-2].minor.yy190, yymsp[0].minor.yy190, TK_MINUS); }
yymsp[-2].minor.yy66 = yylhsminor.yy66; yymsp[-2].minor.yy190 = yylhsminor.yy190;
break; break;
case 208: /* expr ::= expr STAR expr */ case 209: /* expr ::= expr STAR expr */
{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_STAR); } {yylhsminor.yy190 = tSQLExprCreate(yymsp[-2].minor.yy190, yymsp[0].minor.yy190, TK_STAR); }
yymsp[-2].minor.yy66 = yylhsminor.yy66; yymsp[-2].minor.yy190 = yylhsminor.yy190;
break; break;
case 209: /* expr ::= expr SLASH expr */ case 210: /* expr ::= expr SLASH expr */
{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_DIVIDE);} {yylhsminor.yy190 = tSQLExprCreate(yymsp[-2].minor.yy190, yymsp[0].minor.yy190, TK_DIVIDE);}
yymsp[-2].minor.yy66 = yylhsminor.yy66; yymsp[-2].minor.yy190 = yylhsminor.yy190;
break; break;
case 210: /* expr ::= expr REM expr */ case 211: /* expr ::= expr REM expr */
{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_REM); } {yylhsminor.yy190 = tSQLExprCreate(yymsp[-2].minor.yy190, yymsp[0].minor.yy190, TK_REM); }
yymsp[-2].minor.yy66 = yylhsminor.yy66; yymsp[-2].minor.yy190 = yylhsminor.yy190;
break; break;
case 211: /* expr ::= expr LIKE expr */ case 212: /* expr ::= expr LIKE expr */
{yylhsminor.yy66 = tSQLExprCreate(yymsp[-2].minor.yy66, yymsp[0].minor.yy66, TK_LIKE); } {yylhsminor.yy190 = tSQLExprCreate(yymsp[-2].minor.yy190, yymsp[0].minor.yy190, TK_LIKE); }
yymsp[-2].minor.yy66 = yylhsminor.yy66; yymsp[-2].minor.yy190 = yylhsminor.yy190;
break; break;
case 212: /* expr ::= expr IN LP exprlist RP */ case 213: /* expr ::= expr IN LP exprlist RP */
{yylhsminor.yy66 = tSQLExprCreate(yymsp[-4].minor.yy66, (tSQLExpr*)yymsp[-1].minor.yy224, TK_IN); } {yylhsminor.yy190 = tSQLExprCreate(yymsp[-4].minor.yy190, (tSQLExpr*)yymsp[-1].minor.yy158, TK_IN); }
yymsp[-4].minor.yy66 = yylhsminor.yy66; yymsp[-4].minor.yy190 = yylhsminor.yy190;
break; break;
case 213: /* exprlist ::= exprlist COMMA expritem */ case 214: /* exprlist ::= exprlist COMMA expritem */
{yylhsminor.yy224 = tSQLExprListAppend(yymsp[-2].minor.yy224,yymsp[0].minor.yy66,0);} {yylhsminor.yy158 = tSQLExprListAppend(yymsp[-2].minor.yy158,yymsp[0].minor.yy190,0);}
yymsp[-2].minor.yy224 = yylhsminor.yy224; yymsp[-2].minor.yy158 = yylhsminor.yy158;
break; break;
case 214: /* exprlist ::= expritem */ case 215: /* exprlist ::= expritem */
{yylhsminor.yy224 = tSQLExprListAppend(0,yymsp[0].minor.yy66,0);} {yylhsminor.yy158 = tSQLExprListAppend(0,yymsp[0].minor.yy190,0);}
yymsp[0].minor.yy224 = yylhsminor.yy224; yymsp[0].minor.yy158 = yylhsminor.yy158;
break; break;
case 215: /* expritem ::= expr */ case 216: /* expritem ::= expr */
{yylhsminor.yy66 = yymsp[0].minor.yy66;} {yylhsminor.yy190 = yymsp[0].minor.yy190;}
yymsp[0].minor.yy66 = yylhsminor.yy66; yymsp[0].minor.yy190 = yylhsminor.yy190;
break; break;
case 217: /* cmd ::= RESET QUERY CACHE */ case 218: /* cmd ::= RESET QUERY CACHE */
{ setDCLSQLElems(pInfo, TSDB_SQL_RESET_CACHE, 0);} { setDCLSQLElems(pInfo, TSDB_SQL_RESET_CACHE, 0);}
break; break;
case 218: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ case 219: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */
{ {
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&yymsp[-4].minor.yy0, yymsp[0].minor.yy449, NULL, TSDB_ALTER_TABLE_ADD_COLUMN); SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&yymsp[-4].minor.yy0, yymsp[0].minor.yy511, NULL, TSDB_ALTER_TABLE_ADD_COLUMN);
setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
} }
break; break;
case 219: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ case 220: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */
{ {
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
...@@ -2757,14 +3021,14 @@ static void yy_reduce( ...@@ -2757,14 +3021,14 @@ static void yy_reduce(
setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
} }
break; break;
case 220: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ case 221: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */
{ {
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&yymsp[-4].minor.yy0, yymsp[0].minor.yy449, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN); SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&yymsp[-4].minor.yy0, yymsp[0].minor.yy511, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN);
setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
} }
break; break;
case 221: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ case 222: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */
{ {
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
...@@ -2775,7 +3039,7 @@ static void yy_reduce( ...@@ -2775,7 +3039,7 @@ static void yy_reduce(
setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
} }
break; break;
case 222: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ case 223: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */
{ {
yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n;
...@@ -2789,34 +3053,34 @@ static void yy_reduce( ...@@ -2789,34 +3053,34 @@ static void yy_reduce(
setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
} }
break; break;
case 223: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ case 224: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */
{ {
yymsp[-6].minor.yy0.n += yymsp[-5].minor.yy0.n; yymsp[-6].minor.yy0.n += yymsp[-5].minor.yy0.n;
toTSDBType(yymsp[-2].minor.yy0.type); toTSDBType(yymsp[-2].minor.yy0.type);
tVariantList* A = tVariantListAppendToken(NULL, &yymsp[-2].minor.yy0, -1); tVariantList* A = tVariantListAppendToken(NULL, &yymsp[-2].minor.yy0, -1);
A = tVariantListAppend(A, &yymsp[0].minor.yy312, -1); A = tVariantListAppend(A, &yymsp[0].minor.yy506, -1);
SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&yymsp[-6].minor.yy0, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_VAL); SAlterTableSQL* pAlterTable = tAlterTableSQLElems(&yymsp[-6].minor.yy0, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_VAL);
setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); setSQLInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
} }
break; break;
case 224: /* cmd ::= KILL CONNECTION INTEGER */ case 225: /* cmd ::= KILL CONNECTION INTEGER */
{setKillSQL(pInfo, TSDB_SQL_KILL_CONNECTION, &yymsp[0].minor.yy0);} {setKillSQL(pInfo, TSDB_SQL_KILL_CONNECTION, &yymsp[0].minor.yy0);}
break; break;
case 225: /* cmd ::= KILL STREAM INTEGER COLON INTEGER */ case 226: /* 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);} {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; break;
case 226: /* cmd ::= KILL QUERY INTEGER COLON INTEGER */ case 227: /* 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);} {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; break;
default: default:
break; break;
/********** End reduce actions ************************************************/ /********** End reduce actions ************************************************/
}; };
assert( yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) ); assert( yyruleno<sizeof(yyRuleInfoLhs)/sizeof(yyRuleInfoLhs[0]) );
yygoto = yyRuleInfo[yyruleno].lhs; yygoto = yyRuleInfoLhs[yyruleno];
yysize = yyRuleInfo[yyruleno].nrhs; yysize = yyRuleInfoNRhs[yyruleno];
yyact = yy_find_reduce_action(yymsp[yysize].stateno,(YYCODETYPE)yygoto); yyact = yy_find_reduce_action(yymsp[yysize].stateno,(YYCODETYPE)yygoto);
/* There are no SHIFTREDUCE actions on nonterminals because the table /* There are no SHIFTREDUCE actions on nonterminals because the table
...@@ -2831,6 +3095,7 @@ static void yy_reduce( ...@@ -2831,6 +3095,7 @@ static void yy_reduce(
yymsp->stateno = (YYACTIONTYPE)yyact; yymsp->stateno = (YYACTIONTYPE)yyact;
yymsp->major = (YYCODETYPE)yygoto; yymsp->major = (YYCODETYPE)yygoto;
yyTraceShift(yypParser, yyact, "... then shift"); yyTraceShift(yypParser, yyact, "... then shift");
return yyact;
} }
/* /*
...@@ -2840,7 +3105,8 @@ static void yy_reduce( ...@@ -2840,7 +3105,8 @@ static void yy_reduce(
static void yy_parse_failed( static void yy_parse_failed(
yyParser *yypParser /* The parser */ yyParser *yypParser /* The parser */
){ ){
ParseARG_FETCH; ParseARG_FETCH
ParseCTX_FETCH
#ifndef NDEBUG #ifndef NDEBUG
if( yyTraceFILE ){ if( yyTraceFILE ){
fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt); fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt);
...@@ -2851,7 +3117,8 @@ static void yy_parse_failed( ...@@ -2851,7 +3117,8 @@ static void yy_parse_failed(
** parser fails */ ** parser fails */
/************ Begin %parse_failure code ***************************************/ /************ Begin %parse_failure code ***************************************/
/************ End %parse_failure code *****************************************/ /************ End %parse_failure code *****************************************/
ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ ParseARG_STORE /* Suppress warning about unused %extra_argument variable */
ParseCTX_STORE
} }
#endif /* YYNOERRORRECOVERY */ #endif /* YYNOERRORRECOVERY */
...@@ -2863,7 +3130,8 @@ static void yy_syntax_error( ...@@ -2863,7 +3130,8 @@ static void yy_syntax_error(
int yymajor, /* The major type of the error token */ int yymajor, /* The major type of the error token */
ParseTOKENTYPE yyminor /* The minor type of the error token */ ParseTOKENTYPE yyminor /* The minor type of the error token */
){ ){
ParseARG_FETCH; ParseARG_FETCH
ParseCTX_FETCH
#define TOKEN yyminor #define TOKEN yyminor
/************ Begin %syntax_error code ****************************************/ /************ Begin %syntax_error code ****************************************/
...@@ -2889,7 +3157,8 @@ static void yy_syntax_error( ...@@ -2889,7 +3157,8 @@ static void yy_syntax_error(
assert(len <= outputBufLen); assert(len <= outputBufLen);
/************ End %syntax_error code ******************************************/ /************ End %syntax_error code ******************************************/
ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ ParseARG_STORE /* Suppress warning about unused %extra_argument variable */
ParseCTX_STORE
} }
/* /*
...@@ -2898,7 +3167,8 @@ static void yy_syntax_error( ...@@ -2898,7 +3167,8 @@ static void yy_syntax_error(
static void yy_accept( static void yy_accept(
yyParser *yypParser /* The parser */ yyParser *yypParser /* The parser */
){ ){
ParseARG_FETCH; ParseARG_FETCH
ParseCTX_FETCH
#ifndef NDEBUG #ifndef NDEBUG
if( yyTraceFILE ){ if( yyTraceFILE ){
fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt); fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt);
...@@ -2913,7 +3183,8 @@ static void yy_accept( ...@@ -2913,7 +3183,8 @@ static void yy_accept(
/*********** Begin %parse_accept code *****************************************/ /*********** Begin %parse_accept code *****************************************/
/*********** End %parse_accept code *******************************************/ /*********** End %parse_accept code *******************************************/
ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ ParseARG_STORE /* Suppress warning about unused %extra_argument variable */
ParseCTX_STORE
} }
/* The main parser program. /* The main parser program.
...@@ -2942,45 +3213,47 @@ void Parse( ...@@ -2942,45 +3213,47 @@ void Parse(
ParseARG_PDECL /* Optional %extra_argument parameter */ ParseARG_PDECL /* Optional %extra_argument parameter */
){ ){
YYMINORTYPE yyminorunion; YYMINORTYPE yyminorunion;
unsigned int yyact; /* The parser action. */ YYACTIONTYPE yyact; /* The parser action. */
#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY) #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
int yyendofinput; /* True if we are at the end of input */ int yyendofinput; /* True if we are at the end of input */
#endif #endif
#ifdef YYERRORSYMBOL #ifdef YYERRORSYMBOL
int yyerrorhit = 0; /* True if yymajor has invoked an error */ int yyerrorhit = 0; /* True if yymajor has invoked an error */
#endif #endif
yyParser *yypParser; /* The parser */ yyParser *yypParser = (yyParser*)yyp; /* The parser */
ParseCTX_FETCH
ParseARG_STORE
yypParser = (yyParser*)yyp;
assert( yypParser->yytos!=0 ); assert( yypParser->yytos!=0 );
#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY) #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
yyendofinput = (yymajor==0); yyendofinput = (yymajor==0);
#endif #endif
ParseARG_STORE;
yyact = yypParser->yytos->stateno;
#ifndef NDEBUG #ifndef NDEBUG
if( yyTraceFILE ){ if( yyTraceFILE ){
int stateno = yypParser->yytos->stateno; if( yyact < YY_MIN_REDUCE ){
if( stateno < YY_MIN_REDUCE ){
fprintf(yyTraceFILE,"%sInput '%s' in state %d\n", fprintf(yyTraceFILE,"%sInput '%s' in state %d\n",
yyTracePrompt,yyTokenName[yymajor],stateno); yyTracePrompt,yyTokenName[yymajor],yyact);
}else{ }else{
fprintf(yyTraceFILE,"%sInput '%s' with pending reduce %d\n", fprintf(yyTraceFILE,"%sInput '%s' with pending reduce %d\n",
yyTracePrompt,yyTokenName[yymajor],stateno-YY_MIN_REDUCE); yyTracePrompt,yyTokenName[yymajor],yyact-YY_MIN_REDUCE);
} }
} }
#endif #endif
do{ do{
yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor); assert( yyact==yypParser->yytos->stateno );
yyact = yy_find_shift_action((YYCODETYPE)yymajor,yyact);
if( yyact >= YY_MIN_REDUCE ){ if( yyact >= YY_MIN_REDUCE ){
yy_reduce(yypParser,yyact-YY_MIN_REDUCE,yymajor,yyminor); yyact = yy_reduce(yypParser,yyact-YY_MIN_REDUCE,yymajor,
yyminor ParseCTX_PARAM);
}else if( yyact <= YY_MAX_SHIFTREDUCE ){ }else if( yyact <= YY_MAX_SHIFTREDUCE ){
yy_shift(yypParser,yyact,yymajor,yyminor); yy_shift(yypParser,yyact,(YYCODETYPE)yymajor,yyminor);
#ifndef YYNOERRORRECOVERY #ifndef YYNOERRORRECOVERY
yypParser->yyerrcnt--; yypParser->yyerrcnt--;
#endif #endif
yymajor = YYNOCODE; break;
}else if( yyact==YY_ACCEPT_ACTION ){ }else if( yyact==YY_ACCEPT_ACTION ){
yypParser->yytos--; yypParser->yytos--;
yy_accept(yypParser); yy_accept(yypParser);
...@@ -3031,10 +3304,9 @@ void Parse( ...@@ -3031,10 +3304,9 @@ void Parse(
yymajor = YYNOCODE; yymajor = YYNOCODE;
}else{ }else{
while( yypParser->yytos >= yypParser->yystack while( yypParser->yytos >= yypParser->yystack
&& yymx != YYERRORSYMBOL
&& (yyact = yy_find_reduce_action( && (yyact = yy_find_reduce_action(
yypParser->yytos->stateno, yypParser->yytos->stateno,
YYERRORSYMBOL)) >= YY_MIN_REDUCE YYERRORSYMBOL)) > YY_MAX_SHIFTREDUCE
){ ){
yy_pop_parser_stack(yypParser); yy_pop_parser_stack(yypParser);
} }
...@@ -3051,6 +3323,8 @@ void Parse( ...@@ -3051,6 +3323,8 @@ void Parse(
} }
yypParser->yyerrcnt = 3; yypParser->yyerrcnt = 3;
yyerrorhit = 1; yyerrorhit = 1;
if( yymajor==YYNOCODE ) break;
yyact = yypParser->yytos->stateno;
#elif defined(YYNOERRORRECOVERY) #elif defined(YYNOERRORRECOVERY)
/* If the YYNOERRORRECOVERY macro is defined, then do not attempt to /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to
** do any kind of error recovery. Instead, simply invoke the syntax ** do any kind of error recovery. Instead, simply invoke the syntax
...@@ -3061,8 +3335,7 @@ void Parse( ...@@ -3061,8 +3335,7 @@ void Parse(
*/ */
yy_syntax_error(yypParser,yymajor, yyminor); yy_syntax_error(yypParser,yymajor, yyminor);
yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
yymajor = YYNOCODE; break;
#else /* YYERRORSYMBOL is not defined */ #else /* YYERRORSYMBOL is not defined */
/* This is what we do if the grammar does not define ERROR: /* This is what we do if the grammar does not define ERROR:
** **
...@@ -3084,10 +3357,10 @@ void Parse( ...@@ -3084,10 +3357,10 @@ void Parse(
yypParser->yyerrcnt = -1; yypParser->yyerrcnt = -1;
#endif #endif
} }
yymajor = YYNOCODE; break;
#endif #endif
} }
}while( yymajor!=YYNOCODE && yypParser->yytos>yypParser->yystack ); }while( yypParser->yytos>yypParser->yystack );
#ifndef NDEBUG #ifndef NDEBUG
if( yyTraceFILE ){ if( yyTraceFILE ){
yyStackEntry *i; yyStackEntry *i;
...@@ -3102,3 +3375,17 @@ void Parse( ...@@ -3102,3 +3375,17 @@ void Parse(
#endif #endif
return; return;
} }
/*
** Return the fallback token corresponding to canonical token iToken, or
** 0 if iToken has no fallback.
*/
int ParseFallback(int iToken){
#ifdef YYFALLBACK
assert( iToken<(int)(sizeof(yyFallback)/sizeof(yyFallback[0])) );
return yyFallback[iToken];
#else
(void)iToken;
return 0;
#endif
}
...@@ -2707,4 +2707,5 @@ void tsdbDestroyTableGroup(STableGroupInfo *pGroupList) { ...@@ -2707,4 +2707,5 @@ void tsdbDestroyTableGroup(STableGroupInfo *pGroupList) {
} }
taosArrayDestroy(pGroupList->pGroupList); taosArrayDestroy(pGroupList->pGroupList);
pGroupList->numOfTables = 0;
} }
文件模式从 100755 更改为 100644
###################################################################
# Copyright (c) 2020 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
import taos
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())
def general(self):
tdSql.execute("create table meters(ts timestamp, s int) tags(id int)")
tdSql.execute("create table t0 using meters tags(0)")
tdSql.execute("create table t1 using meters tags(1)")
tdSql.execute("create table t2 using meters tags(2)")
tdSql.execute("create table t3 using meters tags(3)")
tdSql.execute("create table t4 using meters tags(4)")
tdSql.execute("insert into t0 values('2019-01-01 00:00:00', 1)")
tdSql.execute("insert into t1 values('2019-01-01 00:00:01', 1)")
tdSql.execute("insert into t2 values('2019-01-01 00:01:00', 1)")
tdSql.execute("insert into t1 values('2019-01-01 00:01:01', 1)")
tdSql.execute("insert into t1 values('2019-01-01 00:01:02', 1)")
tdSql.execute("insert into t1 values('2019-01-01 00:01:03', 1)")
tdSql.execute("insert into t1 values('2019-01-01 00:01:30', 1)")
tdSql.execute("insert into t1 values('2019-01-01 00:01:50', 1)")
tdSql.execute("insert into t2 values('2019-01-01 00:02:00', 1)")
tdSql.execute("insert into t3 values('2019-01-01 00:02:02', 1)")
tdSql.execute("insert into t3 values('2019-01-01 00:02:59', 1)")
tdSql.execute("insert into t4 values('2019-01-01 00:02:59', 1)")
tdSql.execute("insert into t1 values('2019-01-01 00:03:10', 1)")
tdSql.execute("insert into t2 values('2019-01-01 00:08:00', 1)")
tdSql.execute("insert into t1 values('2019-01-01 00:08:00', 1)")
tdSql.query("select count(*) from meters interval(1m, 1s)")
tdSql.checkData(0, 1, 1)
tdSql.checkData(1, 1, 2)
tdSql.checkData(2, 1, 6)
tdSql.checkData(3, 1, 3)
tdSql.checkData(4, 1, 1)
tdSql.checkData(5, 1, 2)
tdSql.query("select count(*) from meters interval(1m, 2s)")
tdSql.checkData(0, 1, 2)
tdSql.checkData(1, 1, 2)
tdSql.checkData(2, 1, 5)
tdSql.checkData(3, 1, 3)
tdSql.checkData(4, 1, 1)
tdSql.checkData(5, 1, 2)
tdSql.query("select count(*) from meters interval(90s, 1500a)")
tdSql.checkData(0, 1, 2)
tdSql.checkData(1, 1, 5)
tdSql.checkData(2, 1, 5)
tdSql.checkData(3, 1, 1)
tdSql.checkData(4, 1, 2)
def singleTable(self):
tdSql.execute("create table car(ts timestamp, s int)")
tdSql.execute("insert into car values('2019-01-01 00:00:00', 1)")
tdSql.execute("insert into car values('2019-05-13 12:00:00', 1)")
tdSql.execute("insert into car values('2019-12-31 23:59:59', 1)")
tdSql.execute("insert into car values('2020-01-01 12:00:00', 1)")
tdSql.execute("insert into car values('2020-01-02 12:00:00', 1)")
tdSql.execute("insert into car values('2020-01-03 12:00:00', 1)")
tdSql.execute("insert into car values('2020-01-04 12:00:00', 1)")
tdSql.execute("insert into car values('2020-01-05 12:00:00', 1)")
tdSql.execute("insert into car values('2020-01-31 12:00:00', 1)")
tdSql.execute("insert into car values('2020-02-01 12:00:00', 1)")
tdSql.execute("insert into car values('2020-02-02 12:00:00', 1)")
tdSql.execute("insert into car values('2020-02-29 12:00:00', 1)")
tdSql.execute("insert into car values('2020-03-01 12:00:00', 1)")
tdSql.execute("insert into car values('2020-03-02 12:00:00', 1)")
tdSql.execute("insert into car values('2020-03-15 12:00:00', 1)")
tdSql.execute("insert into car values('2020-03-31 12:00:00', 1)")
tdSql.execute("insert into car values('2020-05-01 12:00:00', 1)")
tdSql.query("select count(*) from car interval(1n, 10d)")
tdSql.checkData(0, 1, 1)
tdSql.checkData(1, 1, 1)
tdSql.checkData(2, 1, 6)
tdSql.checkData(3, 1, 3)
tdSql.checkData(4, 1, 3)
tdSql.checkData(5, 1, 2)
tdSql.checkData(6, 1, 1)
tdSql.query("select count(*) from car interval(1n, 10d) order by ts desc")
tdSql.checkData(0, 1, 1)
tdSql.checkData(1, 1, 2)
tdSql.checkData(2, 1, 3)
tdSql.checkData(3, 1, 3)
tdSql.checkData(4, 1, 6)
tdSql.checkData(5, 1, 1)
tdSql.checkData(6, 1, 1)
tdSql.query("select count(*) from car interval(2n, 5d)")
tdSql.checkData(0, 1, 1)
tdSql.checkData(1, 1, 1)
tdSql.checkData(2, 1, 6)
tdSql.checkData(3, 1, 6)
tdSql.checkData(4, 1, 3)
tdSql.query("select count(*) from car interval(2n) order by ts desc")
tdSql.checkData(0, 1, 3)
tdSql.checkData(1, 1, 6)
tdSql.checkData(2, 1, 6)
tdSql.checkData(3, 1, 1)
tdSql.checkData(4, 1, 1)
tdSql.query("select count(*) from car interval(1y, 1n)")
tdSql.checkData(0, 1, 1)
tdSql.checkData(1, 1, 8)
tdSql.checkData(2, 1, 8)
tdSql.query("select count(*) from car interval(1y, 2n)")
tdSql.checkData(0, 1, 1)
tdSql.checkData(1, 1, 11)
tdSql.checkData(2, 1, 5)
tdSql.query("select count(*) from car where ts > '2019-05-14 00:00:00' interval(1y, 5d)")
tdSql.checkData(0, 1, 6)
tdSql.checkData(1, 1, 9)
def superTable(self):
tdSql.execute("create table cars(ts timestamp, s int) tags(id int)")
tdSql.execute("create table car0 using cars tags(0)")
tdSql.execute("create table car1 using cars tags(1)")
tdSql.execute("create table car2 using cars tags(2)")
tdSql.execute("create table car3 using cars tags(3)")
tdSql.execute("create table car4 using cars tags(4)")
tdSql.execute("insert into car0 values('2019-01-01 00:00:00', 1)")
tdSql.execute("insert into car1 values('2019-05-13 12:00:00', 1)")
tdSql.execute("insert into car2 values('2019-12-31 23:59:59', 1)")
tdSql.execute("insert into car1 values('2020-01-01 12:00:00', 1)")
tdSql.execute("insert into car1 values('2020-01-02 12:00:00', 1)")
tdSql.execute("insert into car1 values('2020-01-03 12:00:00', 1)")
tdSql.execute("insert into car1 values('2020-01-04 12:00:00', 1)")
tdSql.execute("insert into car1 values('2020-01-05 12:00:00', 1)")
tdSql.execute("insert into car1 values('2020-01-31 12:00:00', 1)")
tdSql.execute("insert into car1 values('2020-02-01 12:00:00', 1)")
tdSql.execute("insert into car2 values('2020-02-02 12:00:00', 1)")
tdSql.execute("insert into car2 values('2020-02-29 12:00:00', 1)")
tdSql.execute("insert into car3 values('2020-03-01 12:00:00', 1)")
tdSql.execute("insert into car3 values('2020-03-02 12:00:00', 1)")
tdSql.execute("insert into car3 values('2020-03-15 12:00:00', 1)")
tdSql.execute("insert into car4 values('2020-03-31 12:00:00', 1)")
tdSql.execute("insert into car3 values('2020-05-01 12:00:00', 1)")
tdSql.query("select count(*) from cars interval(1n, 10d)")
tdSql.checkData(0, 1, 1)
tdSql.checkData(1, 1, 1)
tdSql.checkData(2, 1, 6)
tdSql.checkData(3, 1, 3)
tdSql.checkData(4, 1, 3)
tdSql.checkData(5, 1, 2)
tdSql.checkData(6, 1, 1)
tdSql.query("select count(*) from cars interval(1n, 10d) order by ts desc")
tdSql.checkData(0, 1, 1)
tdSql.checkData(1, 1, 2)
tdSql.checkData(2, 1, 3)
tdSql.checkData(3, 1, 3)
tdSql.checkData(4, 1, 6)
tdSql.checkData(5, 1, 1)
tdSql.checkData(6, 1, 1)
tdSql.query("select count(*) from cars interval(2n, 5d)")
tdSql.checkData(0, 1, 1)
tdSql.checkData(1, 1, 1)
tdSql.checkData(2, 1, 6)
tdSql.checkData(3, 1, 6)
tdSql.checkData(4, 1, 3)
tdSql.query("select count(*) from cars interval(2n) order by ts desc")
tdSql.checkData(0, 1, 3)
tdSql.checkData(1, 1, 6)
tdSql.checkData(2, 1, 6)
tdSql.checkData(3, 1, 1)
tdSql.checkData(4, 1, 1)
tdSql.query("select count(*) from cars interval(1y, 1n)")
tdSql.checkData(0, 1, 1)
tdSql.checkData(1, 1, 8)
tdSql.checkData(2, 1, 8)
tdSql.query("select count(*) from cars interval(1y, 2n)")
tdSql.checkData(0, 1, 1)
tdSql.checkData(1, 1, 11)
tdSql.checkData(2, 1, 5)
tdSql.query("select count(*) from cars where ts > '2019-05-14 00:00:00' interval(1y, 5d)")
tdSql.checkData(0, 1, 6)
tdSql.checkData(1, 1, 9)
def run(self):
tdSql.prepare()
self.general()
self.singleTable()
self.superTable()
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
...@@ -89,10 +89,10 @@ class TDTestCase: ...@@ -89,10 +89,10 @@ class TDTestCase:
def superTable(self): def superTable(self):
tdSql.execute("create table cars(ts timestamp, s int) tags(id int)") tdSql.execute("create table cars(ts timestamp, s int) tags(id int)")
tdSql.execute("create table car0 using cars tags(0)") tdSql.execute("create table car0 using cars tags(0)")
tdSql.execute("create table car1 using cars tags(0)") tdSql.execute("create table car1 using cars tags(1)")
tdSql.execute("create table car2 using cars tags(0)") tdSql.execute("create table car2 using cars tags(2)")
tdSql.execute("create table car3 using cars tags(0)") tdSql.execute("create table car3 using cars tags(3)")
tdSql.execute("create table car4 using cars tags(0)") tdSql.execute("create table car4 using cars tags(4)")
tdSql.execute("insert into car0 values('2019-01-01 00:00:00', 1)") tdSql.execute("insert into car0 values('2019-01-01 00:00:00', 1)")
tdSql.execute("insert into car1 values('2019-05-13 12:00:00', 1)") tdSql.execute("insert into car1 values('2019-05-13 12:00:00', 1)")
......
system sh/stop_dnodes.sh system sh/stop_dnodes.sh
system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4
system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode1 -i 1
print ========= start dnodes print ========= start dnodes
......
system sh/stop_dnodes.sh system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4
print ========= start dnodes print ========= start dnodes
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode1 -s start
......
...@@ -4,6 +4,8 @@ system sh/deploy.sh -n dnode1 -i 1 ...@@ -4,6 +4,8 @@ system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 2 system sh/cfg.sh -n dnode1 -c walLevel -v 2
system sh/deploy.sh -n dnode2 -i 2 system sh/deploy.sh -n dnode2 -i 2
system sh/cfg.sh -n dnode1 -c walLevel -v 2 system sh/cfg.sh -n dnode1 -c walLevel -v 2
system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4
print ========== prepare data print ========== prepare data
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode1 -s start
......
system sh/stop_dnodes.sh system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1 system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 1 system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode1 -c ctime -v 30 system sh/cfg.sh -n dnode1 -c ctime -v 30
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode1 -s start
sleep 3000 sleep 3000
......
...@@ -86,8 +86,6 @@ print ========== insert data by multi-format ...@@ -86,8 +86,6 @@ print ========== insert data by multi-format
sql create table abc.tk_mt (ts timestamp, a int, b binary(16), c bool, d float, e double, f nchar(16)) tags (t1 int, t2 binary(16)) sql create table abc.tk_mt (ts timestamp, a int, b binary(16), c bool, d float, e double, f nchar(16)) tags (t1 int, t2 binary(16))
sql create table abc.tk_subt001 using tk_mt tags(1, 'subt001') sql create table abc.tk_subt001 using tk_mt tags(1, 'subt001')
sql insert into abc.tk_subt001 values (now-1y, 1, 'binary_1', true, 1.001, 2.001, 'nchar_1')
sql insert into abc.tk_subt001 values (now-1n, 2, 'binary_2', true, 1.002, 2.002, 'nchar_2')
sql insert into abc.tk_subt001 values (now-1w, 3, 'binary_3', true, 1.003, 2.003, 'nchar_3') sql insert into abc.tk_subt001 values (now-1w, 3, 'binary_3', true, 1.003, 2.003, 'nchar_3')
sql insert into abc.tk_subt001 (ts, a, c, e, f) values (now-1d, 4, false, 2.004, 'nchar_4') sql insert into abc.tk_subt001 (ts, a, c, e, f) values (now-1d, 4, false, 2.004, 'nchar_4')
sql insert into abc.tk_subt001 (ts, a, c, e, f) values (now-1h, 5, false, 2.005, 'nchar_5') sql insert into abc.tk_subt001 (ts, a, c, e, f) values (now-1h, 5, false, 2.005, 'nchar_5')
...@@ -95,35 +93,29 @@ sql insert into abc.tk_subt001 (ts, b, d) values (now-1m, 'binary_6', ...@@ -95,35 +93,29 @@ sql insert into abc.tk_subt001 (ts, b, d) values (now-1m, 'binary_6',
sql insert into abc.tk_subt001 (ts, b, d) values (now-1s, 'binary_7', 1.007) sql insert into abc.tk_subt001 (ts, b, d) values (now-1s, 'binary_7', 1.007)
sql insert into abc.tk_subt001 (ts, b, d) values (now-1a, 'binary_8', 1.008) sql insert into abc.tk_subt001 (ts, b, d) values (now-1a, 'binary_8', 1.008)
sql select * from tk_subt001 sql select * from tk_subt001
if $rows != 8 then if $rows != 6 then
print ==== expect rows is 8, but actually is $rows print ==== expect rows is 6, but actually is $rows
return -1 return -1
endi endi
sql insert into abc.tk_subt002 using tk_mt tags (22,'subt002x') values (now-2y, 2008, 'binary_2008', false, 2008.001, 2008.001, 'nchar_2008') sql insert into abc.tk_subt002 using tk_mt tags (22, 'subt002x') values (now+1s, 2001, 'binary_2001', true, 2001.001, 2001.001, 'nchar_2001')
sql insert into abc.tk_subt002 using tk_mt tags (2, 'subt002') values (now-1y, 2007, 'binary_2007', false, 2007.001, 2007.001, 'nchar_2007')
sql insert into abc.tk_subt002 using tk_mt tags (2, 'subt002') values (now-1n, 2006, 'binary_2006', true, 2006.001, 2006.001, 'nchar_2006')
sql insert into abc.tk_subt002 using tk_mt tags (2, 'subt002') values (now+1s, 2001, 'binary_2001', true, 2001.001, 2001.001, 'nchar_2001')
sql insert into abc.tk_subt002 using tk_mt tags (2, 'subt002') values (now+1m, 2002, 'binary_2002', false, 2002.001, 2002.001, 'nchar_2002') sql insert into abc.tk_subt002 using tk_mt tags (2, 'subt002') values (now+1m, 2002, 'binary_2002', false, 2002.001, 2002.001, 'nchar_2002')
sql insert into abc.tk_subt002 using tk_mt tags (2, 'subt002') values (now+1h, 2003, 'binary_2003', false, 2003.001, 2003.001, 'nchar_2003') sql insert into abc.tk_subt002 using tk_mt tags (2, 'subt002') values (now+1h, 2003, 'binary_2003', false, 2003.001, 2003.001, 'nchar_2003')
sql insert into abc.tk_subt002 using tk_mt tags (2, 'subt002') values (now+1d, 2004, 'binary_2004', true, 2004.001, 2004.001, 'nchar_2004') sql insert into abc.tk_subt002 using tk_mt tags (2, 'subt002') values (now+1d, 2004, 'binary_2004', true, 2004.001, 2004.001, 'nchar_2004')
sql insert into abc.tk_subt002 using tk_mt tags (2, 'subt002') values (now+1w, 2005, 'binary_2005', false, 2005.001, 2005.001, 'nchar_2005') sql insert into abc.tk_subt002 using tk_mt tags (2, 'subt002') values (now+1w, 2005, 'binary_2005', false, 2005.001, 2005.001, 'nchar_2005')
sql select * from tk_subt002 sql select * from tk_subt002
if $rows != 8 then if $rows != 5 then
print ==== expect rows is 8, but actually is $rows print ==== expect rows is 5, but actually is $rows
return -1 return -1
endi endi
sql insert into abc.tk_subt003 (ts, a, c, e, f) using tk_mt tags (3, 'subt003') values (now-5y, 3001, false, 3001.001, 'nchar_3001') sql insert into abc.tk_subt003 (ts, a, c, e, f) using tk_mt tags (3, 'subt003') values (now-38d, 3004, false, 3004.001, 'nchar_3004')
sql insert into abc.tk_subt003 (ts, a, c, e, f) using tk_mt tags (3, 'subt003') values (now-4y, 3002, false, 3002.001, 'nchar_3002') sql insert into abc.tk_subt003 (ts, a, c, e, f) using tk_mt tags (3, 'subt003') values (now-37d, 3005, false, 3005.001, 'nchar_3005')
sql insert into abc.tk_subt003 (ts, a, c, e, f) using tk_mt tags (3, 'subt003') values (now-3y, 3003, true , 3003.001, 'nchar_3003')
sql insert into abc.tk_subt003 (ts, a, c, e, f) using tk_mt tags (3, 'subt003') values (now-2y, 3004, false, 3004.001, 'nchar_3004')
sql insert into abc.tk_subt003 values (now-37d, 3005, 'binary_3005', false, 3005.001, 3005.001, 'nchar_3005')
sql insert into abc.tk_subt003 values (now-36d, 3006, 'binary_3006', true, 3006.001, 3006.001, 'nchar_3006') sql insert into abc.tk_subt003 values (now-36d, 3006, 'binary_3006', true, 3006.001, 3006.001, 'nchar_3006')
sql insert into abc.tk_subt003 (ts, a, c, e, f) using tk_mt tags (33, 'subt003x') values (now-35d, 3007, false, 3007.001, 'nchar_3007') sql insert into abc.tk_subt003 (ts, a, c, e, f) using tk_mt tags (33, 'subt003x') values (now-35d, 3007, false, 3007.001, 'nchar_3007')
sql select * from tk_subt003 sql select * from tk_subt003
if $rows != 7 then if $rows != 4 then
print ==== expect rows is 7, but actually is $rows print ==== expect rows is 4, but actually is $rows
return -1 return -1
endi endi
......
...@@ -850,6 +850,8 @@ if $rows != 12 then ...@@ -850,6 +850,8 @@ if $rows != 12 then
return -1 return -1
endi endi
print =====================>td-1442
sql_error select count(*) from m_fl_tb0 interval(1s) fill(prev);
print =============== clear print =============== clear
sql drop database $db sql drop database $db
......
...@@ -65,22 +65,23 @@ endi ...@@ -65,22 +65,23 @@ endi
if $data00 != @18-09-18 01:40:00.000@ then if $data00 != @18-09-18 01:40:00.000@ then
return -1 return -1
endi endi
#if $data01 != NULL then
if $data01 != 999 then if $data01 != 999 then
return -1 return -1
endi endi
#if $data02 != NULL then
if $data02 != 999 then if $data02 != 999 then
return -1 return -1
endi endi
#if $data03 != NULL then
if $data03 != 999.00000 then if $data03 != 999.00000 then
return -1 return -1
endi endi
#if $data04 != NULL then
if $data04 != 999.000000000 then if $data04 != 999.000000000 then
return -1 return -1
endi endi
#if $data05 != NULL then #if $data05 != NULL then
if $data05 != 999 then if $data05 != 999 then
return -1 return -1
...@@ -127,7 +128,7 @@ if $data01 != 0 then ...@@ -127,7 +128,7 @@ if $data01 != 0 then
return -1 return -1
endi endi
#add check for out of range first/last query print =============> add check for out of range first/last query
sql select first(ts),last(ts) from first_tb4 where ts>'2018-9-18 1:40:01'; sql select first(ts),last(ts) from first_tb4 where ts>'2018-9-18 1:40:01';
if $row != 0 then if $row != 0 then
return -1 return -1
...@@ -136,4 +137,130 @@ endi ...@@ -136,4 +137,130 @@ endi
sql select first(ts),last(ts) from first_tb4 where ts<'2018-9-17 8:50:0'; sql select first(ts),last(ts) from first_tb4 where ts<'2018-9-17 8:50:0';
if $row != 0 then if $row != 0 then
return -1 return -1
endi
#first/last mix up query
#select first(size),last(size) from stest interval(1d) group by tbname;
print =====================>td-1477
sql create table stest(ts timestamp,size INT,filenum INT) tags (appname binary(500),tenant binary(500));
sql insert into test1 using stest tags('test1','aaa') values ('2020-09-04 16:53:54.003',210,3);
sql insert into test2 using stest tags('test1','aaa') values ('2020-09-04 16:53:56.003',210,3);
sql insert into test11 using stest tags('test11','bbb') values ('2020-09-04 16:53:57.003',210,3);
sql insert into test12 using stest tags('test11','bbb') values ('2020-09-04 16:53:58.003',210,3);
sql insert into test21 using stest tags('test21','ccc') values ('2020-09-04 16:53:59.003',210,3);
sql insert into test22 using stest tags('test21','ccc') values ('2020-09-04 16:54:54.003',210,3);
sql select sum(size) from stest group by appname;
if $rows != 3 then
return -1
endi
if $data00 != 420 then
return -1
endi
if $data10 != 420 then
return -1
endi
if $data20 != 420 then
return -1
endi
if $data01 != @test1@ then
return -1
endi
if $data11 != @test11@ then
return -1
endi
if $data21 != @test21@ then
return -1
endi
sql select sum(size) from stest interval(1d) group by appname;
if $rows != 3 then
return -1
endi
#2020-09-04 00:00:00.000 | 420 | test1 |
#2020-09-04 00:00:00.000 | 420 | test11 |
#2020-09-04 00:00:00.000 | 420 | test21 |
if $data00 != @20-09-04 00:00:00.000@ then
return -1
endi
if $data10 != @20-09-04 00:00:00.000@ then
return -1
endi
if $data20 != @20-09-04 00:00:00.000@ then
return -1
endi
if $data01 != 420 then
print expect 420 , actual $data01
return -1
endi
if $data11 != 420 then
return -1
endi
if $data21 != 420 then
return -1
endi
if $data02 != @test1@ then
return -1
endi
if $data12 != @test11@ then
return -1
endi
if $data22 != @test21@ then
return -1
endi
print ===================>td-1477, one table has only one block occurs this bug.
sql select first(size),count(*),LAST(SIZE) from stest where tbname in ('test1', 'test2') interval(1d) group by tbname;
if $rows != 2 then
return -1
endi
if $data00 != @20-09-04 00:00:00.000@ then
return -1
endi
if $data01 != 210 then
return -1
endi
if $data02 != 1 then
return -1
endi
if $data03 != 210 then
return -1
endi
if $data04 != @test1@ then
return -1
endi
if $data10 != @20-09-04 00:00:00.000@ then
return -1
endi
if $data11 != 210 then
return -1
endi
if $data12 != 1 then
return -1
endi
if $data13 != 210 then
return -1
endi
if $data14 != @test2@ then
print expect test2 , actual: $data14
return -1
endi endi
\ No newline at end of file
...@@ -218,4 +218,10 @@ endi ...@@ -218,4 +218,10 @@ endi
if $data04 != 123.981000000 then if $data04 != 123.981000000 then
print expect 123.981000000, actual: $data04 print expect 123.981000000, actual: $data04
return -1 return -1
endi
sql create table tu(ts timestamp, k int)
sql select last_row(*) from tu
if $row != 0 then
return -1
endi endi
\ No newline at end of file
...@@ -4,6 +4,7 @@ system sh/stop_dnodes.sh ...@@ -4,6 +4,7 @@ system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/cfg.sh -n dnode1 -c walLevel -v 0
system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode1 -s start
sleep 3000 sleep 3000
......
...@@ -3,6 +3,7 @@ system sh/stop_dnodes.sh ...@@ -3,6 +3,7 @@ system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/cfg.sh -n dnode1 -c walLevel -v 0
system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode1 -s start
sleep 3000 sleep 3000
......
...@@ -2,6 +2,7 @@ system sh/stop_dnodes.sh ...@@ -2,6 +2,7 @@ system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/cfg.sh -n dnode1 -c walLevel -v 0
system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 4 system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 4
system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode1 -s start
sleep 3000 sleep 3000
......
...@@ -35,6 +35,16 @@ system sh/cfg.sh -n dnode6 -c wallevel -v 1 ...@@ -35,6 +35,16 @@ system sh/cfg.sh -n dnode6 -c wallevel -v 1
system sh/cfg.sh -n dnode7 -c wallevel -v 1 system sh/cfg.sh -n dnode7 -c wallevel -v 1
system sh/cfg.sh -n dnode8 -c wallevel -v 1 system sh/cfg.sh -n dnode8 -c wallevel -v 1
system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode5 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode6 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode7 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode8 -c maxTablesPerVnode -v 4
print ============== step1 print ============== step1
print ========= start dnode1 print ========= start dnode1
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode1 -s start
......
...@@ -35,6 +35,16 @@ system sh/cfg.sh -n dnode6 -c mnodeEqualVnodeNum -v 0 ...@@ -35,6 +35,16 @@ system sh/cfg.sh -n dnode6 -c mnodeEqualVnodeNum -v 0
system sh/cfg.sh -n dnode7 -c mnodeEqualVnodeNum -v 0 system sh/cfg.sh -n dnode7 -c mnodeEqualVnodeNum -v 0
system sh/cfg.sh -n dnode8 -c mnodeEqualVnodeNum -v 0 system sh/cfg.sh -n dnode8 -c mnodeEqualVnodeNum -v 0
system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode5 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode6 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode7 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode8 -c maxTablesPerVnode -v 4
print ============== step1 print ============== step1
print ========= start dnode1 print ========= start dnode1
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode1 -s start
......
...@@ -16,6 +16,11 @@ system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 ...@@ -16,6 +16,11 @@ system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3
system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3
system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4
print ========== step1 print ========== step1
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode1 -s start
sleep 3000 sleep 3000
......
...@@ -25,6 +25,11 @@ system sh/cfg.sh -n dnode2 -c wallevel -v 2 ...@@ -25,6 +25,11 @@ system sh/cfg.sh -n dnode2 -c wallevel -v 2
system sh/cfg.sh -n dnode3 -c wallevel -v 2 system sh/cfg.sh -n dnode3 -c wallevel -v 2
system sh/cfg.sh -n dnode4 -c wallevel -v 2 system sh/cfg.sh -n dnode4 -c wallevel -v 2
system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4
print ========== step1 print ========== step1
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode1 -s start
sql connect sql connect
......
...@@ -12,6 +12,12 @@ system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 ...@@ -12,6 +12,12 @@ system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode5 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode5 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode5 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode1 -c wallevel -v 1 system sh/cfg.sh -n dnode1 -c wallevel -v 1
system sh/cfg.sh -n dnode2 -c wallevel -v 1 system sh/cfg.sh -n dnode2 -c wallevel -v 1
system sh/cfg.sh -n dnode3 -c wallevel -v 1 system sh/cfg.sh -n dnode3 -c wallevel -v 1
......
...@@ -21,6 +21,13 @@ system sh/cfg.sh -n dnode4 -c wallevel -v 1 ...@@ -21,6 +21,13 @@ system sh/cfg.sh -n dnode4 -c wallevel -v 1
system sh/cfg.sh -n dnode5 -c wallevel -v 1 system sh/cfg.sh -n dnode5 -c wallevel -v 1
system sh/cfg.sh -n dnode6 -c wallevel -v 1 system sh/cfg.sh -n dnode6 -c wallevel -v 1
system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode5 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode6 -c maxTablesPerVnode -v 4
print ========== step1 print ========== step1
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode1 -s start
sql connect sql connect
......
...@@ -15,6 +15,11 @@ system sh/cfg.sh -n dnode2 -c wallevel -v 1 ...@@ -15,6 +15,11 @@ system sh/cfg.sh -n dnode2 -c wallevel -v 1
system sh/cfg.sh -n dnode3 -c wallevel -v 1 system sh/cfg.sh -n dnode3 -c wallevel -v 1
system sh/cfg.sh -n dnode4 -c wallevel -v 1 system sh/cfg.sh -n dnode4 -c wallevel -v 1
system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4
print ========== step1 print ========== step1
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode1 -s start
sql connect sql connect
......
...@@ -16,6 +16,13 @@ system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 ...@@ -16,6 +16,13 @@ system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode1 -c wallevel -v 1 system sh/cfg.sh -n dnode1 -c wallevel -v 1
system sh/cfg.sh -n dnode2 -c wallevel -v 1 system sh/cfg.sh -n dnode2 -c wallevel -v 1
system sh/cfg.sh -n dnode3 -c wallevel -v 1 system sh/cfg.sh -n dnode3 -c wallevel -v 1
......
...@@ -15,6 +15,11 @@ system sh/cfg.sh -n dnode2 -c wallevel -v 1 ...@@ -15,6 +15,11 @@ system sh/cfg.sh -n dnode2 -c wallevel -v 1
system sh/cfg.sh -n dnode3 -c wallevel -v 1 system sh/cfg.sh -n dnode3 -c wallevel -v 1
system sh/cfg.sh -n dnode4 -c wallevel -v 1 system sh/cfg.sh -n dnode4 -c wallevel -v 1
system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4
print ========== step1 print ========== step1
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode1 -s start
sleep 3000 sleep 3000
......
...@@ -15,6 +15,11 @@ system sh/cfg.sh -n dnode2 -c wallevel -v 2 ...@@ -15,6 +15,11 @@ system sh/cfg.sh -n dnode2 -c wallevel -v 2
system sh/cfg.sh -n dnode3 -c wallevel -v 2 system sh/cfg.sh -n dnode3 -c wallevel -v 2
system sh/cfg.sh -n dnode4 -c wallevel -v 2 system sh/cfg.sh -n dnode4 -c wallevel -v 2
system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4
print ========== step1 print ========== step1
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode1 -s start
sleep 3000 sleep 3000
......
...@@ -15,6 +15,11 @@ system sh/cfg.sh -n dnode2 -c wallevel -v 1 ...@@ -15,6 +15,11 @@ system sh/cfg.sh -n dnode2 -c wallevel -v 1
system sh/cfg.sh -n dnode3 -c wallevel -v 1 system sh/cfg.sh -n dnode3 -c wallevel -v 1
system sh/cfg.sh -n dnode4 -c wallevel -v 1 system sh/cfg.sh -n dnode4 -c wallevel -v 1
system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4
print ========== step1 print ========== step1
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode1 -s start
sql connect sql connect
......
...@@ -30,6 +30,11 @@ system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 ...@@ -30,6 +30,11 @@ system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3
system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册