提交 efdb7132 编写于 作者: T tickduan

Merge branch 'develop' into compress_float

...@@ -68,6 +68,8 @@ CMakeError.log ...@@ -68,6 +68,8 @@ CMakeError.log
*.o *.o
version.c version.c
taos.rc taos.rc
src/connector/jdbc/.classpath
src/connector/jdbc/.project
src/connector/jdbc/.settings/ src/connector/jdbc/.settings/
tests/comparisonTest/cassandra/cassandratest/.classpath tests/comparisonTest/cassandra/cassandratest/.classpath
tests/comparisonTest/cassandra/cassandratest/.project tests/comparisonTest/cassandra/cassandratest/.project
......
...@@ -185,9 +185,10 @@ cmake .. && cmake --build . ...@@ -185,9 +185,10 @@ cmake .. && cmake --build .
# 安装 # 安装
如果你不想安装,可以直接在shell中运行。生成完成后,安装 TDengine: 生成完成后,安装 TDengine(下文给出的指令以 Linux 为例,如果是在 Windows 下,那么对应的指令会是 `nmake install`):
```bash ```bash
make install sudo make install
``` ```
用户可以在[文件目录结构](https://www.taosdata.com/cn/documentation/administrator#directories)中了解更多在操作系统中生成的目录或文件。 用户可以在[文件目录结构](https://www.taosdata.com/cn/documentation/administrator#directories)中了解更多在操作系统中生成的目录或文件。
...@@ -195,7 +196,7 @@ make install ...@@ -195,7 +196,7 @@ make install
安装成功后,在终端中启动 TDengine 服务: 安装成功后,在终端中启动 TDengine 服务:
```bash ```bash
taosd sudo systemctl start taosd
``` ```
用户可以使用 TDengine Shell 来连接 TDengine 服务,在终端中,输入: 用户可以使用 TDengine Shell 来连接 TDengine 服务,在终端中,输入:
...@@ -208,7 +209,7 @@ taos ...@@ -208,7 +209,7 @@ taos
## 快速运行 ## 快速运行
TDengine 生成后,在终端执行以下命令 如果不希望以服务方式运行 TDengine,也可以在终端中直接运行它。也即在生成完成后,执行以下命令(在 Windows 下,生成的可执行文件会带有 .exe 后缀,例如会名为 taosd.exe )
```bash ```bash
./build/bin/taosd -c test/cfg ./build/bin/taosd -c test/cfg
......
...@@ -175,7 +175,7 @@ cmake .. && cmake --build . ...@@ -175,7 +175,7 @@ cmake .. && cmake --build .
# Installing # Installing
After building successfully, TDengine can be installed by: After building successfully, TDengine can be installed by: (On Windows platform, the following command should be `nmake install`)
```bash ```bash
sudo make install sudo make install
``` ```
...@@ -197,7 +197,7 @@ If TDengine shell connects the server successfully, welcome messages and version ...@@ -197,7 +197,7 @@ If TDengine shell connects the server successfully, welcome messages and version
## Quick Run ## Quick Run
If you don't want to run TDengine as a service, you can run it in current shell. For example, to quickly start a TDengine server after building, run the command below in terminal: If you don't want to run TDengine as a service, you can run it in current shell. For example, to quickly start a TDengine server after building, run the command below in terminal: (We take Linux as an example, command on Windows will be `taosd.exe`)
```bash ```bash
./build/bin/taosd -c test/cfg ./build/bin/taosd -c test/cfg
``` ```
......
...@@ -7,8 +7,9 @@ set -e ...@@ -7,8 +7,9 @@ set -e
cpuType=amd64 # [armv6l | arm64 | amd64 | 386] cpuType=amd64 # [armv6l | arm64 | amd64 | 386]
osType=linux # [linux | darwin | windows] osType=linux # [linux | darwin | windows]
version="" version=""
verType=stable # [stable, beta]
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:n:" arg while getopts "h:c:o:n:V:" arg
do do
case $arg in case $arg in
c) c)
...@@ -23,6 +24,10 @@ do ...@@ -23,6 +24,10 @@ do
#echo "version=$OPTARG" #echo "version=$OPTARG"
version=$(echo $OPTARG) version=$(echo $OPTARG)
;; ;;
V)
#echo "verType=$OPTARG"
verType=$(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
...@@ -55,6 +60,22 @@ cp alert alert.cfg install_driver.sh ./TDengine-alert/. ...@@ -55,6 +60,22 @@ cp alert alert.cfg install_driver.sh ./TDengine-alert/.
cp ../../../debug/build/lib/libtaos.so.${version} ./TDengine-alert/driver/. cp ../../../debug/build/lib/libtaos.so.${version} ./TDengine-alert/driver/.
chmod 777 ./TDengine-alert/install_driver.sh chmod 777 ./TDengine-alert/install_driver.sh
tar -I 'gzip -9' -cf ${startdir}/TDengine-alert-${version}-${osType^}-${archMap[${cpuType}]}.tar.gz TDengine-alert/ tar -I 'gzip -9' -cf ${scriptdir}/TDengine-alert-${version}-${osType^}-${archMap[${cpuType}]}.tar.gz TDengine-alert/
rm -rf ./TDengine-alert rm -rf ./TDengine-alert
# mv package to comminuty/release/
pkg_name=TDengine-alert-${version}-${osType^}-${archMap[${cpuType}]}
if [ "$verType" == "beta" ]; then
pkg_name=TDengine-alert-${version}-${verType}-${osType^}-${archMap[${cpuType}]}
elif [ "$verType" == "stable" ]; then
pkg_name=${pkg_name}
else
echo "unknow verType, nor stabel or beta"
exit 1
fi
cd ${scriptdir}/../release/
mv ${scriptdir}/TDengine-alert-${version}-${osType^}-${archMap[${cpuType}]}.tar.gz ${pkg_name}.tar.gz
...@@ -4,7 +4,7 @@ PROJECT(TDengine) ...@@ -4,7 +4,7 @@ PROJECT(TDengine)
IF (DEFINED VERNUMBER) IF (DEFINED VERNUMBER)
SET(TD_VER_NUMBER ${VERNUMBER}) SET(TD_VER_NUMBER ${VERNUMBER})
ELSE () ELSE ()
SET(TD_VER_NUMBER "2.1.3.0") SET(TD_VER_NUMBER "2.1.4.1")
ENDIF () ENDIF ()
IF (DEFINED VERCOMPATIBLE) IF (DEFINED VERCOMPATIBLE)
......
...@@ -123,8 +123,8 @@ taosd -C ...@@ -123,8 +123,8 @@ taosd -C
- minRows:文件块中记录的最小条数。单位为条,默认值:100。 - minRows:文件块中记录的最小条数。单位为条,默认值:100。
- maxRows:文件块中记录的最大条数。单位为条,默认值:4096。 - maxRows:文件块中记录的最大条数。单位为条,默认值:4096。
- comp:文件压缩标志位。0:关闭;1:一阶段压缩;2:两阶段压缩。默认值:2。(可通过 alter database 修改) - comp:文件压缩标志位。0:关闭;1:一阶段压缩;2:两阶段压缩。默认值:2。(可通过 alter database 修改)
- wal:WAL级别。1:写wal,但不执行fsync;2:写wal, 而且执行fsync。默认值:1。(在 taos.cfg 中参数名需要写作 walLevel)(可通过 alter database 修改) - wal:WAL级别。1:写wal,但不执行fsync;2:写wal, 而且执行fsync。默认值:1。(在 taos.cfg 中参数名需要写作 walLevel)
- fsync:当wal设置为2时,执行fsync的周期。设置为0,表示每次写入,立即执行fsync。单位为毫秒,默认值:3000。(可通过 alter database 修改) - fsync:当wal设置为2时,执行fsync的周期。设置为0,表示每次写入,立即执行fsync。单位为毫秒,默认值:3000。
- cache:内存块的大小。单位为兆字节(MB),默认值:16。 - cache:内存块的大小。单位为兆字节(MB),默认值:16。
- blocks:每个VNODE(TSDB)中有多少cache大小的内存块。因此一个VNODE的用的内存大小粗略为(cache * blocks)。单位为块,默认值:4。(可通过 alter database 修改) - blocks:每个VNODE(TSDB)中有多少cache大小的内存块。因此一个VNODE的用的内存大小粗略为(cache * blocks)。单位为块,默认值:4。(可通过 alter database 修改)
- replica:副本个数。取值范围:1-3,单位为个,默认值:1。(可通过 alter database 修改) - replica:副本个数。取值范围:1-3,单位为个,默认值:1。(可通过 alter database 修改)
......
...@@ -129,16 +129,6 @@ TDengine 缺省的时间戳是毫秒精度,但通过在 CREATE DATABASE 时传 ...@@ -129,16 +129,6 @@ TDengine 缺省的时间戳是毫秒精度,但通过在 CREATE DATABASE 时传
CACHELAST 参数控制是否在内存中缓存子表的最近数据。缺省值为 0,取值范围 [0, 1, 2, 3]。其中 0 表示不缓存,1 表示缓存子表最近一行数据,2 表示缓存子表每一列的最近的非 NULL 值,3 表示同时打开缓存最近行和列功能。(从 2.0.11.0 版本开始支持参数值 [0, 1],从 2.1.2.0 版本开始支持参数值 [0, 1, 2, 3]。) CACHELAST 参数控制是否在内存中缓存子表的最近数据。缺省值为 0,取值范围 [0, 1, 2, 3]。其中 0 表示不缓存,1 表示缓存子表最近一行数据,2 表示缓存子表每一列的最近的非 NULL 值,3 表示同时打开缓存最近行和列功能。(从 2.0.11.0 版本开始支持参数值 [0, 1],从 2.1.2.0 版本开始支持参数值 [0, 1, 2, 3]。)
说明:缓存最近行,将显著改善 LAST_ROW 函数的性能表现;缓存每列的最近非 NULL 值,将显著改善无特殊影响(WHERE、ORDER BY、GROUP BY、INTERVAL)下的 LAST 函数的性能表现。 说明:缓存最近行,将显著改善 LAST_ROW 函数的性能表现;缓存每列的最近非 NULL 值,将显著改善无特殊影响(WHERE、ORDER BY、GROUP BY、INTERVAL)下的 LAST 函数的性能表现。
```mysql
ALTER DATABASE db_name WAL 1;
```
WAL 参数控制 WAL 日志的落盘方式。缺省值为 1,取值范围为 [1, 2]。1 表示写 WAL,但不执行 fsync;2 表示写 WAL,而且执行 fsync。
```mysql
ALTER DATABASE db_name FSYNC 3000;
```
FSYNC 参数控制执行 fsync 操作的周期。缺省值为 3000,单位是毫秒,取值范围为 [0, 180000]。如果设置为 0,表示每次写入,立即执行 fsync。该设置项主要用于调节 WAL 参数设为 2 时的系统行为。
**Tips**: 以上所有参数修改后都可以用show databases来确认是否修改成功。另外,从 2.1.3.0 版本开始,修改这些参数后无需重启服务器即可生效。 **Tips**: 以上所有参数修改后都可以用show databases来确认是否修改成功。另外,从 2.1.3.0 版本开始,修改这些参数后无需重启服务器即可生效。
- **显示系统所有数据库** - **显示系统所有数据库**
...@@ -372,77 +362,82 @@ TDengine 缺省的时间戳是毫秒精度,但通过在 CREATE DATABASE 时传 ...@@ -372,77 +362,82 @@ TDengine 缺省的时间戳是毫秒精度,但通过在 CREATE DATABASE 时传
## <a class="anchor" id="insert"></a>数据写入 ## <a class="anchor" id="insert"></a>数据写入
- **插入一条记录** ### 写入语法:
```mysql
INSERT INTO tb_name VALUES (field_value, ...);
```
向表tb_name中插入一条记录。
- **插入一条记录,数据对应到指定的列** ```mysql
```mysql INSERT INTO
INSERT INTO tb_name (field1_name, ...) VALUES (field1_value1, ...); tb_name
``` [USING stb_name [(tag1_name, ...)] TAGS (tag1_value, ...)]
向表tb_name中插入一条记录,数据对应到指定的列。SQL语句中没有出现的列,数据库将自动填充为NULL。主键(时间戳)不能为NULL。 [(field1_name, ...)]
VALUES (field1_value, ...) [(field1_value2, ...) ...] | FILE csv_file_path
[tb2_name
[USING stb_name [(tag1_name, ...)] TAGS (tag1_value, ...)]
[(field1_name, ...)]
VALUES (field1_value, ...) [(field1_value2, ...) ...] | FILE csv_file_path
...];
```
### 详细描述及示例:
- **插入多条记录** - **插入一条或多条记录**
指定已经创建好的数据子表的表名,并通过 VALUES 关键字提供一行或多行数据,即可向数据库写入这些数据。例如,执行如下语句可以写入一行记录:
```mysql ```mysql
INSERT INTO tb_name VALUES (field1_value1, ...) (field1_value2, ...) ...; INSERT INTO d1001 VALUES (NOW, 10.2, 219, 0.32);
``` ```
向表tb_name中插入多条记录。 或者,可以通过如下语句写入两行记录:
**注意**:在使用“插入多条记录”方式写入数据时,不能把第一列的时间戳取值都设为now,否则会导致语句中的多条记录使用相同的时间戳,于是就可能出现相互覆盖以致这些数据行无法全部被正确保存。
- **按指定的列插入多条记录**
```mysql ```mysql
INSERT INTO tb_name (field1_name, ...) VALUES (field1_value1, ...) (field1_value2, ...) ...; INSERT INTO d1001 VALUES ('2021-07-13 14:06:32.272', 10.2, 219, 0.32) (1626164208000, 10.15, 217, 0.33);
``` ```
向表tb_name中按指定的列插入多条记录。 **注意:**
1)在第二个例子中,两行记录的首列时间戳使用了不同格式的写法。其中字符串格式的时间戳写法不受所在 DATABASE 的时间精度设置影响;而长整形格式的时间戳写法会受到所在 DATABASE 的时间精度设置影响——例子中的时间戳在毫秒精度下可以写作 1626164208000,而如果是在微秒精度设置下就需要写为 1626164208000000。
2)在使用“插入多条记录”方式写入数据时,不能把第一列的时间戳取值都设为 NOW,否则会导致语句中的多条记录使用相同的时间戳,于是就可能出现相互覆盖以致这些数据行无法全部被正确保存。其原因在于,NOW 函数在执行中会被解析为所在 SQL 语句的实际执行时间,出现在同一语句中的多个 NOW 标记也就会被替换为完全相同的时间戳取值。
3)允许插入的最老记录的时间戳,是相对于当前服务器时间,减去配置的 keep 值(数据保留的天数);允许插入的最新记录的时间戳,是相对于当前服务器时间,加上配置的 days 值(数据文件存储数据的时间跨度,单位为天)。keep 和 days 都是可以在创建数据库时指定的,缺省值分别是 3650 天和 10 天。
- **向多个表插入多条记录** - **插入记录,数据对应到指定的列**
向数据子表中插入记录时,无论插入一行还是多行,都可以让数据对应到指定的列。对于 SQL 语句中没有出现的列,数据库将自动填充为 NULL。主键(时间戳)不能为 NULL。例如:
```mysql ```mysql
INSERT INTO tb1_name VALUES (field1_value1, ...) (field1_value2, ...) ... INSERT INTO d1001 (ts, current, phase) VALUES ('2021-07-13 14:06:33.196', 10.27, 0.31);
tb2_name VALUES (field1_value1, ...) (field1_value2, ...) ...;
``` ```
同时向表tb1_name和tb2_name中分别插入多条记录 **说明:**如果不指定列,也即使用全列模式——那么在 VALUES 部分提供的数据,必须为数据表的每个列都显式地提供数据。全列模式写入速度会远快于指定列,因此建议尽可能采用全列写入方式,此时空列可以填入 NULL
- **同时向多个表按列插入多条记录** - **向多个表插入记录**
可以在一条语句中,分别向多个表插入一条或多条记录,并且也可以在插入过程中指定列。例如:
```mysql ```mysql
INSERT INTO tb1_name (tb1_field1_name, ...) VALUES (field1_value1, ...) (field1_value2, ...) ... INSERT INTO d1001 VALUES ('2021-07-13 14:06:34.630', 10.2, 219, 0.32) ('2021-07-13 14:06:35.779', 10.15, 217, 0.33)
tb2_name (tb2_field1_name, ...) VALUES (field1_value1, ...) (field1_value2, ...) ...; d1002 (ts, current, phase) VALUES ('2021-07-13 14:06:34.255', 10.27, 0.31);
``` ```
同时向表tb1_name和tb2_name中按列分别插入多条记录。
注意:
1) 如果时间戳为now,系统将自动使用客户端当前时间作为该记录的时间戳;
2) 允许插入的最老记录的时间戳,是相对于当前服务器时间,减去配置的keep值(数据保留的天数),允许插入的最新记录的时间戳,是相对于当前服务器时间,加上配置的days值(数据文件存储数据的时间跨度,单位为天)。keep和days都是可以在创建数据库时指定的,缺省值分别是3650天和10天。
- <a class="anchor" id="auto_create_table"></a>**插入记录时自动建表** - <a class="anchor" id="auto_create_table"></a>**插入记录时自动建表**
如果用户在写数据时并不确定某个表是否存在,此时可以在写入数据时使用自动建表语法来创建不存在的表,若该表已存在则不会建立新表。自动建表时,要求必须以超级表为模板,并写明数据表的 TAGS 取值。例如:
```mysql ```mysql
INSERT INTO tb_name USING stb_name TAGS (tag_value1, ...) VALUES (field_value1, ...); INSERT INTO d21001 USING meters TAGS ('Beijing.Chaoyang', 2) VALUES ('2021-07-13 14:06:32.272', 10.2, 219, 0.32);
``` ```
如果用户在写数据时并不确定某个表是否存在,此时可以在写入数据时使用自动建表语法来创建不存在的表,若该表已存在则不会建立新表。自动建表时,要求必须以超级表为模板,并写明数据表的 TAGS 取值。 也可以在自动建表时,只是指定部分 TAGS 列的取值,未被指定的 TAGS 列将置为 NULL。例如:
- **插入记录时自动建表,并指定具体的 TAGS 列**
```mysql ```mysql
INSERT INTO tb_name USING stb_name (tag_name1, ...) TAGS (tag_value1, ...) VALUES (field_value1, ...); INSERT INTO d21001 USING meters (groupdId) TAGS (2) VALUES ('2021-07-13 14:06:33.196', 10.15, 217, 0.33);
``` ```
在自动建表时,可以只是指定部分 TAGS 列的取值,未被指定的 TAGS 列将取为空值。 自动建表语法也支持在一条语句中向多个表插入记录。例如:
- **同时向多个表按列插入多条记录,自动建表**
```mysql ```mysql
INSERT INTO tb1_name (tb1_field1_name, ...) [USING stb1_name TAGS (tag_value1, ...)] VALUES (field1_value1, ...) (field1_value2, ...) ... INSERT INTO d21001 USING meters TAGS ('Beijing.Chaoyang', 2) VALUES ('2021-07-13 14:06:34.630', 10.2, 219, 0.32) ('2021-07-13 14:06:35.779', 10.15, 217, 0.33)
tb2_name (tb2_field1_name, ...) [USING stb2_name TAGS (tag_value2, ...)] VALUES (field1_value1, ...) (field1_value2, ...) ...; d21002 USING meters (groupdId) TAGS (2) VALUES ('2021-07-13 14:06:34.255', 10.15, 217, 0.33)
d21003 USING meters (groupdId) TAGS (2) (ts, current, phase) VALUES ('2021-07-13 14:06:34.255', 10.27, 0.31);
```
**说明:**在 2.0.20.5 版本之前,在使用自动建表语法并指定列时,子表的列名必须紧跟在子表名称后面,而不能如例子里那样放在 TAGS 和 VALUES 之间。从 2.0.20.5 版本开始,两种写法都可以,但不能在一条 SQL 语句中混用,否则会报语法错误。
- **插入来自文件的数据记录**
除了使用 VALUES 关键字插入一行或多行数据外,也可以把要写入的数据放在 CSV 文件中(英文逗号分隔、英文单引号括住每个值)供 SQL 指令读取。其中 CSV 文件无需表头。例如,如果 /tmp/csvfile.csv 文件的内容为:
```
'2021-07-13 14:07:34.630', '10.2', '219', '0.32'
'2021-07-13 14:07:35.779', '10.15', '217', '0.33'
``` ```
以自动建表的方式,同时向表tb1_name和tb2_name中按列分别插入多条记录。 那么通过如下指令可以把这个文件中的数据写入子表中:
说明:`(tb1_field1_name, ...)`的部分可以省略掉,这样就是使用全列模式写入——也即在 VALUES 部分提供的数据,必须为数据表的每个列都显式地提供数据。全列写入速度会远快于指定列,因此建议尽可能采用全列写入方式,此时空列可以填入NULL。
从 2.0.20.5 版本开始,子表的列名可以不跟在子表名称后面,而是可以放在 TAGS 和 VALUES 之间,例如像下面这样写:
```mysql ```mysql
INSERT INTO tb1_name [USING stb1_name TAGS (tag_value1, ...)] (tb1_field1_name, ...) VALUES (field1_value1, ...) (field1_value2, ...) ...; INSERT INTO d1001 FILE '/tmp/csvfile.csv';
``` ```
注意:虽然两种写法都可以,但并不能在一条 SQL 语句中混用,否则会报语法错误。
**历史记录写入**:可使用IMPORT或者INSERT命令,IMPORT的语法,功能与INSERT完全一样。 **历史记录写入**:可使用IMPORT或者INSERT命令,IMPORT的语法,功能与INSERT完全一样。
说明:针对 insert 类型的 SQL 语句,我们采用的流式解析策略,在发现后面的错误之前,前面正确的部分SQL仍会执行。下面的sql中,insert语句是无效的,但是d1001仍会被创建。 **说明:**针对 insert 类型的 SQL 语句,我们采用的流式解析策略,在发现后面的错误之前,前面正确的部分 SQL 仍会执行。下面的 SQL 中,INSERT 语句是无效的,但是 d1001 仍会被创建。
```mysql ```mysql
taos> CREATE TABLE meters(ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS(location BINARY(30), groupId INT); taos> CREATE TABLE meters(ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS(location BINARY(30), groupId INT);
...@@ -1342,6 +1337,7 @@ SELECT function_list FROM stb_name ...@@ -1342,6 +1337,7 @@ SELECT function_list FROM stb_name
- 在聚合查询中,function_list 位置允许使用聚合和选择函数,并要求每个函数仅输出单个结果(例如:COUNT、AVG、SUM、STDDEV、LEASTSQUARES、PERCENTILE、MIN、MAX、FIRST、LAST),而不能使用具有多行输出结果的函数(例如:TOP、BOTTOM、DIFF 以及四则运算)。 - 在聚合查询中,function_list 位置允许使用聚合和选择函数,并要求每个函数仅输出单个结果(例如:COUNT、AVG、SUM、STDDEV、LEASTSQUARES、PERCENTILE、MIN、MAX、FIRST、LAST),而不能使用具有多行输出结果的函数(例如:TOP、BOTTOM、DIFF 以及四则运算)。
- 查询过滤、聚合等操作按照每个切分窗口为独立的单位执行。聚合查询目前支持三种窗口的划分方式: - 查询过滤、聚合等操作按照每个切分窗口为独立的单位执行。聚合查询目前支持三种窗口的划分方式:
1. 时间窗口:聚合时间段的窗口宽度由关键词 INTERVAL 指定,最短时间间隔 10 毫秒(10a);并且支持偏移 offset(偏移必须小于间隔),也即时间窗口划分与“UTC 时刻 0”相比的偏移量。SLIDING 语句用于指定聚合时间段的前向增量,也即每次窗口向前滑动的时长。当 SLIDING 与 INTERVAL 取值相等的时候,滑动窗口即为翻转窗口。 1. 时间窗口:聚合时间段的窗口宽度由关键词 INTERVAL 指定,最短时间间隔 10 毫秒(10a);并且支持偏移 offset(偏移必须小于间隔),也即时间窗口划分与“UTC 时刻 0”相比的偏移量。SLIDING 语句用于指定聚合时间段的前向增量,也即每次窗口向前滑动的时长。当 SLIDING 与 INTERVAL 取值相等的时候,滑动窗口即为翻转窗口。
* 从 2.1.5.0 版本开始,INTERVAL 语句允许的最短时间间隔调整为 1 微秒(1u),当然如果所查询的 DATABASE 的时间精度设置为毫秒级,那么允许的最短时间间隔为 1 毫秒(1a)。
2. 状态窗口:使用整数(布尔值)或字符串来标识产生记录时设备的状态量,产生的记录如果具有相同的状态量取值则归属于同一个状态窗口,数值改变后该窗口关闭。状态量所对应的列作为 STATE_WINDOW 语句的参数来指定。 2. 状态窗口:使用整数(布尔值)或字符串来标识产生记录时设备的状态量,产生的记录如果具有相同的状态量取值则归属于同一个状态窗口,数值改变后该窗口关闭。状态量所对应的列作为 STATE_WINDOW 语句的参数来指定。
3. 会话窗口:时间戳所在的列由 SESSION 语句的 ts_col 参数指定,会话窗口根据相邻两条记录的时间戳差值来确定是否属于同一个会话——如果时间戳差异在 tol_val 以内,则认为记录仍属于同一个窗口;如果时间变化超过 tol_val,则自动开启下一个窗口。 3. 会话窗口:时间戳所在的列由 SESSION 语句的 ts_col 参数指定,会话窗口根据相邻两条记录的时间戳差值来确定是否属于同一个会话——如果时间戳差异在 tol_val 以内,则认为记录仍属于同一个窗口;如果时间变化超过 tol_val,则自动开启下一个窗口。
- WHERE 语句可以指定查询的起止时间和其他过滤条件。 - WHERE 语句可以指定查询的起止时间和其他过滤条件。
......
...@@ -149,6 +149,8 @@ keepColumnName 1 ...@@ -149,6 +149,8 @@ keepColumnName 1
# system time zone # system time zone
# timezone Asia/Shanghai (CST, +0800) # timezone Asia/Shanghai (CST, +0800)
# system time zone (for windows 10)
# timezone UTC-8
# system locale # system locale
# locale en_US.UTF-8 # locale en_US.UTF-8
......
...@@ -123,7 +123,7 @@ else ...@@ -123,7 +123,7 @@ else
fi fi
if [ "$verType" == "beta" ]; then if [ "$verType" == "beta" ]; then
debname=${debname}-${verType}".deb" debname="TDengine-server-"${tdengine_ver}-${verType}-${osType}-${cpuType}".deb"
elif [ "$verType" == "stable" ]; then elif [ "$verType" == "stable" ]; then
debname=${debname}".deb" debname=${debname}".deb"
else else
...@@ -131,6 +131,8 @@ else ...@@ -131,6 +131,8 @@ else
exit 1 exit 1
fi fi
# make deb package # make deb package
dpkg -b ${pkg_dir} $debname dpkg -b ${pkg_dir} $debname
echo "make deb package success!" echo "make deb package success!"
......
...@@ -5,22 +5,28 @@ set -e ...@@ -5,22 +5,28 @@ set -e
# dockerbuild.sh # dockerbuild.sh
# -n [version number] # -n [version number]
# -p [xxxx] # -p [xxxx]
# -V [stable | beta]
# set parameters by default value # set parameters by default value
verNumber="" version=""
passWord="" passWord=""
verType=""
while getopts "hn:p:" arg while getopts "hn:p:V:" arg
do do
case $arg in case $arg in
n) n)
#echo "verNumber=$OPTARG" #echo "version=$OPTARG"
verNumber=$(echo $OPTARG) version=$(echo $OPTARG)
;; ;;
p) p)
#echo "passWord=$OPTARG" #echo "passWord=$OPTARG"
passWord=$(echo $OPTARG) passWord=$(echo $OPTARG)
;; ;;
V)
#echo "verType=$OPTARG"
verType=$(echo $OPTARG)
;;
h) h)
echo "Usage: `basename $0` -n [version number] " echo "Usage: `basename $0` -n [version number] "
echo " -p [password for docker hub] " echo " -p [password for docker hub] "
...@@ -33,13 +39,34 @@ do ...@@ -33,13 +39,34 @@ do
esac esac
done done
echo "verNumber=${verNumber}" echo "version=${version}"
#docker manifest rm tdengine/tdengine
#docker manifest rm tdengine/tdengine:${version}
if [ "$verType" == "beta" ]; then
docker manifest create -a tdengine/tdengine-beta:${version} tdengine/tdengine-amd64-beta:${version} tdengine/tdengine-aarch64-beta:${version} tdengine/tdengine-aarch32-beta:${version}
docker manifest create -a tdengine/tdengine-beta:latest tdengine/tdengine-amd64-beta:latest tdengine/tdengine-aarch64-beta:latest tdengine/tdengine-aarch32-beta:latest
docker login -u tdengine -p ${passWord} #replace the docker registry username and password
docker manifest push tdengine/tdengine-beta:latest
docker manifest push tdengine/tdengine-beta:${version}
elif [ "$verType" == "stable" ]; then
docker manifest create -a tdengine/tdengine:${version} tdengine/tdengine-amd64:${version} tdengine/tdengine-aarch64:${version} tdengine/tdengine-aarch32:${version}
docker manifest create -a tdengine/tdengine:latest tdengine/tdengine-amd64:latest tdengine/tdengine-aarch64:latest tdengine/tdengine-aarch32:latest
docker login -u tdengine -p ${passWord} #replace the docker registry username and password
docker manifest push tdengine/tdengine:latest
docker manifest push tdengine/tdengine:${version}
else
echo "unknow verType, nor stabel or beta"
exit 1
fi
#docker manifest create -a tdengine/tdengine:${verNumber} tdengine/tdengine-amd64:${verNumber} tdengine/tdengine-aarch64:${verNumber} tdengine/tdengine-aarch32:${verNumber} # docker manifest create -a tdengine/${dockername}:${version} tdengine/tdengine-amd64:${version} tdengine/tdengine-aarch64:${version} tdengine/tdengine-aarch32:${version}
docker manifest create -a tdengine/tdengine:latest tdengine/tdengine-amd64:latest tdengine/tdengine-aarch64:latest tdengine/tdengine-aarch32:latest # docker manifest create -a tdengine/${dockername}:latest tdengine/tdengine-amd64:latest tdengine/tdengine-aarch64:latest tdengine/tdengine-aarch32:latest
docker login -u tdengine -p ${passWord} #replace the docker registry username and password # docker login -u tdengine -p ${passWord} #replace the docker registry username and password
docker manifest push tdengine/tdengine:latest # docker manifest push tdengine/tdengine:latest
# how set latest version ??? # # how set latest version ???
#!/bin/bash #!/bin/bash
#
set -e set -e
#set -x #set -x
# dockerbuild.sh # dockerbuild.sh
# -c [aarch32 | aarch64 | amd64 | x86 | mips64 ...] # -c [aarch32 | aarch64 | amd64 | x86 | mips64 ...]
# -f [pkg file]
# -n [version number] # -n [version number]
# -p [password for docker hub] # -p [password for docker hub]
# -V [stable | beta]
# -f [pkg file]
# set parameters by default value # set parameters by default value
cpuType=amd64 cpuType=""
verNumber="" version=""
passWord="" passWord=""
pkgFile="" pkgFile=""
verType="stable"
while getopts "hc:n:p:f:" arg while getopts "hc:n:p:f:V:" arg
do do
case $arg in case $arg in
c) c)
...@@ -22,8 +26,8 @@ do ...@@ -22,8 +26,8 @@ do
cpuType=$(echo $OPTARG) cpuType=$(echo $OPTARG)
;; ;;
n) n)
#echo "verNumber=$OPTARG" #echo "version=$OPTARG"
verNumber=$(echo $OPTARG) version=$(echo $OPTARG)
;; ;;
p) p)
#echo "passWord=$OPTARG" #echo "passWord=$OPTARG"
...@@ -33,11 +37,17 @@ do ...@@ -33,11 +37,17 @@ do
#echo "pkgFile=$OPTARG" #echo "pkgFile=$OPTARG"
pkgFile=$(echo $OPTARG) pkgFile=$(echo $OPTARG)
;; ;;
V)
#echo "verType=$OPTARG"
verType=$(echo $OPTARG)
;;
h) h)
echo "Usage: `basename $0` -c [aarch32 | aarch64 | amd64 | x86 | mips64 ...] " echo "Usage: `basename $0` -c [aarch32 | aarch64 | amd64 | x86 | mips64 ...] "
echo " -f [pkg file] "
echo " -n [version number] " echo " -n [version number] "
echo " -p [password for docker hub] " echo " -p [password for docker hub] "
echo " -V [stable | beta] "
echo " -f [pkg file] "
exit 0 exit 0
;; ;;
?) #unknow option ?) #unknow option
...@@ -47,17 +57,44 @@ do ...@@ -47,17 +57,44 @@ do
esac esac
done done
echo "cpuType=${cpuType} verNumber=${verNumber} pkgFile=${pkgFile} " # if [ "$verType" == "beta" ]; then
# pkgFile=TDengine-server-${version}-Linux-${cpuType}-${verType}.tar.gz
# elif [ "$verType" == "stable" ]; then
# pkgFile=TDengine-server-${version}-Linux-${cpuType}.tar.gz
# else
# echo "unknow verType, nor stabel or beta"
# exit 1
if [ "$verType" == "beta" ]; then
dockername=${cpuType}-${verType}
elif [ "$verType" == "stable" ]; then
dockername=${cpuType}
else
echo "unknow verType, nor stabel or beta"
exit 1
fi
echo "cpuType=${cpuType} version=${version} pkgFile=${pkgFile} verType=${verType} "
echo "$(pwd)" echo "$(pwd)"
echo "====NOTES: ${pkgFile} must be in the same directory as dockerbuild.sh====" echo "====NOTES: ${pkgFile} must be in the same directory as dockerbuild.sh===="
scriptDir=$(dirname $(readlink -f $0))
comunityArchiveDir=/nas/TDengine/v$version/community # community version’package directory
cd ${scriptDir}
cp -f ${comunityArchiveDir}/${pkgFile} .
dirName=${pkgFile%-Linux*} dirName=${pkgFile%-Linux*}
#echo "dirName=${dirName}" echo "dirName=${dirName}"
docker build --rm -f "Dockerfile" -t tdengine/tdengine-${cpuType}:${verNumber} "." --build-arg pkgFile=${pkgFile} --build-arg dirName=${dirName}
docker build --rm -f "Dockerfile" -t tdengine/tdengine-${dockername}:${version} "." --build-arg pkgFile=${pkgFile} --build-arg dirName=${dirName}
docker login -u tdengine -p ${passWord} #replace the docker registry username and password docker login -u tdengine -p ${passWord} #replace the docker registry username and password
docker push tdengine/tdengine-${cpuType}:${verNumber} docker push tdengine/tdengine-${dockername}:${version}
# set this version to latest version # set this version to latest version
docker tag tdengine/tdengine-${cpuType}:${verNumber} tdengine/tdengine-${cpuType}:latest docker tag tdengine/tdengine-${dockername}:${version} tdengine/tdengine-${dockername}:latest
docker push tdengine/tdengine-${cpuType}:latest docker push tdengine/tdengine-${dockername}:latest
rm -f ${pkgFile}
\ No newline at end of file
...@@ -73,7 +73,7 @@ else ...@@ -73,7 +73,7 @@ else
fi fi
if [ "$verType" == "beta" ]; then if [ "$verType" == "beta" ]; then
rpmname=${rpmname}-${verType}".rpm" rpmname="TDengine-server-"${tdengine_ver}-${verType}-${osType}-${cpuType}".rpm"
elif [ "$verType" == "stable" ]; then elif [ "$verType" == "stable" ]; then
rpmname=${rpmname}".rpm" rpmname=${rpmname}".rpm"
else else
......
...@@ -47,17 +47,20 @@ mkdir -p ${install_dir}/init.d && cp ${init_file_tarbitrator_rpm} ${install_dir} ...@@ -47,17 +47,20 @@ mkdir -p ${install_dir}/init.d && cp ${init_file_tarbitrator_rpm} ${install_dir}
cd ${release_dir} cd ${release_dir}
if [ "$verMode" == "cluster" ]; then # install_dir has been distinguishes cluster from edege, so comments this code
pkg_name=${install_dir}-${osType}-${cpuType} pkg_name=${install_dir}-${osType}-${cpuType}
elif [ "$verMode" == "edge" ]; then
pkg_name=${install_dir}-${osType}-${cpuType} # if [ "$verMode" == "cluster" ]; then
else # pkg_name=${install_dir}-${osType}-${cpuType}
echo "unknow verMode, nor cluster or edge" # elif [ "$verMode" == "edge" ]; then
exit 1 # pkg_name=${install_dir}-${osType}-${cpuType}
fi # else
# echo "unknow verMode, nor cluster or edge"
# exit 1
# fi
if [ "$verType" == "beta" ]; then if [ "$verType" == "beta" ]; then
pkg_name=${pkg_name}-${verType} pkg_name=${install_dir}-${verType}-${osType}-${cpuType}
elif [ "$verType" == "stable" ]; then elif [ "$verType" == "stable" ]; then
pkg_name=${pkg_name} pkg_name=${pkg_name}
else else
...@@ -65,6 +68,7 @@ else ...@@ -65,6 +68,7 @@ else
exit 1 exit 1
fi fi
tar -zcv -f "$(basename ${pkg_name}).tar.gz" $(basename ${install_dir}) --remove-files || : tar -zcv -f "$(basename ${pkg_name}).tar.gz" $(basename ${install_dir}) --remove-files || :
exitcode=$? exitcode=$?
if [ "$exitcode" != "0" ]; then if [ "$exitcode" != "0" ]; then
......
...@@ -69,6 +69,39 @@ mkdir -p ${install_dir}/inc && cp ${header_files} ${install_dir}/inc ...@@ -69,6 +69,39 @@ mkdir -p ${install_dir}/inc && cp ${header_files} ${install_dir}/inc
mkdir -p ${install_dir}/cfg && cp ${cfg_dir}/taos.cfg ${install_dir}/cfg/taos.cfg mkdir -p ${install_dir}/cfg && cp ${cfg_dir}/taos.cfg ${install_dir}/cfg/taos.cfg
mkdir -p ${install_dir}/bin && cp ${bin_files} ${install_dir}/bin && chmod a+x ${install_dir}/bin/* mkdir -p ${install_dir}/bin && cp ${bin_files} ${install_dir}/bin && chmod a+x ${install_dir}/bin/*
if [ -f ${build_dir}/bin/jemalloc-config ]; then
mkdir -p ${install_dir}/jemalloc/{bin,lib,lib/pkgconfig,include/jemalloc,share/doc/jemalloc,share/man/man3}
cp ${build_dir}/bin/jemalloc-config ${install_dir}/jemalloc/bin
if [ -f ${build_dir}/bin/jemalloc.sh ]; then
cp ${build_dir}/bin/jemalloc.sh ${install_dir}/jemalloc/bin
fi
if [ -f ${build_dir}/bin/jeprof ]; then
cp ${build_dir}/bin/jeprof ${install_dir}/jemalloc/bin
fi
if [ -f ${build_dir}/include/jemalloc/jemalloc.h ]; then
cp ${build_dir}/include/jemalloc/jemalloc.h ${install_dir}/jemalloc/include/jemalloc
fi
if [ -f ${build_dir}/lib/libjemalloc.so.2 ]; then
cp ${build_dir}/lib/libjemalloc.so.2 ${install_dir}/jemalloc/lib
ln -sf libjemalloc.so.2 ${install_dir}/jemalloc/lib/libjemalloc.so
fi
if [ -f ${build_dir}/lib/libjemalloc.a ]; then
cp ${build_dir}/lib/libjemalloc.a ${install_dir}/jemalloc/lib
fi
if [ -f ${build_dir}/lib/libjemalloc_pic.a ]; then
cp ${build_dir}/lib/libjemalloc_pic.a ${install_dir}/jemalloc/lib
fi
if [ -f ${build_dir}/lib/pkgconfig/jemalloc.pc ]; then
cp ${build_dir}/lib/pkgconfig/jemalloc.pc ${install_dir}/jemalloc/lib/pkgconfig
fi
if [ -f ${build_dir}/share/doc/jemalloc/jemalloc.html ]; then
cp ${build_dir}/share/doc/jemalloc/jemalloc.html ${install_dir}/jemalloc/share/doc/jemalloc
fi
if [ -f ${build_dir}/share/man/man3/jemalloc.3 ]; then
cp ${build_dir}/share/man/man3/jemalloc.3 ${install_dir}/jemalloc/share/man/man3
fi
fi
cd ${install_dir} cd ${install_dir}
if [ "$osType" != "Darwin" ]; then if [ "$osType" != "Darwin" ]; then
...@@ -137,28 +170,31 @@ fi ...@@ -137,28 +170,31 @@ fi
cd ${release_dir} cd ${release_dir}
if [ "$verMode" == "cluster" ]; then # install_dir has been distinguishes cluster from edege, so comments this code
pkg_name=${install_dir}-${osType}-${cpuType} pkg_name=${install_dir}-${osType}-${cpuType}
elif [ "$verMode" == "edge" ]; then
pkg_name=${install_dir}-${osType}-${cpuType}
else
echo "unknow verMode, nor cluster or edge"
exit 1
fi
if [ "$pagMode" == "lite" ]; then # if [ "$verMode" == "cluster" ]; then
pkg_name=${pkg_name}-Lite # pkg_name=${install_dir}-${osType}-${cpuType}
fi # elif [ "$verMode" == "edge" ]; then
# pkg_name=${install_dir}-${osType}-${cpuType}
# else
# echo "unknow verMode, nor cluster or edge"
# exit 1
# fi
if [ "$verType" == "beta" ]; then if [ "$verType" == "beta" ]; then
pkg_name=${pkg_name}-${verType} pkg_name=${install_dir}-${verType}-${osType}-${cpuType}
elif [ "$verType" == "stable" ]; then elif [ "$verType" == "stable" ]; then
pkg_name=${pkg_name} pkg_name=${pkg_name}
else else
echo "unknow verType, nor stable or beta" echo "unknow verType, nor stabel or beta"
exit 1 exit 1
fi fi
if [ "$pagMode" == "lite" ]; then
pkg_name=${pkg_name}-Lite
fi
if [ "$osType" != "Darwin" ]; then if [ "$osType" != "Darwin" ]; then
tar -zcv -f "$(basename ${pkg_name}).tar.gz" $(basename ${install_dir}) --remove-files || : tar -zcv -f "$(basename ${pkg_name}).tar.gz" $(basename ${install_dir}) --remove-files || :
else else
......
...@@ -91,6 +91,39 @@ else ...@@ -91,6 +91,39 @@ else
fi fi
chmod a+x ${install_dir}/bin/* || : chmod a+x ${install_dir}/bin/* || :
if [ -f ${build_dir}/bin/jemalloc-config ]; then
mkdir -p ${install_dir}/jemalloc/{bin,lib,lib/pkgconfig,include/jemalloc,share/doc/jemalloc,share/man/man3}
cp ${build_dir}/bin/jemalloc-config ${install_dir}/jemalloc/bin
if [ -f ${build_dir}/bin/jemalloc.sh ]; then
cp ${build_dir}/bin/jemalloc.sh ${install_dir}/jemalloc/bin
fi
if [ -f ${build_dir}/bin/jeprof ]; then
cp ${build_dir}/bin/jeprof ${install_dir}/jemalloc/bin
fi
if [ -f ${build_dir}/include/jemalloc/jemalloc.h ]; then
cp ${build_dir}/include/jemalloc/jemalloc.h ${install_dir}/jemalloc/include/jemalloc
fi
if [ -f ${build_dir}/lib/libjemalloc.so.2 ]; then
cp ${build_dir}/lib/libjemalloc.so.2 ${install_dir}/jemalloc/lib
ln -sf libjemalloc.so.2 ${install_dir}/jemalloc/lib/libjemalloc.so
fi
if [ -f ${build_dir}/lib/libjemalloc.a ]; then
cp ${build_dir}/lib/libjemalloc.a ${install_dir}/jemalloc/lib
fi
if [ -f ${build_dir}/lib/libjemalloc_pic.a ]; then
cp ${build_dir}/lib/libjemalloc_pic.a ${install_dir}/jemalloc/lib
fi
if [ -f ${build_dir}/lib/pkgconfig/jemalloc.pc ]; then
cp ${build_dir}/lib/pkgconfig/jemalloc.pc ${install_dir}/jemalloc/lib/pkgconfig
fi
if [ -f ${build_dir}/share/doc/jemalloc/jemalloc.html ]; then
cp ${build_dir}/share/doc/jemalloc/jemalloc.html ${install_dir}/jemalloc/share/doc/jemalloc
fi
if [ -f ${build_dir}/share/man/man3/jemalloc.3 ]; then
cp ${build_dir}/share/man/man3/jemalloc.3 ${install_dir}/jemalloc/share/man/man3
fi
fi
cd ${install_dir} cd ${install_dir}
if [ "$osType" != "Darwin" ]; then if [ "$osType" != "Darwin" ]; then
......
...@@ -91,6 +91,39 @@ else ...@@ -91,6 +91,39 @@ else
fi fi
chmod a+x ${install_dir}/bin/* || : chmod a+x ${install_dir}/bin/* || :
if [ -f ${build_dir}/bin/jemalloc-config ]; then
mkdir -p ${install_dir}/jemalloc/{bin,lib,lib/pkgconfig,include/jemalloc,share/doc/jemalloc,share/man/man3}
cp ${build_dir}/bin/jemalloc-config ${install_dir}/jemalloc/bin
if [ -f ${build_dir}/bin/jemalloc.sh ]; then
cp ${build_dir}/bin/jemalloc.sh ${install_dir}/jemalloc/bin
fi
if [ -f ${build_dir}/bin/jeprof ]; then
cp ${build_dir}/bin/jeprof ${install_dir}/jemalloc/bin
fi
if [ -f ${build_dir}/include/jemalloc/jemalloc.h ]; then
cp ${build_dir}/include/jemalloc/jemalloc.h ${install_dir}/jemalloc/include/jemalloc
fi
if [ -f ${build_dir}/lib/libjemalloc.so.2 ]; then
cp ${build_dir}/lib/libjemalloc.so.2 ${install_dir}/jemalloc/lib
ln -sf libjemalloc.so.2 ${install_dir}/jemalloc/lib/libjemalloc.so
fi
if [ -f ${build_dir}/lib/libjemalloc.a ]; then
cp ${build_dir}/lib/libjemalloc.a ${install_dir}/jemalloc/lib
fi
if [ -f ${build_dir}/lib/libjemalloc_pic.a ]; then
cp ${build_dir}/lib/libjemalloc_pic.a ${install_dir}/jemalloc/lib
fi
if [ -f ${build_dir}/lib/pkgconfig/jemalloc.pc ]; then
cp ${build_dir}/lib/pkgconfig/jemalloc.pc ${install_dir}/jemalloc/lib/pkgconfig
fi
if [ -f ${build_dir}/share/doc/jemalloc/jemalloc.html ]; then
cp ${build_dir}/share/doc/jemalloc/jemalloc.html ${install_dir}/jemalloc/share/doc/jemalloc
fi
if [ -f ${build_dir}/share/man/man3/jemalloc.3 ]; then
cp ${build_dir}/share/man/man3/jemalloc.3 ${install_dir}/jemalloc/share/man/man3
fi
fi
cd ${install_dir} cd ${install_dir}
if [ "$osType" != "Darwin" ]; then if [ "$osType" != "Darwin" ]; then
......
...@@ -203,21 +203,20 @@ fi ...@@ -203,21 +203,20 @@ fi
cd ${release_dir} cd ${release_dir}
if [ "$verMode" == "cluster" ]; then # install_dir has been distinguishes cluster from edege, so comments this code
pkg_name=${install_dir}-${osType}-${cpuType} pkg_name=${install_dir}-${osType}-${cpuType}
elif [ "$verMode" == "edge" ]; then
pkg_name=${install_dir}-${osType}-${cpuType} # if [ "$verMode" == "cluster" ]; then
else # pkg_name=${install_dir}-${osType}-${cpuType}
echo "unknow verMode, nor cluster or edge" # elif [ "$verMode" == "edge" ]; then
exit 1 # pkg_name=${install_dir}-${osType}-${cpuType}
fi # else
# echo "unknow verMode, nor cluster or edge"
if [ "$pagMode" == "lite" ]; then # exit 1
pkg_name=${pkg_name}-Lite # fi
fi
if [ "$verType" == "beta" ]; then if [ "$verType" == "beta" ]; then
pkg_name=${pkg_name}-${verType} pkg_name=${install_dir}-${verType}-${osType}-${cpuType}
elif [ "$verType" == "stable" ]; then elif [ "$verType" == "stable" ]; then
pkg_name=${pkg_name} pkg_name=${pkg_name}
else else
...@@ -225,6 +224,10 @@ else ...@@ -225,6 +224,10 @@ else
exit 1 exit 1
fi fi
if [ "$pagMode" == "lite" ]; then
pkg_name=${pkg_name}-Lite
fi
tar -zcv -f "$(basename ${pkg_name}).tar.gz" $(basename ${install_dir}) --remove-files || : tar -zcv -f "$(basename ${pkg_name}).tar.gz" $(basename ${install_dir}) --remove-files || :
exitcode=$? exitcode=$?
if [ "$exitcode" != "0" ]; then if [ "$exitcode" != "0" ]; then
......
name: tdengine name: tdengine
base: core18 base: core18
version: '2.1.3.0' version: '2.1.4.1'
icon: snap/gui/t-dengine.svg icon: snap/gui/t-dengine.svg
summary: an open-source big data platform designed and optimized for IoT. summary: an open-source big data platform designed and optimized for IoT.
description: | description: |
...@@ -72,7 +72,7 @@ parts: ...@@ -72,7 +72,7 @@ parts:
- usr/bin/taosd - usr/bin/taosd
- usr/bin/taos - usr/bin/taos
- usr/bin/taosdemo - usr/bin/taosdemo
- usr/lib/libtaos.so.2.1.3.0 - usr/lib/libtaos.so.2.1.4.1
- usr/lib/libtaos.so.1 - usr/lib/libtaos.so.1
- usr/lib/libtaos.so - usr/lib/libtaos.so
......
...@@ -1129,6 +1129,7 @@ int tsParseInsertSql(SSqlObj *pSql) { ...@@ -1129,6 +1129,7 @@ int tsParseInsertSql(SSqlObj *pSql) {
SSqlCmd *pCmd = &pSql->cmd; SSqlCmd *pCmd = &pSql->cmd;
SInsertStatementParam* pInsertParam = &pCmd->insertParam; SInsertStatementParam* pInsertParam = &pCmd->insertParam;
pInsertParam->objectId = pSql->self;
char* str = pInsertParam->sql; char* str = pInsertParam->sql;
int32_t totalNum = 0; int32_t totalNum = 0;
......
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "os.h"
#include "osString.h"
#include "ttype.h"
#include "tmd5.h"
#include "tstrbuild.h"
#include "tname.h"
#include "hash.h"
#include "tskiplist.h"
#include "tscUtil.h"
#include "tsclient.h"
#include "tscLog.h"
#include "taos.h"
typedef struct {
char sTableName[TSDB_TABLE_NAME_LEN];
SHashObj* tagHash;
SHashObj* fieldHash;
SArray* tags; //SArray<SSchema>
SArray* fields; //SArray<SSchema>
uint8_t precision;
} SSmlSTableSchema;
typedef struct {
char* key;
uint8_t type;
int16_t length;
char* value;
//===================================
SSchema* schema;
} TAOS_SML_KV;
typedef struct {
char* stableName;
char* childTableName;
TAOS_SML_KV* tags;
int tagNum;
// first kv must be timestamp
TAOS_SML_KV* fields;
int fieldNum;
//================================
SSmlSTableSchema* schema;
} TAOS_SML_DATA_POINT;
//=================================================================================================
int compareSmlColKv(const void* p1, const void* p2) {
TAOS_SML_KV* kv1 = (TAOS_SML_KV*)p1;
TAOS_SML_KV* kv2 = (TAOS_SML_KV*)p2;
int kvLen1 = (int)strlen(kv1->key);
int kvLen2 = (int)strlen(kv2->key);
int res = strncasecmp(kv1->key, kv2->key, MIN(kvLen1, kvLen2));
if (res != 0) {
return res;
} else {
return kvLen1-kvLen2;
}
}
typedef enum {
SCHEMA_ACTION_CREATE_STABLE,
SCHEMA_ACTION_ADD_COLUMN,
SCHEMA_ACTION_ADD_TAG,
SCHEMA_ACTION_CHANGE_COLUMN_SIZE,
SCHEMA_ACTION_CHANGE_TAG_SIZE,
} ESchemaAction;
typedef struct {
char sTableName[TSDB_TABLE_NAME_LEN];
SArray* tags; //SArray<SSchema>
SArray* fields; //SArray<SSchema>
} SCreateSTableActionInfo;
typedef struct {
char sTableName[TSDB_TABLE_NAME_LEN];
SSchema* field;
} SAlterSTableActionInfo;
typedef struct {
ESchemaAction action;
union {
SCreateSTableActionInfo createSTable;
SAlterSTableActionInfo alterSTable;
};
} SSchemaAction;
static int32_t getFieldBytesFromSmlKv(TAOS_SML_KV* kv, int32_t* bytes) {
if (!IS_VAR_DATA_TYPE(kv->type)) {
*bytes = tDataTypes[kv->type].bytes;
} else {
if (kv->type == TSDB_DATA_TYPE_NCHAR) {
char* ucs = malloc(kv->length * TSDB_NCHAR_SIZE + 1);
int32_t bytesNeeded = 0;
bool succ = taosMbsToUcs4(kv->value, kv->length, ucs, kv->length * TSDB_NCHAR_SIZE, &bytesNeeded);
if (!succ) {
free(ucs);
tscError("convert nchar string to UCS4_LE failed:%s", kv->value);
return TSDB_CODE_TSC_INVALID_VALUE;
}
free(ucs);
*bytes = bytesNeeded + VARSTR_HEADER_SIZE;
} else if (kv->type == TSDB_DATA_TYPE_BINARY) {
*bytes = kv->length + VARSTR_HEADER_SIZE;
}
}
return 0;
}
static int32_t buildSmlKvSchema(TAOS_SML_KV* smlKv, SHashObj* hash, SArray* array) {
SSchema* pField = NULL;
SSchema** ppField = taosHashGet(hash, smlKv->key, strlen(smlKv->key));
int32_t code = 0;
if (ppField) {
pField = *ppField;
if (pField->type != smlKv->type) {
tscError("type mismatch. key %s, type %d. type before %d", smlKv->key, smlKv->type, pField->type);
return TSDB_CODE_TSC_INVALID_VALUE;
}
int32_t bytes = 0;
code = getFieldBytesFromSmlKv(smlKv, &bytes);
if (code != 0) {
return code;
}
pField->bytes = MAX(pField->bytes, bytes);
} else {
SSchema field = {0};
size_t tagKeyLen = strlen(smlKv->key);
strncpy(field.name, smlKv->key, tagKeyLen);
field.name[tagKeyLen] = '\0';
field.type = smlKv->type;
int32_t bytes = 0;
code = getFieldBytesFromSmlKv(smlKv, &bytes);
if (code != 0) {
return code;
}
field.bytes = bytes;
pField = taosArrayPush(array, &field);
taosHashPut(hash, field.name, tagKeyLen, &pField, POINTER_BYTES);
}
smlKv->schema = pField;
return 0;
}
static int32_t buildDataPointSchemas(TAOS_SML_DATA_POINT* points, int numPoint, SArray* stableSchemas) {
int32_t code = 0;
SHashObj* sname2shema = taosHashInit(32,
taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false);
for (int i = 0; i < numPoint; ++i) {
TAOS_SML_DATA_POINT* point = &points[i];
size_t stableNameLen = strlen(point->stableName);
SSmlSTableSchema** ppStableSchema = taosHashGet(sname2shema, point->stableName, stableNameLen);
SSmlSTableSchema* pStableSchema = NULL;
if (ppStableSchema) {
pStableSchema= *ppStableSchema;
} else {
SSmlSTableSchema schema;
strncpy(schema.sTableName, point->stableName, stableNameLen);
schema.sTableName[stableNameLen] = '\0';
schema.fields = taosArrayInit(64, sizeof(SSchema));
schema.tags = taosArrayInit(8, sizeof(SSchema));
schema.tagHash = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false);
schema.fieldHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false);
pStableSchema = taosArrayPush(stableSchemas, &schema);
taosHashPut(sname2shema, schema.sTableName, stableNameLen, &pStableSchema, POINTER_BYTES);
}
for (int j = 0; j < point->tagNum; ++j) {
TAOS_SML_KV* tagKv = point->tags + j;
code = buildSmlKvSchema(tagKv, pStableSchema->tagHash, pStableSchema->tags);
if (code != 0) {
tscError("build data point schema failed. point no.: %d, tag key: %s", i, tagKv->key);
return code;
}
}
for (int j = 0; j < point->fieldNum; ++j) {
TAOS_SML_KV* fieldKv = point->fields + j;
code = buildSmlKvSchema(fieldKv, pStableSchema->fieldHash, pStableSchema->fields);
if (code != 0) {
tscError("build data point schema failed. point no.: %d, tag key: %s", i, fieldKv->key);
return code;
}
}
point->schema = pStableSchema;
}
size_t numStables = taosArrayGetSize(stableSchemas);
for (int32_t i = 0; i < numStables; ++i) {
SSmlSTableSchema* schema = taosArrayGet(stableSchemas, i);
taosHashCleanup(schema->tagHash);
taosHashCleanup(schema->fieldHash);
}
taosHashCleanup(sname2shema);
tscDebug("build point schema succeed. num of super table: %zu", numStables);
for (int32_t i = 0; i < numStables; ++i) {
SSmlSTableSchema* schema = taosArrayGet(stableSchemas, i);
tscDebug("\ttable name: %s, tags number: %zu, fields number: %zu", schema->sTableName,
taosArrayGetSize(schema->tags), taosArrayGetSize(schema->fields));
}
return 0;
}
static int32_t generateSchemaAction(SSchema* pointColField, SHashObj* dbAttrHash, bool isTag, char sTableName[],
SSchemaAction* action, bool* actionNeeded) {
SSchema** ppDbAttr = taosHashGet(dbAttrHash, pointColField->name, strlen(pointColField->name));
if (ppDbAttr) {
SSchema* dbAttr = *ppDbAttr;
if (pointColField->type != dbAttr->type) {
tscError("point type and db type mismatch. key: %s. point type: %d, db type: %d", pointColField->name,
pointColField->type, dbAttr->type);
return TSDB_CODE_TSC_INVALID_VALUE;
}
if (IS_VAR_DATA_TYPE(pointColField->type) && (pointColField->bytes > dbAttr->bytes)) {
if (isTag) {
action->action = SCHEMA_ACTION_CHANGE_TAG_SIZE;
} else {
action->action = SCHEMA_ACTION_CHANGE_COLUMN_SIZE;
}
memset(&action->alterSTable, 0, sizeof(SAlterSTableActionInfo));
memcpy(action->alterSTable.sTableName, sTableName, TSDB_TABLE_NAME_LEN);
action->alterSTable.field = pointColField;
*actionNeeded = true;
}
} else {
if (isTag) {
action->action = SCHEMA_ACTION_ADD_TAG;
} else {
action->action = SCHEMA_ACTION_ADD_COLUMN;
}
memset(&action->alterSTable, 0, sizeof(SAlterSTableActionInfo));
memcpy(action->alterSTable.sTableName, sTableName, TSDB_TABLE_NAME_LEN);
action->alterSTable.field = pointColField;
*actionNeeded = true;
}
tscDebug("generate schema action. action needed: %d, action: %d", *actionNeeded, action->action);
return 0;
}
static int32_t buildColumnDescription(SSchema* field,
char* buf, int32_t bufSize, int32_t* outBytes) {
uint8_t type = field->type;
if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) {
int32_t bytes = field->bytes - VARSTR_HEADER_SIZE;
if (type == TSDB_DATA_TYPE_NCHAR) {
bytes = bytes/TSDB_NCHAR_SIZE;
}
int out = snprintf(buf, bufSize,"%s %s(%d)",
field->name,tDataTypes[field->type].name, bytes);
*outBytes = out;
} else {
int out = snprintf(buf, bufSize, "%s %s",
field->name, tDataTypes[type].name);
*outBytes = out;
}
return 0;
}
static int32_t applySchemaAction(TAOS* taos, SSchemaAction* action) {
int32_t code = 0;
int32_t capacity = TSDB_MAX_BINARY_LEN;
int32_t outBytes = 0;
char *result = (char *)calloc(1, capacity);
tscDebug("apply schema action: %d", action->action);
switch (action->action) {
case SCHEMA_ACTION_ADD_COLUMN: {
int n = sprintf(result, "alter stable %s add column ", action->alterSTable.sTableName);
buildColumnDescription(action->alterSTable.field, result+n, capacity-n, &outBytes);
TAOS_RES* res = taos_query(taos, result); //TODO async doAsyncQuery
code = taos_errno(res);
taos_free_result(res);
break;
}
case SCHEMA_ACTION_ADD_TAG: {
int n = sprintf(result, "alter stable %s add tag ", action->alterSTable.sTableName);
buildColumnDescription(action->alterSTable.field,
result+n, capacity-n, &outBytes);
TAOS_RES* res = taos_query(taos, result); //TODO async doAsyncQuery
code = taos_errno(res);
taos_free_result(res);
break;
}
case SCHEMA_ACTION_CHANGE_COLUMN_SIZE: {
int n = sprintf(result, "alter stable %s modify column ", action->alterSTable.sTableName);
buildColumnDescription(action->alterSTable.field, result+n,
capacity-n, &outBytes);
TAOS_RES* res = taos_query(taos, result); //TODO async doAsyncQuery
code = taos_errno(res);
taos_free_result(res);
break;
}
case SCHEMA_ACTION_CHANGE_TAG_SIZE: {
int n = sprintf(result, "alter stable %s modify tag ", action->alterSTable.sTableName);
buildColumnDescription(action->alterSTable.field, result+n,
capacity-n, &outBytes);
TAOS_RES* res = taos_query(taos, result); //TODO async doAsyncQuery
code = taos_errno(res);
taos_free_result(res);
break;
}
case SCHEMA_ACTION_CREATE_STABLE: {
int n = sprintf(result, "create stable %s (", action->createSTable.sTableName);
char* pos = result + n; int freeBytes = capacity - n;
size_t numCols = taosArrayGetSize(action->createSTable.fields);
for (int32_t i = 0; i < numCols; ++i) {
SSchema* field = taosArrayGet(action->createSTable.fields, i);
buildColumnDescription(field, pos, freeBytes, &outBytes);
pos += outBytes; freeBytes -= outBytes;
*pos = ','; ++pos; --freeBytes;
}
--pos; ++freeBytes;
outBytes = snprintf(pos, freeBytes, ") tags (");
pos += outBytes; freeBytes -= outBytes;
size_t numTags = taosArrayGetSize(action->createSTable.tags);
for (int32_t i = 0; i < numTags; ++i) {
SSchema* field = taosArrayGet(action->createSTable.tags, i);
buildColumnDescription(field, pos, freeBytes, &outBytes);
pos += outBytes; freeBytes -= outBytes;
*pos = ','; ++pos; --freeBytes;
}
pos--; ++freeBytes;
outBytes = snprintf(pos, freeBytes, ")");
TAOS_RES* res = taos_query(taos, result);
code = taos_errno(res);
taos_free_result(res);
break;
}
default:
break;
}
free(result);
if (code != 0) {
tscError("apply schema action failure. %s", tstrerror(code));
}
return code;
}
static int32_t destroySmlSTableSchema(SSmlSTableSchema* schema) {
taosHashCleanup(schema->tagHash);
taosHashCleanup(schema->fieldHash);
taosArrayDestroy(schema->tags);
taosArrayDestroy(schema->fields);
return 0;
}
int32_t loadTableMeta(TAOS* taos, char* tableName, SSmlSTableSchema* schema) {
int32_t code = 0;
STscObj *pObj = (STscObj *)taos;
if (pObj == NULL || pObj->signature != pObj) {
terrno = TSDB_CODE_TSC_DISCONNECTED;
return TSDB_CODE_TSC_DISCONNECTED;
}
tscDebug("load table schema. super table name: %s", tableName);
char sql[256];
snprintf(sql, 256, "describe %s", tableName);
TAOS_RES* res = taos_query(taos, sql);
code = taos_errno(res);
if (code != 0) {
tscError("describe table failure. %s", taos_errstr(res));
taos_free_result(res);
return code;
}
taos_free_result(res);
SSqlObj* pSql = calloc(1, sizeof(SSqlObj));
pSql->pTscObj = taos;
pSql->signature = pSql;
pSql->fp = NULL;
SStrToken tableToken = {.z=tableName, .n=(uint32_t)strlen(tableName), .type=TK_ID};
tGetToken(tableName, &tableToken.type);
// Check if the table name available or not
if (tscValidateName(&tableToken) != TSDB_CODE_SUCCESS) {
code = TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH;
sprintf(pSql->cmd.payload, "table name is invalid");
return code;
}
SName sname = {0};
if ((code = tscSetTableFullName(&sname, &tableToken, pSql)) != TSDB_CODE_SUCCESS) {
return code;
}
char fullTableName[TSDB_TABLE_FNAME_LEN] = {0};
memset(fullTableName, 0, tListLen(fullTableName));
tNameExtractFullName(&sname, fullTableName);
if (code != TSDB_CODE_SUCCESS) {
tscFreeSqlObj(pSql);
return code;
}
tscFreeSqlObj(pSql);
schema->tags = taosArrayInit(8, sizeof(SSchema));
schema->fields = taosArrayInit(64, sizeof(SSchema));
schema->tagHash = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false);
schema->fieldHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false);
uint32_t size = tscGetTableMetaMaxSize();
STableMeta* tableMeta = calloc(1, size);
taosHashGetClone(tscTableMetaInfo, fullTableName, strlen(fullTableName), NULL, tableMeta, -1);
tstrncpy(schema->sTableName, tableName, strlen(tableName)+1);
schema->precision = tableMeta->tableInfo.precision;
for (int i=0; i<tableMeta->tableInfo.numOfColumns; ++i) {
SSchema field;
tstrncpy(field.name, tableMeta->schema[i].name, strlen(tableMeta->schema[i].name)+1);
field.type = tableMeta->schema[i].type;
field.bytes = tableMeta->schema[i].bytes;
SSchema* pField = taosArrayPush(schema->fields, &field);
taosHashPut(schema->fieldHash, field.name, strlen(field.name), &pField, POINTER_BYTES);
}
for (int i=0; i<tableMeta->tableInfo.numOfTags; ++i) {
int j = i + tableMeta->tableInfo.numOfColumns;
SSchema field;
tstrncpy(field.name, tableMeta->schema[j].name, strlen(tableMeta->schema[j].name)+1);
field.type = tableMeta->schema[j].type;
field.bytes = tableMeta->schema[j].bytes;
SSchema* pField = taosArrayPush(schema->tags, &field);
taosHashPut(schema->tagHash, field.name, strlen(field.name), &pField, POINTER_BYTES);
}
tscDebug("load table meta succeed. %s, columns number: %d, tag number: %d, precision: %d",
tableName, tableMeta->tableInfo.numOfColumns, tableMeta->tableInfo.numOfTags, schema->precision);
free(tableMeta); tableMeta = NULL;
return code;
}
static int32_t reconcileDBSchemas(TAOS* taos, SArray* stableSchemas) {
int32_t code = 0;
size_t numStable = taosArrayGetSize(stableSchemas);
for (int i = 0; i < numStable; ++i) {
SSmlSTableSchema* pointSchema = taosArrayGet(stableSchemas, i);
SSmlSTableSchema dbSchema;
memset(&dbSchema, 0, sizeof(SSmlSTableSchema));
code = loadTableMeta(taos, pointSchema->sTableName, &dbSchema);
if (code == TSDB_CODE_MND_INVALID_TABLE_NAME) {
SSchemaAction schemaAction = {0};
schemaAction.action = SCHEMA_ACTION_CREATE_STABLE;
memset(&schemaAction.createSTable, 0, sizeof(SCreateSTableActionInfo));
memcpy(schemaAction.createSTable.sTableName, pointSchema->sTableName, TSDB_TABLE_NAME_LEN);
schemaAction.createSTable.tags = pointSchema->tags;
schemaAction.createSTable.fields = pointSchema->fields;
applySchemaAction(taos, &schemaAction);
code = loadTableMeta(taos, pointSchema->sTableName, &dbSchema);
if (code != 0) {
tscError("reconcile point schema failed. can not create %s", pointSchema->sTableName);
} else {
pointSchema->precision = dbSchema.precision;
destroySmlSTableSchema(&dbSchema);
}
} else if (code == TSDB_CODE_SUCCESS) {
size_t pointTagSize = taosArrayGetSize(pointSchema->tags);
size_t pointFieldSize = taosArrayGetSize(pointSchema->fields);
SHashObj* dbTagHash = dbSchema.tagHash;
SHashObj* dbFieldHash = dbSchema.fieldHash;
for (int j = 0; j < pointTagSize; ++j) {
SSchema* pointTag = taosArrayGet(pointSchema->tags, j);
SSchemaAction schemaAction = {0};
bool actionNeeded = false;
generateSchemaAction(pointTag, dbTagHash, true, pointSchema->sTableName, &schemaAction, &actionNeeded);
if (actionNeeded) {
applySchemaAction(taos, &schemaAction);
}
}
SSchema* pointColTs = taosArrayGet(pointSchema->fields, 0);
SSchema* dbColTs = taosArrayGet(dbSchema.fields, 0);
memcpy(pointColTs->name, dbColTs->name, TSDB_COL_NAME_LEN);
for (int j = 1; j < pointFieldSize; ++j) {
SSchema* pointCol = taosArrayGet(pointSchema->fields, j);
SSchemaAction schemaAction = {0};
bool actionNeeded = false;
generateSchemaAction(pointCol, dbFieldHash, false, pointSchema->sTableName, &schemaAction, &actionNeeded);
if (actionNeeded) {
applySchemaAction(taos, &schemaAction);
}
}
pointSchema->precision = dbSchema.precision;
destroySmlSTableSchema(&dbSchema);
} else {
tscError("load table meta error: %s", tstrerror(code));
return code;
}
}
return 0;
}
static int32_t getChildTableName(TAOS_SML_DATA_POINT* point, char* tableName, int* tableNameLen) {
qsort(point->tags, point->tagNum, sizeof(TAOS_SML_KV), compareSmlColKv);
SStringBuilder sb; memset(&sb, 0, sizeof(sb));
taosStringBuilderAppendString(&sb, point->stableName);
for (int j = 0; j < point->tagNum; ++j) {
taosStringBuilderAppendChar(&sb, ',');
TAOS_SML_KV* tagKv = point->tags + j;
taosStringBuilderAppendString(&sb, tagKv->key);
taosStringBuilderAppendChar(&sb, '=');
taosStringBuilderAppend(&sb, tagKv->value, tagKv->length);
}
size_t len = 0;
char* keyJoined = taosStringBuilderGetResult(&sb, &len);
MD5_CTX context;
MD5Init(&context);
MD5Update(&context, (uint8_t *)keyJoined, (uint32_t)len);
MD5Final(&context);
*tableNameLen = snprintf(tableName, *tableNameLen,
"t_%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", context.digest[0],
context.digest[1], context.digest[2], context.digest[3], context.digest[4], context.digest[5], context.digest[6],
context.digest[7], context.digest[8], context.digest[9], context.digest[10], context.digest[11],
context.digest[12], context.digest[13], context.digest[14], context.digest[15]);
taosStringBuilderDestroy(&sb);
tscDebug("child table name: %s", tableName);
return 0;
}
static int32_t creatChildTableIfNotExists(TAOS* taos, const char* cTableName, const char* sTableName, SArray* tagsSchema, SArray* tagsBind) {
size_t numTags = taosArrayGetSize(tagsSchema);
char sql[TSDB_MAX_BINARY_LEN] = {0};
int freeBytes = TSDB_MAX_BINARY_LEN;
sprintf(sql, "create table if not exists %s using %s", cTableName, sTableName);
snprintf(sql+strlen(sql), freeBytes-strlen(sql), "(");
for (int i = 0; i < numTags; ++i) {
SSchema* tagSchema = taosArrayGet(tagsSchema, i);
snprintf(sql+strlen(sql), freeBytes-strlen(sql), "%s,", tagSchema->name);
}
snprintf(sql + strlen(sql) - 1, freeBytes-strlen(sql)+1, ")");
snprintf(sql + strlen(sql), freeBytes-strlen(sql), " tags (");
for (int i = 0; i < numTags; ++i) {
snprintf(sql+strlen(sql), freeBytes-strlen(sql), "?,");
}
snprintf(sql + strlen(sql) - 1, freeBytes-strlen(sql)+1, ")");
tscDebug("create table : %s", sql);
TAOS_STMT* stmt = taos_stmt_init(taos);
int32_t code;
code = taos_stmt_prepare(stmt, sql, (unsigned long)strlen(sql));
if (code != 0) {
tscError("%s", taos_stmt_errstr(stmt));
return code;
}
code = taos_stmt_bind_param(stmt, TARRAY_GET_START(tagsBind));
if (code != 0) {
tscError("%s", taos_stmt_errstr(stmt));
return code;
}
code = taos_stmt_execute(stmt);
if (code != 0) {
tscError("%s", taos_stmt_errstr(stmt));
return code;
}
taos_stmt_close(stmt);
return 0;
}
static int32_t insertChildTableBatch(TAOS* taos, char* cTableName, SArray* colsSchema, SArray* rowsBind) {
size_t numCols = taosArrayGetSize(colsSchema);
char sql[TSDB_MAX_BINARY_LEN];
int32_t freeBytes = TSDB_MAX_BINARY_LEN;
sprintf(sql, "insert into ? (");
for (int i = 0; i < numCols; ++i) {
SSchema* colSchema = taosArrayGet(colsSchema, i);
snprintf(sql+strlen(sql), freeBytes-strlen(sql), "%s,", colSchema->name);
}
snprintf(sql + strlen(sql)-1, freeBytes-strlen(sql)+1, ") values (");
for (int i = 0; i < numCols; ++i) {
snprintf(sql+strlen(sql), freeBytes-strlen(sql), "?,");
}
snprintf(sql + strlen(sql)-1, freeBytes-strlen(sql)+1, ")");
tscDebug("insert rows %zu into child table %s. ", taosArrayGetSize(rowsBind), cTableName);
int32_t code = 0;
int32_t try = 0;
TAOS_STMT* stmt = taos_stmt_init(taos);
code = taos_stmt_prepare(stmt, sql, (unsigned long)strlen(sql));
if (code != 0) {
tscError("%s", taos_stmt_errstr(stmt));
return code;
}
do {
code = taos_stmt_set_tbname(stmt, cTableName);
if (code != 0) {
tscError("%s", taos_stmt_errstr(stmt));
return code;
}
size_t rows = taosArrayGetSize(rowsBind);
for (int32_t i = 0; i < rows; ++i) {
TAOS_BIND* colsBinds = taosArrayGetP(rowsBind, i);
code = taos_stmt_bind_param(stmt, colsBinds);
if (code != 0) {
tscError("%s", taos_stmt_errstr(stmt));
return code;
}
code = taos_stmt_add_batch(stmt);
if (code != 0) {
tscError("%s", taos_stmt_errstr(stmt));
return code;
}
}
code = taos_stmt_execute(stmt);
if (code != 0) {
tscError("%s", taos_stmt_errstr(stmt));
}
} while (code == TSDB_CODE_TDB_TABLE_RECONFIGURE && try++ < TSDB_MAX_REPLICA);
if (code != 0) {
tscError("%s", taos_stmt_errstr(stmt));
taos_stmt_close(stmt);
} else {
taos_stmt_close(stmt);
}
return code;
}
static int32_t arrangePointsByChildTableName(TAOS_SML_DATA_POINT* points, int numPoints, SHashObj* cname2points) {
for (int32_t i = 0; i < numPoints; ++i) {
TAOS_SML_DATA_POINT * point = points + i;
if (!point->childTableName) {
char childTableName[TSDB_TABLE_NAME_LEN];
int32_t tableNameLen = TSDB_TABLE_NAME_LEN;
getChildTableName(point, childTableName, &tableNameLen);
point->childTableName = calloc(1, tableNameLen+1);
strncpy(point->childTableName, childTableName, tableNameLen);
point->childTableName[tableNameLen] = '\0';
}
for (int j = 0; j < point->tagNum; ++j) {
TAOS_SML_KV* kv = point->tags + j;
if (kv->type == TSDB_DATA_TYPE_TIMESTAMP) {
int64_t ts = *(int64_t*)(kv->value);
ts = convertTimePrecision(ts, TSDB_TIME_PRECISION_NANO, point->schema->precision);
*(int64_t*)(kv->value) = ts;
}
}
for (int j = 0; j < point->fieldNum; ++j) {
TAOS_SML_KV* kv = point->fields + j;
if (kv->type == TSDB_DATA_TYPE_TIMESTAMP) {
int64_t ts = *(int64_t*)(kv->value);
ts = convertTimePrecision(ts, TSDB_TIME_PRECISION_NANO, point->schema->precision);
*(int64_t*)(kv->value) = ts;
}
}
SArray* cTablePoints = NULL;
SArray** pCTablePoints = taosHashGet(cname2points, point->childTableName, strlen(point->childTableName));
if (pCTablePoints) {
cTablePoints = *pCTablePoints;
} else {
cTablePoints = taosArrayInit(64, sizeof(point));
taosHashPut(cname2points, point->childTableName, strlen(point->childTableName), &cTablePoints, POINTER_BYTES);
}
taosArrayPush(cTablePoints, &point);
}
return 0;
}
static int32_t insertPoints(TAOS* taos, TAOS_SML_DATA_POINT* points, int32_t numPoints) {
SHashObj* cname2points = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY),
true, false);
arrangePointsByChildTableName(points, numPoints, cname2points);
int isNullColBind = TSDB_TRUE;
SArray** pCTablePoints = taosHashIterate(cname2points, NULL);
while (pCTablePoints) {
SArray* cTablePoints = *pCTablePoints;
TAOS_SML_DATA_POINT * point = taosArrayGetP(cTablePoints, 0);
size_t numTags = taosArrayGetSize(point->schema->tags);
size_t numCols = taosArrayGetSize(point->schema->fields);
SArray* tagBinds = taosArrayInit(numTags, sizeof(TAOS_BIND));
taosArraySetSize(tagBinds, numTags);
for (int j = 0; j < numTags; ++j) {
TAOS_BIND* bind = taosArrayGet(tagBinds, j);
bind->is_null = &isNullColBind;
}
for (int j = 0; j < point->tagNum; ++j) {
TAOS_SML_KV* kv = point->tags + j;
size_t idx = TARRAY_ELEM_IDX(point->schema->tags, kv->schema);
TAOS_BIND* bind = taosArrayGet(tagBinds, idx);
bind->buffer_type = kv->type;
bind->length = malloc(sizeof(uintptr_t*));
*bind->length = kv->length;
bind->buffer = kv->value;
bind->is_null = NULL;
}
size_t rows = taosArrayGetSize(cTablePoints);
SArray* rowsBind = taosArrayInit(rows, POINTER_BYTES);
for (int i = 0; i < rows; ++i) {
point = taosArrayGetP(cTablePoints, i);
TAOS_BIND* colBinds = calloc(numCols, sizeof(TAOS_BIND));
for (int j = 0; j < numCols; ++j) {
TAOS_BIND* bind = colBinds + j;
bind->is_null = &isNullColBind;
}
for (int j = 0; j < point->fieldNum; ++j) {
TAOS_SML_KV* kv = point->fields + j;
size_t idx = TARRAY_ELEM_IDX(point->schema->fields, kv->schema);
TAOS_BIND* bind = colBinds + idx;
bind->buffer_type = kv->type;
bind->length = malloc(sizeof(uintptr_t*));
*bind->length = kv->length;
bind->buffer = kv->value;
bind->is_null = NULL;
}
taosArrayPush(rowsBind, &colBinds);
}
creatChildTableIfNotExists(taos, point->childTableName, point->stableName, point->schema->tags, tagBinds);
for (int i = 0; i < taosArrayGetSize(tagBinds); ++i) {
TAOS_BIND* bind = taosArrayGet(tagBinds, i);
free(bind->length);
}
taosArrayDestroy(tagBinds);
insertChildTableBatch(taos, point->childTableName, point->schema->fields, rowsBind);
for (int i = 0; i < rows; ++i) {
TAOS_BIND* colBinds = taosArrayGetP(rowsBind, i);
for (int j = 0; j < numCols; ++j) {
TAOS_BIND* bind = colBinds + j;
free(bind->length);
}
free(colBinds);
}
taosArrayDestroy(rowsBind);
taosArrayDestroy(cTablePoints);
pCTablePoints = taosHashIterate(cname2points, pCTablePoints);
}
taosHashCleanup(cname2points);
return 0;
}
int taos_sml_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint) {
tscDebug("taos_sml_insert. number of points: %d", numPoint);
int32_t code = TSDB_CODE_SUCCESS;
SArray* stableSchemas = taosArrayInit(32, sizeof(SSmlSTableSchema)); // SArray<STableColumnsSchema>
code = buildDataPointSchemas(points, numPoint, stableSchemas);
if (code != 0) {
tscError("error building data point schemas : %s", tstrerror(code));
goto clean_up;
}
code = reconcileDBSchemas(taos, stableSchemas);
if (code != 0) {
tscError("error change db schema : %s", tstrerror(code));
goto clean_up;
}
code = insertPoints(taos, points, numPoint);
if (code != 0) {
tscError("error insert points : %s", tstrerror(code));
}
clean_up:
for (int i = 0; i < taosArrayGetSize(stableSchemas); ++i) {
SSmlSTableSchema* schema = taosArrayGet(stableSchemas, i);
taosArrayDestroy(schema->fields);
taosArrayDestroy(schema->tags);
}
taosArrayDestroy(stableSchemas);
return code;
}
//=========================================================================
typedef enum {
LP_ITEM_TAG,
LP_ITEM_FIELD
} LPItemKind;
typedef struct {
SStrToken keyToken;
SStrToken valueToken;
char key[TSDB_COL_NAME_LEN];
int8_t type;
int16_t length;
char* value;
}SLPItem;
typedef struct {
SStrToken measToken;
SStrToken tsToken;
char sTableName[TSDB_TABLE_NAME_LEN];
SArray* tags;
SArray* fields;
int64_t ts;
} SLPPoint;
typedef enum {
LP_MEASUREMENT,
LP_TAG_KEY,
LP_TAG_VALUE,
LP_FIELD_KEY,
LP_FIELD_VALUE
} LPPart;
int32_t scanToCommaOrSpace(SStrToken s, int32_t start, int32_t* index, LPPart part) {
for (int32_t i = start; i < s.n; ++i) {
if (s.z[i] == ',' || s.z[i] == ' ') {
*index = i;
return 0;
}
}
return -1;
}
int32_t scanToEqual(SStrToken s, int32_t start, int32_t* index) {
for (int32_t i = start; i < s.n; ++i) {
if (s.z[i] == '=') {
*index = i;
return 0;
}
}
return -1;
}
int32_t setPointMeasurement(SLPPoint* point, SStrToken token) {
point->measToken = token;
if (point->measToken.n < TSDB_TABLE_NAME_LEN) {
strncpy(point->sTableName, point->measToken.z, point->measToken.n);
point->sTableName[point->measToken.n] = '\0';
}
return 0;
}
int32_t setItemKey(SLPItem* item, SStrToken key, LPPart part) {
item->keyToken = key;
if (item->keyToken.n < TSDB_COL_NAME_LEN) {
strncpy(item->key, item->keyToken.z, item->keyToken.n);
item->key[item->keyToken.n] = '\0';
}
return 0;
}
int32_t setItemValue(SLPItem* item, SStrToken value, LPPart part) {
item->valueToken = value;
return 0;
}
int32_t parseItemValue(SLPItem* item, LPItemKind kind) {
char* sv = item->valueToken.z;
char* last = item->valueToken.z + item->valueToken.n - 1;
if (isdigit(sv[0]) || sv[0] == '-') {
if (*last == 'i') {
item->type = TSDB_DATA_TYPE_BIGINT;
item->length = (int16_t)tDataTypes[item->type].bytes;
item->value = malloc(item->length);
char* endptr = NULL;
*(int64_t*)(item->value) = strtoll(sv, &endptr, 10);
} else if (*last == 'u') {
item->type = TSDB_DATA_TYPE_UBIGINT;
item->length = (int16_t)tDataTypes[item->type].bytes;
item->value = malloc(item->length);
char* endptr = NULL;
*(uint64_t*)(item->value) = (uint64_t)strtoull(sv, &endptr, 10);
} else if (*last == 'b') {
item->type = TSDB_DATA_TYPE_TINYINT;
item->length = (int16_t)tDataTypes[item->type].bytes;
item->value = malloc(item->length);
char* endptr = NULL;
*(int8_t*)(item->value) = (int8_t)strtoll(sv, &endptr, 10);
} else if (*last == 's') {
item->type = TSDB_DATA_TYPE_SMALLINT;
item->length = (int16_t)tDataTypes[item->type].bytes;
item->value = malloc(item->length);
char* endptr = NULL;
*(int16_t*)(item->value) = (int16_t)strtoll(sv, &endptr, 10);
} else if (*last == 'w') {
item->type = TSDB_DATA_TYPE_INT;
item->length = (int16_t)tDataTypes[item->type].bytes;
item->value = malloc(item->length);
char* endptr = NULL;
*(int32_t*)(item->value) = (int32_t)strtoll(sv, &endptr, 10);
} else if (*last == 'f') {
item->type = TSDB_DATA_TYPE_FLOAT;
item->length = (int16_t)tDataTypes[item->type].bytes;
item->value = malloc(item->length);
char* endptr = NULL;
*(float*)(item->value) = (float)strtold(sv, &endptr);
} else {
item->type = TSDB_DATA_TYPE_DOUBLE;
item->length = (int16_t)tDataTypes[item->type].bytes;
item->value = malloc(item->length);
char* endptr = NULL;
*(double*)(item->value) = strtold(sv, &endptr);
}
} else if ((sv[0] == 'L' && sv[1] =='"') || sv[0] == '"' ) {
if (sv[0] == 'L') {
item->type = TSDB_DATA_TYPE_NCHAR;
uint32_t bytes = item->valueToken.n - 3;
item->length = bytes;
item->value = malloc(bytes);
memcpy(item->value, sv+2, bytes);
} else if (sv[0]=='"'){
item->type = TSDB_DATA_TYPE_BINARY;
uint32_t bytes = item->valueToken.n - 2;
item->length = bytes;
item->value = malloc(bytes);
memcpy(item->value, sv+1, bytes);
}
} else if (sv[0] == 't' || sv[0] == 'f' || sv[0]=='T' || sv[0] == 'F') {
item->type = TSDB_DATA_TYPE_BOOL;
item->length = tDataTypes[item->type].bytes;
item->value = malloc(tDataTypes[item->type].bytes);
*(uint8_t*)(item->value) = tolower(sv[0])=='t' ? TSDB_TRUE : TSDB_FALSE;
}
return 0;
}
int32_t compareLPItemKey(const void* p1, const void* p2) {
const SLPItem* t1 = p1;
const SLPItem* t2 = p2;
uint32_t min = (t1->keyToken.n < t2->keyToken.n) ? t1->keyToken.n : t2->keyToken.n;
int res = strncmp(t1->keyToken.z, t2->keyToken.z, min);
if (res != 0) {
return res;
} else {
return (int)(t1->keyToken.n) - (int)(t2->keyToken.n);
}
}
int32_t setPointTimeStamp(SLPPoint* point, SStrToken tsToken) {
point->tsToken = tsToken;
return 0;
}
int32_t parsePointTime(SLPPoint* point) {
if (point->tsToken.n <= 0) {
point->ts = taosGetTimestampNs();
} else {
char* endptr = NULL;
point->ts = strtoll(point->tsToken.z, &endptr, 10);
char* last = point->tsToken.z + point->tsToken.n - 1;
if (*last == 's') {
point->ts *= (int64_t)1e9;
} else if (*last == 'a') {
point->ts *= (int64_t)1e6;
} else if (*last == 'u') {
point->ts *= (int64_t)1e3;
} else if (*last == 'b') {
point->ts *= 1;
}
}
return 0;
}
int32_t tscParseLine(SStrToken line, SLPPoint* point) {
int32_t pos = 0;
int32_t start = 0;
int32_t err = scanToCommaOrSpace(line, start, &pos, LP_MEASUREMENT);
if (err != 0) {
tscError("a");
return err;
}
SStrToken measurement = {.z = line.z+start, .n = pos-start};
setPointMeasurement(point, measurement);
point->tags = taosArrayInit(64, sizeof(SLPItem));
start = pos;
while (line.z[start] == ',') {
SLPItem item;
start++;
err = scanToEqual(line, start, &pos);
if (err != 0) {
tscError("b");
goto error;
}
SStrToken tagKey = {.z = line.z + start, .n = pos-start};
setItemKey(&item, tagKey, LP_TAG_KEY);
start = pos + 1;
err = scanToCommaOrSpace(line, start, &pos, LP_TAG_VALUE);
if (err != 0) {
tscError("c");
goto error;
}
SStrToken tagValue = {.z = line.z + start, .n = pos-start};
setItemValue(&item, tagValue, LP_TAG_VALUE);
parseItemValue(&item, LP_ITEM_TAG);
taosArrayPush(point->tags, &item);
start = pos;
}
taosArraySort(point->tags, compareLPItemKey);
point->fields = taosArrayInit(64, sizeof(SLPItem));
start++;
do {
SLPItem item;
err = scanToEqual(line, start, &pos);
if (err != 0) {
goto error;
}
SStrToken fieldKey = {.z = line.z + start, .n = pos- start};
setItemKey(&item, fieldKey, LP_FIELD_KEY);
start = pos + 1;
err = scanToCommaOrSpace(line, start, &pos, LP_FIELD_VALUE);
if (err != 0) {
goto error;
}
SStrToken fieldValue = {.z = line.z + start, .n = pos - start};
setItemValue(&item, fieldValue, LP_TAG_VALUE);
parseItemValue(&item, LP_ITEM_FIELD);
taosArrayPush(point->fields, &item);
start = pos + 1;
} while (line.z[pos] == ',');
taosArraySort(point->fields, compareLPItemKey);
SStrToken tsToken = {.z = line.z+start, .n = line.n-start};
setPointTimeStamp(point, tsToken);
parsePointTime(point);
goto done;
error:
// free array
return err;
done:
return 0;
}
int32_t tscParseLines(char* lines[], int numLines, SArray* points, SArray* failedLines) {
for (int32_t i = 0; i < numLines; ++i) {
SStrToken tkLine = {.z = lines[i], .n = (uint32_t)strlen(lines[i])};
SLPPoint point;
tscParseLine(tkLine, &point);
taosArrayPush(points, &point);
}
return 0;
}
void destroyLPPoint(void* p) {
SLPPoint* lpPoint = p;
for (int i=0; i<taosArrayGetSize(lpPoint->fields); ++i) {
SLPItem* item = taosArrayGet(lpPoint->fields, i);
free(item->value);
}
taosArrayDestroy(lpPoint->fields);
for (int i=0; i<taosArrayGetSize(lpPoint->tags); ++i) {
SLPItem* item = taosArrayGet(lpPoint->tags, i);
free(item->value);
}
taosArrayDestroy(lpPoint->tags);
}
void destroySmlDataPoint(TAOS_SML_DATA_POINT* point) {
for (int i=0; i<point->tagNum; ++i) {
free((point->tags+i)->key);
free((point->tags+i)->value);
}
free(point->tags);
for (int i=0; i<point->fieldNum; ++i) {
free((point->fields+i)->key);
free((point->fields+i)->value);
}
free(point->fields);
free(point->stableName);
free(point->childTableName);
}
int taos_insert_lines(TAOS* taos, char* lines[], int numLines) {
SArray* lpPoints = taosArrayInit(numLines, sizeof(SLPPoint));
tscParseLines(lines, numLines, lpPoints, NULL);
size_t numPoints = taosArrayGetSize(lpPoints);
TAOS_SML_DATA_POINT* points = calloc(numPoints, sizeof(TAOS_SML_DATA_POINT));
for (int i = 0; i < numPoints; ++i) {
SLPPoint* lpPoint = taosArrayGet(lpPoints, i);
TAOS_SML_DATA_POINT* point = points+i;
point->stableName = calloc(1, strlen(lpPoint->sTableName)+1);
strncpy(point->stableName, lpPoint->sTableName, strlen(lpPoint->sTableName));
point->stableName[strlen(lpPoint->sTableName)] = '\0';
size_t lpTagSize = taosArrayGetSize(lpPoint->tags);
point->tags = calloc(lpTagSize, sizeof(TAOS_SML_KV));
point->tagNum = (int)lpTagSize;
for (int j=0; j<lpTagSize; ++j) {
SLPItem* lpTag = taosArrayGet(lpPoint->tags, j);
TAOS_SML_KV* tagKv = point->tags + j;
size_t kenLen = strlen(lpTag->key);
tagKv->key = calloc(1, kenLen+1);
strncpy(tagKv->key, lpTag->key, kenLen);
tagKv->key[kenLen] = '\0';
tagKv->type = lpTag->type;
tagKv->length = lpTag->length;
tagKv->value = malloc(tagKv->length);
memcpy(tagKv->value, lpTag->value, tagKv->length);
}
size_t lpFieldsSize = taosArrayGetSize(lpPoint->fields);
point->fields = calloc(lpFieldsSize + 1, sizeof(TAOS_SML_KV));
point->fieldNum = (int)(lpFieldsSize + 1);
TAOS_SML_KV* tsField = point->fields + 0;
char tsKey[256];
snprintf(tsKey, 256, "_%s_ts", point->stableName);
size_t tsKeyLen = strlen(tsKey);
tsField->key = calloc(1, tsKeyLen+1);
strncpy(tsField->key, tsKey, tsKeyLen);
tsField->key[tsKeyLen] = '\0';
tsField->type = TSDB_DATA_TYPE_TIMESTAMP;
tsField->length = tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes;
tsField->value = malloc(tsField->length);
memcpy(tsField->value, &(lpPoint->ts), tsField->length);
for (int j=0; j<lpFieldsSize; ++j) {
SLPItem* lpField = taosArrayGet(lpPoint->fields, j);
TAOS_SML_KV* fieldKv = point->fields + j + 1;
size_t kenLen = strlen(lpField->key);
fieldKv->key = calloc(1, kenLen+1);
strncpy(fieldKv->key, lpField->key, kenLen);
fieldKv->key[kenLen] = '\0';
fieldKv->type = lpField->type;
fieldKv->length = lpField->length;
fieldKv->value = malloc(fieldKv->length);
memcpy(fieldKv->value, lpField->value, fieldKv->length);
}
}
taos_sml_insert(taos, points, (int)numPoints);
for (int i=0; i<numPoints; ++i) {
destroySmlDataPoint(points+i);
}
free(points);
taosArrayDestroyEx(lpPoints, destroyLPPoint);
return 0;
}
...@@ -1200,9 +1200,11 @@ static int insertBatchStmtExecute(STscStmt* pStmt) { ...@@ -1200,9 +1200,11 @@ static int insertBatchStmtExecute(STscStmt* pStmt) {
// wait for the callback function to post the semaphore // wait for the callback function to post the semaphore
tsem_wait(&pStmt->pSql->rspSem); tsem_wait(&pStmt->pSql->rspSem);
code = pStmt->pSql->res.code;
insertBatchClean(pStmt); insertBatchClean(pStmt);
return pStmt->pSql->res.code; return code;
} }
int stmtParseInsertTbTags(SSqlObj* pSql, STscStmt* pStmt) { int stmtParseInsertTbTags(SSqlObj* pSql, STscStmt* pStmt) {
...@@ -1470,6 +1472,7 @@ int taos_stmt_prepare(TAOS_STMT* stmt, const char* sql, unsigned long length) { ...@@ -1470,6 +1472,7 @@ int taos_stmt_prepare(TAOS_STMT* stmt, const char* sql, unsigned long length) {
pSql->fetchFp = waitForQueryRsp; pSql->fetchFp = waitForQueryRsp;
pCmd->insertParam.insertType = TSDB_QUERY_TYPE_STMT_INSERT; pCmd->insertParam.insertType = TSDB_QUERY_TYPE_STMT_INSERT;
pCmd->insertParam.objectId = pSql->self;
pSql->sqlstr = realloc(pSql->sqlstr, sqlLen + 1); pSql->sqlstr = realloc(pSql->sqlstr, sqlLen + 1);
...@@ -1646,7 +1649,11 @@ int taos_stmt_close(TAOS_STMT* stmt) { ...@@ -1646,7 +1649,11 @@ int taos_stmt_close(TAOS_STMT* stmt) {
} else { } else {
if (pStmt->multiTbInsert) { if (pStmt->multiTbInsert) {
taosHashCleanup(pStmt->mtb.pTableHash); taosHashCleanup(pStmt->mtb.pTableHash);
pStmt->mtb.pTableBlockHashList = tscDestroyBlockHashTable(pStmt->mtb.pTableBlockHashList, false); bool rmMeta = false;
if (pStmt->pSql && pStmt->pSql->res.code != 0) {
rmMeta = true;
}
pStmt->mtb.pTableBlockHashList = tscDestroyBlockHashTable(pStmt->mtb.pTableBlockHashList, rmMeta);
taosHashCleanup(pStmt->pSql->cmd.insertParam.pTableBlockHashList); taosHashCleanup(pStmt->pSql->cmd.insertParam.pTableBlockHashList);
pStmt->pSql->cmd.insertParam.pTableBlockHashList = NULL; pStmt->pSql->cmd.insertParam.pTableBlockHashList = NULL;
taosArrayDestroy(pStmt->mtb.tags); taosArrayDestroy(pStmt->mtb.tags);
......
...@@ -7802,26 +7802,34 @@ static int32_t doLoadAllTableMeta(SSqlObj* pSql, SQueryInfo* pQueryInfo, SSqlNod ...@@ -7802,26 +7802,34 @@ static int32_t doLoadAllTableMeta(SSqlObj* pSql, SQueryInfo* pQueryInfo, SSqlNod
} }
static STableMeta* extractTempTableMetaFromSubquery(SQueryInfo* pUpstream) { static STableMeta* extractTempTableMetaFromSubquery(SQueryInfo* pUpstream) {
int32_t numOfColumns = pUpstream->fieldsInfo.numOfOutput; STableMetaInfo* pUpstreamTableMetaInfo = tscGetMetaInfo(pUpstream, 0);
STableMeta* meta = calloc(1, sizeof(STableMeta) + sizeof(SSchema) * numOfColumns); int32_t numOfColumns = pUpstream->fieldsInfo.numOfOutput;
STableMeta *meta = calloc(1, sizeof(STableMeta) + sizeof(SSchema) * numOfColumns);
meta->tableType = TSDB_TEMP_TABLE; meta->tableType = TSDB_TEMP_TABLE;
STableComInfo *info = &meta->tableInfo; STableComInfo *info = &meta->tableInfo;
info->numOfColumns = numOfColumns; info->numOfColumns = numOfColumns;
info->precision = pUpstreamTableMetaInfo->pTableMeta->tableInfo.precision;
info->numOfTags = 0; info->numOfTags = 0;
int32_t n = 0; int32_t n = 0;
for(int32_t i = 0; i < numOfColumns; ++i) { for(int32_t i = 0; i < numOfColumns; ++i) {
SInternalField* pField = tscFieldInfoGetInternalField(&pUpstream->fieldsInfo, i); SInternalField* pField = tscFieldInfoGetInternalField(&pUpstream->fieldsInfo, i);
if (pField->visible) { if (!pField->visible) {
continue;
}
meta->schema[n].bytes = pField->field.bytes; meta->schema[n].bytes = pField->field.bytes;
meta->schema[n].type = pField->field.type; meta->schema[n].type = pField->field.type;
meta->schema[n].colId = pField->pExpr->base.resColId;
SExprInfo* pExpr = pField->pExpr;
meta->schema[n].colId = pExpr->base.resColId;
tstrncpy(meta->schema[n].name, pField->pExpr->base.aliasName, TSDB_COL_NAME_LEN); tstrncpy(meta->schema[n].name, pField->pExpr->base.aliasName, TSDB_COL_NAME_LEN);
info->rowSize += meta->schema[n].bytes;
n += 1; n += 1;
} }
}
return meta; return meta;
} }
......
...@@ -3342,6 +3342,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, __async_cb_func_t ...@@ -3342,6 +3342,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, __async_cb_func_t
pnCmd->insertParam.numOfTables = 0; pnCmd->insertParam.numOfTables = 0;
pnCmd->insertParam.pTableNameList = NULL; pnCmd->insertParam.pTableNameList = NULL;
pnCmd->insertParam.pTableBlockHashList = NULL; pnCmd->insertParam.pTableBlockHashList = NULL;
pnCmd->insertParam.objectId = pNew->self;
memset(&pnCmd->insertParam.tagData, 0, sizeof(STagData)); memset(&pnCmd->insertParam.tagData, 0, sizeof(STagData));
...@@ -3608,6 +3609,7 @@ void executeQuery(SSqlObj* pSql, SQueryInfo* pQueryInfo) { ...@@ -3608,6 +3609,7 @@ void executeQuery(SSqlObj* pSql, SQueryInfo* pQueryInfo) {
pNew->signature = pNew; pNew->signature = pNew;
pNew->sqlstr = strdup(pSql->sqlstr); // todo refactor pNew->sqlstr = strdup(pSql->sqlstr); // todo refactor
pNew->fp = tscSubqueryCompleteCallback; pNew->fp = tscSubqueryCompleteCallback;
tsem_init(&pNew->rspSem, 0, 0);
SRetrieveSupport* ps = calloc(1, sizeof(SRetrieveSupport)); // todo use object id SRetrieveSupport* ps = calloc(1, sizeof(SRetrieveSupport)); // todo use object id
ps->pParentSql = pSql; ps->pParentSql = pSql;
......
...@@ -57,8 +57,8 @@ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStat ...@@ -57,8 +57,8 @@ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStat
parameterCnt++; parameterCnt++;
} }
} }
parameters = new Object[parameterCnt];
} }
parameters = new Object[parameterCnt];
if (parameterCnt > 1) { if (parameterCnt > 1) {
// the table name is also a parameter, so ignore it. // the table name is also a parameter, so ignore it.
......
...@@ -22,16 +22,16 @@ public class RestfulPreparedStatement extends RestfulStatement implements Prepar ...@@ -22,16 +22,16 @@ public class RestfulPreparedStatement extends RestfulStatement implements Prepar
super(conn, database); super(conn, database);
this.rawSql = sql; this.rawSql = sql;
if (sql.contains("?")) {
int parameterCnt = 0; int parameterCnt = 0;
if (sql.contains("?")) {
for (int i = 0; i < sql.length(); i++) { for (int i = 0; i < sql.length(); i++) {
if ('?' == sql.charAt(i)) { if ('?' == sql.charAt(i)) {
parameterCnt++; parameterCnt++;
} }
} }
parameters = new Object[parameterCnt];
this.isPrepared = true; this.isPrepared = true;
} }
parameters = new Object[parameterCnt];
// build parameterMetaData // build parameterMetaData
this.parameterMetaData = new RestfulParameterMetaData(parameters); this.parameterMetaData = new RestfulParameterMetaData(parameters);
......
...@@ -15,6 +15,8 @@ public class RestfulPreparedStatementTest { ...@@ -15,6 +15,8 @@ public class RestfulPreparedStatementTest {
private static PreparedStatement pstmt_insert; private static PreparedStatement pstmt_insert;
private static final String sql_select = "select * from t1 where ts > ? and ts <= ? and f1 >= ?"; private static final String sql_select = "select * from t1 where ts > ? and ts <= ? and f1 >= ?";
private static PreparedStatement pstmt_select; private static PreparedStatement pstmt_select;
private static final String sql_without_parameters = "select count(*) from t1";
private static PreparedStatement pstmt_without_parameters;
@Test @Test
public void executeQuery() throws SQLException { public void executeQuery() throws SQLException {
...@@ -237,6 +239,7 @@ public class RestfulPreparedStatementTest { ...@@ -237,6 +239,7 @@ public class RestfulPreparedStatementTest {
@Test @Test
public void clearParameters() throws SQLException { public void clearParameters() throws SQLException {
pstmt_insert.clearParameters(); pstmt_insert.clearParameters();
pstmt_without_parameters.clearParameters();
} }
@Test @Test
...@@ -382,6 +385,7 @@ public class RestfulPreparedStatementTest { ...@@ -382,6 +385,7 @@ public class RestfulPreparedStatementTest {
pstmt_insert = conn.prepareStatement(sql_insert); pstmt_insert = conn.prepareStatement(sql_insert);
pstmt_select = conn.prepareStatement(sql_select); pstmt_select = conn.prepareStatement(sql_select);
pstmt_without_parameters = conn.prepareStatement(sql_without_parameters);
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -394,6 +398,8 @@ public class RestfulPreparedStatementTest { ...@@ -394,6 +398,8 @@ public class RestfulPreparedStatementTest {
pstmt_insert.close(); pstmt_insert.close();
if (pstmt_select != null) if (pstmt_select != null)
pstmt_select.close(); pstmt_select.close();
if (pstmt_without_parameters != null)
pstmt_without_parameters.close();
if (conn != null) if (conn != null)
conn.close(); conn.close();
} catch (SQLException e) { } catch (SQLException e) {
......
...@@ -15,36 +15,18 @@ const { NULL_POINTER } = require('ref-napi'); ...@@ -15,36 +15,18 @@ const { NULL_POINTER } = require('ref-napi');
module.exports = CTaosInterface; module.exports = CTaosInterface;
function convertMillisecondsToDatetime(time) { function convertTimestamp(data, num_of_rows, nbytes = 0, offset = 0, precision = 0) {
return new TaosObjects.TaosTimestamp(time);
}
function convertMicrosecondsToDatetime(time) {
return new TaosObjects.TaosTimestamp(time * 0.001, true);
}
function convertTimestamp(data, num_of_rows, nbytes = 0, offset = 0, micro = false) {
timestampConverter = convertMillisecondsToDatetime;
if (micro == true) {
timestampConverter = convertMicrosecondsToDatetime;
}
data = ref.reinterpret(data.deref(), nbytes * num_of_rows, offset); data = ref.reinterpret(data.deref(), nbytes * num_of_rows, offset);
let res = []; let res = [];
let currOffset = 0; let currOffset = 0;
while (currOffset < data.length) { while (currOffset < data.length) {
let queue = []; let time = data.readInt64LE(currOffset);
let time = 0;
for (let i = currOffset; i < currOffset + nbytes; i++) {
queue.push(data[i]);
}
for (let i = queue.length - 1; i >= 0; i--) {
time += queue[i] * Math.pow(16, i * 2);
}
currOffset += nbytes; currOffset += nbytes;
res.push(timestampConverter(time)); res.push(new TaosObjects.TaosTimestamp(time, precision));
} }
return res; return res;
} }
function convertBool(data, num_of_rows, nbytes = 0, offset = 0, micro = false) { function convertBool(data, num_of_rows, nbytes = 0, offset = 0, precision = 0) {
data = ref.reinterpret(data.deref(), nbytes * num_of_rows, offset); data = ref.reinterpret(data.deref(), nbytes * num_of_rows, offset);
let res = new Array(data.length); let res = new Array(data.length);
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
...@@ -60,7 +42,7 @@ function convertBool(data, num_of_rows, nbytes = 0, offset = 0, micro = false) { ...@@ -60,7 +42,7 @@ function convertBool(data, num_of_rows, nbytes = 0, offset = 0, micro = false) {
} }
return res; return res;
} }
function convertTinyint(data, num_of_rows, nbytes = 0, offset = 0, micro = false) { function convertTinyint(data, num_of_rows, nbytes = 0, offset = 0, precision = 0) {
data = ref.reinterpret(data.deref(), nbytes * num_of_rows, offset); data = ref.reinterpret(data.deref(), nbytes * num_of_rows, offset);
let res = []; let res = [];
let currOffset = 0; let currOffset = 0;
...@@ -71,7 +53,7 @@ function convertTinyint(data, num_of_rows, nbytes = 0, offset = 0, micro = false ...@@ -71,7 +53,7 @@ function convertTinyint(data, num_of_rows, nbytes = 0, offset = 0, micro = false
} }
return res; return res;
} }
function convertSmallint(data, num_of_rows, nbytes = 0, offset = 0, micro = false) { function convertSmallint(data, num_of_rows, nbytes = 0, offset = 0, precision = 0) {
data = ref.reinterpret(data.deref(), nbytes * num_of_rows, offset); data = ref.reinterpret(data.deref(), nbytes * num_of_rows, offset);
let res = []; let res = [];
let currOffset = 0; let currOffset = 0;
...@@ -82,7 +64,7 @@ function convertSmallint(data, num_of_rows, nbytes = 0, offset = 0, micro = fals ...@@ -82,7 +64,7 @@ function convertSmallint(data, num_of_rows, nbytes = 0, offset = 0, micro = fals
} }
return res; return res;
} }
function convertInt(data, num_of_rows, nbytes = 0, offset = 0, micro = false) { function convertInt(data, num_of_rows, nbytes = 0, offset = 0, precision = 0) {
data = ref.reinterpret(data.deref(), nbytes * num_of_rows, offset); data = ref.reinterpret(data.deref(), nbytes * num_of_rows, offset);
let res = []; let res = [];
let currOffset = 0; let currOffset = 0;
...@@ -93,7 +75,7 @@ function convertInt(data, num_of_rows, nbytes = 0, offset = 0, micro = false) { ...@@ -93,7 +75,7 @@ function convertInt(data, num_of_rows, nbytes = 0, offset = 0, micro = false) {
} }
return res; return res;
} }
function convertBigint(data, num_of_rows, nbytes = 0, offset = 0, micro = false) { function convertBigint(data, num_of_rows, nbytes = 0, offset = 0, precision = 0) {
data = ref.reinterpret(data.deref(), nbytes * num_of_rows, offset); data = ref.reinterpret(data.deref(), nbytes * num_of_rows, offset);
let res = []; let res = [];
let currOffset = 0; let currOffset = 0;
...@@ -104,7 +86,7 @@ function convertBigint(data, num_of_rows, nbytes = 0, offset = 0, micro = false) ...@@ -104,7 +86,7 @@ function convertBigint(data, num_of_rows, nbytes = 0, offset = 0, micro = false)
} }
return res; return res;
} }
function convertFloat(data, num_of_rows, nbytes = 0, offset = 0, micro = false) { function convertFloat(data, num_of_rows, nbytes = 0, offset = 0, precision = 0) {
data = ref.reinterpret(data.deref(), nbytes * num_of_rows, offset); data = ref.reinterpret(data.deref(), nbytes * num_of_rows, offset);
let res = []; let res = [];
let currOffset = 0; let currOffset = 0;
...@@ -115,7 +97,7 @@ function convertFloat(data, num_of_rows, nbytes = 0, offset = 0, micro = false) ...@@ -115,7 +97,7 @@ function convertFloat(data, num_of_rows, nbytes = 0, offset = 0, micro = false)
} }
return res; return res;
} }
function convertDouble(data, num_of_rows, nbytes = 0, offset = 0, micro = false) { function convertDouble(data, num_of_rows, nbytes = 0, offset = 0, precision = 0) {
data = ref.reinterpret(data.deref(), nbytes * num_of_rows, offset); data = ref.reinterpret(data.deref(), nbytes * num_of_rows, offset);
let res = []; let res = [];
let currOffset = 0; let currOffset = 0;
...@@ -127,7 +109,7 @@ function convertDouble(data, num_of_rows, nbytes = 0, offset = 0, micro = false) ...@@ -127,7 +109,7 @@ function convertDouble(data, num_of_rows, nbytes = 0, offset = 0, micro = false)
return res; return res;
} }
function convertNchar(data, num_of_rows, nbytes = 0, offset = 0, micro = false) { function convertNchar(data, num_of_rows, nbytes = 0, offset = 0, precision = 0) {
data = ref.reinterpret(data.deref(), nbytes * num_of_rows, offset); data = ref.reinterpret(data.deref(), nbytes * num_of_rows, offset);
let res = []; let res = [];
...@@ -272,7 +254,7 @@ CTaosInterface.prototype.config = function config() { ...@@ -272,7 +254,7 @@ CTaosInterface.prototype.config = function config() {
CTaosInterface.prototype.connect = function connect(host = null, user = "root", password = "taosdata", db = null, port = 0) { CTaosInterface.prototype.connect = function connect(host = null, user = "root", password = "taosdata", db = null, port = 0) {
let _host, _user, _password, _db, _port; let _host, _user, _password, _db, _port;
try { try {
_host = host != null ? ref.allocCString(host) : ref.alloc(ref.types.char_ptr, ref.NULL); _host = host != null ? ref.allocCString(host) : ref.NULL;
} }
catch (err) { catch (err) {
throw "Attribute Error: host is expected as a str"; throw "Attribute Error: host is expected as a str";
...@@ -290,7 +272,7 @@ CTaosInterface.prototype.connect = function connect(host = null, user = "root", ...@@ -290,7 +272,7 @@ CTaosInterface.prototype.connect = function connect(host = null, user = "root",
throw "Attribute Error: password is expected as a str"; throw "Attribute Error: password is expected as a str";
} }
try { try {
_db = db != null ? ref.allocCString(db) : ref.alloc(ref.types.char_ptr, ref.NULL); _db = db != null ? ref.allocCString(db) : ref.NULL;
} }
catch (err) { catch (err) {
throw "Attribute Error: db is expected as a str"; throw "Attribute Error: db is expected as a str";
...@@ -345,8 +327,7 @@ CTaosInterface.prototype.fetchBlock = function fetchBlock(result, fields) { ...@@ -345,8 +327,7 @@ CTaosInterface.prototype.fetchBlock = function fetchBlock(result, fields) {
} }
var fieldL = this.libtaos.taos_fetch_lengths(result); var fieldL = this.libtaos.taos_fetch_lengths(result);
let precision = this.libtaos.taos_result_precision(result);
let isMicro = (this.libtaos.taos_result_precision(result) == FieldTypes.C_TIMESTAMP_MICRO);
var fieldlens = []; var fieldlens = [];
...@@ -373,7 +354,7 @@ CTaosInterface.prototype.fetchBlock = function fetchBlock(result, fields) { ...@@ -373,7 +354,7 @@ CTaosInterface.prototype.fetchBlock = function fetchBlock(result, fields) {
if (!convertFunctions[fields[i]['type']]) { if (!convertFunctions[fields[i]['type']]) {
throw new errors.DatabaseError("Invalid data type returned from database"); throw new errors.DatabaseError("Invalid data type returned from database");
} }
blocks[i] = convertFunctions[fields[i]['type']](pdata, num_of_rows, fieldlens[i], offset, isMicro); blocks[i] = convertFunctions[fields[i]['type']](pdata, num_of_rows, fieldlens[i], offset, precision);
} }
} }
return { blocks: blocks, num_of_rows } return { blocks: blocks, num_of_rows }
...@@ -423,7 +404,7 @@ CTaosInterface.prototype.fetch_rows_a = function fetch_rows_a(result, callback, ...@@ -423,7 +404,7 @@ CTaosInterface.prototype.fetch_rows_a = function fetch_rows_a(result, callback,
let row = cti.libtaos.taos_fetch_row(result2); let row = cti.libtaos.taos_fetch_row(result2);
let fields = cti.fetchFields_a(result2); let fields = cti.fetchFields_a(result2);
let isMicro = (cti.libtaos.taos_result_precision(result2) == FieldTypes.C_TIMESTAMP_MICRO); let precision = cti.libtaos.taos_result_precision(result2);
let blocks = new Array(fields.length); let blocks = new Array(fields.length);
blocks.fill(null); blocks.fill(null);
numOfRows2 = Math.abs(numOfRows2); numOfRows2 = Math.abs(numOfRows2);
...@@ -449,7 +430,7 @@ CTaosInterface.prototype.fetch_rows_a = function fetch_rows_a(result, callback, ...@@ -449,7 +430,7 @@ CTaosInterface.prototype.fetch_rows_a = function fetch_rows_a(result, callback,
let prow = ref.reinterpret(row, 8, i * 8); let prow = ref.reinterpret(row, 8, i * 8);
prow = prow.readPointer(); prow = prow.readPointer();
prow = ref.ref(prow); prow = ref.ref(prow);
blocks[i] = convertFunctions[fields[i]['type']](prow, 1, fieldlens[i], offset, isMicro); blocks[i] = convertFunctions[fields[i]['type']](prow, 1, fieldlens[i], offset, precision);
//offset += fields[i]['bytes'] * numOfRows2; //offset += fields[i]['bytes'] * numOfRows2;
} }
} }
...@@ -572,7 +553,7 @@ CTaosInterface.prototype.openStream = function openStream(connection, sql, callb ...@@ -572,7 +553,7 @@ CTaosInterface.prototype.openStream = function openStream(connection, sql, callb
var cti = this; var cti = this;
let asyncCallbackWrapper = function (param2, result2, row) { let asyncCallbackWrapper = function (param2, result2, row) {
let fields = cti.fetchFields_a(result2); let fields = cti.fetchFields_a(result2);
let isMicro = (cti.libtaos.taos_result_precision(result2) == FieldTypes.C_TIMESTAMP_MICRO); let precision = cti.libtaos.taos_result_precision(result2);
let blocks = new Array(fields.length); let blocks = new Array(fields.length);
blocks.fill(null); blocks.fill(null);
let numOfRows2 = 1; let numOfRows2 = 1;
...@@ -582,7 +563,7 @@ CTaosInterface.prototype.openStream = function openStream(connection, sql, callb ...@@ -582,7 +563,7 @@ CTaosInterface.prototype.openStream = function openStream(connection, sql, callb
if (!convertFunctions[fields[i]['type']]) { if (!convertFunctions[fields[i]['type']]) {
throw new errors.DatabaseError("Invalid data type returned from database"); throw new errors.DatabaseError("Invalid data type returned from database");
} }
blocks[i] = convertFunctions[fields[i]['type']](row, numOfRows2, fields[i]['bytes'], offset, isMicro); blocks[i] = convertFunctions[fields[i]['type']](row, numOfRows2, fields[i]['bytes'], offset, precision);
offset += fields[i]['bytes'] * numOfRows2; offset += fields[i]['bytes'] * numOfRows2;
} }
} }
......
const FieldTypes = require('./constants'); const FieldTypes = require('./constants');
const util = require('util');
/** /**
* Various objects such as TaosRow and TaosColumn that help make parsing data easier * Various objects such as TaosRow and TaosColumn that help make parsing data easier
* @module TaosObjects * @module TaosObjects
...@@ -14,7 +14,7 @@ const FieldTypes = require('./constants'); ...@@ -14,7 +14,7 @@ const FieldTypes = require('./constants');
* var trow = new TaosRow(row); * var trow = new TaosRow(row);
* console.log(trow.data); * console.log(trow.data);
*/ */
function TaosRow (row) { function TaosRow(row) {
this.data = row; this.data = row;
this.length = row.length; this.length = row.length;
return this; return this;
...@@ -42,25 +42,85 @@ function TaosField(field) { ...@@ -42,25 +42,85 @@ function TaosField(field) {
* @param {Date} date - A Javascript date time object or the time in milliseconds past 1970-1-1 00:00:00.000 * @param {Date} date - A Javascript date time object or the time in milliseconds past 1970-1-1 00:00:00.000
*/ */
class TaosTimestamp extends Date { class TaosTimestamp extends Date {
constructor(date, micro = false) { constructor(date, precision = 0) {
super(date); if (precision === 1) {
this._type = 'TaosTimestamp'; super(Math.floor(date / 1000));
if (micro) { this.precisionExtras = date % 1000;
this.microTime = date - Math.floor(date); } else if (precision === 2) {
super(parseInt(date / 1000000));
// use BigInt to fix: 1625801548423914405 % 1000000 = 914496 which not expected (914405)
this.precisionExtras = parseInt(BigInt(date) % 1000000n);
} else {
super(parseInt(date));
}
this.precision = precision;
}
/**
* TDengine raw timestamp.
* @returns raw taos timestamp (int64)
*/
taosTimestamp() {
if (this.precision == 1) {
return (this * 1000 + this.precisionExtras);
} else if (this.precision == 2) {
return (this * 1000000 + this.precisionExtras);
} else {
return Math.floor(this);
}
}
/**
* Gets the microseconds of a Date.
* @return {Int} A microseconds integer
*/
getMicroseconds() {
if (this.precision == 1) {
return this.getMilliseconds() * 1000 + this.precisionExtras;
} else if (this.precision == 2) {
return this.getMilliseconds() * 1000 + this.precisionExtras / 1000;
} else {
return 0;
}
}
/**
* Gets the nanoseconds of a TaosTimestamp.
* @return {Int} A nanoseconds integer
*/
getNanoseconds() {
if (this.precision == 1) {
return this.getMilliseconds() * 1000000 + this.precisionExtras * 1000;
} else if (this.precision == 2) {
return this.getMilliseconds() * 1000000 + this.precisionExtras;
} else {
return 0;
}
}
/**
* @returns {String} a string for timestamp string format
*/
_precisionExtra() {
if (this.precision == 1) {
return String(this.precisionExtras).padStart(3, '0');
} else if (this.precision == 2) {
return String(this.precisionExtras).padStart(6, '0');
} else {
return '';
} }
} }
/** /**
* @function Returns the date into a string usable by TDengine * @function Returns the date into a string usable by TDengine
* @return {string} A Taos Timestamp String * @return {string} A Taos Timestamp String
*/ */
toTaosString(){ toTaosString() {
var tzo = -this.getTimezoneOffset(), var tzo = -this.getTimezoneOffset(),
dif = tzo >= 0 ? '+' : '-', dif = tzo >= 0 ? '+' : '-',
pad = function(num) { pad = function (num) {
var norm = Math.floor(Math.abs(num)); var norm = Math.floor(Math.abs(num));
return (norm < 10 ? '0' : '') + norm; return (norm < 10 ? '0' : '') + norm;
}, },
pad2 = function(num) { pad2 = function (num) {
var norm = Math.floor(Math.abs(num)); var norm = Math.floor(Math.abs(num));
if (norm < 10) return '00' + norm; if (norm < 10) return '00' + norm;
if (norm < 100) return '0' + norm; if (norm < 100) return '0' + norm;
...@@ -73,8 +133,19 @@ class TaosTimestamp extends Date { ...@@ -73,8 +133,19 @@ class TaosTimestamp extends Date {
':' + pad(this.getMinutes()) + ':' + pad(this.getMinutes()) +
':' + pad(this.getSeconds()) + ':' + pad(this.getSeconds()) +
'.' + pad2(this.getMilliseconds()) + '.' + pad2(this.getMilliseconds()) +
'' + (this.microTime ? pad2(Math.round(this.microTime * 1000)) : ''); '' + this._precisionExtra();
}
/**
* Custom console.log
* @returns {String} string format for debug
*/
[util.inspect.custom](depth, opts) {
return this.toTaosString() + JSON.stringify({ precision: this.precision, precisionExtras: this.precisionExtras }, opts);
}
toString() {
return this.toTaosString();
} }
} }
module.exports = {TaosRow, TaosField, TaosTimestamp} module.exports = { TaosRow, TaosField, TaosTimestamp }
{ {
"name": "td2.0-connector", "name": "td2.0-connector",
"version": "2.0.8", "version": "2.0.9",
"description": "A Node.js connector for TDengine.", "description": "A Node.js connector for TDengine.",
"main": "tdengine.js", "main": "tdengine.js",
"directories": { "directories": {
"test": "test" "test": "test"
}, },
"scripts": { "scripts": {
"test": "node test/test.js" "test": "node test/test.js && node test/testMicroseconds.js && node test/testNanoseconds.js"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
......
var TDengineConnection = require('./nodetaos/connection.js') var TDengineConnection = require('./nodetaos/connection.js')
module.exports.connect = function (connection=null) { module.exports.connect = function (connection={}) {
return new TDengineConnection(connection); return new TDengineConnection(connection);
} }
const taos = require('../tdengine'); const taos = require('../tdengine');
var conn = taos.connect({host:"127.0.0.1", user:"root", password:"taosdata", config:"/etc/taos",port:10}); var conn = taos.connect();
var c1 = conn.cursor(); var c1 = conn.cursor();
let stime = new Date(); let stime = new Date();
let interval = 1000; let interval = 1000;
......
const taos = require('../tdengine');
var conn = taos.connect();
var c1 = conn.cursor();
let stime = new Date();
let interval = 1000;
function convertDateToTS(date) {
let tsArr = date.toISOString().split("T")
return "\"" + tsArr[0] + " " + tsArr[1].substring(0, tsArr[1].length - 1) + "\"";
}
function R(l, r) {
return Math.random() * (r - l) - r;
}
function randomBool() {
if (Math.random() < 0.5) {
return true;
}
return false;
}
// Initialize
//c1.execute('drop database td_connector_test;');
const dbname = 'nodejs_test_us';
c1.execute('create database if not exists ' + dbname + ' precision "us"');
c1.execute('use ' + dbname)
c1.execute('create table if not exists tstest (ts timestamp, _int int);');
c1.execute('insert into tstest values(1625801548423914, 0)');
// Select
console.log('select * from tstest');
c1.execute('select * from tstest');
var d = c1.fetchall();
console.log(c1.fields);
let ts = d[0][0];
console.log(ts);
if (ts.taosTimestamp() != 1625801548423914) {
throw "microseconds not match!";
}
if (ts.getMicroseconds() % 1000 !== 914) {
throw "micronsecond precision error";
}
setTimeout(function () {
c1.query('drop database nodejs_us_test;');
}, 200);
setTimeout(function () {
conn.close();
}, 2000);
const taos = require('../tdengine');
var conn = taos.connect();
var c1 = conn.cursor();
let stime = new Date();
let interval = 1000;
function convertDateToTS(date) {
let tsArr = date.toISOString().split("T")
return "\"" + tsArr[0] + " " + tsArr[1].substring(0, tsArr[1].length - 1) + "\"";
}
function R(l, r) {
return Math.random() * (r - l) - r;
}
function randomBool() {
if (Math.random() < 0.5) {
return true;
}
return false;
}
// Initialize
//c1.execute('drop database td_connector_test;');
const dbname = 'nodejs_test_ns';
c1.execute('create database if not exists ' + dbname + ' precision "ns"');
c1.execute('use ' + dbname)
c1.execute('create table if not exists tstest (ts timestamp, _int int);');
c1.execute('insert into tstest values(1625801548423914405, 0)');
// Select
console.log('select * from tstest');
c1.execute('select * from tstest');
var d = c1.fetchall();
console.log(c1.fields);
let ts = d[0][0];
console.log(ts);
if (ts.taosTimestamp() != 1625801548423914405) {
throw "nanosecond not match!";
}
if (ts.getNanoseconds() % 1000000 !== 914405) {
throw "nanosecond precision error";
}
setTimeout(function () {
c1.query('drop database nodejs_ns_test;');
}, 200);
setTimeout(function () {
conn.close();
}, 2000);
...@@ -169,6 +169,8 @@ DLL_EXPORT void taos_close_stream(TAOS_STREAM *tstr); ...@@ -169,6 +169,8 @@ DLL_EXPORT void taos_close_stream(TAOS_STREAM *tstr);
DLL_EXPORT int taos_load_table_info(TAOS *taos, const char* tableNameList); DLL_EXPORT int taos_load_table_info(TAOS *taos, const char* tableNameList);
DLL_EXPORT int taos_insert_lines(TAOS* taos, char* lines[], int numLines);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -236,6 +236,7 @@ typedef struct SArguments_S { ...@@ -236,6 +236,7 @@ typedef struct SArguments_S {
char ** arg_list; char ** arg_list;
uint64_t totalInsertRows; uint64_t totalInsertRows;
uint64_t totalAffectedRows; uint64_t totalAffectedRows;
bool demo_mode; // use default column name and semi-random data
} SArguments; } SArguments;
typedef struct SColumn_S { typedef struct SColumn_S {
...@@ -552,6 +553,8 @@ static int postProceSql(char *host, struct sockaddr_in *pServAddr, ...@@ -552,6 +553,8 @@ static int postProceSql(char *host, struct sockaddr_in *pServAddr,
uint16_t port, char* sqlstr, threadInfo *pThreadInfo); uint16_t port, char* sqlstr, threadInfo *pThreadInfo);
static int64_t getTSRandTail(int64_t timeStampStep, int32_t seq, static int64_t getTSRandTail(int64_t timeStampStep, int32_t seq,
int disorderRatio, int disorderRange); int disorderRatio, int disorderRange);
static bool getInfoFromJsonFile(char* file);
static void init_rand_data();
/* ************ Global variables ************ */ /* ************ Global variables ************ */
...@@ -569,16 +572,16 @@ SArguments g_args = { ...@@ -569,16 +572,16 @@ SArguments g_args = {
6030, // port 6030, // port
TAOSC_IFACE, // iface TAOSC_IFACE, // iface
"root", // user "root", // user
#ifdef _TD_POWER_ #ifdef _TD_POWER_
"powerdb", // password "powerdb", // password
#elif (_TD_TQ_ == true) #elif (_TD_TQ_ == true)
"tqueue", // password "tqueue", // password
#else #else
"taosdata", // password "taosdata", // password
#endif #endif
"test", // database "test", // database
1, // replica 1, // replica
"t", // tb_prefix "d", // tb_prefix
NULL, // sqlFile NULL, // sqlFile
true, // use_metric true, // use_metric
true, // drop_database true, // drop_database
...@@ -590,10 +593,9 @@ SArguments g_args = { ...@@ -590,10 +593,9 @@ SArguments g_args = {
"./output.txt", // output_file "./output.txt", // output_file
0, // mode : sync or async 0, // mode : sync or async
{ {
"FLOAT", // datatype
"INT", // datatype "INT", // datatype
"INT", // datatype "FLOAT", // datatype
"INT", // datatype
"INT", // datatype
}, },
16, // len_of_binary 16, // len_of_binary
4, // num_of_CPR 4, // num_of_CPR
...@@ -609,7 +611,10 @@ SArguments g_args = { ...@@ -609,7 +611,10 @@ SArguments g_args = {
0, // disorderRatio 0, // disorderRatio
1000, // disorderRange 1000, // disorderRange
1, // method_of_delete 1, // method_of_delete
NULL // arg_list NULL, // arg_list
0, // totalInsertRows;
0, // totalAffectedRows;
true, // demo_mode;
}; };
...@@ -709,7 +714,7 @@ static void printHelp() { ...@@ -709,7 +714,7 @@ static void printHelp() {
printf("%s%s%s%s\n", indent, "-a", indent, printf("%s%s%s%s\n", indent, "-a", indent,
"Set the replica parameters of the database, Default 1, min: 1, max: 3."); "Set the replica parameters of the database, Default 1, min: 1, max: 3.");
printf("%s%s%s%s\n", indent, "-m", indent, printf("%s%s%s%s\n", indent, "-m", indent,
"Table prefix name. Default is 't'."); "Table prefix name. Default is 'd'.");
printf("%s%s%s%s\n", indent, "-s", indent, "The select sql file."); printf("%s%s%s%s\n", indent, "-s", indent, "The select sql file.");
printf("%s%s%s%s\n", indent, "-N", indent, "Use normal table flag."); printf("%s%s%s%s\n", indent, "-N", indent, "Use normal table flag.");
printf("%s%s%s%s\n", indent, "-o", indent, printf("%s%s%s%s\n", indent, "-o", indent,
...@@ -717,11 +722,11 @@ static void printHelp() { ...@@ -717,11 +722,11 @@ static void printHelp() {
printf("%s%s%s%s\n", indent, "-q", indent, printf("%s%s%s%s\n", indent, "-q", indent,
"Query mode -- 0: SYNC, 1: ASYNC. Default is SYNC."); "Query mode -- 0: SYNC, 1: ASYNC. Default is SYNC.");
printf("%s%s%s%s\n", indent, "-b", indent, printf("%s%s%s%s\n", indent, "-b", indent,
"The data_type of columns, default: INT,INT,INT,INT."); "The data_type of columns, default: FLOAT, INT, FLOAT.");
printf("%s%s%s%s\n", indent, "-w", indent, printf("%s%s%s%s\n", indent, "-w", indent,
"The length of data_type 'BINARY' or 'NCHAR'. Default is 16"); "The length of data_type 'BINARY' or 'NCHAR'. Default is 16");
printf("%s%s%s%s%d\n", indent, "-l", indent, printf("%s%s%s%s%d\n", indent, "-l", indent,
"The number of columns per record. Default is 4. Max values is ", "The number of columns per record. Default is 3. Max values is ",
MAX_NUM_DATATYPE); MAX_NUM_DATATYPE);
printf("%s%s%s%s\n", indent, "-T", indent, printf("%s%s%s%s\n", indent, "-T", indent,
"The number of threads. Default is 10."); "The number of threads. Default is 10.");
...@@ -733,6 +738,10 @@ static void printHelp() { ...@@ -733,6 +738,10 @@ static void printHelp() {
"The number of tables. Default is 10000."); "The number of tables. Default is 10000.");
printf("%s%s%s%s\n", indent, "-n", indent, printf("%s%s%s%s\n", indent, "-n", indent,
"The number of records per table. Default is 10000."); "The number of records per table. Default is 10000.");
printf("%s%s%s%s\n", indent, "-M", indent,
"The value of records generated are totally random.");
printf("%s%s%s%s\n", indent, indent, indent,
" The default is to simulate power equipment senario.");
printf("%s%s%s%s\n", indent, "-x", indent, "Not insert only flag."); printf("%s%s%s%s\n", indent, "-x", indent, "Not insert only flag.");
printf("%s%s%s%s\n", indent, "-y", indent, "Default input yes for prompt."); printf("%s%s%s%s\n", indent, "-y", indent, "Default input yes for prompt.");
printf("%s%s%s%s\n", indent, "-O", indent, printf("%s%s%s%s\n", indent, "-O", indent,
...@@ -745,8 +754,8 @@ static void printHelp() { ...@@ -745,8 +754,8 @@ static void printHelp() {
"Print version info."); "Print version info.");
printf("%s%s%s%s\n", indent, "--help\t", indent, printf("%s%s%s%s\n", indent, "--help\t", indent,
"Print command line arguments list info."); "Print command line arguments list info.");
/* printf("%s%s%s%s\n", indent, "-D", indent, /* printf("%s%s%s%s\n", indent, "-D", indent,
"if elete database if exists. 0: no, 1: yes, default is 1"); "Delete database if exists. 0: no, 1: yes, default is 1");
*/ */
} }
...@@ -769,6 +778,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { ...@@ -769,6 +778,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
for (int i = 1; i < argc; i++) { for (int i = 1; i < argc; i++) {
if (strcmp(argv[i], "-f") == 0) { if (strcmp(argv[i], "-f") == 0) {
arguments->demo_mode = false;
arguments->metaFile = argv[++i]; arguments->metaFile = argv[++i];
} else if (strcmp(argv[i], "-c") == 0) { } else if (strcmp(argv[i], "-c") == 0) {
if (argc == i+1) { if (argc == i+1) {
...@@ -911,6 +921,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { ...@@ -911,6 +921,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
} }
arguments->database = argv[++i]; arguments->database = argv[++i];
} else if (strcmp(argv[i], "-l") == 0) { } else if (strcmp(argv[i], "-l") == 0) {
arguments->demo_mode = false;
if (argc == i+1) { if (argc == i+1) {
if (!isStringNumber(argv[i+1])) { if (!isStringNumber(argv[i+1])) {
printHelp(); printHelp();
...@@ -931,6 +942,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { ...@@ -931,6 +942,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
} }
} else if (strcmp(argv[i], "-b") == 0) { } else if (strcmp(argv[i], "-b") == 0) {
arguments->demo_mode = false;
if (argc == i+1) { if (argc == i+1) {
printHelp(); printHelp();
errorPrint("%s", "\n\t-b need valid string following!\n"); errorPrint("%s", "\n\t-b need valid string following!\n");
...@@ -1000,6 +1012,8 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { ...@@ -1000,6 +1012,8 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
arguments->tb_prefix = argv[++i]; arguments->tb_prefix = argv[++i];
} else if (strcmp(argv[i], "-N") == 0) { } else if (strcmp(argv[i], "-N") == 0) {
arguments->use_metric = false; arguments->use_metric = false;
} else if (strcmp(argv[i], "-M") == 0) {
arguments->demo_mode = false;
} else if (strcmp(argv[i], "-x") == 0) { } else if (strcmp(argv[i], "-x") == 0) {
arguments->insert_only = false; arguments->insert_only = false;
} else if (strcmp(argv[i], "-y") == 0) { } else if (strcmp(argv[i], "-y") == 0) {
...@@ -1133,8 +1147,6 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { ...@@ -1133,8 +1147,6 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
} }
} }
static bool getInfoFromJsonFile(char* file);
static void init_rand_data();
static void tmfclose(FILE *fp) { static void tmfclose(FILE *fp) {
if (NULL != fp) { if (NULL != fp) {
fclose(fp); fclose(fp);
...@@ -1231,7 +1243,8 @@ static void fetchResult(TAOS_RES *res, threadInfo* pThreadInfo) { ...@@ -1231,7 +1243,8 @@ static void fetchResult(TAOS_RES *res, threadInfo* pThreadInfo) {
//printf("query result:%s\n", temp); //printf("query result:%s\n", temp);
memcpy(databuf + totalLen, temp, len); memcpy(databuf + totalLen, temp, len);
totalLen += len; totalLen += len;
verbosePrint("%s() LN%d, totalLen: %"PRId64"\n", __func__, __LINE__, totalLen); verbosePrint("%s() LN%d, totalLen: %"PRId64"\n",
__func__, __LINE__, totalLen);
} }
verbosePrint("%s() LN%d, databuf=%s resultFile=%s\n", verbosePrint("%s() LN%d, databuf=%s resultFile=%s\n",
...@@ -1314,6 +1327,27 @@ static float rand_float(){ ...@@ -1314,6 +1327,27 @@ static float rand_float(){
return randfloat[cursor]; return randfloat[cursor];
} }
static float demo_current_float(){
static int cursor;
cursor++;
cursor = cursor % MAX_PREPARED_RAND;
return (float)(9.8 + 0.04 * (randint[cursor] % 10) + randfloat[cursor]/1000000000);
}
static int32_t demo_voltage_int(){
static int cursor;
cursor++;
cursor = cursor % MAX_PREPARED_RAND;
return 215 + randint[cursor] % 10;
}
static float demo_phase_float(){
static int cursor;
cursor++;
cursor = cursor % MAX_PREPARED_RAND;
return (float)((115 + randint[cursor] % 10 + randfloat[cursor]/1000000000)/360);
}
#if 0 #if 0
static const char charNum[] = "0123456789"; static const char charNum[] = "0123456789";
...@@ -1351,7 +1385,6 @@ static double rand_double() { ...@@ -1351,7 +1385,6 @@ static double rand_double() {
cursor++; cursor++;
cursor = cursor % MAX_PREPARED_RAND; cursor = cursor % MAX_PREPARED_RAND;
return randdouble[cursor]; return randdouble[cursor];
} }
static void init_rand_data() { static void init_rand_data() {
...@@ -1386,6 +1419,11 @@ static void init_rand_data() { ...@@ -1386,6 +1419,11 @@ static void init_rand_data() {
static int printfInsertMeta() { static int printfInsertMeta() {
SHOW_PARSE_RESULT_START(); SHOW_PARSE_RESULT_START();
if (g_args.demo_mode)
printf("\ntaosdemo is simulating data generated by power equipments monitoring...\n\n");
else
printf("\ntaosdemo is simulating random data as you request..\n\n");
printf("interface: \033[33m%s\033[0m\n", printf("interface: \033[33m%s\033[0m\n",
(g_args.iface==TAOSC_IFACE)?"taosc":(g_args.iface==REST_IFACE)?"rest":"stmt"); (g_args.iface==TAOSC_IFACE)?"taosc":(g_args.iface==REST_IFACE)?"rest":"stmt");
printf("host: \033[33m%s:%u\033[0m\n", printf("host: \033[33m%s:%u\033[0m\n",
...@@ -1519,7 +1557,7 @@ static int printfInsertMeta() { ...@@ -1519,7 +1557,7 @@ static int printfInsertMeta() {
} }
printf(" insertRows: \033[33m%"PRId64"\033[0m\n", printf(" insertRows: \033[33m%"PRId64"\033[0m\n",
g_Dbs.db[i].superTbls[j].insertRows); g_Dbs.db[i].superTbls[j].insertRows);
/* /*
if (0 == g_Dbs.db[i].superTbls[j].multiThreadWriteOneTbl) { if (0 == g_Dbs.db[i].superTbls[j].multiThreadWriteOneTbl) {
printf(" multiThreadWriteOneTbl: \033[33mno\033[0m\n"); printf(" multiThreadWriteOneTbl: \033[33mno\033[0m\n");
}else { }else {
...@@ -1707,7 +1745,7 @@ static void printfInsertMetaToFile(FILE* fp) { ...@@ -1707,7 +1745,7 @@ static void printfInsertMetaToFile(FILE* fp) {
fprintf(fp, " stable insert interval: %"PRIu64"\n", fprintf(fp, " stable insert interval: %"PRIu64"\n",
g_Dbs.db[i].superTbls[j].insertInterval); g_Dbs.db[i].superTbls[j].insertInterval);
} }
/* /*
if (0 == g_Dbs.db[i].superTbls[j].multiThreadWriteOneTbl) { if (0 == g_Dbs.db[i].superTbls[j].multiThreadWriteOneTbl) {
fprintf(fp, " multiThreadWriteOneTbl: no\n"); fprintf(fp, " multiThreadWriteOneTbl: no\n");
}else { }else {
...@@ -1863,7 +1901,7 @@ static char* formatTimestamp(char* buf, int64_t val, int precision) { ...@@ -1863,7 +1901,7 @@ static char* formatTimestamp(char* buf, int64_t val, int precision) {
tt = (time_t)(val / 1000); tt = (time_t)(val / 1000);
} }
/* comment out as it make testcases like select_with_tags.sim fail. /* comment out as it make testcases like select_with_tags.sim fail.
but in windows, this may cause the call to localtime crash if tt < 0, but in windows, this may cause the call to localtime crash if tt < 0,
need to find a better solution. need to find a better solution.
if (tt < 0) { if (tt < 0) {
...@@ -1943,7 +1981,8 @@ static int xDumpResultToFile(const char* fname, TAOS_RES* tres) { ...@@ -1943,7 +1981,8 @@ static int xDumpResultToFile(const char* fname, TAOS_RES* tres) {
FILE* fp = fopen(fname, "at"); FILE* fp = fopen(fname, "at");
if (fp == NULL) { if (fp == NULL) {
errorPrint("%s() LN%d, failed to open file: %s\n", __func__, __LINE__, fname); errorPrint("%s() LN%d, failed to open file: %s\n",
__func__, __LINE__, fname);
return -1; return -1;
} }
...@@ -1966,7 +2005,8 @@ static int xDumpResultToFile(const char* fname, TAOS_RES* tres) { ...@@ -1966,7 +2005,8 @@ static int xDumpResultToFile(const char* fname, TAOS_RES* tres) {
if (i > 0) { if (i > 0) {
fputc(',', fp); fputc(',', fp);
} }
xDumpFieldToFile(fp, (const char*)row[i], fields +i, length[i], precision); xDumpFieldToFile(fp,
(const char*)row[i], fields +i, length[i], precision);
} }
fputc('\n', fp); fputc('\n', fp);
...@@ -1988,7 +2028,8 @@ static int getDbFromServer(TAOS * taos, SDbInfo** dbInfos) { ...@@ -1988,7 +2028,8 @@ static int getDbFromServer(TAOS * taos, SDbInfo** dbInfos) {
int32_t code = taos_errno(res); int32_t code = taos_errno(res);
if (code != 0) { if (code != 0) {
errorPrint( "failed to run <show databases>, reason: %s\n", taos_errstr(res)); errorPrint( "failed to run <show databases>, reason: %s\n",
taos_errstr(res));
return -1; return -1;
} }
...@@ -2318,8 +2359,10 @@ static char* generateTagVaulesForStb(SSuperTable* stbInfo, int32_t tableSeq) { ...@@ -2318,8 +2359,10 @@ static char* generateTagVaulesForStb(SSuperTable* stbInfo, int32_t tableSeq) {
int dataLen = 0; int dataLen = 0;
dataLen += snprintf(dataBuf + dataLen, TSDB_MAX_SQL_LEN - dataLen, "("); dataLen += snprintf(dataBuf + dataLen, TSDB_MAX_SQL_LEN - dataLen, "(");
for (int i = 0; i < stbInfo->tagCount; i++) { for (int i = 0; i < stbInfo->tagCount; i++) {
if ((0 == strncasecmp(stbInfo->tags[i].dataType, "binary", strlen("binary"))) if ((0 == strncasecmp(stbInfo->tags[i].dataType,
|| (0 == strncasecmp(stbInfo->tags[i].dataType, "nchar", strlen("nchar")))) { "binary", strlen("binary")))
|| (0 == strncasecmp(stbInfo->tags[i].dataType,
"nchar", strlen("nchar")))) {
if (stbInfo->tags[i].dataLen > TSDB_MAX_BINARY_LEN) { if (stbInfo->tags[i].dataLen > TSDB_MAX_BINARY_LEN) {
printf("binary or nchar length overflow, max size:%u\n", printf("binary or nchar length overflow, max size:%u\n",
(uint32_t)TSDB_MAX_BINARY_LEN); (uint32_t)TSDB_MAX_BINARY_LEN);
...@@ -2664,13 +2707,20 @@ static int createSuperTable( ...@@ -2664,13 +2707,20 @@ static int createSuperTable(
superTbl->columns[colIndex].dataLen); superTbl->columns[colIndex].dataLen);
lenOfOneRow += superTbl->columns[colIndex].dataLen + 3; lenOfOneRow += superTbl->columns[colIndex].dataLen + 3;
} else if (strcasecmp(dataType, "INT") == 0) { } else if (strcasecmp(dataType, "INT") == 0) {
if ((g_args.demo_mode) && (colIndex == 1)) {
len += snprintf(cols + len, STRING_LEN - len,
", VOLTAGE INT");
} else {
len += snprintf(cols + len, STRING_LEN - len, ", col%d %s", colIndex, "INT"); len += snprintf(cols + len, STRING_LEN - len, ", col%d %s", colIndex, "INT");
}
lenOfOneRow += 11; lenOfOneRow += 11;
} else if (strcasecmp(dataType, "BIGINT") == 0) { } else if (strcasecmp(dataType, "BIGINT") == 0) {
len += snprintf(cols + len, STRING_LEN - len, ", col%d %s", colIndex, "BIGINT"); len += snprintf(cols + len, STRING_LEN - len, ", col%d %s",
colIndex, "BIGINT");
lenOfOneRow += 21; lenOfOneRow += 21;
} else if (strcasecmp(dataType, "SMALLINT") == 0) { } else if (strcasecmp(dataType, "SMALLINT") == 0) {
len += snprintf(cols + len, STRING_LEN - len, ", col%d %s", colIndex, "SMALLINT"); len += snprintf(cols + len, STRING_LEN - len, ", col%d %s",
colIndex, "SMALLINT");
lenOfOneRow += 6; lenOfOneRow += 6;
} else if (strcasecmp(dataType, "TINYINT") == 0) { } else if (strcasecmp(dataType, "TINYINT") == 0) {
len += snprintf(cols + len, STRING_LEN - len, ", col%d %s", colIndex, "TINYINT"); len += snprintf(cols + len, STRING_LEN - len, ", col%d %s", colIndex, "TINYINT");
...@@ -2679,13 +2729,24 @@ static int createSuperTable( ...@@ -2679,13 +2729,24 @@ static int createSuperTable(
len += snprintf(cols + len, STRING_LEN - len, ", col%d %s", colIndex, "BOOL"); len += snprintf(cols + len, STRING_LEN - len, ", col%d %s", colIndex, "BOOL");
lenOfOneRow += 6; lenOfOneRow += 6;
} else if (strcasecmp(dataType, "FLOAT") == 0) { } else if (strcasecmp(dataType, "FLOAT") == 0) {
if (g_args.demo_mode) {
if (colIndex == 0) {
len += snprintf(cols + len, STRING_LEN - len, ", CURRENT FLOAT");
} else if (colIndex == 2) {
len += snprintf(cols + len, STRING_LEN - len, ", PHASE FLOAT");
}
} else {
len += snprintf(cols + len, STRING_LEN - len, ", col%d %s", colIndex, "FLOAT"); len += snprintf(cols + len, STRING_LEN - len, ", col%d %s", colIndex, "FLOAT");
}
lenOfOneRow += 22; lenOfOneRow += 22;
} else if (strcasecmp(dataType, "DOUBLE") == 0) { } else if (strcasecmp(dataType, "DOUBLE") == 0) {
len += snprintf(cols + len, STRING_LEN - len, ", col%d %s", colIndex, "DOUBLE"); len += snprintf(cols + len, STRING_LEN - len, ", col%d %s",
colIndex, "DOUBLE");
lenOfOneRow += 42; lenOfOneRow += 42;
} else if (strcasecmp(dataType, "TIMESTAMP") == 0) { } else if (strcasecmp(dataType, "TIMESTAMP") == 0) {
len += snprintf(cols + len, STRING_LEN - len, ", col%d %s", colIndex, "TIMESTAMP"); len += snprintf(cols + len, STRING_LEN - len, ", col%d %s",
colIndex, "TIMESTAMP");
lenOfOneRow += 21; lenOfOneRow += 21;
} else { } else {
taos_close(taos); taos_close(taos);
...@@ -2696,7 +2757,6 @@ static int createSuperTable( ...@@ -2696,7 +2757,6 @@ static int createSuperTable(
} }
superTbl->lenOfOneRow = lenOfOneRow + 20; // timestamp superTbl->lenOfOneRow = lenOfOneRow + 20; // timestamp
//printf("%s.%s column count:%d, column length:%d\n\n", g_Dbs.db[i].dbName, g_Dbs.db[i].superTbl[j].sTblName, g_Dbs.db[i].superTbl[j].columnCount, lenOfOneRow);
// save for creating child table // save for creating child table
superTbl->colsOfCreateChildTable = (char*)calloc(len+20, 1); superTbl->colsOfCreateChildTable = (char*)calloc(len+20, 1);
...@@ -4746,15 +4806,16 @@ static void postFreeResource() { ...@@ -4746,15 +4806,16 @@ static void postFreeResource() {
static int getRowDataFromSample( static int getRowDataFromSample(
char* dataBuf, int64_t maxLen, int64_t timestamp, char* dataBuf, int64_t maxLen, int64_t timestamp,
SSuperTable* superTblInfo, int64_t* sampleUsePos) { SSuperTable* superTblInfo, int64_t* sampleUsePos)
{
if ((*sampleUsePos) == MAX_SAMPLES_ONCE_FROM_FILE) { if ((*sampleUsePos) == MAX_SAMPLES_ONCE_FROM_FILE) {
/* int ret = readSampleFromCsvFileToMem(superTblInfo); /* int ret = readSampleFromCsvFileToMem(superTblInfo);
if (0 != ret) { if (0 != ret) {
tmfree(superTblInfo->sampleDataBuf); tmfree(superTblInfo->sampleDataBuf);
superTblInfo->sampleDataBuf = NULL; superTblInfo->sampleDataBuf = NULL;
return -1; return -1;
} }
*/ */
*sampleUsePos = 0; *sampleUsePos = 0;
} }
...@@ -4763,7 +4824,9 @@ static int getRowDataFromSample( ...@@ -4763,7 +4824,9 @@ static int getRowDataFromSample(
dataLen += snprintf(dataBuf + dataLen, maxLen - dataLen, dataLen += snprintf(dataBuf + dataLen, maxLen - dataLen,
"(%" PRId64 ", ", timestamp); "(%" PRId64 ", ", timestamp);
dataLen += snprintf(dataBuf + dataLen, maxLen - dataLen, dataLen += snprintf(dataBuf + dataLen, maxLen - dataLen,
"%s", superTblInfo->sampleDataBuf + superTblInfo->lenOfOneRow * (*sampleUsePos)); "%s",
superTblInfo->sampleDataBuf
+ superTblInfo->lenOfOneRow * (*sampleUsePos));
dataLen += snprintf(dataBuf + dataLen, maxLen - dataLen, ")"); dataLen += snprintf(dataBuf + dataLen, maxLen - dataLen, ")");
(*sampleUsePos)++; (*sampleUsePos)++;
...@@ -4803,16 +4866,31 @@ static int64_t generateStbRowData( ...@@ -4803,16 +4866,31 @@ static int64_t generateStbRowData(
tmfree(buf); tmfree(buf);
} else if (0 == strncasecmp(stbInfo->columns[i].dataType, } else if (0 == strncasecmp(stbInfo->columns[i].dataType,
"INT", strlen("INT"))) { "INT", strlen("INT"))) {
if ((g_args.demo_mode) && (i == 1)) {
dataLen += snprintf(pstr + dataLen, maxLen - dataLen,
"%d,", demo_voltage_int());
} else {
dataLen += snprintf(pstr + dataLen, maxLen - dataLen, dataLen += snprintf(pstr + dataLen, maxLen - dataLen,
"%d,", rand_int()); "%d,", rand_int());
}
} else if (0 == strncasecmp(stbInfo->columns[i].dataType, } else if (0 == strncasecmp(stbInfo->columns[i].dataType,
"BIGINT", strlen("BIGINT"))) { "BIGINT", strlen("BIGINT"))) {
dataLen += snprintf(pstr + dataLen, maxLen - dataLen, dataLen += snprintf(pstr + dataLen, maxLen - dataLen,
"%"PRId64",", rand_bigint()); "%"PRId64",", rand_bigint());
} else if (0 == strncasecmp(stbInfo->columns[i].dataType, } else if (0 == strncasecmp(stbInfo->columns[i].dataType,
"FLOAT", strlen("FLOAT"))) { "FLOAT", strlen("FLOAT"))) {
if (g_args.demo_mode) {
if (i == 0) {
dataLen += snprintf(pstr + dataLen, maxLen - dataLen,
"%f,", demo_current_float());
} else {
dataLen += snprintf(pstr + dataLen, maxLen - dataLen,
"%f,", demo_phase_float());
}
} else {
dataLen += snprintf(pstr + dataLen, maxLen - dataLen, dataLen += snprintf(pstr + dataLen, maxLen - dataLen,
"%f,", rand_float()); "%f,", rand_float());
}
} else if (0 == strncasecmp(stbInfo->columns[i].dataType, } else if (0 == strncasecmp(stbInfo->columns[i].dataType,
"DOUBLE", strlen("DOUBLE"))) { "DOUBLE", strlen("DOUBLE"))) {
dataLen += snprintf(pstr + dataLen, maxLen - dataLen, dataLen += snprintf(pstr + dataLen, maxLen - dataLen,
...@@ -6008,8 +6086,10 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) { ...@@ -6008,8 +6086,10 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
errorPrint("[%d] %s() LN%d Failed to insert records of batch %d\n", errorPrint("[%d] %s() LN%d Failed to insert records of batch %d\n",
pThreadInfo->threadID, __func__, __LINE__, pThreadInfo->threadID, __func__, __LINE__,
batchPerTbl); batchPerTbl);
if (batchPerTbl > 0) {
errorPrint("\tIf the batch is %d, the length of the SQL to insert a row must be less then %"PRId64"\n", errorPrint("\tIf the batch is %d, the length of the SQL to insert a row must be less then %"PRId64"\n",
batchPerTbl, maxSqlLen / batchPerTbl); batchPerTbl, maxSqlLen / batchPerTbl);
}
errorPrint("\tPlease check if the buffer length(%"PRId64") or batch(%d) is set with proper value!\n", errorPrint("\tPlease check if the buffer length(%"PRId64") or batch(%d) is set with proper value!\n",
maxSqlLen, batchPerTbl); maxSqlLen, batchPerTbl);
goto free_of_interlace; goto free_of_interlace;
......
...@@ -124,6 +124,9 @@ typedef struct { ...@@ -124,6 +124,9 @@ typedef struct {
extern char version[]; extern char version[];
#define DB_PRECISION_LEN 8
#define DB_STATUS_LEN 16
typedef struct { typedef struct {
char name[TSDB_DB_NAME_LEN]; char name[TSDB_DB_NAME_LEN];
char create_time[32]; char create_time[32];
...@@ -144,9 +147,9 @@ typedef struct { ...@@ -144,9 +147,9 @@ typedef struct {
int32_t fsync; int32_t fsync;
int8_t comp; int8_t comp;
int8_t cachelast; int8_t cachelast;
char precision[8]; // time resolution char precision[DB_PRECISION_LEN]; // time resolution
int8_t update; int8_t update;
char status[16]; char status[DB_STATUS_LEN];
} SDbInfo; } SDbInfo;
typedef struct { typedef struct {
...@@ -542,7 +545,8 @@ static void parse_precision_first( ...@@ -542,7 +545,8 @@ static void parse_precision_first(
free(tmp); free(tmp);
exit(-1); exit(-1);
} }
strncpy(g_args.precision, tmp, strlen(tmp)); strncpy(g_args.precision, tmp,
min(DB_PRECISION_LEN - 1, strlen(tmp)));
free(tmp); free(tmp);
} }
} }
...@@ -1596,6 +1600,7 @@ static void taosStartDumpOutWorkThreads(int32_t numOfThread, char *dbName) ...@@ -1596,6 +1600,7 @@ static void taosStartDumpOutWorkThreads(int32_t numOfThread, char *dbName)
NULL, g_args.port); NULL, g_args.port);
if (pThread->taosCon == NULL) { if (pThread->taosCon == NULL) {
errorPrint("Failed to connect to TDengine server %s\n", g_args.host); errorPrint("Failed to connect to TDengine server %s\n", g_args.host);
free(threadObj);
return; return;
} }
pthread_attr_init(&thattr); pthread_attr_init(&thattr);
...@@ -2607,6 +2612,7 @@ static void taosStartDumpInWorkThreads() ...@@ -2607,6 +2612,7 @@ static void taosStartDumpInWorkThreads()
NULL, g_args.port); NULL, g_args.port);
if (pThread->taosCon == NULL) { if (pThread->taosCon == NULL) {
errorPrint("Failed to connect to TDengine server %s\n", g_args.host); errorPrint("Failed to connect to TDengine server %s\n", g_args.host);
free(threadObj);
return; return;
} }
pthread_attr_init(&thattr); pthread_attr_init(&thattr);
......
...@@ -105,8 +105,7 @@ typedef struct SResultRowInfo { ...@@ -105,8 +105,7 @@ typedef struct SResultRowInfo {
int16_t type:8; // data type for hash key int16_t type:8; // data type for hash key
int32_t size:24; // number of result set int32_t size:24; // number of result set
int32_t capacity; // max capacity int32_t capacity; // max capacity
SResultRow* current; // current start active index int32_t curPos; // current active result row index of pResult list
int64_t prevSKey; // previous (not completed) sliding window start key
} SResultRowInfo; } SResultRowInfo;
typedef struct SColumnFilterElem { typedef struct SColumnFilterElem {
...@@ -277,6 +276,7 @@ typedef struct SQueryRuntimeEnv { ...@@ -277,6 +276,7 @@ typedef struct SQueryRuntimeEnv {
bool enableGroupData; bool enableGroupData;
SDiskbasedResultBuf* pResultBuf; // query result buffer based on blocked-wised disk file SDiskbasedResultBuf* pResultBuf; // query result buffer based on blocked-wised disk file
SHashObj* pResultRowHashTable; // quick locate the window object for each result SHashObj* pResultRowHashTable; // quick locate the window object for each result
SHashObj* pResultRowListSet; // used to check if current ResultRowInfo has ResultRow object or not
char* keyBuf; // window key buffer char* keyBuf; // window key buffer
SResultRowPool* pool; // window result object pool SResultRowPool* pool; // window result object pool
char** prevRow; char** prevRow;
...@@ -423,7 +423,7 @@ typedef struct STagScanInfo { ...@@ -423,7 +423,7 @@ typedef struct STagScanInfo {
SColumnInfo* pCols; SColumnInfo* pCols;
SSDataBlock* pRes; SSDataBlock* pRes;
int32_t totalTables; int32_t totalTables;
int32_t currentIndex; int32_t curPos;
} STagScanInfo; } STagScanInfo;
typedef struct SOptrBasicInfo { typedef struct SOptrBasicInfo {
......
...@@ -303,11 +303,13 @@ alter_db_optr(Y) ::= alter_db_optr(Z) quorum(X). { Y = Z; Y.quorum = strtol ...@@ -303,11 +303,13 @@ alter_db_optr(Y) ::= alter_db_optr(Z) quorum(X). { Y = Z; Y.quorum = strtol
alter_db_optr(Y) ::= alter_db_optr(Z) keep(X). { Y = Z; Y.keep = X; } alter_db_optr(Y) ::= alter_db_optr(Z) keep(X). { Y = Z; Y.keep = X; }
alter_db_optr(Y) ::= alter_db_optr(Z) blocks(X). { Y = Z; Y.numOfBlocks = strtol(X.z, NULL, 10); } alter_db_optr(Y) ::= alter_db_optr(Z) blocks(X). { Y = Z; Y.numOfBlocks = strtol(X.z, NULL, 10); }
alter_db_optr(Y) ::= alter_db_optr(Z) comp(X). { Y = Z; Y.compressionLevel = strtol(X.z, NULL, 10); } alter_db_optr(Y) ::= alter_db_optr(Z) comp(X). { Y = Z; Y.compressionLevel = strtol(X.z, NULL, 10); }
alter_db_optr(Y) ::= alter_db_optr(Z) wal(X). { Y = Z; Y.walLevel = strtol(X.z, NULL, 10); }
alter_db_optr(Y) ::= alter_db_optr(Z) fsync(X). { Y = Z; Y.fsyncPeriod = strtol(X.z, NULL, 10); }
alter_db_optr(Y) ::= alter_db_optr(Z) update(X). { Y = Z; Y.update = strtol(X.z, NULL, 10); } alter_db_optr(Y) ::= alter_db_optr(Z) update(X). { Y = Z; Y.update = strtol(X.z, NULL, 10); }
alter_db_optr(Y) ::= alter_db_optr(Z) cachelast(X). { Y = Z; Y.cachelast = strtol(X.z, NULL, 10); } alter_db_optr(Y) ::= alter_db_optr(Z) cachelast(X). { Y = Z; Y.cachelast = strtol(X.z, NULL, 10); }
// dynamically update the following two parameters are not allowed.
//alter_db_optr(Y) ::= alter_db_optr(Z) fsync(X). { Y = Z; Y.fsyncPeriod = strtol(X.z, NULL, 10); }
//alter_db_optr(Y) ::= alter_db_optr(Z) wal(X). { Y = Z; Y.walLevel = strtol(X.z, NULL, 10); } not support yet
%type alter_topic_optr {SCreateDbInfo} %type alter_topic_optr {SCreateDbInfo}
alter_topic_optr(Y) ::= alter_db_optr(Z). { Y = Z; Y.dbType = TSDB_DB_TYPE_TOPIC; } alter_topic_optr(Y) ::= alter_db_optr(Z). { Y = Z; Y.dbType = TSDB_DB_TYPE_TOPIC; }
......
...@@ -242,6 +242,7 @@ static void sortGroupResByOrderList(SGroupResInfo *pGroupResInfo, SQueryRuntimeE ...@@ -242,6 +242,7 @@ static void sortGroupResByOrderList(SGroupResInfo *pGroupResInfo, SQueryRuntimeE
if (size <= 0) { if (size <= 0) {
return; return;
} }
int32_t orderId = pRuntimeEnv->pQueryAttr->order.orderColId; int32_t orderId = pRuntimeEnv->pQueryAttr->order.orderColId;
if (orderId <= 0) { if (orderId <= 0) {
return; return;
...@@ -410,25 +411,10 @@ static void prepareResultListBuffer(SResultRowInfo* pResultRowInfo, SQueryRuntim ...@@ -410,25 +411,10 @@ static void prepareResultListBuffer(SResultRowInfo* pResultRowInfo, SQueryRuntim
pResultRowInfo->capacity = (int32_t)newCapacity; pResultRowInfo->capacity = (int32_t)newCapacity;
} }
static int32_t ascResultRowCompareFn(const void* p1, const void* p2) { static SResultRow* doSetResultOutBufByKey(SQueryRuntimeEnv* pRuntimeEnv, SResultRowInfo* pResultRowInfo, int64_t tid,
SResultRow* pRow1 = *(SResultRow**)p1; char* pData, int16_t bytes, bool masterscan, uint64_t tableGroupId) {
SResultRow* pRow2 = *(SResultRow**)p2;
if (pRow1 == pRow2) {
return 0;
} else {
return pRow1->win.skey < pRow2->win.skey? -1:1;
}
}
static int32_t descResultRowCompareFn(const void* p1, const void* p2) {
return -ascResultRowCompareFn(p1, p2);
}
static SResultRow *doPrepareResultRowFromKey(SQueryRuntimeEnv *pRuntimeEnv, SResultRowInfo *pResultRowInfo, char *pData,
int16_t bytes, bool masterscan, uint64_t uid) {
bool existed = false; bool existed = false;
SET_RES_WINDOW_KEY(pRuntimeEnv->keyBuf, pData, bytes, uid); SET_RES_WINDOW_KEY(pRuntimeEnv->keyBuf, pData, bytes, tableGroupId);
SResultRow **p1 = SResultRow **p1 =
(SResultRow **)taosHashGet(pRuntimeEnv->pResultRowHashTable, pRuntimeEnv->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes)); (SResultRow **)taosHashGet(pRuntimeEnv->pResultRowHashTable, pRuntimeEnv->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes));
...@@ -440,22 +426,26 @@ static SResultRow *doPrepareResultRowFromKey(SQueryRuntimeEnv *pRuntimeEnv, SRes ...@@ -440,22 +426,26 @@ static SResultRow *doPrepareResultRowFromKey(SQueryRuntimeEnv *pRuntimeEnv, SRes
} }
if (p1 != NULL) { if (p1 != NULL) {
pResultRowInfo->current = (*p1);
if (pResultRowInfo->size == 0) { if (pResultRowInfo->size == 0) {
existed = false; existed = false;
assert(pResultRowInfo->curPos == -1);
} else if (pResultRowInfo->size == 1) { } else if (pResultRowInfo->size == 1) {
existed = (pResultRowInfo->pResult[0] == (*p1)); existed = (pResultRowInfo->pResult[0] == (*p1));
} else { pResultRowInfo->curPos = 0;
__compar_fn_t fn = QUERY_IS_ASC_QUERY(pRuntimeEnv->pQueryAttr)? ascResultRowCompareFn:descResultRowCompareFn; } else { // check if current pResultRowInfo contains the existed pResultRow
void* ptr = taosbsearch(p1, pResultRowInfo->pResult, pResultRowInfo->size, POINTER_BYTES, fn, TD_EQ); SET_RES_WINDOW_KEY(pRuntimeEnv->keyBuf, pData, bytes, tid);
if (ptr != NULL) { int64_t* index = taosHashGet(pRuntimeEnv->pResultRowListSet, pRuntimeEnv->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes));
if (index != NULL) {
pResultRowInfo->curPos = (int32_t) *index;
existed = true; existed = true;
} else {
existed = false;
} }
} }
} }
} else { } else {
if (p1 != NULL) { // group by column query // In case of group by column query, the required SResultRow object must be existed in the pResultRowInfo object.
if (p1 != NULL) {
return *p1; return *p1;
} }
} }
...@@ -477,8 +467,12 @@ static SResultRow *doPrepareResultRowFromKey(SQueryRuntimeEnv *pRuntimeEnv, SRes ...@@ -477,8 +467,12 @@ static SResultRow *doPrepareResultRowFromKey(SQueryRuntimeEnv *pRuntimeEnv, SRes
pResult = *p1; pResult = *p1;
} }
pResultRowInfo->curPos = pResultRowInfo->size;
pResultRowInfo->pResult[pResultRowInfo->size++] = pResult; pResultRowInfo->pResult[pResultRowInfo->size++] = pResult;
pResultRowInfo->current = pResult;
int64_t index = pResultRowInfo->curPos;
SET_RES_WINDOW_KEY(pRuntimeEnv->keyBuf, pData, bytes, tid);
taosHashPut(pRuntimeEnv->pResultRowListSet, pRuntimeEnv->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes), &index, POINTER_BYTES);
} }
// too many time window in query // too many time window in query
...@@ -486,7 +480,7 @@ static SResultRow *doPrepareResultRowFromKey(SQueryRuntimeEnv *pRuntimeEnv, SRes ...@@ -486,7 +480,7 @@ static SResultRow *doPrepareResultRowFromKey(SQueryRuntimeEnv *pRuntimeEnv, SRes
longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_TOO_MANY_TIMEWINDOW); longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_TOO_MANY_TIMEWINDOW);
} }
return pResultRowInfo->current; return pResultRowInfo->pResult[pResultRowInfo->curPos];
} }
static void getInitialStartTimeWindow(SQueryAttr* pQueryAttr, TSKEY ts, STimeWindow* w) { static void getInitialStartTimeWindow(SQueryAttr* pQueryAttr, TSKEY ts, STimeWindow* w) {
...@@ -517,13 +511,8 @@ static void getInitialStartTimeWindow(SQueryAttr* pQueryAttr, TSKEY ts, STimeWin ...@@ -517,13 +511,8 @@ static void getInitialStartTimeWindow(SQueryAttr* pQueryAttr, TSKEY ts, STimeWin
static STimeWindow getActiveTimeWindow(SResultRowInfo * pResultRowInfo, int64_t ts, SQueryAttr *pQueryAttr) { static STimeWindow getActiveTimeWindow(SResultRowInfo * pResultRowInfo, int64_t ts, SQueryAttr *pQueryAttr) {
STimeWindow w = {0}; STimeWindow w = {0};
if (pResultRowInfo->current == NULL) { // the first window, from the previous stored value if (pResultRowInfo->curPos == -1) { // the first window, from the previous stored value
if (pResultRowInfo->prevSKey == TSKEY_INITIAL_VAL) {
getInitialStartTimeWindow(pQueryAttr, ts, &w); getInitialStartTimeWindow(pQueryAttr, ts, &w);
pResultRowInfo->prevSKey = w.skey;
} else {
w.skey = pResultRowInfo->prevSKey;
}
if (pQueryAttr->interval.intervalUnit == 'n' || pQueryAttr->interval.intervalUnit == 'y') { if (pQueryAttr->interval.intervalUnit == 'n' || pQueryAttr->interval.intervalUnit == 'y') {
w.ekey = taosTimeAdd(w.skey, pQueryAttr->interval.interval, pQueryAttr->interval.intervalUnit, pQueryAttr->precision) - 1; w.ekey = taosTimeAdd(w.skey, pQueryAttr->interval.interval, pQueryAttr->interval.intervalUnit, pQueryAttr->precision) - 1;
...@@ -531,10 +520,7 @@ static STimeWindow getActiveTimeWindow(SResultRowInfo * pResultRowInfo, int64_t ...@@ -531,10 +520,7 @@ static STimeWindow getActiveTimeWindow(SResultRowInfo * pResultRowInfo, int64_t
w.ekey = w.skey + pQueryAttr->interval.interval - 1; w.ekey = w.skey + pQueryAttr->interval.interval - 1;
} }
} else { } else {
// int32_t slot = curTimeWindowIndex(pResultRowInfo); w = getResultRow(pResultRowInfo, pResultRowInfo->curPos)->win;
// SResultRow* pWindowRes = getResultRow(pResultRowInfo, slot);
SResultRow* pWindowRes = pResultRowInfo->current;
w = pWindowRes->win;
} }
if (w.skey > ts || w.ekey < ts) { if (w.skey > ts || w.ekey < ts) {
...@@ -614,13 +600,13 @@ static int32_t addNewWindowResultBuf(SResultRow *pWindowRes, SDiskbasedResultBuf ...@@ -614,13 +600,13 @@ static int32_t addNewWindowResultBuf(SResultRow *pWindowRes, SDiskbasedResultBuf
return 0; return 0;
} }
static int32_t setWindowOutputBufByKey(SQueryRuntimeEnv *pRuntimeEnv, SResultRowInfo *pResultRowInfo, STimeWindow *win, static int32_t setResultOutputBufByKey(SQueryRuntimeEnv *pRuntimeEnv, SResultRowInfo *pResultRowInfo, int64_t tid, STimeWindow *win,
bool masterscan, SResultRow **pResult, int64_t groupId, SQLFunctionCtx* pCtx, bool masterscan, SResultRow **pResult, int64_t tableGroupId, SQLFunctionCtx* pCtx,
int32_t numOfOutput, int32_t* rowCellInfoOffset) { int32_t numOfOutput, int32_t* rowCellInfoOffset) {
assert(win->skey <= win->ekey); assert(win->skey <= win->ekey);
SDiskbasedResultBuf *pResultBuf = pRuntimeEnv->pResultBuf; SDiskbasedResultBuf *pResultBuf = pRuntimeEnv->pResultBuf;
SResultRow *pResultRow = doPrepareResultRowFromKey(pRuntimeEnv, pResultRowInfo, (char *)&win->skey, TSDB_KEYSIZE, masterscan, groupId); SResultRow *pResultRow = doSetResultOutBufByKey(pRuntimeEnv, pResultRowInfo, tid, (char *)&win->skey, TSDB_KEYSIZE, masterscan, tableGroupId);
if (pResultRow == NULL) { if (pResultRow == NULL) {
*pResult = NULL; *pResult = NULL;
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
...@@ -628,7 +614,7 @@ static int32_t setWindowOutputBufByKey(SQueryRuntimeEnv *pRuntimeEnv, SResultRow ...@@ -628,7 +614,7 @@ static int32_t setWindowOutputBufByKey(SQueryRuntimeEnv *pRuntimeEnv, SResultRow
// not assign result buffer yet, add new result buffer // not assign result buffer yet, add new result buffer
if (pResultRow->pageId == -1) { if (pResultRow->pageId == -1) {
int32_t ret = addNewWindowResultBuf(pResultRow, pResultBuf, (int32_t) groupId, pRuntimeEnv->pQueryAttr->intermediateResultRowSize); int32_t ret = addNewWindowResultBuf(pResultRow, pResultBuf, (int32_t) tableGroupId, pRuntimeEnv->pQueryAttr->intermediateResultRowSize);
if (ret != TSDB_CODE_SUCCESS) { if (ret != TSDB_CODE_SUCCESS) {
return -1; return -1;
} }
...@@ -721,9 +707,10 @@ static void doUpdateResultRowIndex(SResultRowInfo*pResultRowInfo, TSKEY lastKey, ...@@ -721,9 +707,10 @@ static void doUpdateResultRowIndex(SResultRowInfo*pResultRowInfo, TSKEY lastKey,
if (skey == TSKEY_INITIAL_VAL) { if (skey == TSKEY_INITIAL_VAL) {
if (pResultRowInfo->size == 0) { if (pResultRowInfo->size == 0) {
// assert(pResultRowInfo->current == NULL); // assert(pResultRowInfo->current == NULL);
pResultRowInfo->current = NULL; assert(pResultRowInfo->curPos == -1);
pResultRowInfo->curPos = -1;
} else { } else {
pResultRowInfo->current = pResultRowInfo->pResult[pResultRowInfo->size - 1]; pResultRowInfo->curPos = pResultRowInfo->size - 1;
} }
} else { } else {
...@@ -735,12 +722,10 @@ static void doUpdateResultRowIndex(SResultRowInfo*pResultRowInfo, TSKEY lastKey, ...@@ -735,12 +722,10 @@ static void doUpdateResultRowIndex(SResultRowInfo*pResultRowInfo, TSKEY lastKey,
} }
if (i == pResultRowInfo->size - 1) { if (i == pResultRowInfo->size - 1) {
pResultRowInfo->current = pResultRowInfo->pResult[i]; pResultRowInfo->curPos = i;
} else { } else {
pResultRowInfo->current = pResultRowInfo->pResult[i + 1]; // current not closed result object pResultRowInfo->curPos = i + 1; // current not closed result object
} }
pResultRowInfo->prevSKey = pResultRowInfo->current->win.skey;
} }
} }
...@@ -748,7 +733,7 @@ static void updateResultRowInfoActiveIndex(SResultRowInfo* pResultRowInfo, SQuer ...@@ -748,7 +733,7 @@ static void updateResultRowInfoActiveIndex(SResultRowInfo* pResultRowInfo, SQuer
bool ascQuery = QUERY_IS_ASC_QUERY(pQueryAttr); bool ascQuery = QUERY_IS_ASC_QUERY(pQueryAttr);
if ((lastKey > pQueryAttr->window.ekey && ascQuery) || (lastKey < pQueryAttr->window.ekey && (!ascQuery))) { if ((lastKey > pQueryAttr->window.ekey && ascQuery) || (lastKey < pQueryAttr->window.ekey && (!ascQuery))) {
closeAllResultRows(pResultRowInfo); closeAllResultRows(pResultRowInfo);
pResultRowInfo->current = pResultRowInfo->pResult[pResultRowInfo->size - 1]; pResultRowInfo->curPos = pResultRowInfo->size - 1;
} else { } else {
int32_t step = ascQuery ? 1 : -1; int32_t step = ascQuery ? 1 : -1;
doUpdateResultRowIndex(pResultRowInfo, lastKey - step, ascQuery, pQueryAttr->timeWindowInterpo); doUpdateResultRowIndex(pResultRowInfo, lastKey - step, ascQuery, pQueryAttr->timeWindowInterpo);
...@@ -1247,7 +1232,7 @@ static void doWindowBorderInterpolation(SOperatorInfo* pOperatorInfo, SSDataBloc ...@@ -1247,7 +1232,7 @@ static void doWindowBorderInterpolation(SOperatorInfo* pOperatorInfo, SSDataBloc
} }
} }
static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResultRowInfo, SSDataBlock* pSDataBlock, int32_t groupId) { static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResultRowInfo, SSDataBlock* pSDataBlock, int32_t tableGroupId) {
STableIntervalOperatorInfo* pInfo = (STableIntervalOperatorInfo*) pOperatorInfo->info; STableIntervalOperatorInfo* pInfo = (STableIntervalOperatorInfo*) pOperatorInfo->info;
SQueryRuntimeEnv* pRuntimeEnv = pOperatorInfo->pRuntimeEnv; SQueryRuntimeEnv* pRuntimeEnv = pOperatorInfo->pRuntimeEnv;
...@@ -1257,8 +1242,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul ...@@ -1257,8 +1242,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
int32_t step = GET_FORWARD_DIRECTION_FACTOR(pQueryAttr->order.order); int32_t step = GET_FORWARD_DIRECTION_FACTOR(pQueryAttr->order.order);
bool ascQuery = QUERY_IS_ASC_QUERY(pQueryAttr); bool ascQuery = QUERY_IS_ASC_QUERY(pQueryAttr);
SResultRow* prevRow = pResultRowInfo->current; int32_t prevIndex = pResultRowInfo->curPos;
// int32_t prevIndex = curTimeWindowIndex(pResultRowInfo);
TSKEY* tsCols = NULL; TSKEY* tsCols = NULL;
if (pSDataBlock->pDataBlock != NULL) { if (pSDataBlock->pDataBlock != NULL) {
...@@ -1275,7 +1259,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul ...@@ -1275,7 +1259,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
bool masterScan = IS_MASTER_SCAN(pRuntimeEnv); bool masterScan = IS_MASTER_SCAN(pRuntimeEnv);
SResultRow* pResult = NULL; SResultRow* pResult = NULL;
int32_t ret = setWindowOutputBufByKey(pRuntimeEnv, pResultRowInfo, &win, masterScan, &pResult, groupId, pInfo->pCtx, int32_t ret = setResultOutputBufByKey(pRuntimeEnv, pResultRowInfo, pSDataBlock->info.tid, &win, masterScan, &pResult, tableGroupId, pInfo->pCtx,
numOfOutput, pInfo->rowCellInfoOffset); numOfOutput, pInfo->rowCellInfoOffset);
if (ret != TSDB_CODE_SUCCESS || pResult == NULL) { if (ret != TSDB_CODE_SUCCESS || pResult == NULL) {
longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_OUT_OF_MEMORY); longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
...@@ -1287,33 +1271,26 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul ...@@ -1287,33 +1271,26 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
getNumOfRowsInTimeWindow(pRuntimeEnv, &pSDataBlock->info, tsCols, startPos, ekey, binarySearchForKey, true); getNumOfRowsInTimeWindow(pRuntimeEnv, &pSDataBlock->info, tsCols, startPos, ekey, binarySearchForKey, true);
// prev time window not interpolation yet. // prev time window not interpolation yet.
// int32_t curIndex = curTimeWindowIndex(pResultRowInfo); int32_t curIndex = pResultRowInfo->curPos;
// if (prevIndex != -1 && prevIndex < curIndex && pQueryAttr->timeWindowInterpo) { if (prevIndex != -1 && prevIndex < curIndex && pQueryAttr->timeWindowInterpo) {
// for (int32_t j = prevIndex; j < curIndex; ++j) { // previous time window may be all closed already. for (int32_t j = prevIndex; j < curIndex; ++j) { // previous time window may be all closed already.
if (prevRow != NULL && prevRow != pResultRowInfo->current && pQueryAttr->timeWindowInterpo) { SResultRow* pRes = getResultRow(pResultRowInfo, j);
int32_t j = 0;
while(pResultRowInfo->pResult[j] != prevRow) {
j++;
}
for(; pResultRowInfo->pResult[j] != pResultRowInfo->current; ++j) {
SResultRow* pRes = pResultRowInfo->pResult[j];
if (pRes->closed) { if (pRes->closed) {
assert(resultRowInterpolated(pRes, RESULT_ROW_START_INTERP) && resultRowInterpolated(pRes, RESULT_ROW_END_INTERP)); assert(resultRowInterpolated(pRes, RESULT_ROW_START_INTERP) && resultRowInterpolated(pRes, RESULT_ROW_END_INTERP));
continue; continue;
} }
STimeWindow w = pRes->win; STimeWindow w = pRes->win;
ret = setWindowOutputBufByKey(pRuntimeEnv, pResultRowInfo, &w, masterScan, &pResult, groupId, pInfo->pCtx, ret = setResultOutputBufByKey(pRuntimeEnv, pResultRowInfo, pSDataBlock->info.tid, &w, masterScan, &pResult,
numOfOutput, pInfo->rowCellInfoOffset); tableGroupId, pInfo->pCtx, numOfOutput, pInfo->rowCellInfoOffset);
if (ret != TSDB_CODE_SUCCESS) { if (ret != TSDB_CODE_SUCCESS) {
longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_OUT_OF_MEMORY); longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
} }
assert(!resultRowInterpolated(pResult, RESULT_ROW_END_INTERP)); assert(!resultRowInterpolated(pResult, RESULT_ROW_END_INTERP));
doTimeWindowInterpolation(pOperatorInfo, pInfo, pSDataBlock->pDataBlock, *(TSKEY *)pRuntimeEnv->prevRow[0], doTimeWindowInterpolation(pOperatorInfo, pInfo, pSDataBlock->pDataBlock, *(TSKEY*)pRuntimeEnv->prevRow[0], -1,
-1, tsCols[startPos], startPos, w.ekey, RESULT_ROW_END_INTERP); tsCols[startPos], startPos, w.ekey, RESULT_ROW_END_INTERP);
setResultRowInterpo(pResult, RESULT_ROW_END_INTERP); setResultRowInterpo(pResult, RESULT_ROW_END_INTERP);
setNotInterpoWindowKey(pInfo->pCtx, pQueryAttr->numOfOutput, RESULT_ROW_START_INTERP); setNotInterpoWindowKey(pInfo->pCtx, pQueryAttr->numOfOutput, RESULT_ROW_START_INTERP);
...@@ -1322,7 +1299,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul ...@@ -1322,7 +1299,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
} }
// restore current time window // restore current time window
ret = setWindowOutputBufByKey(pRuntimeEnv, pResultRowInfo, &win, masterScan, &pResult, groupId, pInfo->pCtx, ret = setResultOutputBufByKey(pRuntimeEnv, pResultRowInfo, pSDataBlock->info.tid, &win, masterScan, &pResult, tableGroupId, pInfo->pCtx,
numOfOutput, pInfo->rowCellInfoOffset); numOfOutput, pInfo->rowCellInfoOffset);
if (ret != TSDB_CODE_SUCCESS) { if (ret != TSDB_CODE_SUCCESS) {
longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_OUT_OF_MEMORY); longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
...@@ -1342,7 +1319,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul ...@@ -1342,7 +1319,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
} }
// null data, failed to allocate more memory buffer // null data, failed to allocate more memory buffer
int32_t code = setWindowOutputBufByKey(pRuntimeEnv, pResultRowInfo, &nextWin, masterScan, &pResult, groupId, int32_t code = setResultOutputBufByKey(pRuntimeEnv, pResultRowInfo, pSDataBlock->info.tid, &nextWin, masterScan, &pResult, tableGroupId,
pInfo->pCtx, numOfOutput, pInfo->rowCellInfoOffset); pInfo->pCtx, numOfOutput, pInfo->rowCellInfoOffset);
if (code != TSDB_CODE_SUCCESS || pResult == NULL) { if (code != TSDB_CODE_SUCCESS || pResult == NULL) {
longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_OUT_OF_MEMORY); longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
...@@ -1483,7 +1460,7 @@ static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSWindowOperatorInf ...@@ -1483,7 +1460,7 @@ static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSWindowOperatorInf
SResultRow* pResult = NULL; SResultRow* pResult = NULL;
pInfo->curWindow.ekey = pInfo->curWindow.skey; pInfo->curWindow.ekey = pInfo->curWindow.skey;
int32_t ret = setWindowOutputBufByKey(pRuntimeEnv, &pBInfo->resultRowInfo, &pInfo->curWindow, masterScan, int32_t ret = setResultOutputBufByKey(pRuntimeEnv, &pBInfo->resultRowInfo, pSDataBlock->info.tid, &pInfo->curWindow, masterScan,
&pResult, item->groupIndex, pBInfo->pCtx, pOperator->numOfOutput, &pResult, item->groupIndex, pBInfo->pCtx, pOperator->numOfOutput,
pBInfo->rowCellInfoOffset); pBInfo->rowCellInfoOffset);
if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code
...@@ -1504,7 +1481,7 @@ static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSWindowOperatorInf ...@@ -1504,7 +1481,7 @@ static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSWindowOperatorInf
SResultRow* pResult = NULL; SResultRow* pResult = NULL;
pInfo->curWindow.ekey = pInfo->curWindow.skey; pInfo->curWindow.ekey = pInfo->curWindow.skey;
int32_t ret = setWindowOutputBufByKey(pRuntimeEnv, &pBInfo->resultRowInfo, &pInfo->curWindow, masterScan, int32_t ret = setResultOutputBufByKey(pRuntimeEnv, &pBInfo->resultRowInfo, pSDataBlock->info.tid, &pInfo->curWindow, masterScan,
&pResult, item->groupIndex, pBInfo->pCtx, pOperator->numOfOutput, &pResult, item->groupIndex, pBInfo->pCtx, pOperator->numOfOutput,
pBInfo->rowCellInfoOffset); pBInfo->rowCellInfoOffset);
if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code
...@@ -1547,7 +1524,8 @@ static int32_t setGroupResultOutputBuf(SQueryRuntimeEnv *pRuntimeEnv, SOptrBasic ...@@ -1547,7 +1524,8 @@ static int32_t setGroupResultOutputBuf(SQueryRuntimeEnv *pRuntimeEnv, SOptrBasic
len = varDataLen(pData); len = varDataLen(pData);
} }
SResultRow *pResultRow = doPrepareResultRowFromKey(pRuntimeEnv, pResultRowInfo, d, len, true, groupIndex); int64_t tid = 0;
SResultRow *pResultRow = doSetResultOutBufByKey(pRuntimeEnv, pResultRowInfo, tid, d, len, true, groupIndex);
assert (pResultRow != NULL); assert (pResultRow != NULL);
setResultRowKey(pResultRow, pData, type); setResultRowKey(pResultRow, pData, type);
...@@ -1811,6 +1789,7 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int32_t numOf ...@@ -1811,6 +1789,7 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int32_t numOf
pRuntimeEnv->pQueryAttr = pQueryAttr; pRuntimeEnv->pQueryAttr = pQueryAttr;
pRuntimeEnv->pResultRowHashTable = taosHashInit(numOfTables, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); pRuntimeEnv->pResultRowHashTable = taosHashInit(numOfTables, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
pRuntimeEnv->pResultRowListSet = taosHashInit(numOfTables, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
pRuntimeEnv->keyBuf = malloc(pQueryAttr->maxTableColumnWidth + sizeof(int64_t)); pRuntimeEnv->keyBuf = malloc(pQueryAttr->maxTableColumnWidth + sizeof(int64_t));
pRuntimeEnv->pool = initResultRowPool(getResultRowSize(pRuntimeEnv)); pRuntimeEnv->pool = initResultRowPool(getResultRowSize(pRuntimeEnv));
...@@ -2060,6 +2039,9 @@ static void teardownQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv) { ...@@ -2060,6 +2039,9 @@ static void teardownQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv) {
taosHashCleanup(pRuntimeEnv->pTableRetrieveTsMap); taosHashCleanup(pRuntimeEnv->pTableRetrieveTsMap);
pRuntimeEnv->pTableRetrieveTsMap = NULL; pRuntimeEnv->pTableRetrieveTsMap = NULL;
taosHashCleanup(pRuntimeEnv->pResultRowListSet);
pRuntimeEnv->pResultRowListSet = NULL;
destroyOperatorInfo(pRuntimeEnv->proot); destroyOperatorInfo(pRuntimeEnv->proot);
pRuntimeEnv->pool = destroyResultRowPool(pRuntimeEnv->pool); pRuntimeEnv->pool = destroyResultRowPool(pRuntimeEnv->pool);
...@@ -2790,7 +2772,7 @@ int32_t loadDataBlockOnDemand(SQueryRuntimeEnv* pRuntimeEnv, STableScanInfo* pTa ...@@ -2790,7 +2772,7 @@ int32_t loadDataBlockOnDemand(SQueryRuntimeEnv* pRuntimeEnv, STableScanInfo* pTa
TSKEY k = ascQuery? pBlock->info.window.skey : pBlock->info.window.ekey; TSKEY k = ascQuery? pBlock->info.window.skey : pBlock->info.window.ekey;
STimeWindow win = getActiveTimeWindow(pTableScanInfo->pResultRowInfo, k, pQueryAttr); STimeWindow win = getActiveTimeWindow(pTableScanInfo->pResultRowInfo, k, pQueryAttr);
if (setWindowOutputBufByKey(pRuntimeEnv, pTableScanInfo->pResultRowInfo, &win, masterScan, &pResult, groupId, if (setResultOutputBufByKey(pRuntimeEnv, pTableScanInfo->pResultRowInfo, pBlock->info.tid, &win, masterScan, &pResult, groupId,
pTableScanInfo->pCtx, pTableScanInfo->numOfOutput, pTableScanInfo->pCtx, pTableScanInfo->numOfOutput,
pTableScanInfo->rowCellInfoOffset) != TSDB_CODE_SUCCESS) { pTableScanInfo->rowCellInfoOffset) != TSDB_CODE_SUCCESS) {
longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_OUT_OF_MEMORY); longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
...@@ -2836,7 +2818,7 @@ int32_t loadDataBlockOnDemand(SQueryRuntimeEnv* pRuntimeEnv, STableScanInfo* pTa ...@@ -2836,7 +2818,7 @@ int32_t loadDataBlockOnDemand(SQueryRuntimeEnv* pRuntimeEnv, STableScanInfo* pTa
TSKEY k = ascQuery? pBlock->info.window.skey : pBlock->info.window.ekey; TSKEY k = ascQuery? pBlock->info.window.skey : pBlock->info.window.ekey;
STimeWindow win = getActiveTimeWindow(pTableScanInfo->pResultRowInfo, k, pQueryAttr); STimeWindow win = getActiveTimeWindow(pTableScanInfo->pResultRowInfo, k, pQueryAttr);
if (setWindowOutputBufByKey(pRuntimeEnv, pTableScanInfo->pResultRowInfo, &win, masterScan, &pResult, groupId, if (setResultOutputBufByKey(pRuntimeEnv, pTableScanInfo->pResultRowInfo, pBlock->info.tid, &win, masterScan, &pResult, groupId,
pTableScanInfo->pCtx, pTableScanInfo->numOfOutput, pTableScanInfo->pCtx, pTableScanInfo->numOfOutput,
pTableScanInfo->rowCellInfoOffset) != TSDB_CODE_SUCCESS) { pTableScanInfo->rowCellInfoOffset) != TSDB_CODE_SUCCESS) {
longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_OUT_OF_MEMORY); longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
...@@ -3192,11 +3174,11 @@ static void updateTableQueryInfoForReverseScan(STableQueryInfo *pTableQueryInfo) ...@@ -3192,11 +3174,11 @@ static void updateTableQueryInfoForReverseScan(STableQueryInfo *pTableQueryInfo)
pTableQueryInfo->cur.vgroupIndex = -1; pTableQueryInfo->cur.vgroupIndex = -1;
// set the index to be the end slot of result rows array // set the index to be the end slot of result rows array
SResultRowInfo* pResRowInfo = &pTableQueryInfo->resInfo; SResultRowInfo* pResultRowInfo = &pTableQueryInfo->resInfo;
if (pResRowInfo->size > 0) { if (pResultRowInfo->size > 0) {
pResRowInfo->current = pResRowInfo->pResult[pResRowInfo->size - 1]; pResultRowInfo->curPos = pResultRowInfo->size - 1;
} else { } else {
pResRowInfo->current = NULL; pResultRowInfo->curPos = -1;
} }
} }
...@@ -3250,8 +3232,8 @@ void setDefaultOutputBuf(SQueryRuntimeEnv *pRuntimeEnv, SOptrBasicInfo *pInfo, i ...@@ -3250,8 +3232,8 @@ void setDefaultOutputBuf(SQueryRuntimeEnv *pRuntimeEnv, SOptrBasicInfo *pInfo, i
int32_t* rowCellInfoOffset = pInfo->rowCellInfoOffset; int32_t* rowCellInfoOffset = pInfo->rowCellInfoOffset;
SResultRowInfo* pResultRowInfo = &pInfo->resultRowInfo; SResultRowInfo* pResultRowInfo = &pInfo->resultRowInfo;
int32_t tid = 0; int64_t tid = 0;
SResultRow* pRow = doPrepareResultRowFromKey(pRuntimeEnv, pResultRowInfo, (char *)&tid, sizeof(tid), true, uid); SResultRow* pRow = doSetResultOutBufByKey(pRuntimeEnv, pResultRowInfo, tid, (char *)&tid, sizeof(tid), true, uid);
for (int32_t i = 0; i < pDataBlock->info.numOfCols; ++i) { for (int32_t i = 0; i < pDataBlock->info.numOfCols; ++i) {
SColumnInfoData* pData = taosArrayGet(pDataBlock->pDataBlock, i); SColumnInfoData* pData = taosArrayGet(pDataBlock->pDataBlock, i);
...@@ -3482,10 +3464,13 @@ void setResultRowOutputBufInitCtx(SQueryRuntimeEnv *pRuntimeEnv, SResultRow *pRe ...@@ -3482,10 +3464,13 @@ void setResultRowOutputBufInitCtx(SQueryRuntimeEnv *pRuntimeEnv, SResultRow *pRe
} }
void doSetTableGroupOutputBuf(SQueryRuntimeEnv* pRuntimeEnv, SResultRowInfo* pResultRowInfo, SQLFunctionCtx* pCtx, void doSetTableGroupOutputBuf(SQueryRuntimeEnv* pRuntimeEnv, SResultRowInfo* pResultRowInfo, SQLFunctionCtx* pCtx,
int32_t* rowCellInfoOffset, int32_t numOfOutput, int32_t groupIndex) { int32_t* rowCellInfoOffset, int32_t numOfOutput, int32_t tableGroupId) {
// for simple group by query without interval, all the tables belong to one group result.
int64_t uid = 0; int64_t uid = 0;
int64_t tid = 0;
SResultRow* pResultRow = SResultRow* pResultRow =
doPrepareResultRowFromKey(pRuntimeEnv, pResultRowInfo, (char*)&groupIndex, sizeof(groupIndex), true, uid); doSetResultOutBufByKey(pRuntimeEnv, pResultRowInfo, tid, (char*)&tableGroupId, sizeof(tableGroupId), true, uid);
assert (pResultRow != NULL); assert (pResultRow != NULL);
/* /*
...@@ -3493,7 +3478,7 @@ void doSetTableGroupOutputBuf(SQueryRuntimeEnv* pRuntimeEnv, SResultRowInfo* pRe ...@@ -3493,7 +3478,7 @@ void doSetTableGroupOutputBuf(SQueryRuntimeEnv* pRuntimeEnv, SResultRowInfo* pRe
* all group belong to one result set, and each group result has different group id so set the id to be one * all group belong to one result set, and each group result has different group id so set the id to be one
*/ */
if (pResultRow->pageId == -1) { if (pResultRow->pageId == -1) {
int32_t ret = addNewWindowResultBuf(pResultRow, pRuntimeEnv->pResultBuf, groupIndex, pRuntimeEnv->pQueryAttr->resultRowSize); int32_t ret = addNewWindowResultBuf(pResultRow, pRuntimeEnv->pResultBuf, tableGroupId, pRuntimeEnv->pQueryAttr->resultRowSize);
if (ret != TSDB_CODE_SUCCESS) { if (ret != TSDB_CODE_SUCCESS) {
return; return;
} }
...@@ -3502,20 +3487,20 @@ void doSetTableGroupOutputBuf(SQueryRuntimeEnv* pRuntimeEnv, SResultRowInfo* pRe ...@@ -3502,20 +3487,20 @@ void doSetTableGroupOutputBuf(SQueryRuntimeEnv* pRuntimeEnv, SResultRowInfo* pRe
setResultRowOutputBufInitCtx(pRuntimeEnv, pResultRow, pCtx, numOfOutput, rowCellInfoOffset); setResultRowOutputBufInitCtx(pRuntimeEnv, pResultRow, pCtx, numOfOutput, rowCellInfoOffset);
} }
void setExecutionContext(SQueryRuntimeEnv* pRuntimeEnv, SOptrBasicInfo* pInfo, int32_t numOfOutput, int32_t groupIndex, void setExecutionContext(SQueryRuntimeEnv* pRuntimeEnv, SOptrBasicInfo* pInfo, int32_t numOfOutput, int32_t tableGroupId,
TSKEY nextKey) { TSKEY nextKey) {
STableQueryInfo *pTableQueryInfo = pRuntimeEnv->current; STableQueryInfo *pTableQueryInfo = pRuntimeEnv->current;
// lastKey needs to be updated // lastKey needs to be updated
pTableQueryInfo->lastKey = nextKey; pTableQueryInfo->lastKey = nextKey;
if (pRuntimeEnv->prevGroupId != INT32_MIN && pRuntimeEnv->prevGroupId == groupIndex) { if (pRuntimeEnv->prevGroupId != INT32_MIN && pRuntimeEnv->prevGroupId == tableGroupId) {
return; return;
} }
doSetTableGroupOutputBuf(pRuntimeEnv, &pInfo->resultRowInfo, pInfo->pCtx, pInfo->rowCellInfoOffset, numOfOutput, groupIndex); doSetTableGroupOutputBuf(pRuntimeEnv, &pInfo->resultRowInfo, pInfo->pCtx, pInfo->rowCellInfoOffset, numOfOutput, tableGroupId);
// record the current active group id // record the current active group id
pRuntimeEnv->prevGroupId = groupIndex; pRuntimeEnv->prevGroupId = tableGroupId;
} }
void setResultOutputBuf(SQueryRuntimeEnv *pRuntimeEnv, SResultRow *pResult, SQLFunctionCtx* pCtx, void setResultOutputBuf(SQueryRuntimeEnv *pRuntimeEnv, SResultRow *pResult, SQLFunctionCtx* pCtx,
...@@ -3686,9 +3671,9 @@ void setParamForStableStddevByColData(SQueryRuntimeEnv* pRuntimeEnv, SQLFunction ...@@ -3686,9 +3671,9 @@ void setParamForStableStddevByColData(SQueryRuntimeEnv* pRuntimeEnv, SQLFunction
void setIntervalQueryRange(SQueryRuntimeEnv *pRuntimeEnv, TSKEY key) { void setIntervalQueryRange(SQueryRuntimeEnv *pRuntimeEnv, TSKEY key) {
SQueryAttr *pQueryAttr = pRuntimeEnv->pQueryAttr; SQueryAttr *pQueryAttr = pRuntimeEnv->pQueryAttr;
STableQueryInfo *pTableQueryInfo = pRuntimeEnv->current; STableQueryInfo *pTableQueryInfo = pRuntimeEnv->current;
SResultRowInfo *pWindowResInfo = &pTableQueryInfo->resInfo; SResultRowInfo *pResultRowInfo = &pTableQueryInfo->resInfo;
if (pWindowResInfo->prevSKey != TSKEY_INITIAL_VAL) { if (pResultRowInfo->curPos != -1) {
return; return;
} }
...@@ -3707,13 +3692,13 @@ void setIntervalQueryRange(SQueryRuntimeEnv *pRuntimeEnv, TSKEY key) { ...@@ -3707,13 +3692,13 @@ void setIntervalQueryRange(SQueryRuntimeEnv *pRuntimeEnv, TSKEY key) {
TSKEY ek = MAX(win.skey, win.ekey); TSKEY ek = MAX(win.skey, win.ekey);
getAlignQueryTimeWindow(pQueryAttr, win.skey, sk, ek, &w); getAlignQueryTimeWindow(pQueryAttr, win.skey, sk, ek, &w);
if (pWindowResInfo->prevSKey == TSKEY_INITIAL_VAL) { // if (pResultRowInfo->prevSKey == TSKEY_INITIAL_VAL) {
if (!QUERY_IS_ASC_QUERY(pQueryAttr)) { // if (!QUERY_IS_ASC_QUERY(pQueryAttr)) {
assert(win.ekey == pQueryAttr->window.ekey); // assert(win.ekey == pQueryAttr->window.ekey);
} // }
//
pWindowResInfo->prevSKey = w.skey; // pResultRowInfo->prevSKey = w.skey;
} // }
pTableQueryInfo->lastKey = pTableQueryInfo->win.skey; pTableQueryInfo->lastKey = pTableQueryInfo->win.skey;
} }
...@@ -4613,8 +4598,7 @@ static SSDataBlock* doTableScan(void* param, bool *newgroup) { ...@@ -4613,8 +4598,7 @@ static SSDataBlock* doTableScan(void* param, bool *newgroup) {
} }
if (pResultRowInfo->size > 0) { if (pResultRowInfo->size > 0) {
pResultRowInfo->current = pResultRowInfo->pResult[0]; pResultRowInfo->curPos = 0;
pResultRowInfo->prevSKey = pResultRowInfo->pResult[0]->win.skey;
} }
qDebug("QInfo:0x%"PRIx64" start to repeat scan data blocks due to query func required, qrange:%" PRId64 "-%" PRId64, qDebug("QInfo:0x%"PRIx64" start to repeat scan data blocks due to query func required, qrange:%" PRId64 "-%" PRId64,
...@@ -4639,8 +4623,7 @@ static SSDataBlock* doTableScan(void* param, bool *newgroup) { ...@@ -4639,8 +4623,7 @@ static SSDataBlock* doTableScan(void* param, bool *newgroup) {
pTableScanInfo->order = cond.order; pTableScanInfo->order = cond.order;
if (pResultRowInfo->size > 0) { if (pResultRowInfo->size > 0) {
pResultRowInfo->current = pResultRowInfo->pResult[pResultRowInfo->size - 1]; pResultRowInfo->curPos = pResultRowInfo->size - 1;
pResultRowInfo->prevSKey = pResultRowInfo->current->win.skey;
} }
p = doTableScanImpl(pOperator, newgroup); p = doTableScanImpl(pOperator, newgroup);
...@@ -5500,7 +5483,7 @@ static void doStateWindowAggImpl(SOperatorInfo* pOperator, SStateWindowOperatorI ...@@ -5500,7 +5483,7 @@ static void doStateWindowAggImpl(SOperatorInfo* pOperator, SStateWindowOperatorI
} else { } else {
SResultRow* pResult = NULL; SResultRow* pResult = NULL;
pInfo->curWindow.ekey = pInfo->curWindow.skey; pInfo->curWindow.ekey = pInfo->curWindow.skey;
int32_t ret = setWindowOutputBufByKey(pRuntimeEnv, &pBInfo->resultRowInfo, &pInfo->curWindow, masterScan, int32_t ret = setResultOutputBufByKey(pRuntimeEnv, &pBInfo->resultRowInfo, pSDataBlock->info.tid, &pInfo->curWindow, masterScan,
&pResult, item->groupIndex, pBInfo->pCtx, pOperator->numOfOutput, &pResult, item->groupIndex, pBInfo->pCtx, pOperator->numOfOutput,
pBInfo->rowCellInfoOffset); pBInfo->rowCellInfoOffset);
if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code
...@@ -5517,10 +5500,11 @@ static void doStateWindowAggImpl(SOperatorInfo* pOperator, SStateWindowOperatorI ...@@ -5517,10 +5500,11 @@ static void doStateWindowAggImpl(SOperatorInfo* pOperator, SStateWindowOperatorI
} }
} }
SResultRow* pResult = NULL; SResultRow* pResult = NULL;
pInfo->curWindow.ekey = pInfo->curWindow.skey; pInfo->curWindow.ekey = pInfo->curWindow.skey;
int32_t ret = setWindowOutputBufByKey(pRuntimeEnv, &pBInfo->resultRowInfo, &pInfo->curWindow, masterScan, int32_t ret = setResultOutputBufByKey(pRuntimeEnv, &pBInfo->resultRowInfo, pSDataBlock->info.tid, &pInfo->curWindow, masterScan,
&pResult, item->groupIndex, pBInfo->pCtx, pOperator->numOfOutput, &pResult, item->groupIndex, pBInfo->pCtx, pOperator->numOfOutput,
pBInfo->rowCellInfoOffset); pBInfo->rowCellInfoOffset);
if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code
...@@ -6298,8 +6282,8 @@ static SSDataBlock* doTagScan(void* param, bool* newgroup) { ...@@ -6298,8 +6282,8 @@ static SSDataBlock* doTagScan(void* param, bool* newgroup) {
SColumnInfoData* pColInfo = taosArrayGet(pRes->pDataBlock, 0); SColumnInfoData* pColInfo = taosArrayGet(pRes->pDataBlock, 0);
while(pInfo->currentIndex < pInfo->totalTables && count < maxNumOfTables) { while(pInfo->curPos < pInfo->totalTables && count < maxNumOfTables) {
int32_t i = pInfo->currentIndex++; int32_t i = pInfo->curPos++;
STableQueryInfo *item = taosArrayGetP(pa, i); STableQueryInfo *item = taosArrayGetP(pa, i);
char *output = pColInfo->pData + count * rsize; char *output = pColInfo->pData + count * rsize;
...@@ -6343,8 +6327,8 @@ static SSDataBlock* doTagScan(void* param, bool* newgroup) { ...@@ -6343,8 +6327,8 @@ static SSDataBlock* doTagScan(void* param, bool* newgroup) {
SExprInfo* pExprInfo = pOperator->pExpr; // todo use the column list instead of exprinfo SExprInfo* pExprInfo = pOperator->pExpr; // todo use the column list instead of exprinfo
count = 0; count = 0;
while(pInfo->currentIndex < pInfo->totalTables && count < maxNumOfTables) { while(pInfo->curPos < pInfo->totalTables && count < maxNumOfTables) {
int32_t i = pInfo->currentIndex++; int32_t i = pInfo->curPos++;
STableQueryInfo* item = taosArrayGetP(pa, i); STableQueryInfo* item = taosArrayGetP(pa, i);
...@@ -6373,7 +6357,7 @@ static SSDataBlock* doTagScan(void* param, bool* newgroup) { ...@@ -6373,7 +6357,7 @@ static SSDataBlock* doTagScan(void* param, bool* newgroup) {
count += 1; count += 1;
} }
if (pInfo->currentIndex >= pInfo->totalTables) { if (pInfo->curPos >= pInfo->totalTables) {
pOperator->status = OP_EXEC_DONE; pOperator->status = OP_EXEC_DONE;
} }
...@@ -6392,7 +6376,7 @@ SOperatorInfo* createTagScanOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SExprInf ...@@ -6392,7 +6376,7 @@ SOperatorInfo* createTagScanOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SExprInf
assert(numOfGroup == 0 || numOfGroup == 1); assert(numOfGroup == 0 || numOfGroup == 1);
pInfo->totalTables = pRuntimeEnv->tableqinfoGroupInfo.numOfTables; pInfo->totalTables = pRuntimeEnv->tableqinfoGroupInfo.numOfTables;
pInfo->currentIndex = 0; pInfo->curPos = 0;
SOperatorInfo* pOperator = calloc(1, sizeof(SOperatorInfo)); SOperatorInfo* pOperator = calloc(1, sizeof(SOperatorInfo));
pOperator->name = "SeqTableTagScan"; pOperator->name = "SeqTableTagScan";
......
...@@ -44,8 +44,7 @@ int32_t getOutputInterResultBufSize(SQueryAttr* pQueryAttr) { ...@@ -44,8 +44,7 @@ int32_t getOutputInterResultBufSize(SQueryAttr* pQueryAttr) {
int32_t initResultRowInfo(SResultRowInfo *pResultRowInfo, int32_t size, int16_t type) { int32_t initResultRowInfo(SResultRowInfo *pResultRowInfo, int32_t size, int16_t type) {
pResultRowInfo->type = type; pResultRowInfo->type = type;
pResultRowInfo->size = 0; pResultRowInfo->size = 0;
pResultRowInfo->prevSKey = TSKEY_INITIAL_VAL; pResultRowInfo->curPos = -1;
pResultRowInfo->current = NULL;
pResultRowInfo->capacity = size; pResultRowInfo->capacity = size;
pResultRowInfo->pResult = calloc(pResultRowInfo->capacity, POINTER_BYTES); pResultRowInfo->pResult = calloc(pResultRowInfo->capacity, POINTER_BYTES);
...@@ -92,8 +91,7 @@ void resetResultRowInfo(SQueryRuntimeEnv *pRuntimeEnv, SResultRowInfo *pResultRo ...@@ -92,8 +91,7 @@ void resetResultRowInfo(SQueryRuntimeEnv *pRuntimeEnv, SResultRowInfo *pResultRo
} }
pResultRowInfo->size = 0; pResultRowInfo->size = 0;
pResultRowInfo->current = NULL; pResultRowInfo->curPos = -1;
pResultRowInfo->prevSKey = TSKEY_INITIAL_VAL;
} }
int32_t numOfClosedResultRows(SResultRowInfo *pResultRowInfo) { int32_t numOfClosedResultRows(SResultRowInfo *pResultRowInfo) {
......
...@@ -129,16 +129,16 @@ typedef union { ...@@ -129,16 +129,16 @@ typedef union {
#define ParseARG_STORE yypParser->pInfo = pInfo #define ParseARG_STORE yypParser->pInfo = pInfo
#define YYFALLBACK 1 #define YYFALLBACK 1
#define YYNSTATE 347 #define YYNSTATE 347
#define YYNRULE 285 #define YYNRULE 283
#define YYNTOKEN 190 #define YYNTOKEN 190
#define YY_MAX_SHIFT 346 #define YY_MAX_SHIFT 346
#define YY_MIN_SHIFTREDUCE 549 #define YY_MIN_SHIFTREDUCE 547
#define YY_MAX_SHIFTREDUCE 833 #define YY_MAX_SHIFTREDUCE 829
#define YY_ERROR_ACTION 834 #define YY_ERROR_ACTION 830
#define YY_ACCEPT_ACTION 835 #define YY_ACCEPT_ACTION 831
#define YY_NO_ACTION 836 #define YY_NO_ACTION 832
#define YY_MIN_REDUCE 837 #define YY_MIN_REDUCE 833
#define YY_MAX_REDUCE 1121 #define YY_MAX_REDUCE 1115
/************* End control #defines *******************************************/ /************* End control #defines *******************************************/
/* 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
...@@ -204,82 +204,82 @@ typedef union { ...@@ -204,82 +204,82 @@ 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 (735) #define YY_ACTTAB_COUNT (731)
static const YYACTIONTYPE yy_action[] = { static const YYACTIONTYPE yy_action[] = {
/* 0 */ 23, 598, 1010, 598, 219, 344, 194, 835, 346, 599, /* 0 */ 23, 596, 1004, 596, 219, 344, 194, 831, 346, 597,
/* 10 */ 598, 599, 197, 54, 55, 225, 58, 59, 599, 988, /* 10 */ 596, 597, 197, 54, 55, 225, 58, 59, 597, 982,
/* 20 */ 239, 48, 1097, 57, 300, 62, 60, 63, 61, 1001, /* 20 */ 239, 48, 1091, 57, 302, 62, 60, 63, 61, 995,
/* 30 */ 1001, 231, 233, 53, 52, 988, 988, 51, 50, 49, /* 30 */ 995, 231, 233, 53, 52, 982, 982, 51, 50, 49,
/* 40 */ 54, 55, 35, 58, 59, 222, 223, 239, 48, 598, /* 40 */ 54, 55, 35, 58, 59, 222, 223, 239, 48, 596,
/* 50 */ 57, 300, 62, 60, 63, 61, 1001, 599, 152, 236, /* 50 */ 57, 302, 62, 60, 63, 61, 995, 597, 152, 236,
/* 60 */ 53, 52, 235, 152, 51, 50, 49, 55, 1007, 58, /* 60 */ 53, 52, 235, 152, 51, 50, 49, 55, 1001, 58,
/* 70 */ 59, 630, 261, 239, 48, 240, 57, 300, 62, 60, /* 70 */ 59, 770, 261, 239, 48, 240, 57, 302, 62, 60,
/* 80 */ 63, 61, 29, 83, 982, 221, 53, 52, 145, 985, /* 80 */ 63, 61, 29, 83, 976, 221, 53, 52, 145, 979,
/* 90 */ 51, 50, 49, 550, 551, 552, 553, 554, 555, 556, /* 90 */ 51, 50, 49, 548, 549, 550, 551, 552, 553, 554,
/* 100 */ 557, 558, 559, 560, 561, 562, 345, 80, 772, 220, /* 100 */ 555, 556, 557, 558, 559, 560, 345, 771, 768, 220,
/* 110 */ 95, 77, 54, 55, 35, 58, 59, 42, 197, 239, /* 110 */ 95, 77, 54, 55, 35, 58, 59, 42, 197, 239,
/* 120 */ 48, 197, 57, 300, 62, 60, 63, 61, 1098, 232, /* 120 */ 48, 197, 57, 302, 62, 60, 63, 61, 1092, 232,
/* 130 */ 1046, 1098, 53, 52, 197, 89, 51, 50, 49, 54, /* 130 */ 1040, 1092, 53, 52, 197, 89, 51, 50, 49, 54,
/* 140 */ 56, 264, 58, 59, 1098, 976, 239, 48, 974, 57, /* 140 */ 56, 968, 58, 59, 1092, 970, 239, 48, 262, 57,
/* 150 */ 300, 62, 60, 63, 61, 268, 267, 229, 298, 53, /* 150 */ 302, 62, 60, 63, 61, 268, 267, 229, 36, 53,
/* 160 */ 52, 985, 248, 51, 50, 49, 41, 296, 339, 338, /* 160 */ 52, 979, 248, 51, 50, 49, 41, 298, 339, 338,
/* 170 */ 295, 294, 293, 337, 292, 336, 335, 334, 291, 333, /* 170 */ 297, 296, 295, 337, 294, 293, 292, 336, 291, 335,
/* 180 */ 332, 948, 936, 937, 938, 939, 940, 941, 942, 943, /* 180 */ 334, 944, 932, 933, 934, 935, 936, 937, 938, 939,
/* 190 */ 944, 945, 946, 947, 949, 950, 58, 59, 24, 986, /* 190 */ 940, 941, 942, 943, 945, 946, 58, 59, 24, 980,
/* 200 */ 239, 48, 253, 57, 300, 62, 60, 63, 61, 35, /* 200 */ 239, 48, 90, 57, 302, 62, 60, 63, 61, 51,
/* 210 */ 195, 257, 256, 53, 52, 205, 330, 51, 50, 49, /* 210 */ 50, 49, 152, 53, 52, 205, 78, 51, 50, 49,
/* 220 */ 53, 52, 206, 14, 51, 50, 49, 129, 128, 204, /* 220 */ 53, 52, 206, 300, 51, 50, 49, 129, 128, 204,
/* 230 */ 298, 238, 787, 305, 83, 776, 81, 779, 116, 782, /* 230 */ 732, 238, 783, 307, 83, 772, 740, 775, 35, 778,
/* 240 */ 200, 238, 787, 883, 35, 776, 330, 779, 179, 782, /* 240 */ 147, 238, 783, 116, 253, 772, 65, 775, 35, 778,
/* 250 */ 114, 108, 119, 94, 91, 1094, 984, 118, 124, 127, /* 250 */ 300, 332, 152, 257, 256, 35, 879, 62, 60, 63,
/* 260 */ 117, 987, 35, 217, 218, 152, 121, 301, 42, 41, /* 260 */ 61, 179, 332, 217, 218, 53, 52, 303, 42, 51,
/* 270 */ 264, 339, 338, 217, 218, 242, 337, 1093, 336, 335, /* 270 */ 50, 49, 700, 217, 218, 697, 304, 698, 14, 699,
/* 280 */ 334, 704, 333, 332, 701, 1117, 702, 230, 703, 1092, /* 280 */ 41, 230, 339, 338, 1041, 979, 280, 337, 340, 913,
/* 290 */ 260, 985, 75, 956, 680, 954, 955, 340, 917, 213, /* 290 */ 260, 336, 75, 335, 334, 978, 1, 167, 311, 213,
/* 300 */ 957, 247, 959, 960, 958, 309, 961, 962, 152, 985, /* 300 */ 628, 242, 979, 244, 245, 114, 108, 119, 94, 91,
/* 310 */ 64, 35, 244, 245, 1, 167, 62, 60, 63, 61, /* 310 */ 64, 195, 118, 124, 127, 117, 952, 80, 950, 951,
/* 320 */ 64, 893, 320, 319, 53, 52, 179, 1109, 51, 50, /* 320 */ 64, 121, 282, 953, 88, 76, 247, 954, 35, 955,
/* 330 */ 49, 5, 38, 169, 92, 282, 215, 88, 168, 102, /* 330 */ 956, 5, 38, 169, 92, 3, 180, 35, 168, 102,
/* 340 */ 97, 101, 788, 783, 720, 76, 243, 35, 241, 784, /* 340 */ 97, 101, 784, 779, 35, 35, 35, 35, 716, 780,
/* 350 */ 308, 307, 788, 783, 310, 188, 186, 184, 985, 784, /* 350 */ 676, 264, 784, 779, 188, 186, 184, 200, 967, 780,
/* 360 */ 35, 35, 183, 132, 131, 130, 971, 972, 34, 975, /* 360 */ 35, 183, 132, 131, 130, 1088, 965, 966, 34, 969,
/* 370 */ 35, 68, 249, 35, 246, 35, 315, 314, 973, 778, /* 370 */ 1087, 312, 243, 787, 241, 979, 310, 309, 322, 321,
/* 380 */ 1047, 781, 280, 884, 51, 50, 49, 777, 179, 780, /* 380 */ 313, 889, 701, 702, 979, 81, 179, 314, 318, 319,
/* 390 */ 311, 705, 706, 71, 985, 343, 342, 137, 143, 141, /* 390 */ 320, 979, 979, 979, 979, 880, 774, 249, 777, 246,
/* 400 */ 140, 90, 717, 312, 316, 3, 180, 985, 985, 753, /* 400 */ 179, 317, 316, 324, 773, 713, 776, 979, 343, 342,
/* 410 */ 754, 774, 33, 317, 69, 78, 318, 985, 322, 302, /* 410 */ 137, 741, 143, 141, 140, 749, 750, 68, 71, 264,
/* 420 */ 985, 262, 985, 736, 724, 744, 745, 690, 216, 9, /* 420 */ 686, 26, 237, 285, 16, 688, 15, 287, 720, 687,
/* 430 */ 285, 36, 692, 147, 72, 65, 26, 36, 287, 691, /* 430 */ 36, 981, 9, 36, 33, 65, 804, 93, 785, 65,
/* 440 */ 36, 288, 65, 808, 789, 237, 597, 775, 93, 65, /* 440 */ 595, 74, 6, 107, 1086, 106, 25, 18, 25, 17,
/* 450 */ 16, 74, 15, 25, 25, 107, 25, 106, 18, 709, /* 450 */ 25, 705, 703, 706, 704, 20, 113, 19, 112, 72,
/* 460 */ 17, 710, 707, 198, 708, 6, 20, 113, 19, 112, /* 460 */ 69, 215, 22, 288, 21, 126, 125, 216, 198, 675,
/* 470 */ 199, 22, 201, 21, 126, 125, 196, 202, 203, 679, /* 470 */ 199, 201, 196, 202, 203, 208, 209, 210, 207, 193,
/* 480 */ 208, 209, 210, 207, 193, 1057, 1056, 227, 1053, 1052, /* 480 */ 1111, 1103, 1051, 1050, 227, 1047, 1046, 228, 323, 45,
/* 490 */ 228, 321, 258, 785, 144, 1009, 45, 1020, 1017, 1018, /* 490 */ 258, 144, 1003, 1014, 1011, 1012, 1016, 996, 142, 265,
/* 500 */ 1002, 786, 265, 1022, 1039, 163, 146, 150, 274, 1038, /* 500 */ 146, 1033, 150, 274, 1032, 977, 163, 164, 269, 224,
/* 510 */ 983, 164, 142, 981, 165, 166, 791, 896, 290, 43, /* 510 */ 781, 975, 165, 166, 892, 290, 731, 43, 782, 191,
/* 520 */ 735, 999, 191, 39, 279, 154, 269, 299, 892, 306, /* 520 */ 283, 993, 39, 301, 154, 888, 308, 1110, 104, 1109,
/* 530 */ 224, 1116, 104, 1115, 271, 1112, 278, 170, 73, 70, /* 530 */ 1106, 170, 315, 73, 1102, 110, 271, 278, 70, 153,
/* 540 */ 153, 47, 313, 283, 1108, 281, 110, 1107, 1104, 171, /* 540 */ 47, 1101, 155, 1098, 281, 171, 910, 40, 279, 277,
/* 550 */ 914, 155, 277, 40, 37, 44, 275, 156, 192, 273, /* 550 */ 37, 275, 44, 273, 192, 270, 156, 876, 120, 874,
/* 560 */ 880, 120, 878, 122, 123, 158, 876, 875, 270, 250, /* 560 */ 122, 123, 872, 871, 250, 182, 869, 868, 867, 866,
/* 570 */ 182, 873, 872, 871, 870, 869, 46, 868, 185, 331, /* 570 */ 865, 864, 185, 187, 861, 859, 857, 855, 189, 852,
/* 580 */ 187, 865, 863, 861, 859, 189, 856, 190, 115, 263, /* 580 */ 190, 333, 263, 79, 46, 84, 115, 272, 1034, 325,
/* 590 */ 79, 84, 272, 323, 1040, 324, 325, 326, 327, 328, /* 590 */ 326, 327, 328, 329, 330, 331, 214, 341, 829, 234,
/* 600 */ 329, 341, 833, 252, 214, 832, 251, 254, 234, 289, /* 600 */ 251, 252, 289, 828, 254, 255, 827, 211, 212, 809,
/* 610 */ 255, 831, 814, 813, 259, 211, 212, 264, 98, 10, /* 610 */ 98, 810, 99, 259, 264, 284, 10, 82, 708, 266,
/* 620 */ 99, 82, 284, 712, 266, 85, 30, 874, 737, 148, /* 620 */ 85, 30, 870, 174, 178, 863, 911, 172, 173, 175,
/* 630 */ 867, 174, 133, 173, 915, 172, 175, 176, 178, 177, /* 630 */ 176, 4, 133, 177, 862, 912, 134, 135, 948, 136,
/* 640 */ 134, 135, 916, 136, 866, 952, 858, 4, 857, 740, /* 640 */ 854, 733, 148, 853, 157, 158, 159, 160, 736, 161,
/* 650 */ 162, 159, 157, 149, 86, 160, 964, 2, 161, 742, /* 650 */ 149, 162, 958, 2, 86, 226, 738, 87, 276, 31,
/* 660 */ 87, 226, 276, 31, 746, 151, 11, 32, 13, 12, /* 660 */ 742, 151, 32, 13, 11, 27, 286, 28, 12, 641,
/* 670 */ 27, 28, 286, 643, 94, 96, 639, 637, 636, 635, /* 670 */ 96, 94, 639, 638, 637, 635, 634, 633, 630, 299,
/* 680 */ 632, 297, 7, 100, 602, 790, 303, 792, 8, 304, /* 680 */ 600, 100, 7, 305, 786, 788, 8, 306, 103, 105,
/* 690 */ 103, 682, 66, 105, 36, 67, 109, 111, 681, 678, /* 690 */ 66, 67, 109, 111, 678, 36, 677, 674, 622, 620,
/* 700 */ 624, 622, 614, 620, 616, 618, 612, 610, 646, 645, /* 700 */ 612, 618, 614, 616, 610, 608, 644, 643, 642, 640,
/* 710 */ 644, 642, 641, 640, 638, 634, 633, 181, 600, 566, /* 710 */ 636, 632, 631, 181, 598, 564, 562, 833, 832, 832,
/* 720 */ 564, 837, 836, 836, 836, 836, 836, 836, 836, 836, /* 720 */ 832, 832, 832, 832, 832, 832, 832, 832, 832, 138,
/* 730 */ 836, 836, 836, 138, 139, /* 730 */ 139,
}; };
static const YYCODETYPE yy_lookahead[] = { static const YYCODETYPE yy_lookahead[] = {
/* 0 */ 259, 1, 194, 1, 193, 194, 259, 191, 192, 9, /* 0 */ 259, 1, 194, 1, 193, 194, 259, 191, 192, 9,
...@@ -289,73 +289,73 @@ static const YYCODETYPE yy_lookahead[] = { ...@@ -289,73 +289,73 @@ static const YYCODETYPE yy_lookahead[] = {
/* 40 */ 13, 14, 194, 16, 17, 256, 256, 20, 21, 1, /* 40 */ 13, 14, 194, 16, 17, 256, 256, 20, 21, 1,
/* 50 */ 23, 24, 25, 26, 27, 28, 240, 9, 194, 200, /* 50 */ 23, 24, 25, 26, 27, 28, 240, 9, 194, 200,
/* 60 */ 33, 34, 200, 194, 37, 38, 39, 14, 260, 16, /* 60 */ 33, 34, 200, 194, 37, 38, 39, 14, 260, 16,
/* 70 */ 17, 5, 256, 20, 21, 200, 23, 24, 25, 26, /* 70 */ 17, 1, 256, 20, 21, 200, 23, 24, 25, 26,
/* 80 */ 27, 28, 80, 80, 194, 237, 33, 34, 194, 241, /* 80 */ 27, 28, 80, 80, 194, 237, 33, 34, 194, 241,
/* 90 */ 37, 38, 39, 45, 46, 47, 48, 49, 50, 51, /* 90 */ 37, 38, 39, 45, 46, 47, 48, 49, 50, 51,
/* 100 */ 52, 53, 54, 55, 56, 57, 58, 81, 81, 61, /* 100 */ 52, 53, 54, 55, 56, 57, 58, 37, 81, 61,
/* 110 */ 201, 111, 13, 14, 194, 16, 17, 114, 259, 20, /* 110 */ 201, 111, 13, 14, 194, 16, 17, 114, 259, 20,
/* 120 */ 21, 259, 23, 24, 25, 26, 27, 28, 269, 239, /* 120 */ 21, 259, 23, 24, 25, 26, 27, 28, 269, 239,
/* 130 */ 266, 269, 33, 34, 259, 266, 37, 38, 39, 13, /* 130 */ 266, 269, 33, 34, 259, 266, 37, 38, 39, 13,
/* 140 */ 14, 115, 16, 17, 269, 236, 20, 21, 0, 23, /* 140 */ 14, 0, 16, 17, 269, 236, 20, 21, 81, 23,
/* 150 */ 24, 25, 26, 27, 28, 261, 262, 237, 82, 33, /* 150 */ 24, 25, 26, 27, 28, 261, 262, 237, 91, 33,
/* 160 */ 34, 241, 194, 37, 38, 39, 92, 93, 94, 95, /* 160 */ 34, 241, 194, 37, 38, 39, 92, 93, 94, 95,
/* 170 */ 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, /* 170 */ 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
/* 180 */ 106, 215, 216, 217, 218, 219, 220, 221, 222, 223, /* 180 */ 106, 215, 216, 217, 218, 219, 220, 221, 222, 223,
/* 190 */ 224, 225, 226, 227, 228, 229, 16, 17, 44, 231, /* 190 */ 224, 225, 226, 227, 228, 229, 16, 17, 44, 231,
/* 200 */ 20, 21, 137, 23, 24, 25, 26, 27, 28, 194, /* 200 */ 20, 21, 243, 23, 24, 25, 26, 27, 28, 37,
/* 210 */ 259, 146, 147, 33, 34, 61, 84, 37, 38, 39, /* 210 */ 38, 39, 194, 33, 34, 61, 257, 37, 38, 39,
/* 220 */ 33, 34, 68, 80, 37, 38, 39, 73, 74, 75, /* 220 */ 33, 34, 68, 82, 37, 38, 39, 73, 74, 75,
/* 230 */ 82, 1, 2, 79, 80, 5, 81, 7, 76, 9, /* 230 */ 81, 1, 2, 79, 80, 5, 81, 7, 194, 9,
/* 240 */ 259, 1, 2, 199, 194, 5, 84, 7, 204, 9, /* 240 */ 91, 1, 2, 76, 137, 5, 91, 7, 194, 9,
/* 250 */ 62, 63, 64, 110, 111, 259, 241, 69, 70, 71, /* 250 */ 82, 84, 194, 146, 147, 194, 199, 25, 26, 27,
/* 260 */ 72, 242, 194, 33, 34, 194, 78, 37, 114, 92, /* 260 */ 28, 204, 84, 33, 34, 33, 34, 37, 114, 37,
/* 270 */ 115, 94, 95, 33, 34, 68, 99, 259, 101, 102, /* 270 */ 38, 39, 2, 33, 34, 5, 15, 7, 80, 9,
/* 280 */ 103, 2, 105, 106, 5, 242, 7, 237, 9, 259, /* 280 */ 92, 237, 94, 95, 266, 241, 268, 99, 213, 214,
/* 290 */ 136, 241, 138, 215, 5, 217, 218, 213, 214, 145, /* 290 */ 136, 103, 138, 105, 106, 241, 202, 203, 237, 145,
/* 300 */ 222, 68, 224, 225, 226, 237, 228, 229, 194, 241, /* 300 */ 5, 68, 241, 33, 34, 62, 63, 64, 110, 111,
/* 310 */ 80, 194, 33, 34, 202, 203, 25, 26, 27, 28, /* 310 */ 80, 259, 69, 70, 71, 72, 215, 81, 217, 218,
/* 320 */ 80, 199, 33, 34, 33, 34, 204, 242, 37, 38, /* 320 */ 80, 78, 264, 222, 266, 201, 68, 226, 194, 228,
/* 330 */ 39, 62, 63, 64, 201, 264, 259, 266, 69, 70, /* 330 */ 229, 62, 63, 64, 201, 197, 198, 194, 69, 70,
/* 340 */ 71, 72, 112, 113, 37, 201, 139, 194, 141, 119, /* 340 */ 71, 72, 112, 113, 194, 194, 194, 194, 37, 119,
/* 350 */ 143, 144, 112, 113, 237, 62, 63, 64, 241, 119, /* 350 */ 5, 115, 112, 113, 62, 63, 64, 259, 234, 119,
/* 360 */ 194, 194, 69, 70, 71, 72, 233, 234, 235, 236, /* 360 */ 194, 69, 70, 71, 72, 259, 233, 234, 235, 236,
/* 370 */ 194, 91, 139, 194, 141, 194, 143, 144, 234, 5, /* 370 */ 259, 237, 139, 112, 141, 241, 143, 144, 33, 34,
/* 380 */ 266, 7, 268, 199, 37, 38, 39, 5, 204, 7, /* 380 */ 237, 199, 112, 113, 241, 81, 204, 237, 237, 237,
/* 390 */ 237, 112, 113, 91, 241, 65, 66, 67, 62, 63, /* 390 */ 237, 241, 241, 241, 241, 199, 5, 139, 7, 141,
/* 400 */ 64, 243, 91, 237, 237, 197, 198, 241, 241, 127, /* 400 */ 204, 143, 144, 237, 5, 91, 7, 241, 65, 66,
/* 410 */ 128, 1, 80, 237, 134, 257, 237, 241, 237, 15, /* 410 */ 67, 81, 62, 63, 64, 127, 128, 91, 91, 115,
/* 420 */ 241, 81, 241, 81, 117, 81, 81, 81, 259, 118, /* 420 */ 81, 91, 60, 81, 140, 81, 142, 81, 117, 81,
/* 430 */ 81, 91, 81, 91, 132, 91, 91, 91, 81, 81, /* 430 */ 91, 242, 118, 91, 80, 91, 81, 91, 81, 91,
/* 440 */ 91, 109, 91, 81, 81, 60, 81, 37, 91, 91, /* 440 */ 81, 80, 80, 140, 259, 142, 91, 140, 91, 142,
/* 450 */ 140, 80, 142, 91, 91, 140, 91, 142, 140, 5, /* 450 */ 91, 5, 5, 7, 7, 140, 140, 142, 142, 132,
/* 460 */ 142, 7, 5, 259, 7, 80, 140, 140, 142, 142, /* 460 */ 134, 259, 140, 109, 142, 76, 77, 259, 259, 108,
/* 470 */ 259, 140, 259, 142, 76, 77, 259, 259, 259, 108, /* 470 */ 259, 259, 259, 259, 259, 259, 259, 259, 259, 259,
/* 480 */ 259, 259, 259, 259, 259, 232, 232, 232, 232, 232, /* 480 */ 242, 242, 232, 232, 232, 232, 232, 232, 232, 258,
/* 490 */ 232, 232, 194, 119, 194, 194, 258, 194, 194, 194, /* 490 */ 194, 194, 194, 194, 194, 194, 194, 240, 60, 240,
/* 500 */ 240, 119, 240, 194, 267, 244, 194, 194, 194, 267, /* 500 */ 194, 267, 194, 194, 267, 240, 244, 194, 263, 263,
/* 510 */ 240, 194, 60, 194, 194, 194, 112, 194, 194, 194, /* 510 */ 119, 194, 194, 194, 194, 194, 119, 194, 119, 194,
/* 520 */ 119, 255, 194, 194, 124, 253, 263, 194, 194, 194, /* 520 */ 125, 255, 194, 194, 253, 194, 194, 194, 194, 194,
/* 530 */ 263, 194, 194, 194, 263, 194, 263, 194, 131, 133, /* 530 */ 194, 194, 194, 131, 194, 194, 263, 263, 133, 254,
/* 540 */ 254, 130, 194, 125, 194, 129, 194, 194, 194, 194, /* 540 */ 130, 194, 252, 194, 129, 194, 194, 194, 124, 123,
/* 550 */ 194, 252, 123, 194, 194, 194, 122, 251, 194, 121, /* 550 */ 194, 122, 194, 121, 194, 120, 251, 194, 194, 194,
/* 560 */ 194, 194, 194, 194, 194, 249, 194, 194, 120, 194, /* 560 */ 194, 194, 194, 194, 194, 194, 194, 194, 194, 194,
/* 570 */ 194, 194, 194, 194, 194, 194, 135, 194, 194, 107, /* 570 */ 194, 194, 194, 194, 194, 194, 194, 194, 194, 194,
/* 580 */ 194, 194, 194, 194, 194, 194, 194, 194, 90, 195, /* 580 */ 194, 107, 195, 195, 135, 195, 90, 195, 195, 89,
/* 590 */ 195, 195, 195, 89, 195, 50, 86, 88, 54, 87, /* 590 */ 50, 86, 88, 54, 87, 85, 195, 82, 5, 195,
/* 600 */ 85, 82, 5, 5, 195, 5, 148, 148, 195, 195, /* 600 */ 148, 5, 195, 5, 148, 5, 5, 195, 195, 93,
/* 610 */ 5, 5, 94, 93, 137, 195, 195, 115, 201, 80, /* 610 */ 201, 94, 201, 137, 115, 109, 80, 116, 81, 91,
/* 620 */ 201, 116, 109, 81, 91, 91, 80, 195, 81, 80, /* 620 */ 91, 80, 195, 206, 205, 195, 212, 211, 210, 209,
/* 630 */ 195, 206, 196, 210, 212, 211, 209, 207, 205, 208, /* 630 */ 207, 197, 196, 208, 195, 214, 196, 196, 230, 196,
/* 640 */ 196, 196, 214, 196, 195, 230, 195, 197, 195, 81, /* 640 */ 195, 81, 80, 195, 250, 249, 248, 247, 81, 246,
/* 650 */ 245, 248, 250, 91, 80, 247, 230, 202, 246, 81, /* 650 */ 91, 245, 230, 202, 80, 1, 81, 80, 80, 91,
/* 660 */ 80, 1, 80, 91, 81, 80, 126, 91, 80, 126, /* 660 */ 81, 80, 91, 80, 126, 80, 109, 80, 126, 9,
/* 670 */ 80, 80, 109, 9, 110, 76, 5, 5, 5, 5, /* 670 */ 76, 110, 5, 5, 5, 5, 5, 5, 5, 15,
/* 680 */ 5, 15, 80, 76, 83, 81, 24, 112, 80, 58, /* 680 */ 83, 76, 80, 24, 81, 112, 80, 58, 142, 142,
/* 690 */ 142, 5, 16, 142, 91, 16, 142, 142, 5, 81, /* 690 */ 16, 16, 142, 142, 5, 91, 5, 81, 5, 5,
/* 700 */ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, /* 700 */ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
/* 710 */ 5, 5, 5, 5, 5, 5, 5, 91, 83, 60, /* 710 */ 5, 5, 5, 91, 83, 60, 59, 0, 270, 270,
/* 720 */ 59, 0, 270, 270, 270, 270, 270, 270, 270, 270, /* 720 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 21,
/* 730 */ 270, 270, 270, 21, 21, 270, 270, 270, 270, 270, /* 730 */ 21, 270, 270, 270, 270, 270, 270, 270, 270, 270,
/* 740 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, /* 740 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270,
/* 750 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, /* 750 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270,
/* 760 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, /* 760 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270,
...@@ -374,109 +374,109 @@ static const YYCODETYPE yy_lookahead[] = { ...@@ -374,109 +374,109 @@ static const YYCODETYPE yy_lookahead[] = {
/* 890 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, /* 890 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270,
/* 900 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, /* 900 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270,
/* 910 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, /* 910 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270,
/* 920 */ 270, 270, 270, 270, 270, /* 920 */ 270,
}; };
#define YY_SHIFT_COUNT (346) #define YY_SHIFT_COUNT (346)
#define YY_SHIFT_MIN (0) #define YY_SHIFT_MIN (0)
#define YY_SHIFT_MAX (721) #define YY_SHIFT_MAX (717)
static const unsigned short int yy_shift_ofst[] = { static const unsigned short int yy_shift_ofst[] = {
/* 0 */ 154, 74, 74, 177, 177, 76, 230, 240, 240, 2, /* 0 */ 154, 74, 74, 188, 188, 168, 230, 240, 240, 2,
/* 10 */ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, /* 10 */ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
/* 20 */ 9, 9, 9, 0, 48, 240, 279, 279, 279, 3, /* 20 */ 9, 9, 9, 0, 48, 240, 270, 270, 270, 3,
/* 30 */ 3, 9, 9, 9, 148, 9, 9, 162, 76, 132, /* 30 */ 3, 9, 9, 9, 141, 9, 9, 167, 168, 178,
/* 40 */ 132, 66, 735, 735, 735, 240, 240, 240, 240, 240, /* 40 */ 178, 295, 731, 731, 731, 240, 240, 240, 240, 240,
/* 50 */ 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, /* 50 */ 240, 240, 240, 240, 240, 240, 240, 240, 240, 240,
/* 60 */ 240, 240, 240, 240, 240, 279, 279, 279, 289, 289, /* 60 */ 240, 240, 240, 240, 240, 270, 270, 270, 345, 345,
/* 70 */ 289, 289, 289, 289, 289, 9, 9, 9, 307, 9, /* 70 */ 345, 345, 345, 345, 345, 9, 9, 9, 311, 9,
/* 80 */ 9, 9, 3, 3, 9, 9, 9, 9, 282, 282, /* 80 */ 9, 9, 3, 3, 9, 9, 9, 9, 288, 288,
/* 90 */ 311, 3, 9, 9, 9, 9, 9, 9, 9, 9, /* 90 */ 314, 3, 9, 9, 9, 9, 9, 9, 9, 9,
/* 100 */ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, /* 100 */ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
/* 110 */ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, /* 110 */ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
/* 120 */ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, /* 120 */ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
/* 130 */ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, /* 130 */ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
/* 140 */ 9, 9, 9, 9, 452, 452, 452, 401, 401, 401, /* 140 */ 9, 9, 9, 9, 438, 438, 438, 397, 397, 397,
/* 150 */ 452, 401, 452, 407, 406, 411, 418, 416, 400, 429, /* 150 */ 438, 397, 438, 402, 405, 395, 410, 415, 424, 426,
/* 160 */ 434, 438, 448, 441, 452, 452, 452, 472, 76, 76, /* 160 */ 429, 432, 435, 449, 438, 438, 438, 474, 168, 168,
/* 170 */ 452, 452, 498, 504, 545, 510, 509, 544, 512, 515, /* 170 */ 438, 438, 496, 500, 540, 505, 504, 539, 507, 510,
/* 180 */ 472, 66, 452, 519, 519, 452, 519, 452, 519, 452, /* 180 */ 474, 295, 438, 515, 515, 438, 515, 438, 515, 438,
/* 190 */ 452, 735, 735, 27, 99, 99, 126, 99, 53, 180, /* 190 */ 438, 731, 731, 27, 99, 99, 126, 99, 53, 180,
/* 200 */ 291, 291, 291, 291, 188, 269, 293, 187, 187, 187, /* 200 */ 232, 232, 232, 232, 243, 269, 292, 187, 187, 187,
/* 210 */ 187, 207, 233, 65, 143, 347, 347, 374, 382, 330, /* 210 */ 187, 233, 258, 107, 198, 172, 172, 391, 399, 343,
/* 220 */ 336, 340, 26, 155, 342, 344, 345, 280, 302, 346, /* 220 */ 350, 67, 236, 304, 149, 155, 330, 326, 327, 339,
/* 230 */ 349, 351, 357, 358, 332, 362, 363, 410, 385, 404, /* 230 */ 342, 344, 346, 348, 354, 355, 357, 70, 362, 261,
/* 240 */ 365, 310, 315, 318, 454, 457, 326, 327, 371, 331, /* 240 */ 359, 284, 303, 307, 446, 447, 315, 316, 361, 322,
/* 250 */ 398, 597, 458, 598, 600, 459, 605, 606, 518, 520, /* 250 */ 389, 593, 452, 596, 598, 456, 600, 601, 517, 516,
/* 260 */ 477, 502, 513, 539, 505, 542, 546, 533, 534, 547, /* 260 */ 476, 499, 506, 536, 501, 537, 541, 528, 529, 560,
/* 270 */ 549, 568, 562, 574, 578, 580, 660, 582, 583, 585, /* 270 */ 562, 567, 559, 574, 575, 577, 654, 578, 579, 581,
/* 280 */ 572, 540, 576, 543, 588, 513, 590, 563, 591, 564, /* 280 */ 568, 538, 571, 542, 583, 506, 585, 557, 587, 561,
/* 290 */ 599, 664, 671, 672, 673, 674, 675, 601, 666, 607, /* 290 */ 594, 660, 667, 668, 669, 670, 671, 672, 673, 597,
/* 300 */ 602, 604, 575, 608, 662, 631, 676, 548, 551, 603, /* 300 */ 664, 605, 602, 603, 573, 606, 659, 629, 674, 546,
/* 310 */ 603, 603, 603, 679, 554, 555, 603, 603, 603, 686, /* 310 */ 547, 604, 604, 604, 604, 675, 550, 551, 604, 604,
/* 320 */ 693, 618, 603, 695, 696, 697, 698, 699, 700, 701, /* 320 */ 604, 689, 691, 616, 604, 693, 694, 695, 696, 697,
/* 330 */ 702, 703, 704, 705, 706, 707, 708, 709, 710, 711, /* 330 */ 698, 699, 700, 701, 702, 703, 704, 705, 706, 707,
/* 340 */ 626, 635, 712, 713, 659, 661, 721, /* 340 */ 622, 631, 708, 709, 655, 657, 717,
}; };
#define YY_REDUCE_COUNT (192) #define YY_REDUCE_COUNT (192)
#define YY_REDUCE_MIN (-259) #define YY_REDUCE_MIN (-259)
#define YY_REDUCE_MAX (455) #define YY_REDUCE_MAX (451)
static const short yy_reduce_ofst[] = { static const short yy_reduce_ofst[] = {
/* 0 */ -184, -34, -34, 78, 78, 133, -141, -138, -125, -106, /* 0 */ -184, -34, -34, 101, 101, 133, -141, -138, -125, -106,
/* 10 */ -152, 114, 71, -80, 50, 68, 117, 153, 166, 167, /* 10 */ -152, 18, 58, -80, 44, 61, 134, 143, 150, 151,
/* 20 */ 176, 179, 181, -192, -189, -247, -223, -207, -206, -211, /* 20 */ 152, 153, 166, -192, -189, -247, -223, -207, -206, -211,
/* 30 */ -210, -136, -131, -110, -91, -32, 15, 44, 144, 122, /* 30 */ -210, -136, -131, -110, -91, -32, 54, 57, 124, 182,
/* 40 */ 184, 84, 158, 112, 208, -259, -253, -49, -19, -4, /* 40 */ 196, 75, -41, 94, 138, -259, -253, 52, 98, 106,
/* 50 */ 18, 30, 77, 169, 204, 211, 213, 217, 218, 219, /* 50 */ 111, 185, 202, 208, 209, 211, 212, 213, 214, 215,
/* 60 */ 221, 222, 223, 224, 225, 19, 43, 85, 253, 254, /* 60 */ 216, 217, 218, 219, 220, 189, 238, 239, 250, 251,
/* 70 */ 255, 256, 257, 258, 259, 298, 300, 301, 238, 303, /* 70 */ 252, 253, 254, 255, 256, 296, 297, 298, 231, 299,
/* 80 */ 304, 305, 260, 262, 309, 312, 313, 314, 237, 242, /* 80 */ 300, 301, 257, 259, 302, 306, 308, 309, 234, 237,
/* 90 */ 261, 270, 317, 319, 320, 321, 323, 324, 325, 328, /* 90 */ 262, 265, 313, 317, 318, 319, 320, 321, 323, 325,
/* 100 */ 329, 333, 334, 335, 337, 338, 339, 341, 343, 348, /* 100 */ 328, 329, 331, 332, 333, 334, 335, 336, 337, 338,
/* 110 */ 350, 352, 353, 354, 355, 356, 359, 360, 361, 364, /* 110 */ 340, 341, 347, 349, 351, 352, 353, 356, 358, 360,
/* 120 */ 366, 367, 368, 369, 370, 372, 373, 375, 376, 377, /* 120 */ 363, 364, 365, 366, 367, 368, 369, 370, 371, 372,
/* 130 */ 378, 379, 380, 381, 383, 384, 386, 387, 388, 389, /* 130 */ 373, 374, 375, 376, 377, 378, 379, 380, 381, 382,
/* 140 */ 390, 391, 392, 393, 394, 395, 396, 263, 267, 271, /* 140 */ 383, 384, 385, 386, 387, 388, 390, 245, 246, 273,
/* 150 */ 397, 273, 399, 266, 286, 272, 299, 306, 402, 316, /* 150 */ 392, 274, 393, 266, 285, 271, 290, 305, 394, 396,
/* 160 */ 403, 408, 412, 405, 409, 413, 414, 415, 417, 419, /* 160 */ 398, 400, 403, 406, 401, 404, 407, 408, 409, 411,
/* 170 */ 420, 421, 422, 424, 423, 425, 427, 430, 431, 433, /* 170 */ 412, 413, 414, 416, 418, 417, 420, 423, 425, 419,
/* 180 */ 426, 428, 432, 436, 444, 435, 445, 449, 447, 451, /* 180 */ 422, 421, 427, 436, 440, 430, 441, 439, 443, 445,
/* 190 */ 453, 455, 450, /* 190 */ 448, 451, 434,
}; };
static const YYACTIONTYPE yy_default[] = { static const YYACTIONTYPE yy_default[] = {
/* 0 */ 834, 951, 894, 963, 881, 891, 1100, 1100, 1100, 834, /* 0 */ 830, 947, 890, 957, 877, 887, 1094, 1094, 1094, 830,
/* 10 */ 834, 834, 834, 834, 834, 834, 834, 834, 834, 834, /* 10 */ 830, 830, 830, 830, 830, 830, 830, 830, 830, 830,
/* 20 */ 834, 834, 834, 1011, 853, 1100, 834, 834, 834, 834, /* 20 */ 830, 830, 830, 1005, 849, 1094, 830, 830, 830, 830,
/* 30 */ 834, 834, 834, 834, 891, 834, 834, 897, 891, 897, /* 30 */ 830, 830, 830, 830, 887, 830, 830, 893, 887, 893,
/* 40 */ 897, 834, 1006, 935, 953, 834, 834, 834, 834, 834, /* 40 */ 893, 830, 1000, 931, 949, 830, 830, 830, 830, 830,
/* 50 */ 834, 834, 834, 834, 834, 834, 834, 834, 834, 834, /* 50 */ 830, 830, 830, 830, 830, 830, 830, 830, 830, 830,
/* 60 */ 834, 834, 834, 834, 834, 834, 834, 834, 834, 834, /* 60 */ 830, 830, 830, 830, 830, 830, 830, 830, 830, 830,
/* 70 */ 834, 834, 834, 834, 834, 834, 834, 834, 1013, 1019, /* 70 */ 830, 830, 830, 830, 830, 830, 830, 830, 1007, 1013,
/* 80 */ 1016, 834, 834, 834, 1021, 834, 834, 834, 1043, 1043, /* 80 */ 1010, 830, 830, 830, 1015, 830, 830, 830, 1037, 1037,
/* 90 */ 1004, 834, 834, 834, 834, 834, 834, 834, 834, 834, /* 90 */ 998, 830, 830, 830, 830, 830, 830, 830, 830, 830,
/* 100 */ 834, 834, 834, 834, 834, 834, 834, 834, 834, 834, /* 100 */ 830, 830, 830, 830, 830, 830, 830, 830, 830, 830,
/* 110 */ 834, 834, 834, 834, 834, 834, 834, 834, 834, 834, /* 110 */ 830, 830, 830, 830, 830, 830, 830, 830, 830, 830,
/* 120 */ 879, 834, 877, 834, 834, 834, 834, 834, 834, 834, /* 120 */ 875, 830, 873, 830, 830, 830, 830, 830, 830, 830,
/* 130 */ 834, 834, 834, 834, 834, 834, 834, 864, 834, 834, /* 130 */ 830, 830, 830, 830, 830, 830, 830, 860, 830, 830,
/* 140 */ 834, 834, 834, 834, 855, 855, 855, 834, 834, 834, /* 140 */ 830, 830, 830, 830, 851, 851, 851, 830, 830, 830,
/* 150 */ 855, 834, 855, 1050, 1054, 1048, 1036, 1044, 1035, 1031, /* 150 */ 851, 830, 851, 1044, 1048, 1030, 1042, 1038, 1029, 1025,
/* 160 */ 1029, 1027, 1026, 1058, 855, 855, 855, 895, 891, 891, /* 160 */ 1023, 1021, 1020, 1052, 851, 851, 851, 891, 887, 887,
/* 170 */ 855, 855, 913, 911, 909, 901, 907, 903, 905, 899, /* 170 */ 851, 851, 909, 907, 905, 897, 903, 899, 901, 895,
/* 180 */ 882, 834, 855, 889, 889, 855, 889, 855, 889, 855, /* 180 */ 878, 830, 851, 885, 885, 851, 885, 851, 885, 851,
/* 190 */ 855, 935, 953, 834, 1059, 1049, 834, 1099, 1089, 1088, /* 190 */ 851, 931, 949, 830, 1053, 1043, 830, 1093, 1083, 1082,
/* 200 */ 1095, 1087, 1086, 1085, 834, 834, 834, 1081, 1084, 1083, /* 200 */ 1089, 1081, 1080, 1079, 830, 830, 830, 1075, 1078, 1077,
/* 210 */ 1082, 834, 834, 834, 834, 1091, 1090, 834, 834, 834, /* 210 */ 1076, 830, 830, 830, 830, 1085, 1084, 830, 830, 830,
/* 220 */ 834, 834, 834, 834, 834, 834, 834, 1055, 1051, 834, /* 220 */ 830, 830, 830, 830, 830, 830, 830, 1049, 1045, 830,
/* 230 */ 834, 834, 834, 834, 834, 834, 834, 834, 1061, 834, /* 230 */ 830, 830, 830, 830, 830, 830, 830, 830, 1055, 830,
/* 240 */ 834, 834, 834, 834, 834, 834, 834, 834, 965, 834, /* 240 */ 830, 830, 830, 830, 830, 830, 830, 830, 959, 830,
/* 250 */ 834, 834, 834, 834, 834, 834, 834, 834, 834, 834, /* 250 */ 830, 830, 830, 830, 830, 830, 830, 830, 830, 830,
/* 260 */ 834, 1003, 834, 834, 834, 834, 834, 1015, 1014, 834, /* 260 */ 830, 997, 830, 830, 830, 830, 830, 1009, 1008, 830,
/* 270 */ 834, 834, 834, 834, 834, 834, 834, 834, 834, 834, /* 270 */ 830, 830, 830, 830, 830, 830, 830, 830, 830, 830,
/* 280 */ 1045, 834, 1037, 834, 834, 977, 834, 834, 834, 834, /* 280 */ 1039, 830, 1031, 830, 830, 971, 830, 830, 830, 830,
/* 290 */ 834, 834, 834, 834, 834, 834, 834, 834, 834, 834, /* 290 */ 830, 830, 830, 830, 830, 830, 830, 830, 830, 830,
/* 300 */ 834, 834, 834, 834, 834, 834, 834, 834, 834, 1118, /* 300 */ 830, 830, 830, 830, 830, 830, 830, 830, 830, 830,
/* 310 */ 1113, 1114, 1111, 834, 834, 834, 1110, 1105, 1106, 834, /* 310 */ 830, 1112, 1107, 1108, 1105, 830, 830, 830, 1104, 1099,
/* 320 */ 834, 834, 1103, 834, 834, 834, 834, 834, 834, 834, /* 320 */ 1100, 830, 830, 830, 1097, 830, 830, 830, 830, 830,
/* 330 */ 834, 834, 834, 834, 834, 834, 834, 834, 834, 834, /* 330 */ 830, 830, 830, 830, 830, 830, 830, 830, 830, 830,
/* 340 */ 919, 834, 862, 860, 834, 851, 834, /* 340 */ 915, 830, 858, 856, 830, 847, 830,
}; };
/********** End of lemon-generated parsing tables *****************************/ /********** End of lemon-generated parsing tables *****************************/
...@@ -1024,8 +1024,8 @@ static const char *const yyTokenName[] = { ...@@ -1024,8 +1024,8 @@ static const char *const yyTokenName[] = {
/* 249 */ "fill_opt", /* 249 */ "fill_opt",
/* 250 */ "sliding_opt", /* 250 */ "sliding_opt",
/* 251 */ "groupby_opt", /* 251 */ "groupby_opt",
/* 252 */ "orderby_opt", /* 252 */ "having_opt",
/* 253 */ "having_opt", /* 253 */ "orderby_opt",
/* 254 */ "slimit_opt", /* 254 */ "slimit_opt",
/* 255 */ "limit_opt", /* 255 */ "limit_opt",
/* 256 */ "union", /* 256 */ "union",
...@@ -1171,169 +1171,167 @@ static const char *const yyRuleName[] = { ...@@ -1171,169 +1171,167 @@ static const char *const yyRuleName[] = {
/* 119 */ "alter_db_optr ::= alter_db_optr keep", /* 119 */ "alter_db_optr ::= alter_db_optr keep",
/* 120 */ "alter_db_optr ::= alter_db_optr blocks", /* 120 */ "alter_db_optr ::= alter_db_optr blocks",
/* 121 */ "alter_db_optr ::= alter_db_optr comp", /* 121 */ "alter_db_optr ::= alter_db_optr comp",
/* 122 */ "alter_db_optr ::= alter_db_optr wal", /* 122 */ "alter_db_optr ::= alter_db_optr update",
/* 123 */ "alter_db_optr ::= alter_db_optr fsync", /* 123 */ "alter_db_optr ::= alter_db_optr cachelast",
/* 124 */ "alter_db_optr ::= alter_db_optr update", /* 124 */ "alter_topic_optr ::= alter_db_optr",
/* 125 */ "alter_db_optr ::= alter_db_optr cachelast", /* 125 */ "alter_topic_optr ::= alter_topic_optr partitions",
/* 126 */ "alter_topic_optr ::= alter_db_optr", /* 126 */ "typename ::= ids",
/* 127 */ "alter_topic_optr ::= alter_topic_optr partitions", /* 127 */ "typename ::= ids LP signed RP",
/* 128 */ "typename ::= ids", /* 128 */ "typename ::= ids UNSIGNED",
/* 129 */ "typename ::= ids LP signed RP", /* 129 */ "signed ::= INTEGER",
/* 130 */ "typename ::= ids UNSIGNED", /* 130 */ "signed ::= PLUS INTEGER",
/* 131 */ "signed ::= INTEGER", /* 131 */ "signed ::= MINUS INTEGER",
/* 132 */ "signed ::= PLUS INTEGER", /* 132 */ "cmd ::= CREATE TABLE create_table_args",
/* 133 */ "signed ::= MINUS INTEGER", /* 133 */ "cmd ::= CREATE TABLE create_stable_args",
/* 134 */ "cmd ::= CREATE TABLE create_table_args", /* 134 */ "cmd ::= CREATE STABLE create_stable_args",
/* 135 */ "cmd ::= CREATE TABLE create_stable_args", /* 135 */ "cmd ::= CREATE TABLE create_table_list",
/* 136 */ "cmd ::= CREATE STABLE create_stable_args", /* 136 */ "create_table_list ::= create_from_stable",
/* 137 */ "cmd ::= CREATE TABLE create_table_list", /* 137 */ "create_table_list ::= create_table_list create_from_stable",
/* 138 */ "create_table_list ::= create_from_stable", /* 138 */ "create_table_args ::= ifnotexists ids cpxName LP columnlist RP",
/* 139 */ "create_table_list ::= create_table_list create_from_stable", /* 139 */ "create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP",
/* 140 */ "create_table_args ::= ifnotexists ids cpxName LP columnlist RP", /* 140 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP",
/* 141 */ "create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP", /* 141 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP",
/* 142 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP", /* 142 */ "tagNamelist ::= tagNamelist COMMA ids",
/* 143 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP", /* 143 */ "tagNamelist ::= ids",
/* 144 */ "tagNamelist ::= tagNamelist COMMA ids", /* 144 */ "create_table_args ::= ifnotexists ids cpxName AS select",
/* 145 */ "tagNamelist ::= ids", /* 145 */ "columnlist ::= columnlist COMMA column",
/* 146 */ "create_table_args ::= ifnotexists ids cpxName AS select", /* 146 */ "columnlist ::= column",
/* 147 */ "columnlist ::= columnlist COMMA column", /* 147 */ "column ::= ids typename",
/* 148 */ "columnlist ::= column", /* 148 */ "tagitemlist ::= tagitemlist COMMA tagitem",
/* 149 */ "column ::= ids typename", /* 149 */ "tagitemlist ::= tagitem",
/* 150 */ "tagitemlist ::= tagitemlist COMMA tagitem", /* 150 */ "tagitem ::= INTEGER",
/* 151 */ "tagitemlist ::= tagitem", /* 151 */ "tagitem ::= FLOAT",
/* 152 */ "tagitem ::= INTEGER", /* 152 */ "tagitem ::= STRING",
/* 153 */ "tagitem ::= FLOAT", /* 153 */ "tagitem ::= BOOL",
/* 154 */ "tagitem ::= STRING", /* 154 */ "tagitem ::= NULL",
/* 155 */ "tagitem ::= BOOL", /* 155 */ "tagitem ::= NOW",
/* 156 */ "tagitem ::= NULL", /* 156 */ "tagitem ::= MINUS INTEGER",
/* 157 */ "tagitem ::= NOW", /* 157 */ "tagitem ::= MINUS FLOAT",
/* 158 */ "tagitem ::= MINUS INTEGER", /* 158 */ "tagitem ::= PLUS INTEGER",
/* 159 */ "tagitem ::= MINUS FLOAT", /* 159 */ "tagitem ::= PLUS FLOAT",
/* 160 */ "tagitem ::= PLUS INTEGER", /* 160 */ "select ::= SELECT selcollist from where_opt interval_opt session_option windowstate_option fill_opt sliding_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt",
/* 161 */ "tagitem ::= PLUS FLOAT", /* 161 */ "select ::= LP select RP",
/* 162 */ "select ::= SELECT selcollist from where_opt interval_opt session_option windowstate_option fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt", /* 162 */ "union ::= select",
/* 163 */ "select ::= LP select RP", /* 163 */ "union ::= union UNION ALL select",
/* 164 */ "union ::= select", /* 164 */ "cmd ::= union",
/* 165 */ "union ::= union UNION ALL select", /* 165 */ "select ::= SELECT selcollist",
/* 166 */ "cmd ::= union", /* 166 */ "sclp ::= selcollist COMMA",
/* 167 */ "select ::= SELECT selcollist", /* 167 */ "sclp ::=",
/* 168 */ "sclp ::= selcollist COMMA", /* 168 */ "selcollist ::= sclp distinct expr as",
/* 169 */ "sclp ::=", /* 169 */ "selcollist ::= sclp STAR",
/* 170 */ "selcollist ::= sclp distinct expr as", /* 170 */ "as ::= AS ids",
/* 171 */ "selcollist ::= sclp STAR", /* 171 */ "as ::= ids",
/* 172 */ "as ::= AS ids", /* 172 */ "as ::=",
/* 173 */ "as ::= ids", /* 173 */ "distinct ::= DISTINCT",
/* 174 */ "as ::=", /* 174 */ "distinct ::=",
/* 175 */ "distinct ::= DISTINCT", /* 175 */ "from ::= FROM tablelist",
/* 176 */ "distinct ::=", /* 176 */ "from ::= FROM sub",
/* 177 */ "from ::= FROM tablelist", /* 177 */ "sub ::= LP union RP",
/* 178 */ "from ::= FROM sub", /* 178 */ "sub ::= LP union RP ids",
/* 179 */ "sub ::= LP union RP", /* 179 */ "sub ::= sub COMMA LP union RP ids",
/* 180 */ "sub ::= LP union RP ids", /* 180 */ "tablelist ::= ids cpxName",
/* 181 */ "sub ::= sub COMMA LP union RP ids", /* 181 */ "tablelist ::= ids cpxName ids",
/* 182 */ "tablelist ::= ids cpxName", /* 182 */ "tablelist ::= tablelist COMMA ids cpxName",
/* 183 */ "tablelist ::= ids cpxName ids", /* 183 */ "tablelist ::= tablelist COMMA ids cpxName ids",
/* 184 */ "tablelist ::= tablelist COMMA ids cpxName", /* 184 */ "tmvar ::= VARIABLE",
/* 185 */ "tablelist ::= tablelist COMMA ids cpxName ids", /* 185 */ "interval_opt ::= INTERVAL LP tmvar RP",
/* 186 */ "tmvar ::= VARIABLE", /* 186 */ "interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP",
/* 187 */ "interval_opt ::= INTERVAL LP tmvar RP", /* 187 */ "interval_opt ::=",
/* 188 */ "interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP", /* 188 */ "session_option ::=",
/* 189 */ "interval_opt ::=", /* 189 */ "session_option ::= SESSION LP ids cpxName COMMA tmvar RP",
/* 190 */ "session_option ::=", /* 190 */ "windowstate_option ::=",
/* 191 */ "session_option ::= SESSION LP ids cpxName COMMA tmvar RP", /* 191 */ "windowstate_option ::= STATE_WINDOW LP ids RP",
/* 192 */ "windowstate_option ::=", /* 192 */ "fill_opt ::=",
/* 193 */ "windowstate_option ::= STATE_WINDOW LP ids RP", /* 193 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP",
/* 194 */ "fill_opt ::=", /* 194 */ "fill_opt ::= FILL LP ID RP",
/* 195 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP", /* 195 */ "sliding_opt ::= SLIDING LP tmvar RP",
/* 196 */ "fill_opt ::= FILL LP ID RP", /* 196 */ "sliding_opt ::=",
/* 197 */ "sliding_opt ::= SLIDING LP tmvar RP", /* 197 */ "orderby_opt ::=",
/* 198 */ "sliding_opt ::=", /* 198 */ "orderby_opt ::= ORDER BY sortlist",
/* 199 */ "orderby_opt ::=", /* 199 */ "sortlist ::= sortlist COMMA item sortorder",
/* 200 */ "orderby_opt ::= ORDER BY sortlist", /* 200 */ "sortlist ::= item sortorder",
/* 201 */ "sortlist ::= sortlist COMMA item sortorder", /* 201 */ "item ::= ids cpxName",
/* 202 */ "sortlist ::= item sortorder", /* 202 */ "sortorder ::= ASC",
/* 203 */ "item ::= ids cpxName", /* 203 */ "sortorder ::= DESC",
/* 204 */ "sortorder ::= ASC", /* 204 */ "sortorder ::=",
/* 205 */ "sortorder ::= DESC", /* 205 */ "groupby_opt ::=",
/* 206 */ "sortorder ::=", /* 206 */ "groupby_opt ::= GROUP BY grouplist",
/* 207 */ "groupby_opt ::=", /* 207 */ "grouplist ::= grouplist COMMA item",
/* 208 */ "groupby_opt ::= GROUP BY grouplist", /* 208 */ "grouplist ::= item",
/* 209 */ "grouplist ::= grouplist COMMA item", /* 209 */ "having_opt ::=",
/* 210 */ "grouplist ::= item", /* 210 */ "having_opt ::= HAVING expr",
/* 211 */ "having_opt ::=", /* 211 */ "limit_opt ::=",
/* 212 */ "having_opt ::= HAVING expr", /* 212 */ "limit_opt ::= LIMIT signed",
/* 213 */ "limit_opt ::=", /* 213 */ "limit_opt ::= LIMIT signed OFFSET signed",
/* 214 */ "limit_opt ::= LIMIT signed", /* 214 */ "limit_opt ::= LIMIT signed COMMA signed",
/* 215 */ "limit_opt ::= LIMIT signed OFFSET signed", /* 215 */ "slimit_opt ::=",
/* 216 */ "limit_opt ::= LIMIT signed COMMA signed", /* 216 */ "slimit_opt ::= SLIMIT signed",
/* 217 */ "slimit_opt ::=", /* 217 */ "slimit_opt ::= SLIMIT signed SOFFSET signed",
/* 218 */ "slimit_opt ::= SLIMIT signed", /* 218 */ "slimit_opt ::= SLIMIT signed COMMA signed",
/* 219 */ "slimit_opt ::= SLIMIT signed SOFFSET signed", /* 219 */ "where_opt ::=",
/* 220 */ "slimit_opt ::= SLIMIT signed COMMA signed", /* 220 */ "where_opt ::= WHERE expr",
/* 221 */ "where_opt ::=", /* 221 */ "expr ::= LP expr RP",
/* 222 */ "where_opt ::= WHERE expr", /* 222 */ "expr ::= ID",
/* 223 */ "expr ::= LP expr RP", /* 223 */ "expr ::= ID DOT ID",
/* 224 */ "expr ::= ID", /* 224 */ "expr ::= ID DOT STAR",
/* 225 */ "expr ::= ID DOT ID", /* 225 */ "expr ::= INTEGER",
/* 226 */ "expr ::= ID DOT STAR", /* 226 */ "expr ::= MINUS INTEGER",
/* 227 */ "expr ::= INTEGER", /* 227 */ "expr ::= PLUS INTEGER",
/* 228 */ "expr ::= MINUS INTEGER", /* 228 */ "expr ::= FLOAT",
/* 229 */ "expr ::= PLUS INTEGER", /* 229 */ "expr ::= MINUS FLOAT",
/* 230 */ "expr ::= FLOAT", /* 230 */ "expr ::= PLUS FLOAT",
/* 231 */ "expr ::= MINUS FLOAT", /* 231 */ "expr ::= STRING",
/* 232 */ "expr ::= PLUS FLOAT", /* 232 */ "expr ::= NOW",
/* 233 */ "expr ::= STRING", /* 233 */ "expr ::= VARIABLE",
/* 234 */ "expr ::= NOW", /* 234 */ "expr ::= PLUS VARIABLE",
/* 235 */ "expr ::= VARIABLE", /* 235 */ "expr ::= MINUS VARIABLE",
/* 236 */ "expr ::= PLUS VARIABLE", /* 236 */ "expr ::= BOOL",
/* 237 */ "expr ::= MINUS VARIABLE", /* 237 */ "expr ::= NULL",
/* 238 */ "expr ::= BOOL", /* 238 */ "expr ::= ID LP exprlist RP",
/* 239 */ "expr ::= NULL", /* 239 */ "expr ::= ID LP STAR RP",
/* 240 */ "expr ::= ID LP exprlist RP", /* 240 */ "expr ::= expr IS NULL",
/* 241 */ "expr ::= ID LP STAR RP", /* 241 */ "expr ::= expr IS NOT NULL",
/* 242 */ "expr ::= expr IS NULL", /* 242 */ "expr ::= expr LT expr",
/* 243 */ "expr ::= expr IS NOT NULL", /* 243 */ "expr ::= expr GT expr",
/* 244 */ "expr ::= expr LT expr", /* 244 */ "expr ::= expr LE expr",
/* 245 */ "expr ::= expr GT expr", /* 245 */ "expr ::= expr GE expr",
/* 246 */ "expr ::= expr LE expr", /* 246 */ "expr ::= expr NE expr",
/* 247 */ "expr ::= expr GE expr", /* 247 */ "expr ::= expr EQ expr",
/* 248 */ "expr ::= expr NE expr", /* 248 */ "expr ::= expr BETWEEN expr AND expr",
/* 249 */ "expr ::= expr EQ expr", /* 249 */ "expr ::= expr AND expr",
/* 250 */ "expr ::= expr BETWEEN expr AND expr", /* 250 */ "expr ::= expr OR expr",
/* 251 */ "expr ::= expr AND expr", /* 251 */ "expr ::= expr PLUS expr",
/* 252 */ "expr ::= expr OR expr", /* 252 */ "expr ::= expr MINUS expr",
/* 253 */ "expr ::= expr PLUS expr", /* 253 */ "expr ::= expr STAR expr",
/* 254 */ "expr ::= expr MINUS expr", /* 254 */ "expr ::= expr SLASH expr",
/* 255 */ "expr ::= expr STAR expr", /* 255 */ "expr ::= expr REM expr",
/* 256 */ "expr ::= expr SLASH expr", /* 256 */ "expr ::= expr LIKE expr",
/* 257 */ "expr ::= expr REM expr", /* 257 */ "expr ::= expr IN LP exprlist RP",
/* 258 */ "expr ::= expr LIKE expr", /* 258 */ "exprlist ::= exprlist COMMA expritem",
/* 259 */ "expr ::= expr IN LP exprlist RP", /* 259 */ "exprlist ::= expritem",
/* 260 */ "exprlist ::= exprlist COMMA expritem", /* 260 */ "expritem ::= expr",
/* 261 */ "exprlist ::= expritem", /* 261 */ "expritem ::=",
/* 262 */ "expritem ::= expr", /* 262 */ "cmd ::= RESET QUERY CACHE",
/* 263 */ "expritem ::=", /* 263 */ "cmd ::= SYNCDB ids REPLICA",
/* 264 */ "cmd ::= RESET QUERY CACHE", /* 264 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist",
/* 265 */ "cmd ::= SYNCDB ids REPLICA", /* 265 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids",
/* 266 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist", /* 266 */ "cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist",
/* 267 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids", /* 267 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist",
/* 268 */ "cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist", /* 268 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids",
/* 269 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist", /* 269 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids",
/* 270 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids", /* 270 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem",
/* 271 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids", /* 271 */ "cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist",
/* 272 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem", /* 272 */ "cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist",
/* 273 */ "cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist", /* 273 */ "cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids",
/* 274 */ "cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist", /* 274 */ "cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist",
/* 275 */ "cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids", /* 275 */ "cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist",
/* 276 */ "cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist", /* 276 */ "cmd ::= ALTER STABLE ids cpxName DROP TAG ids",
/* 277 */ "cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist", /* 277 */ "cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids",
/* 278 */ "cmd ::= ALTER STABLE ids cpxName DROP TAG ids", /* 278 */ "cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem",
/* 279 */ "cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids", /* 279 */ "cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist",
/* 280 */ "cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem", /* 280 */ "cmd ::= KILL CONNECTION INTEGER",
/* 281 */ "cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist", /* 281 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER",
/* 282 */ "cmd ::= KILL CONNECTION INTEGER", /* 282 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER",
/* 283 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER",
/* 284 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER",
}; };
#endif /* NDEBUG */ #endif /* NDEBUG */
...@@ -1468,7 +1466,7 @@ tSqlExprListDestroy((yypminor->yy441)); ...@@ -1468,7 +1466,7 @@ tSqlExprListDestroy((yypminor->yy441));
case 239: /* tagNamelist */ case 239: /* tagNamelist */
case 249: /* fill_opt */ case 249: /* fill_opt */
case 251: /* groupby_opt */ case 251: /* groupby_opt */
case 252: /* orderby_opt */ case 253: /* orderby_opt */
case 264: /* sortlist */ case 264: /* sortlist */
case 268: /* grouplist */ case 268: /* grouplist */
{ {
...@@ -1493,7 +1491,7 @@ destroyRelationInfo((yypminor->yy244)); ...@@ -1493,7 +1491,7 @@ destroyRelationInfo((yypminor->yy244));
} }
break; break;
case 245: /* where_opt */ case 245: /* where_opt */
case 253: /* having_opt */ case 252: /* having_opt */
case 259: /* expr */ case 259: /* expr */
case 269: /* expritem */ case 269: /* expritem */
{ {
...@@ -1923,169 +1921,167 @@ static const struct { ...@@ -1923,169 +1921,167 @@ static const struct {
{ 197, -2 }, /* (119) alter_db_optr ::= alter_db_optr keep */ { 197, -2 }, /* (119) alter_db_optr ::= alter_db_optr keep */
{ 197, -2 }, /* (120) alter_db_optr ::= alter_db_optr blocks */ { 197, -2 }, /* (120) alter_db_optr ::= alter_db_optr blocks */
{ 197, -2 }, /* (121) alter_db_optr ::= alter_db_optr comp */ { 197, -2 }, /* (121) alter_db_optr ::= alter_db_optr comp */
{ 197, -2 }, /* (122) alter_db_optr ::= alter_db_optr wal */ { 197, -2 }, /* (122) alter_db_optr ::= alter_db_optr update */
{ 197, -2 }, /* (123) alter_db_optr ::= alter_db_optr fsync */ { 197, -2 }, /* (123) alter_db_optr ::= alter_db_optr cachelast */
{ 197, -2 }, /* (124) alter_db_optr ::= alter_db_optr update */ { 198, -1 }, /* (124) alter_topic_optr ::= alter_db_optr */
{ 197, -2 }, /* (125) alter_db_optr ::= alter_db_optr cachelast */ { 198, -2 }, /* (125) alter_topic_optr ::= alter_topic_optr partitions */
{ 198, -1 }, /* (126) alter_topic_optr ::= alter_db_optr */ { 231, -1 }, /* (126) typename ::= ids */
{ 198, -2 }, /* (127) alter_topic_optr ::= alter_topic_optr partitions */ { 231, -4 }, /* (127) typename ::= ids LP signed RP */
{ 231, -1 }, /* (128) typename ::= ids */ { 231, -2 }, /* (128) typename ::= ids UNSIGNED */
{ 231, -4 }, /* (129) typename ::= ids LP signed RP */ { 232, -1 }, /* (129) signed ::= INTEGER */
{ 231, -2 }, /* (130) typename ::= ids UNSIGNED */ { 232, -2 }, /* (130) signed ::= PLUS INTEGER */
{ 232, -1 }, /* (131) signed ::= INTEGER */ { 232, -2 }, /* (131) signed ::= MINUS INTEGER */
{ 232, -2 }, /* (132) signed ::= PLUS INTEGER */ { 192, -3 }, /* (132) cmd ::= CREATE TABLE create_table_args */
{ 232, -2 }, /* (133) signed ::= MINUS INTEGER */ { 192, -3 }, /* (133) cmd ::= CREATE TABLE create_stable_args */
{ 192, -3 }, /* (134) cmd ::= CREATE TABLE create_table_args */ { 192, -3 }, /* (134) cmd ::= CREATE STABLE create_stable_args */
{ 192, -3 }, /* (135) cmd ::= CREATE TABLE create_stable_args */ { 192, -3 }, /* (135) cmd ::= CREATE TABLE create_table_list */
{ 192, -3 }, /* (136) cmd ::= CREATE STABLE create_stable_args */ { 235, -1 }, /* (136) create_table_list ::= create_from_stable */
{ 192, -3 }, /* (137) cmd ::= CREATE TABLE create_table_list */ { 235, -2 }, /* (137) create_table_list ::= create_table_list create_from_stable */
{ 235, -1 }, /* (138) create_table_list ::= create_from_stable */ { 233, -6 }, /* (138) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */
{ 235, -2 }, /* (139) create_table_list ::= create_table_list create_from_stable */ { 234, -10 }, /* (139) create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */
{ 233, -6 }, /* (140) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ { 236, -10 }, /* (140) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */
{ 234, -10 }, /* (141) create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ { 236, -13 }, /* (141) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */
{ 236, -10 }, /* (142) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ { 239, -3 }, /* (142) tagNamelist ::= tagNamelist COMMA ids */
{ 236, -13 }, /* (143) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ { 239, -1 }, /* (143) tagNamelist ::= ids */
{ 239, -3 }, /* (144) tagNamelist ::= tagNamelist COMMA ids */ { 233, -5 }, /* (144) create_table_args ::= ifnotexists ids cpxName AS select */
{ 239, -1 }, /* (145) tagNamelist ::= ids */ { 237, -3 }, /* (145) columnlist ::= columnlist COMMA column */
{ 233, -5 }, /* (146) create_table_args ::= ifnotexists ids cpxName AS select */ { 237, -1 }, /* (146) columnlist ::= column */
{ 237, -3 }, /* (147) columnlist ::= columnlist COMMA column */ { 241, -2 }, /* (147) column ::= ids typename */
{ 237, -1 }, /* (148) columnlist ::= column */ { 238, -3 }, /* (148) tagitemlist ::= tagitemlist COMMA tagitem */
{ 241, -2 }, /* (149) column ::= ids typename */ { 238, -1 }, /* (149) tagitemlist ::= tagitem */
{ 238, -3 }, /* (150) tagitemlist ::= tagitemlist COMMA tagitem */ { 242, -1 }, /* (150) tagitem ::= INTEGER */
{ 238, -1 }, /* (151) tagitemlist ::= tagitem */ { 242, -1 }, /* (151) tagitem ::= FLOAT */
{ 242, -1 }, /* (152) tagitem ::= INTEGER */ { 242, -1 }, /* (152) tagitem ::= STRING */
{ 242, -1 }, /* (153) tagitem ::= FLOAT */ { 242, -1 }, /* (153) tagitem ::= BOOL */
{ 242, -1 }, /* (154) tagitem ::= STRING */ { 242, -1 }, /* (154) tagitem ::= NULL */
{ 242, -1 }, /* (155) tagitem ::= BOOL */ { 242, -1 }, /* (155) tagitem ::= NOW */
{ 242, -1 }, /* (156) tagitem ::= NULL */ { 242, -2 }, /* (156) tagitem ::= MINUS INTEGER */
{ 242, -1 }, /* (157) tagitem ::= NOW */ { 242, -2 }, /* (157) tagitem ::= MINUS FLOAT */
{ 242, -2 }, /* (158) tagitem ::= MINUS INTEGER */ { 242, -2 }, /* (158) tagitem ::= PLUS INTEGER */
{ 242, -2 }, /* (159) tagitem ::= MINUS FLOAT */ { 242, -2 }, /* (159) tagitem ::= PLUS FLOAT */
{ 242, -2 }, /* (160) tagitem ::= PLUS INTEGER */ { 240, -14 }, /* (160) select ::= SELECT selcollist from where_opt interval_opt session_option windowstate_option fill_opt sliding_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */
{ 242, -2 }, /* (161) tagitem ::= PLUS FLOAT */ { 240, -3 }, /* (161) select ::= LP select RP */
{ 240, -14 }, /* (162) select ::= SELECT selcollist from where_opt interval_opt session_option windowstate_option fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */ { 256, -1 }, /* (162) union ::= select */
{ 240, -3 }, /* (163) select ::= LP select RP */ { 256, -4 }, /* (163) union ::= union UNION ALL select */
{ 256, -1 }, /* (164) union ::= select */ { 192, -1 }, /* (164) cmd ::= union */
{ 256, -4 }, /* (165) union ::= union UNION ALL select */ { 240, -2 }, /* (165) select ::= SELECT selcollist */
{ 192, -1 }, /* (166) cmd ::= union */ { 257, -2 }, /* (166) sclp ::= selcollist COMMA */
{ 240, -2 }, /* (167) select ::= SELECT selcollist */ { 257, 0 }, /* (167) sclp ::= */
{ 257, -2 }, /* (168) sclp ::= selcollist COMMA */ { 243, -4 }, /* (168) selcollist ::= sclp distinct expr as */
{ 257, 0 }, /* (169) sclp ::= */ { 243, -2 }, /* (169) selcollist ::= sclp STAR */
{ 243, -4 }, /* (170) selcollist ::= sclp distinct expr as */ { 260, -2 }, /* (170) as ::= AS ids */
{ 243, -2 }, /* (171) selcollist ::= sclp STAR */ { 260, -1 }, /* (171) as ::= ids */
{ 260, -2 }, /* (172) as ::= AS ids */ { 260, 0 }, /* (172) as ::= */
{ 260, -1 }, /* (173) as ::= ids */ { 258, -1 }, /* (173) distinct ::= DISTINCT */
{ 260, 0 }, /* (174) as ::= */ { 258, 0 }, /* (174) distinct ::= */
{ 258, -1 }, /* (175) distinct ::= DISTINCT */ { 244, -2 }, /* (175) from ::= FROM tablelist */
{ 258, 0 }, /* (176) distinct ::= */ { 244, -2 }, /* (176) from ::= FROM sub */
{ 244, -2 }, /* (177) from ::= FROM tablelist */ { 262, -3 }, /* (177) sub ::= LP union RP */
{ 244, -2 }, /* (178) from ::= FROM sub */ { 262, -4 }, /* (178) sub ::= LP union RP ids */
{ 262, -3 }, /* (179) sub ::= LP union RP */ { 262, -6 }, /* (179) sub ::= sub COMMA LP union RP ids */
{ 262, -4 }, /* (180) sub ::= LP union RP ids */ { 261, -2 }, /* (180) tablelist ::= ids cpxName */
{ 262, -6 }, /* (181) sub ::= sub COMMA LP union RP ids */ { 261, -3 }, /* (181) tablelist ::= ids cpxName ids */
{ 261, -2 }, /* (182) tablelist ::= ids cpxName */ { 261, -4 }, /* (182) tablelist ::= tablelist COMMA ids cpxName */
{ 261, -3 }, /* (183) tablelist ::= ids cpxName ids */ { 261, -5 }, /* (183) tablelist ::= tablelist COMMA ids cpxName ids */
{ 261, -4 }, /* (184) tablelist ::= tablelist COMMA ids cpxName */ { 263, -1 }, /* (184) tmvar ::= VARIABLE */
{ 261, -5 }, /* (185) tablelist ::= tablelist COMMA ids cpxName ids */ { 246, -4 }, /* (185) interval_opt ::= INTERVAL LP tmvar RP */
{ 263, -1 }, /* (186) tmvar ::= VARIABLE */ { 246, -6 }, /* (186) interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */
{ 246, -4 }, /* (187) interval_opt ::= INTERVAL LP tmvar RP */ { 246, 0 }, /* (187) interval_opt ::= */
{ 246, -6 }, /* (188) interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ { 247, 0 }, /* (188) session_option ::= */
{ 246, 0 }, /* (189) interval_opt ::= */ { 247, -7 }, /* (189) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */
{ 247, 0 }, /* (190) session_option ::= */ { 248, 0 }, /* (190) windowstate_option ::= */
{ 247, -7 }, /* (191) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ { 248, -4 }, /* (191) windowstate_option ::= STATE_WINDOW LP ids RP */
{ 248, 0 }, /* (192) windowstate_option ::= */ { 249, 0 }, /* (192) fill_opt ::= */
{ 248, -4 }, /* (193) windowstate_option ::= STATE_WINDOW LP ids RP */ { 249, -6 }, /* (193) fill_opt ::= FILL LP ID COMMA tagitemlist RP */
{ 249, 0 }, /* (194) fill_opt ::= */ { 249, -4 }, /* (194) fill_opt ::= FILL LP ID RP */
{ 249, -6 }, /* (195) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ { 250, -4 }, /* (195) sliding_opt ::= SLIDING LP tmvar RP */
{ 249, -4 }, /* (196) fill_opt ::= FILL LP ID RP */ { 250, 0 }, /* (196) sliding_opt ::= */
{ 250, -4 }, /* (197) sliding_opt ::= SLIDING LP tmvar RP */ { 253, 0 }, /* (197) orderby_opt ::= */
{ 250, 0 }, /* (198) sliding_opt ::= */ { 253, -3 }, /* (198) orderby_opt ::= ORDER BY sortlist */
{ 252, 0 }, /* (199) orderby_opt ::= */ { 264, -4 }, /* (199) sortlist ::= sortlist COMMA item sortorder */
{ 252, -3 }, /* (200) orderby_opt ::= ORDER BY sortlist */ { 264, -2 }, /* (200) sortlist ::= item sortorder */
{ 264, -4 }, /* (201) sortlist ::= sortlist COMMA item sortorder */ { 266, -2 }, /* (201) item ::= ids cpxName */
{ 264, -2 }, /* (202) sortlist ::= item sortorder */ { 267, -1 }, /* (202) sortorder ::= ASC */
{ 266, -2 }, /* (203) item ::= ids cpxName */ { 267, -1 }, /* (203) sortorder ::= DESC */
{ 267, -1 }, /* (204) sortorder ::= ASC */ { 267, 0 }, /* (204) sortorder ::= */
{ 267, -1 }, /* (205) sortorder ::= DESC */ { 251, 0 }, /* (205) groupby_opt ::= */
{ 267, 0 }, /* (206) sortorder ::= */ { 251, -3 }, /* (206) groupby_opt ::= GROUP BY grouplist */
{ 251, 0 }, /* (207) groupby_opt ::= */ { 268, -3 }, /* (207) grouplist ::= grouplist COMMA item */
{ 251, -3 }, /* (208) groupby_opt ::= GROUP BY grouplist */ { 268, -1 }, /* (208) grouplist ::= item */
{ 268, -3 }, /* (209) grouplist ::= grouplist COMMA item */ { 252, 0 }, /* (209) having_opt ::= */
{ 268, -1 }, /* (210) grouplist ::= item */ { 252, -2 }, /* (210) having_opt ::= HAVING expr */
{ 253, 0 }, /* (211) having_opt ::= */ { 255, 0 }, /* (211) limit_opt ::= */
{ 253, -2 }, /* (212) having_opt ::= HAVING expr */ { 255, -2 }, /* (212) limit_opt ::= LIMIT signed */
{ 255, 0 }, /* (213) limit_opt ::= */ { 255, -4 }, /* (213) limit_opt ::= LIMIT signed OFFSET signed */
{ 255, -2 }, /* (214) limit_opt ::= LIMIT signed */ { 255, -4 }, /* (214) limit_opt ::= LIMIT signed COMMA signed */
{ 255, -4 }, /* (215) limit_opt ::= LIMIT signed OFFSET signed */ { 254, 0 }, /* (215) slimit_opt ::= */
{ 255, -4 }, /* (216) limit_opt ::= LIMIT signed COMMA signed */ { 254, -2 }, /* (216) slimit_opt ::= SLIMIT signed */
{ 254, 0 }, /* (217) slimit_opt ::= */ { 254, -4 }, /* (217) slimit_opt ::= SLIMIT signed SOFFSET signed */
{ 254, -2 }, /* (218) slimit_opt ::= SLIMIT signed */ { 254, -4 }, /* (218) slimit_opt ::= SLIMIT signed COMMA signed */
{ 254, -4 }, /* (219) slimit_opt ::= SLIMIT signed SOFFSET signed */ { 245, 0 }, /* (219) where_opt ::= */
{ 254, -4 }, /* (220) slimit_opt ::= SLIMIT signed COMMA signed */ { 245, -2 }, /* (220) where_opt ::= WHERE expr */
{ 245, 0 }, /* (221) where_opt ::= */ { 259, -3 }, /* (221) expr ::= LP expr RP */
{ 245, -2 }, /* (222) where_opt ::= WHERE expr */ { 259, -1 }, /* (222) expr ::= ID */
{ 259, -3 }, /* (223) expr ::= LP expr RP */ { 259, -3 }, /* (223) expr ::= ID DOT ID */
{ 259, -1 }, /* (224) expr ::= ID */ { 259, -3 }, /* (224) expr ::= ID DOT STAR */
{ 259, -3 }, /* (225) expr ::= ID DOT ID */ { 259, -1 }, /* (225) expr ::= INTEGER */
{ 259, -3 }, /* (226) expr ::= ID DOT STAR */ { 259, -2 }, /* (226) expr ::= MINUS INTEGER */
{ 259, -1 }, /* (227) expr ::= INTEGER */ { 259, -2 }, /* (227) expr ::= PLUS INTEGER */
{ 259, -2 }, /* (228) expr ::= MINUS INTEGER */ { 259, -1 }, /* (228) expr ::= FLOAT */
{ 259, -2 }, /* (229) expr ::= PLUS INTEGER */ { 259, -2 }, /* (229) expr ::= MINUS FLOAT */
{ 259, -1 }, /* (230) expr ::= FLOAT */ { 259, -2 }, /* (230) expr ::= PLUS FLOAT */
{ 259, -2 }, /* (231) expr ::= MINUS FLOAT */ { 259, -1 }, /* (231) expr ::= STRING */
{ 259, -2 }, /* (232) expr ::= PLUS FLOAT */ { 259, -1 }, /* (232) expr ::= NOW */
{ 259, -1 }, /* (233) expr ::= STRING */ { 259, -1 }, /* (233) expr ::= VARIABLE */
{ 259, -1 }, /* (234) expr ::= NOW */ { 259, -2 }, /* (234) expr ::= PLUS VARIABLE */
{ 259, -1 }, /* (235) expr ::= VARIABLE */ { 259, -2 }, /* (235) expr ::= MINUS VARIABLE */
{ 259, -2 }, /* (236) expr ::= PLUS VARIABLE */ { 259, -1 }, /* (236) expr ::= BOOL */
{ 259, -2 }, /* (237) expr ::= MINUS VARIABLE */ { 259, -1 }, /* (237) expr ::= NULL */
{ 259, -1 }, /* (238) expr ::= BOOL */ { 259, -4 }, /* (238) expr ::= ID LP exprlist RP */
{ 259, -1 }, /* (239) expr ::= NULL */ { 259, -4 }, /* (239) expr ::= ID LP STAR RP */
{ 259, -4 }, /* (240) expr ::= ID LP exprlist RP */ { 259, -3 }, /* (240) expr ::= expr IS NULL */
{ 259, -4 }, /* (241) expr ::= ID LP STAR RP */ { 259, -4 }, /* (241) expr ::= expr IS NOT NULL */
{ 259, -3 }, /* (242) expr ::= expr IS NULL */ { 259, -3 }, /* (242) expr ::= expr LT expr */
{ 259, -4 }, /* (243) expr ::= expr IS NOT NULL */ { 259, -3 }, /* (243) expr ::= expr GT expr */
{ 259, -3 }, /* (244) expr ::= expr LT expr */ { 259, -3 }, /* (244) expr ::= expr LE expr */
{ 259, -3 }, /* (245) expr ::= expr GT expr */ { 259, -3 }, /* (245) expr ::= expr GE expr */
{ 259, -3 }, /* (246) expr ::= expr LE expr */ { 259, -3 }, /* (246) expr ::= expr NE expr */
{ 259, -3 }, /* (247) expr ::= expr GE expr */ { 259, -3 }, /* (247) expr ::= expr EQ expr */
{ 259, -3 }, /* (248) expr ::= expr NE expr */ { 259, -5 }, /* (248) expr ::= expr BETWEEN expr AND expr */
{ 259, -3 }, /* (249) expr ::= expr EQ expr */ { 259, -3 }, /* (249) expr ::= expr AND expr */
{ 259, -5 }, /* (250) expr ::= expr BETWEEN expr AND expr */ { 259, -3 }, /* (250) expr ::= expr OR expr */
{ 259, -3 }, /* (251) expr ::= expr AND expr */ { 259, -3 }, /* (251) expr ::= expr PLUS expr */
{ 259, -3 }, /* (252) expr ::= expr OR expr */ { 259, -3 }, /* (252) expr ::= expr MINUS expr */
{ 259, -3 }, /* (253) expr ::= expr PLUS expr */ { 259, -3 }, /* (253) expr ::= expr STAR expr */
{ 259, -3 }, /* (254) expr ::= expr MINUS expr */ { 259, -3 }, /* (254) expr ::= expr SLASH expr */
{ 259, -3 }, /* (255) expr ::= expr STAR expr */ { 259, -3 }, /* (255) expr ::= expr REM expr */
{ 259, -3 }, /* (256) expr ::= expr SLASH expr */ { 259, -3 }, /* (256) expr ::= expr LIKE expr */
{ 259, -3 }, /* (257) expr ::= expr REM expr */ { 259, -5 }, /* (257) expr ::= expr IN LP exprlist RP */
{ 259, -3 }, /* (258) expr ::= expr LIKE expr */ { 200, -3 }, /* (258) exprlist ::= exprlist COMMA expritem */
{ 259, -5 }, /* (259) expr ::= expr IN LP exprlist RP */ { 200, -1 }, /* (259) exprlist ::= expritem */
{ 200, -3 }, /* (260) exprlist ::= exprlist COMMA expritem */ { 269, -1 }, /* (260) expritem ::= expr */
{ 200, -1 }, /* (261) exprlist ::= expritem */ { 269, 0 }, /* (261) expritem ::= */
{ 269, -1 }, /* (262) expritem ::= expr */ { 192, -3 }, /* (262) cmd ::= RESET QUERY CACHE */
{ 269, 0 }, /* (263) expritem ::= */ { 192, -3 }, /* (263) cmd ::= SYNCDB ids REPLICA */
{ 192, -3 }, /* (264) cmd ::= RESET QUERY CACHE */ { 192, -7 }, /* (264) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */
{ 192, -3 }, /* (265) cmd ::= SYNCDB ids REPLICA */ { 192, -7 }, /* (265) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */
{ 192, -7 }, /* (266) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ { 192, -7 }, /* (266) cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */
{ 192, -7 }, /* (267) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ { 192, -7 }, /* (267) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */
{ 192, -7 }, /* (268) cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ { 192, -7 }, /* (268) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */
{ 192, -7 }, /* (269) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ { 192, -8 }, /* (269) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */
{ 192, -7 }, /* (270) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ { 192, -9 }, /* (270) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */
{ 192, -8 }, /* (271) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ { 192, -7 }, /* (271) cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */
{ 192, -9 }, /* (272) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ { 192, -7 }, /* (272) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */
{ 192, -7 }, /* (273) cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ { 192, -7 }, /* (273) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */
{ 192, -7 }, /* (274) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ { 192, -7 }, /* (274) cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */
{ 192, -7 }, /* (275) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ { 192, -7 }, /* (275) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */
{ 192, -7 }, /* (276) cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ { 192, -7 }, /* (276) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */
{ 192, -7 }, /* (277) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ { 192, -8 }, /* (277) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */
{ 192, -7 }, /* (278) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ { 192, -9 }, /* (278) cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */
{ 192, -8 }, /* (279) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ { 192, -7 }, /* (279) cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */
{ 192, -9 }, /* (280) cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ { 192, -3 }, /* (280) cmd ::= KILL CONNECTION INTEGER */
{ 192, -7 }, /* (281) cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ { 192, -5 }, /* (281) cmd ::= KILL STREAM INTEGER COLON INTEGER */
{ 192, -3 }, /* (282) cmd ::= KILL CONNECTION INTEGER */ { 192, -5 }, /* (282) cmd ::= KILL QUERY INTEGER COLON INTEGER */
{ 192, -5 }, /* (283) cmd ::= KILL STREAM INTEGER COLON INTEGER */
{ 192, -5 }, /* (284) cmd ::= KILL QUERY INTEGER COLON INTEGER */
}; };
static void yy_accept(yyParser*); /* Forward Declaration */ static void yy_accept(yyParser*); /* Forward Declaration */
...@@ -2166,9 +2162,9 @@ static void yy_reduce( ...@@ -2166,9 +2162,9 @@ static void yy_reduce(
/********** Begin reduce actions **********************************************/ /********** Begin reduce actions **********************************************/
YYMINORTYPE yylhsminor; YYMINORTYPE yylhsminor;
case 0: /* program ::= cmd */ case 0: /* program ::= cmd */
case 134: /* cmd ::= CREATE TABLE create_table_args */ yytestcase(yyruleno==134); case 132: /* cmd ::= CREATE TABLE create_table_args */ yytestcase(yyruleno==132);
case 135: /* cmd ::= CREATE TABLE create_stable_args */ yytestcase(yyruleno==135); case 133: /* cmd ::= CREATE TABLE create_stable_args */ yytestcase(yyruleno==133);
case 136: /* cmd ::= CREATE STABLE create_stable_args */ yytestcase(yyruleno==136); case 134: /* cmd ::= CREATE STABLE create_stable_args */ yytestcase(yyruleno==134);
{} {}
break; break;
case 1: /* cmd ::= SHOW DATABASES */ case 1: /* cmd ::= SHOW DATABASES */
...@@ -2359,7 +2355,7 @@ static void yy_reduce( ...@@ -2359,7 +2355,7 @@ static void yy_reduce(
break; break;
case 52: /* ifexists ::= */ case 52: /* ifexists ::= */
case 54: /* ifnotexists ::= */ yytestcase(yyruleno==54); case 54: /* ifnotexists ::= */ yytestcase(yyruleno==54);
case 176: /* distinct ::= */ yytestcase(yyruleno==176); case 174: /* distinct ::= */ yytestcase(yyruleno==174);
{ yymsp[1].minor.yy0.n = 0;} { yymsp[1].minor.yy0.n = 0;}
break; break;
case 53: /* ifnotexists ::= IF NOT EXISTS */ case 53: /* ifnotexists ::= IF NOT EXISTS */
...@@ -2415,20 +2411,20 @@ static void yy_reduce( ...@@ -2415,20 +2411,20 @@ static void yy_reduce(
yymsp[-8].minor.yy151 = yylhsminor.yy151; yymsp[-8].minor.yy151 = yylhsminor.yy151;
break; break;
case 79: /* intitemlist ::= intitemlist COMMA intitem */ case 79: /* intitemlist ::= intitemlist COMMA intitem */
case 150: /* tagitemlist ::= tagitemlist COMMA tagitem */ yytestcase(yyruleno==150); case 148: /* tagitemlist ::= tagitemlist COMMA tagitem */ yytestcase(yyruleno==148);
{ yylhsminor.yy441 = tVariantListAppend(yymsp[-2].minor.yy441, &yymsp[0].minor.yy506, -1); } { yylhsminor.yy441 = tVariantListAppend(yymsp[-2].minor.yy441, &yymsp[0].minor.yy506, -1); }
yymsp[-2].minor.yy441 = yylhsminor.yy441; yymsp[-2].minor.yy441 = yylhsminor.yy441;
break; break;
case 80: /* intitemlist ::= intitem */ case 80: /* intitemlist ::= intitem */
case 151: /* tagitemlist ::= tagitem */ yytestcase(yyruleno==151); case 149: /* tagitemlist ::= tagitem */ yytestcase(yyruleno==149);
{ yylhsminor.yy441 = tVariantListAppend(NULL, &yymsp[0].minor.yy506, -1); } { yylhsminor.yy441 = tVariantListAppend(NULL, &yymsp[0].minor.yy506, -1); }
yymsp[0].minor.yy441 = yylhsminor.yy441; yymsp[0].minor.yy441 = yylhsminor.yy441;
break; break;
case 81: /* intitem ::= INTEGER */ case 81: /* intitem ::= INTEGER */
case 152: /* tagitem ::= INTEGER */ yytestcase(yyruleno==152); case 150: /* tagitem ::= INTEGER */ yytestcase(yyruleno==150);
case 153: /* tagitem ::= FLOAT */ yytestcase(yyruleno==153); case 151: /* tagitem ::= FLOAT */ yytestcase(yyruleno==151);
case 154: /* tagitem ::= STRING */ yytestcase(yyruleno==154); case 152: /* tagitem ::= STRING */ yytestcase(yyruleno==152);
case 155: /* tagitem ::= BOOL */ yytestcase(yyruleno==155); case 153: /* tagitem ::= BOOL */ yytestcase(yyruleno==153);
{ toTSDBType(yymsp[0].minor.yy0.type); tVariantCreate(&yylhsminor.yy506, &yymsp[0].minor.yy0); } { toTSDBType(yymsp[0].minor.yy0.type); tVariantCreate(&yylhsminor.yy506, &yymsp[0].minor.yy0); }
yymsp[0].minor.yy506 = yylhsminor.yy506; yymsp[0].minor.yy506 = yylhsminor.yy506;
break; break;
...@@ -2491,12 +2487,10 @@ static void yy_reduce( ...@@ -2491,12 +2487,10 @@ static void yy_reduce(
yymsp[-1].minor.yy382 = yylhsminor.yy382; yymsp[-1].minor.yy382 = yylhsminor.yy382;
break; break;
case 107: /* db_optr ::= db_optr wal */ case 107: /* db_optr ::= db_optr wal */
case 122: /* alter_db_optr ::= alter_db_optr wal */ yytestcase(yyruleno==122);
{ yylhsminor.yy382 = yymsp[-1].minor.yy382; yylhsminor.yy382.walLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy382 = yymsp[-1].minor.yy382; yylhsminor.yy382.walLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy382 = yylhsminor.yy382; yymsp[-1].minor.yy382 = yylhsminor.yy382;
break; break;
case 108: /* db_optr ::= db_optr fsync */ case 108: /* db_optr ::= db_optr fsync */
case 123: /* alter_db_optr ::= alter_db_optr fsync */ yytestcase(yyruleno==123);
{ yylhsminor.yy382 = yymsp[-1].minor.yy382; yylhsminor.yy382.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy382 = yymsp[-1].minor.yy382; yylhsminor.yy382.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy382 = yylhsminor.yy382; yymsp[-1].minor.yy382 = yylhsminor.yy382;
break; break;
...@@ -2515,36 +2509,36 @@ static void yy_reduce( ...@@ -2515,36 +2509,36 @@ static void yy_reduce(
yymsp[-1].minor.yy382 = yylhsminor.yy382; yymsp[-1].minor.yy382 = yylhsminor.yy382;
break; break;
case 112: /* db_optr ::= db_optr update */ case 112: /* db_optr ::= db_optr update */
case 124: /* alter_db_optr ::= alter_db_optr update */ yytestcase(yyruleno==124); case 122: /* alter_db_optr ::= alter_db_optr update */ yytestcase(yyruleno==122);
{ yylhsminor.yy382 = yymsp[-1].minor.yy382; yylhsminor.yy382.update = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy382 = yymsp[-1].minor.yy382; yylhsminor.yy382.update = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy382 = yylhsminor.yy382; yymsp[-1].minor.yy382 = yylhsminor.yy382;
break; break;
case 113: /* db_optr ::= db_optr cachelast */ case 113: /* db_optr ::= db_optr cachelast */
case 125: /* alter_db_optr ::= alter_db_optr cachelast */ yytestcase(yyruleno==125); case 123: /* alter_db_optr ::= alter_db_optr cachelast */ yytestcase(yyruleno==123);
{ yylhsminor.yy382 = yymsp[-1].minor.yy382; yylhsminor.yy382.cachelast = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy382 = yymsp[-1].minor.yy382; yylhsminor.yy382.cachelast = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy382 = yylhsminor.yy382; yymsp[-1].minor.yy382 = yylhsminor.yy382;
break; break;
case 114: /* topic_optr ::= db_optr */ case 114: /* topic_optr ::= db_optr */
case 126: /* alter_topic_optr ::= alter_db_optr */ yytestcase(yyruleno==126); case 124: /* alter_topic_optr ::= alter_db_optr */ yytestcase(yyruleno==124);
{ yylhsminor.yy382 = yymsp[0].minor.yy382; yylhsminor.yy382.dbType = TSDB_DB_TYPE_TOPIC; } { yylhsminor.yy382 = yymsp[0].minor.yy382; yylhsminor.yy382.dbType = TSDB_DB_TYPE_TOPIC; }
yymsp[0].minor.yy382 = yylhsminor.yy382; yymsp[0].minor.yy382 = yylhsminor.yy382;
break; break;
case 115: /* topic_optr ::= topic_optr partitions */ case 115: /* topic_optr ::= topic_optr partitions */
case 127: /* alter_topic_optr ::= alter_topic_optr partitions */ yytestcase(yyruleno==127); case 125: /* alter_topic_optr ::= alter_topic_optr partitions */ yytestcase(yyruleno==125);
{ yylhsminor.yy382 = yymsp[-1].minor.yy382; yylhsminor.yy382.partitions = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy382 = yymsp[-1].minor.yy382; yylhsminor.yy382.partitions = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[-1].minor.yy382 = yylhsminor.yy382; yymsp[-1].minor.yy382 = yylhsminor.yy382;
break; break;
case 116: /* alter_db_optr ::= */ case 116: /* alter_db_optr ::= */
{ setDefaultCreateDbOption(&yymsp[1].minor.yy382); yymsp[1].minor.yy382.dbType = TSDB_DB_TYPE_DEFAULT;} { setDefaultCreateDbOption(&yymsp[1].minor.yy382); yymsp[1].minor.yy382.dbType = TSDB_DB_TYPE_DEFAULT;}
break; break;
case 128: /* typename ::= ids */ case 126: /* typename ::= ids */
{ {
yymsp[0].minor.yy0.type = 0; yymsp[0].minor.yy0.type = 0;
tSetColumnType (&yylhsminor.yy343, &yymsp[0].minor.yy0); tSetColumnType (&yylhsminor.yy343, &yymsp[0].minor.yy0);
} }
yymsp[0].minor.yy343 = yylhsminor.yy343; yymsp[0].minor.yy343 = yylhsminor.yy343;
break; break;
case 129: /* typename ::= ids LP signed RP */ case 127: /* typename ::= ids LP signed RP */
{ {
if (yymsp[-1].minor.yy369 <= 0) { if (yymsp[-1].minor.yy369 <= 0) {
yymsp[-3].minor.yy0.type = 0; yymsp[-3].minor.yy0.type = 0;
...@@ -2556,7 +2550,7 @@ static void yy_reduce( ...@@ -2556,7 +2550,7 @@ static void yy_reduce(
} }
yymsp[-3].minor.yy343 = yylhsminor.yy343; yymsp[-3].minor.yy343 = yylhsminor.yy343;
break; break;
case 130: /* typename ::= ids UNSIGNED */ case 128: /* typename ::= ids UNSIGNED */
{ {
yymsp[-1].minor.yy0.type = 0; yymsp[-1].minor.yy0.type = 0;
yymsp[-1].minor.yy0.n = ((yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z); yymsp[-1].minor.yy0.n = ((yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z);
...@@ -2564,20 +2558,20 @@ static void yy_reduce( ...@@ -2564,20 +2558,20 @@ static void yy_reduce(
} }
yymsp[-1].minor.yy343 = yylhsminor.yy343; yymsp[-1].minor.yy343 = yylhsminor.yy343;
break; break;
case 131: /* signed ::= INTEGER */ case 129: /* signed ::= INTEGER */
{ yylhsminor.yy369 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yylhsminor.yy369 = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
yymsp[0].minor.yy369 = yylhsminor.yy369; yymsp[0].minor.yy369 = yylhsminor.yy369;
break; break;
case 132: /* signed ::= PLUS INTEGER */ case 130: /* signed ::= PLUS INTEGER */
{ yymsp[-1].minor.yy369 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } { yymsp[-1].minor.yy369 = strtol(yymsp[0].minor.yy0.z, NULL, 10); }
break; break;
case 133: /* signed ::= MINUS INTEGER */ case 131: /* signed ::= MINUS INTEGER */
{ yymsp[-1].minor.yy369 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);} { yymsp[-1].minor.yy369 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);}
break; break;
case 137: /* cmd ::= CREATE TABLE create_table_list */ case 135: /* cmd ::= CREATE TABLE create_table_list */
{ pInfo->type = TSDB_SQL_CREATE_TABLE; pInfo->pCreateTableInfo = yymsp[0].minor.yy182;} { pInfo->type = TSDB_SQL_CREATE_TABLE; pInfo->pCreateTableInfo = yymsp[0].minor.yy182;}
break; break;
case 138: /* create_table_list ::= create_from_stable */ case 136: /* create_table_list ::= create_from_stable */
{ {
SCreateTableSql* pCreateTable = calloc(1, sizeof(SCreateTableSql)); SCreateTableSql* pCreateTable = calloc(1, sizeof(SCreateTableSql));
pCreateTable->childTableInfo = taosArrayInit(4, sizeof(SCreatedTableInfo)); pCreateTable->childTableInfo = taosArrayInit(4, sizeof(SCreatedTableInfo));
...@@ -2588,14 +2582,14 @@ static void yy_reduce( ...@@ -2588,14 +2582,14 @@ static void yy_reduce(
} }
yymsp[0].minor.yy182 = yylhsminor.yy182; yymsp[0].minor.yy182 = yylhsminor.yy182;
break; break;
case 139: /* create_table_list ::= create_table_list create_from_stable */ case 137: /* create_table_list ::= create_table_list create_from_stable */
{ {
taosArrayPush(yymsp[-1].minor.yy182->childTableInfo, &yymsp[0].minor.yy456); taosArrayPush(yymsp[-1].minor.yy182->childTableInfo, &yymsp[0].minor.yy456);
yylhsminor.yy182 = yymsp[-1].minor.yy182; yylhsminor.yy182 = yymsp[-1].minor.yy182;
} }
yymsp[-1].minor.yy182 = yylhsminor.yy182; yymsp[-1].minor.yy182 = yylhsminor.yy182;
break; break;
case 140: /* create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ case 138: /* create_table_args ::= ifnotexists ids cpxName LP columnlist RP */
{ {
yylhsminor.yy182 = tSetCreateTableInfo(yymsp[-1].minor.yy441, NULL, NULL, TSQL_CREATE_TABLE); yylhsminor.yy182 = tSetCreateTableInfo(yymsp[-1].minor.yy441, NULL, NULL, TSQL_CREATE_TABLE);
setSqlInfo(pInfo, yylhsminor.yy182, NULL, TSDB_SQL_CREATE_TABLE); setSqlInfo(pInfo, yylhsminor.yy182, NULL, TSDB_SQL_CREATE_TABLE);
...@@ -2605,7 +2599,7 @@ static void yy_reduce( ...@@ -2605,7 +2599,7 @@ static void yy_reduce(
} }
yymsp[-5].minor.yy182 = yylhsminor.yy182; yymsp[-5].minor.yy182 = yylhsminor.yy182;
break; break;
case 141: /* create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ case 139: /* create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */
{ {
yylhsminor.yy182 = tSetCreateTableInfo(yymsp[-5].minor.yy441, yymsp[-1].minor.yy441, NULL, TSQL_CREATE_STABLE); yylhsminor.yy182 = tSetCreateTableInfo(yymsp[-5].minor.yy441, yymsp[-1].minor.yy441, NULL, TSQL_CREATE_STABLE);
setSqlInfo(pInfo, yylhsminor.yy182, NULL, TSDB_SQL_CREATE_TABLE); setSqlInfo(pInfo, yylhsminor.yy182, NULL, TSDB_SQL_CREATE_TABLE);
...@@ -2615,7 +2609,7 @@ static void yy_reduce( ...@@ -2615,7 +2609,7 @@ static void yy_reduce(
} }
yymsp[-9].minor.yy182 = yylhsminor.yy182; yymsp[-9].minor.yy182 = yylhsminor.yy182;
break; break;
case 142: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ case 140: /* create_from_stable ::= ifnotexists ids cpxName 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[-8].minor.yy0.n += yymsp[-7].minor.yy0.n; yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n;
...@@ -2623,7 +2617,7 @@ static void yy_reduce( ...@@ -2623,7 +2617,7 @@ static void yy_reduce(
} }
yymsp[-9].minor.yy456 = yylhsminor.yy456; yymsp[-9].minor.yy456 = yylhsminor.yy456;
break; break;
case 143: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ case 141: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */
{ {
yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n; yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n;
yymsp[-11].minor.yy0.n += yymsp[-10].minor.yy0.n; yymsp[-11].minor.yy0.n += yymsp[-10].minor.yy0.n;
...@@ -2631,15 +2625,15 @@ static void yy_reduce( ...@@ -2631,15 +2625,15 @@ static void yy_reduce(
} }
yymsp[-12].minor.yy456 = yylhsminor.yy456; yymsp[-12].minor.yy456 = yylhsminor.yy456;
break; break;
case 144: /* tagNamelist ::= tagNamelist COMMA ids */ case 142: /* tagNamelist ::= tagNamelist COMMA ids */
{taosArrayPush(yymsp[-2].minor.yy441, &yymsp[0].minor.yy0); yylhsminor.yy441 = yymsp[-2].minor.yy441; } {taosArrayPush(yymsp[-2].minor.yy441, &yymsp[0].minor.yy0); yylhsminor.yy441 = yymsp[-2].minor.yy441; }
yymsp[-2].minor.yy441 = yylhsminor.yy441; yymsp[-2].minor.yy441 = yylhsminor.yy441;
break; break;
case 145: /* tagNamelist ::= ids */ case 143: /* tagNamelist ::= ids */
{yylhsminor.yy441 = taosArrayInit(4, sizeof(SStrToken)); taosArrayPush(yylhsminor.yy441, &yymsp[0].minor.yy0);} {yylhsminor.yy441 = taosArrayInit(4, sizeof(SStrToken)); taosArrayPush(yylhsminor.yy441, &yymsp[0].minor.yy0);}
yymsp[0].minor.yy441 = yylhsminor.yy441; yymsp[0].minor.yy441 = yylhsminor.yy441;
break; break;
case 146: /* create_table_args ::= ifnotexists ids cpxName AS select */ case 144: /* create_table_args ::= ifnotexists ids cpxName AS select */
{ {
yylhsminor.yy182 = tSetCreateTableInfo(NULL, NULL, yymsp[0].minor.yy236, TSQL_CREATE_STREAM); yylhsminor.yy182 = tSetCreateTableInfo(NULL, NULL, yymsp[0].minor.yy236, TSQL_CREATE_STREAM);
setSqlInfo(pInfo, yylhsminor.yy182, NULL, TSDB_SQL_CREATE_TABLE); setSqlInfo(pInfo, yylhsminor.yy182, NULL, TSDB_SQL_CREATE_TABLE);
...@@ -2649,32 +2643,32 @@ static void yy_reduce( ...@@ -2649,32 +2643,32 @@ static void yy_reduce(
} }
yymsp[-4].minor.yy182 = yylhsminor.yy182; yymsp[-4].minor.yy182 = yylhsminor.yy182;
break; break;
case 147: /* columnlist ::= columnlist COMMA column */ case 145: /* columnlist ::= columnlist COMMA column */
{taosArrayPush(yymsp[-2].minor.yy441, &yymsp[0].minor.yy343); yylhsminor.yy441 = yymsp[-2].minor.yy441; } {taosArrayPush(yymsp[-2].minor.yy441, &yymsp[0].minor.yy343); yylhsminor.yy441 = yymsp[-2].minor.yy441; }
yymsp[-2].minor.yy441 = yylhsminor.yy441; yymsp[-2].minor.yy441 = yylhsminor.yy441;
break; break;
case 148: /* columnlist ::= column */ case 146: /* columnlist ::= column */
{yylhsminor.yy441 = taosArrayInit(4, sizeof(TAOS_FIELD)); taosArrayPush(yylhsminor.yy441, &yymsp[0].minor.yy343);} {yylhsminor.yy441 = taosArrayInit(4, sizeof(TAOS_FIELD)); taosArrayPush(yylhsminor.yy441, &yymsp[0].minor.yy343);}
yymsp[0].minor.yy441 = yylhsminor.yy441; yymsp[0].minor.yy441 = yylhsminor.yy441;
break; break;
case 149: /* column ::= ids typename */ case 147: /* column ::= ids typename */
{ {
tSetColumnInfo(&yylhsminor.yy343, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy343); tSetColumnInfo(&yylhsminor.yy343, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy343);
} }
yymsp[-1].minor.yy343 = yylhsminor.yy343; yymsp[-1].minor.yy343 = yylhsminor.yy343;
break; break;
case 156: /* tagitem ::= NULL */ case 154: /* tagitem ::= NULL */
{ yymsp[0].minor.yy0.type = 0; tVariantCreate(&yylhsminor.yy506, &yymsp[0].minor.yy0); } { yymsp[0].minor.yy0.type = 0; tVariantCreate(&yylhsminor.yy506, &yymsp[0].minor.yy0); }
yymsp[0].minor.yy506 = yylhsminor.yy506; yymsp[0].minor.yy506 = yylhsminor.yy506;
break; break;
case 157: /* tagitem ::= NOW */ case 155: /* tagitem ::= NOW */
{ yymsp[0].minor.yy0.type = TSDB_DATA_TYPE_TIMESTAMP; tVariantCreate(&yylhsminor.yy506, &yymsp[0].minor.yy0);} { yymsp[0].minor.yy0.type = TSDB_DATA_TYPE_TIMESTAMP; tVariantCreate(&yylhsminor.yy506, &yymsp[0].minor.yy0);}
yymsp[0].minor.yy506 = yylhsminor.yy506; yymsp[0].minor.yy506 = yylhsminor.yy506;
break; break;
case 158: /* tagitem ::= MINUS INTEGER */ case 156: /* tagitem ::= MINUS INTEGER */
case 159: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==159); case 157: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==157);
case 160: /* tagitem ::= PLUS INTEGER */ yytestcase(yyruleno==160); case 158: /* tagitem ::= PLUS INTEGER */ yytestcase(yyruleno==158);
case 161: /* tagitem ::= PLUS FLOAT */ yytestcase(yyruleno==161); case 159: /* tagitem ::= PLUS FLOAT */ yytestcase(yyruleno==159);
{ {
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;
...@@ -2683,142 +2677,142 @@ static void yy_reduce( ...@@ -2683,142 +2677,142 @@ static void yy_reduce(
} }
yymsp[-1].minor.yy506 = yylhsminor.yy506; yymsp[-1].minor.yy506 = yylhsminor.yy506;
break; break;
case 162: /* select ::= SELECT selcollist from where_opt interval_opt session_option windowstate_option fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */ case 160: /* select ::= SELECT selcollist from where_opt interval_opt session_option windowstate_option fill_opt sliding_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */
{ {
yylhsminor.yy236 = tSetQuerySqlNode(&yymsp[-13].minor.yy0, yymsp[-12].minor.yy441, yymsp[-11].minor.yy244, yymsp[-10].minor.yy166, yymsp[-4].minor.yy441, yymsp[-3].minor.yy441, &yymsp[-9].minor.yy340, &yymsp[-8].minor.yy259, &yymsp[-7].minor.yy348, &yymsp[-5].minor.yy0, yymsp[-6].minor.yy441, &yymsp[0].minor.yy414, &yymsp[-1].minor.yy414, yymsp[-2].minor.yy166); yylhsminor.yy236 = tSetQuerySqlNode(&yymsp[-13].minor.yy0, yymsp[-12].minor.yy441, yymsp[-11].minor.yy244, yymsp[-10].minor.yy166, yymsp[-4].minor.yy441, yymsp[-2].minor.yy441, &yymsp[-9].minor.yy340, &yymsp[-8].minor.yy259, &yymsp[-7].minor.yy348, &yymsp[-5].minor.yy0, yymsp[-6].minor.yy441, &yymsp[0].minor.yy414, &yymsp[-1].minor.yy414, yymsp[-3].minor.yy166);
} }
yymsp[-13].minor.yy236 = yylhsminor.yy236; yymsp[-13].minor.yy236 = yylhsminor.yy236;
break; break;
case 163: /* select ::= LP select RP */ case 161: /* select ::= LP select RP */
{yymsp[-2].minor.yy236 = yymsp[-1].minor.yy236;} {yymsp[-2].minor.yy236 = yymsp[-1].minor.yy236;}
break; break;
case 164: /* union ::= select */ case 162: /* union ::= select */
{ yylhsminor.yy441 = setSubclause(NULL, yymsp[0].minor.yy236); } { yylhsminor.yy441 = setSubclause(NULL, yymsp[0].minor.yy236); }
yymsp[0].minor.yy441 = yylhsminor.yy441; yymsp[0].minor.yy441 = yylhsminor.yy441;
break; break;
case 165: /* union ::= union UNION ALL select */ case 163: /* union ::= union UNION ALL select */
{ yylhsminor.yy441 = appendSelectClause(yymsp[-3].minor.yy441, yymsp[0].minor.yy236); } { yylhsminor.yy441 = appendSelectClause(yymsp[-3].minor.yy441, yymsp[0].minor.yy236); }
yymsp[-3].minor.yy441 = yylhsminor.yy441; yymsp[-3].minor.yy441 = yylhsminor.yy441;
break; break;
case 166: /* cmd ::= union */ case 164: /* cmd ::= union */
{ setSqlInfo(pInfo, yymsp[0].minor.yy441, NULL, TSDB_SQL_SELECT); } { setSqlInfo(pInfo, yymsp[0].minor.yy441, NULL, TSDB_SQL_SELECT); }
break; break;
case 167: /* select ::= SELECT selcollist */ case 165: /* select ::= SELECT selcollist */
{ {
yylhsminor.yy236 = tSetQuerySqlNode(&yymsp[-1].minor.yy0, yymsp[0].minor.yy441, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); yylhsminor.yy236 = tSetQuerySqlNode(&yymsp[-1].minor.yy0, yymsp[0].minor.yy441, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
} }
yymsp[-1].minor.yy236 = yylhsminor.yy236; yymsp[-1].minor.yy236 = yylhsminor.yy236;
break; break;
case 168: /* sclp ::= selcollist COMMA */ case 166: /* sclp ::= selcollist COMMA */
{yylhsminor.yy441 = yymsp[-1].minor.yy441;} {yylhsminor.yy441 = yymsp[-1].minor.yy441;}
yymsp[-1].minor.yy441 = yylhsminor.yy441; yymsp[-1].minor.yy441 = yylhsminor.yy441;
break; break;
case 169: /* sclp ::= */ case 167: /* sclp ::= */
case 199: /* orderby_opt ::= */ yytestcase(yyruleno==199); case 197: /* orderby_opt ::= */ yytestcase(yyruleno==197);
{yymsp[1].minor.yy441 = 0;} {yymsp[1].minor.yy441 = 0;}
break; break;
case 170: /* selcollist ::= sclp distinct expr as */ case 168: /* selcollist ::= sclp distinct expr as */
{ {
yylhsminor.yy441 = tSqlExprListAppend(yymsp[-3].minor.yy441, yymsp[-1].minor.yy166, yymsp[-2].minor.yy0.n? &yymsp[-2].minor.yy0:0, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0); yylhsminor.yy441 = tSqlExprListAppend(yymsp[-3].minor.yy441, yymsp[-1].minor.yy166, yymsp[-2].minor.yy0.n? &yymsp[-2].minor.yy0:0, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0);
} }
yymsp[-3].minor.yy441 = yylhsminor.yy441; yymsp[-3].minor.yy441 = yylhsminor.yy441;
break; break;
case 171: /* selcollist ::= sclp STAR */ case 169: /* selcollist ::= sclp STAR */
{ {
tSqlExpr *pNode = tSqlExprCreateIdValue(NULL, TK_ALL); tSqlExpr *pNode = tSqlExprCreateIdValue(NULL, TK_ALL);
yylhsminor.yy441 = tSqlExprListAppend(yymsp[-1].minor.yy441, pNode, 0, 0); yylhsminor.yy441 = tSqlExprListAppend(yymsp[-1].minor.yy441, pNode, 0, 0);
} }
yymsp[-1].minor.yy441 = yylhsminor.yy441; yymsp[-1].minor.yy441 = yylhsminor.yy441;
break; break;
case 172: /* as ::= AS ids */ case 170: /* as ::= AS ids */
{ yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; }
break; break;
case 173: /* as ::= ids */ case 171: /* as ::= ids */
{ 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 174: /* as ::= */ case 172: /* as ::= */
{ yymsp[1].minor.yy0.n = 0; } { yymsp[1].minor.yy0.n = 0; }
break; break;
case 175: /* distinct ::= DISTINCT */ case 173: /* distinct ::= DISTINCT */
{ 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 177: /* from ::= FROM tablelist */ case 175: /* from ::= FROM tablelist */
case 178: /* from ::= FROM sub */ yytestcase(yyruleno==178); case 176: /* from ::= FROM sub */ yytestcase(yyruleno==176);
{yymsp[-1].minor.yy244 = yymsp[0].minor.yy244;} {yymsp[-1].minor.yy244 = yymsp[0].minor.yy244;}
break; break;
case 179: /* sub ::= LP union RP */ case 177: /* sub ::= LP union RP */
{yymsp[-2].minor.yy244 = addSubqueryElem(NULL, yymsp[-1].minor.yy441, NULL);} {yymsp[-2].minor.yy244 = addSubqueryElem(NULL, yymsp[-1].minor.yy441, NULL);}
break; break;
case 180: /* sub ::= LP union RP ids */ case 178: /* sub ::= LP union RP ids */
{yymsp[-3].minor.yy244 = addSubqueryElem(NULL, yymsp[-2].minor.yy441, &yymsp[0].minor.yy0);} {yymsp[-3].minor.yy244 = addSubqueryElem(NULL, yymsp[-2].minor.yy441, &yymsp[0].minor.yy0);}
break; break;
case 181: /* sub ::= sub COMMA LP union RP ids */ case 179: /* sub ::= sub COMMA LP union RP ids */
{yylhsminor.yy244 = addSubqueryElem(yymsp[-5].minor.yy244, yymsp[-2].minor.yy441, &yymsp[0].minor.yy0);} {yylhsminor.yy244 = addSubqueryElem(yymsp[-5].minor.yy244, yymsp[-2].minor.yy441, &yymsp[0].minor.yy0);}
yymsp[-5].minor.yy244 = yylhsminor.yy244; yymsp[-5].minor.yy244 = yylhsminor.yy244;
break; break;
case 182: /* tablelist ::= ids cpxName */ case 180: /* tablelist ::= ids cpxName */
{ {
yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n;
yylhsminor.yy244 = setTableNameList(NULL, &yymsp[-1].minor.yy0, NULL); yylhsminor.yy244 = setTableNameList(NULL, &yymsp[-1].minor.yy0, NULL);
} }
yymsp[-1].minor.yy244 = yylhsminor.yy244; yymsp[-1].minor.yy244 = yylhsminor.yy244;
break; break;
case 183: /* tablelist ::= ids cpxName ids */ case 181: /* tablelist ::= ids cpxName ids */
{ {
yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n;
yylhsminor.yy244 = setTableNameList(NULL, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); yylhsminor.yy244 = setTableNameList(NULL, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
} }
yymsp[-2].minor.yy244 = yylhsminor.yy244; yymsp[-2].minor.yy244 = yylhsminor.yy244;
break; break;
case 184: /* tablelist ::= tablelist COMMA ids cpxName */ case 182: /* tablelist ::= tablelist COMMA ids cpxName */
{ {
yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n;
yylhsminor.yy244 = setTableNameList(yymsp[-3].minor.yy244, &yymsp[-1].minor.yy0, NULL); yylhsminor.yy244 = setTableNameList(yymsp[-3].minor.yy244, &yymsp[-1].minor.yy0, NULL);
} }
yymsp[-3].minor.yy244 = yylhsminor.yy244; yymsp[-3].minor.yy244 = yylhsminor.yy244;
break; break;
case 185: /* tablelist ::= tablelist COMMA ids cpxName ids */ case 183: /* tablelist ::= tablelist COMMA ids cpxName ids */
{ {
yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n;
yylhsminor.yy244 = setTableNameList(yymsp[-4].minor.yy244, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); yylhsminor.yy244 = setTableNameList(yymsp[-4].minor.yy244, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
} }
yymsp[-4].minor.yy244 = yylhsminor.yy244; yymsp[-4].minor.yy244 = yylhsminor.yy244;
break; break;
case 186: /* tmvar ::= VARIABLE */ case 184: /* 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 187: /* interval_opt ::= INTERVAL LP tmvar RP */ case 185: /* interval_opt ::= INTERVAL LP tmvar RP */
{yymsp[-3].minor.yy340.interval = yymsp[-1].minor.yy0; yymsp[-3].minor.yy340.offset.n = 0;} {yymsp[-3].minor.yy340.interval = yymsp[-1].minor.yy0; yymsp[-3].minor.yy340.offset.n = 0;}
break; break;
case 188: /* interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ case 186: /* interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */
{yymsp[-5].minor.yy340.interval = yymsp[-3].minor.yy0; yymsp[-5].minor.yy340.offset = yymsp[-1].minor.yy0;} {yymsp[-5].minor.yy340.interval = yymsp[-3].minor.yy0; yymsp[-5].minor.yy340.offset = yymsp[-1].minor.yy0;}
break; break;
case 189: /* interval_opt ::= */ case 187: /* interval_opt ::= */
{memset(&yymsp[1].minor.yy340, 0, sizeof(yymsp[1].minor.yy340));} {memset(&yymsp[1].minor.yy340, 0, sizeof(yymsp[1].minor.yy340));}
break; break;
case 190: /* session_option ::= */ case 188: /* session_option ::= */
{yymsp[1].minor.yy259.col.n = 0; yymsp[1].minor.yy259.gap.n = 0;} {yymsp[1].minor.yy259.col.n = 0; yymsp[1].minor.yy259.gap.n = 0;}
break; break;
case 191: /* session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ case 189: /* session_option ::= SESSION LP ids cpxName COMMA tmvar RP */
{ {
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
yymsp[-6].minor.yy259.col = yymsp[-4].minor.yy0; yymsp[-6].minor.yy259.col = yymsp[-4].minor.yy0;
yymsp[-6].minor.yy259.gap = yymsp[-1].minor.yy0; yymsp[-6].minor.yy259.gap = yymsp[-1].minor.yy0;
} }
break; break;
case 192: /* windowstate_option ::= */ case 190: /* windowstate_option ::= */
{ yymsp[1].minor.yy348.col.n = 0; yymsp[1].minor.yy348.col.z = NULL;} { yymsp[1].minor.yy348.col.n = 0; yymsp[1].minor.yy348.col.z = NULL;}
break; break;
case 193: /* windowstate_option ::= STATE_WINDOW LP ids RP */ case 191: /* windowstate_option ::= STATE_WINDOW LP ids RP */
{ yymsp[-3].minor.yy348.col = yymsp[-1].minor.yy0; } { yymsp[-3].minor.yy348.col = yymsp[-1].minor.yy0; }
break; break;
case 194: /* fill_opt ::= */ case 192: /* fill_opt ::= */
{ yymsp[1].minor.yy441 = 0; } { yymsp[1].minor.yy441 = 0; }
break; break;
case 195: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */ case 193: /* 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);
...@@ -2828,34 +2822,34 @@ static void yy_reduce( ...@@ -2828,34 +2822,34 @@ static void yy_reduce(
yymsp[-5].minor.yy441 = yymsp[-1].minor.yy441; yymsp[-5].minor.yy441 = yymsp[-1].minor.yy441;
} }
break; break;
case 196: /* fill_opt ::= FILL LP ID RP */ case 194: /* fill_opt ::= FILL LP ID RP */
{ {
toTSDBType(yymsp[-1].minor.yy0.type); toTSDBType(yymsp[-1].minor.yy0.type);
yymsp[-3].minor.yy441 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1); yymsp[-3].minor.yy441 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1);
} }
break; break;
case 197: /* sliding_opt ::= SLIDING LP tmvar RP */ case 195: /* sliding_opt ::= SLIDING LP tmvar RP */
{yymsp[-3].minor.yy0 = yymsp[-1].minor.yy0; } {yymsp[-3].minor.yy0 = yymsp[-1].minor.yy0; }
break; break;
case 198: /* sliding_opt ::= */ case 196: /* sliding_opt ::= */
{yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = NULL; yymsp[1].minor.yy0.type = 0; } {yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = NULL; yymsp[1].minor.yy0.type = 0; }
break; break;
case 200: /* orderby_opt ::= ORDER BY sortlist */ case 198: /* orderby_opt ::= ORDER BY sortlist */
{yymsp[-2].minor.yy441 = yymsp[0].minor.yy441;} {yymsp[-2].minor.yy441 = yymsp[0].minor.yy441;}
break; break;
case 201: /* sortlist ::= sortlist COMMA item sortorder */ case 199: /* sortlist ::= sortlist COMMA item sortorder */
{ {
yylhsminor.yy441 = tVariantListAppend(yymsp[-3].minor.yy441, &yymsp[-1].minor.yy506, yymsp[0].minor.yy112); yylhsminor.yy441 = tVariantListAppend(yymsp[-3].minor.yy441, &yymsp[-1].minor.yy506, yymsp[0].minor.yy112);
} }
yymsp[-3].minor.yy441 = yylhsminor.yy441; yymsp[-3].minor.yy441 = yylhsminor.yy441;
break; break;
case 202: /* sortlist ::= item sortorder */ case 200: /* sortlist ::= item sortorder */
{ {
yylhsminor.yy441 = tVariantListAppend(NULL, &yymsp[-1].minor.yy506, yymsp[0].minor.yy112); yylhsminor.yy441 = tVariantListAppend(NULL, &yymsp[-1].minor.yy506, yymsp[0].minor.yy112);
} }
yymsp[-1].minor.yy441 = yylhsminor.yy441; yymsp[-1].minor.yy441 = yylhsminor.yy441;
break; break;
case 203: /* item ::= ids cpxName */ case 201: /* 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;
...@@ -2864,227 +2858,227 @@ static void yy_reduce( ...@@ -2864,227 +2858,227 @@ static void yy_reduce(
} }
yymsp[-1].minor.yy506 = yylhsminor.yy506; yymsp[-1].minor.yy506 = yylhsminor.yy506;
break; break;
case 204: /* sortorder ::= ASC */ case 202: /* sortorder ::= ASC */
{ yymsp[0].minor.yy112 = TSDB_ORDER_ASC; } { yymsp[0].minor.yy112 = TSDB_ORDER_ASC; }
break; break;
case 205: /* sortorder ::= DESC */ case 203: /* sortorder ::= DESC */
{ yymsp[0].minor.yy112 = TSDB_ORDER_DESC;} { yymsp[0].minor.yy112 = TSDB_ORDER_DESC;}
break; break;
case 206: /* sortorder ::= */ case 204: /* sortorder ::= */
{ yymsp[1].minor.yy112 = TSDB_ORDER_ASC; } { yymsp[1].minor.yy112 = TSDB_ORDER_ASC; }
break; break;
case 207: /* groupby_opt ::= */ case 205: /* groupby_opt ::= */
{ yymsp[1].minor.yy441 = 0;} { yymsp[1].minor.yy441 = 0;}
break; break;
case 208: /* groupby_opt ::= GROUP BY grouplist */ case 206: /* groupby_opt ::= GROUP BY grouplist */
{ yymsp[-2].minor.yy441 = yymsp[0].minor.yy441;} { yymsp[-2].minor.yy441 = yymsp[0].minor.yy441;}
break; break;
case 209: /* grouplist ::= grouplist COMMA item */ case 207: /* grouplist ::= grouplist COMMA item */
{ {
yylhsminor.yy441 = tVariantListAppend(yymsp[-2].minor.yy441, &yymsp[0].minor.yy506, -1); yylhsminor.yy441 = tVariantListAppend(yymsp[-2].minor.yy441, &yymsp[0].minor.yy506, -1);
} }
yymsp[-2].minor.yy441 = yylhsminor.yy441; yymsp[-2].minor.yy441 = yylhsminor.yy441;
break; break;
case 210: /* grouplist ::= item */ case 208: /* grouplist ::= item */
{ {
yylhsminor.yy441 = tVariantListAppend(NULL, &yymsp[0].minor.yy506, -1); yylhsminor.yy441 = tVariantListAppend(NULL, &yymsp[0].minor.yy506, -1);
} }
yymsp[0].minor.yy441 = yylhsminor.yy441; yymsp[0].minor.yy441 = yylhsminor.yy441;
break; break;
case 211: /* having_opt ::= */ case 209: /* having_opt ::= */
case 221: /* where_opt ::= */ yytestcase(yyruleno==221); case 219: /* where_opt ::= */ yytestcase(yyruleno==219);
case 263: /* expritem ::= */ yytestcase(yyruleno==263); case 261: /* expritem ::= */ yytestcase(yyruleno==261);
{yymsp[1].minor.yy166 = 0;} {yymsp[1].minor.yy166 = 0;}
break; break;
case 212: /* having_opt ::= HAVING expr */ case 210: /* having_opt ::= HAVING expr */
case 222: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==222); case 220: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==220);
{yymsp[-1].minor.yy166 = yymsp[0].minor.yy166;} {yymsp[-1].minor.yy166 = yymsp[0].minor.yy166;}
break; break;
case 213: /* limit_opt ::= */ case 211: /* limit_opt ::= */
case 217: /* slimit_opt ::= */ yytestcase(yyruleno==217); case 215: /* slimit_opt ::= */ yytestcase(yyruleno==215);
{yymsp[1].minor.yy414.limit = -1; yymsp[1].minor.yy414.offset = 0;} {yymsp[1].minor.yy414.limit = -1; yymsp[1].minor.yy414.offset = 0;}
break; break;
case 214: /* limit_opt ::= LIMIT signed */ case 212: /* limit_opt ::= LIMIT signed */
case 218: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==218); case 216: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==216);
{yymsp[-1].minor.yy414.limit = yymsp[0].minor.yy369; yymsp[-1].minor.yy414.offset = 0;} {yymsp[-1].minor.yy414.limit = yymsp[0].minor.yy369; yymsp[-1].minor.yy414.offset = 0;}
break; break;
case 215: /* limit_opt ::= LIMIT signed OFFSET signed */ case 213: /* limit_opt ::= LIMIT signed OFFSET signed */
{ yymsp[-3].minor.yy414.limit = yymsp[-2].minor.yy369; yymsp[-3].minor.yy414.offset = yymsp[0].minor.yy369;} { yymsp[-3].minor.yy414.limit = yymsp[-2].minor.yy369; yymsp[-3].minor.yy414.offset = yymsp[0].minor.yy369;}
break; break;
case 216: /* limit_opt ::= LIMIT signed COMMA signed */ case 214: /* limit_opt ::= LIMIT signed COMMA signed */
{ yymsp[-3].minor.yy414.limit = yymsp[0].minor.yy369; yymsp[-3].minor.yy414.offset = yymsp[-2].minor.yy369;} { yymsp[-3].minor.yy414.limit = yymsp[0].minor.yy369; yymsp[-3].minor.yy414.offset = yymsp[-2].minor.yy369;}
break; break;
case 219: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ case 217: /* slimit_opt ::= SLIMIT signed SOFFSET signed */
{yymsp[-3].minor.yy414.limit = yymsp[-2].minor.yy369; yymsp[-3].minor.yy414.offset = yymsp[0].minor.yy369;} {yymsp[-3].minor.yy414.limit = yymsp[-2].minor.yy369; yymsp[-3].minor.yy414.offset = yymsp[0].minor.yy369;}
break; break;
case 220: /* slimit_opt ::= SLIMIT signed COMMA signed */ case 218: /* slimit_opt ::= SLIMIT signed COMMA signed */
{yymsp[-3].minor.yy414.limit = yymsp[0].minor.yy369; yymsp[-3].minor.yy414.offset = yymsp[-2].minor.yy369;} {yymsp[-3].minor.yy414.limit = yymsp[0].minor.yy369; yymsp[-3].minor.yy414.offset = yymsp[-2].minor.yy369;}
break; break;
case 223: /* expr ::= LP expr RP */ case 221: /* expr ::= LP expr RP */
{yylhsminor.yy166 = yymsp[-1].minor.yy166; yylhsminor.yy166->exprToken.z = yymsp[-2].minor.yy0.z; yylhsminor.yy166->exprToken.n = (yymsp[0].minor.yy0.z - yymsp[-2].minor.yy0.z + 1);} {yylhsminor.yy166 = yymsp[-1].minor.yy166; yylhsminor.yy166->exprToken.z = yymsp[-2].minor.yy0.z; yylhsminor.yy166->exprToken.n = (yymsp[0].minor.yy0.z - yymsp[-2].minor.yy0.z + 1);}
yymsp[-2].minor.yy166 = yylhsminor.yy166; yymsp[-2].minor.yy166 = yylhsminor.yy166;
break; break;
case 224: /* expr ::= ID */ case 222: /* expr ::= ID */
{ yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_ID);} { yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_ID);}
yymsp[0].minor.yy166 = yylhsminor.yy166; yymsp[0].minor.yy166 = yylhsminor.yy166;
break; break;
case 225: /* expr ::= ID DOT ID */ case 223: /* expr ::= ID DOT ID */
{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ID);} { yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ID);}
yymsp[-2].minor.yy166 = yylhsminor.yy166; yymsp[-2].minor.yy166 = yylhsminor.yy166;
break; break;
case 226: /* expr ::= ID DOT STAR */ case 224: /* expr ::= ID DOT STAR */
{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ALL);} { yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ALL);}
yymsp[-2].minor.yy166 = yylhsminor.yy166; yymsp[-2].minor.yy166 = yylhsminor.yy166;
break; break;
case 227: /* expr ::= INTEGER */ case 225: /* expr ::= INTEGER */
{ yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_INTEGER);} { yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_INTEGER);}
yymsp[0].minor.yy166 = yylhsminor.yy166; yymsp[0].minor.yy166 = yylhsminor.yy166;
break; break;
case 228: /* expr ::= MINUS INTEGER */ case 226: /* expr ::= MINUS INTEGER */
case 229: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==229); case 227: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==227);
{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_INTEGER);} { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_INTEGER);}
yymsp[-1].minor.yy166 = yylhsminor.yy166; yymsp[-1].minor.yy166 = yylhsminor.yy166;
break; break;
case 230: /* expr ::= FLOAT */ case 228: /* expr ::= FLOAT */
{ yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_FLOAT);} { yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_FLOAT);}
yymsp[0].minor.yy166 = yylhsminor.yy166; yymsp[0].minor.yy166 = yylhsminor.yy166;
break; break;
case 231: /* expr ::= MINUS FLOAT */ case 229: /* expr ::= MINUS FLOAT */
case 232: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==232); case 230: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==230);
{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_FLOAT);} { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_FLOAT);}
yymsp[-1].minor.yy166 = yylhsminor.yy166; yymsp[-1].minor.yy166 = yylhsminor.yy166;
break; break;
case 233: /* expr ::= STRING */ case 231: /* expr ::= STRING */
{ yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_STRING);} { yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_STRING);}
yymsp[0].minor.yy166 = yylhsminor.yy166; yymsp[0].minor.yy166 = yylhsminor.yy166;
break; break;
case 234: /* expr ::= NOW */ case 232: /* expr ::= NOW */
{ yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NOW); } { yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NOW); }
yymsp[0].minor.yy166 = yylhsminor.yy166; yymsp[0].minor.yy166 = yylhsminor.yy166;
break; break;
case 235: /* expr ::= VARIABLE */ case 233: /* expr ::= VARIABLE */
{ yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_VARIABLE);} { yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_VARIABLE);}
yymsp[0].minor.yy166 = yylhsminor.yy166; yymsp[0].minor.yy166 = yylhsminor.yy166;
break; break;
case 236: /* expr ::= PLUS VARIABLE */ case 234: /* expr ::= PLUS VARIABLE */
case 237: /* expr ::= MINUS VARIABLE */ yytestcase(yyruleno==237); case 235: /* expr ::= MINUS VARIABLE */ yytestcase(yyruleno==235);
{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_VARIABLE; yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_VARIABLE);} { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_VARIABLE; yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_VARIABLE);}
yymsp[-1].minor.yy166 = yylhsminor.yy166; yymsp[-1].minor.yy166 = yylhsminor.yy166;
break; break;
case 238: /* expr ::= BOOL */ case 236: /* expr ::= BOOL */
{ yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_BOOL);} { yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_BOOL);}
yymsp[0].minor.yy166 = yylhsminor.yy166; yymsp[0].minor.yy166 = yylhsminor.yy166;
break; break;
case 239: /* expr ::= NULL */ case 237: /* expr ::= NULL */
{ yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NULL);} { yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NULL);}
yymsp[0].minor.yy166 = yylhsminor.yy166; yymsp[0].minor.yy166 = yylhsminor.yy166;
break; break;
case 240: /* expr ::= ID LP exprlist RP */ case 238: /* expr ::= ID LP exprlist RP */
{ yylhsminor.yy166 = tSqlExprCreateFunction(yymsp[-1].minor.yy441, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } { yylhsminor.yy166 = tSqlExprCreateFunction(yymsp[-1].minor.yy441, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); }
yymsp[-3].minor.yy166 = yylhsminor.yy166; yymsp[-3].minor.yy166 = yylhsminor.yy166;
break; break;
case 241: /* expr ::= ID LP STAR RP */ case 239: /* expr ::= ID LP STAR RP */
{ yylhsminor.yy166 = tSqlExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } { yylhsminor.yy166 = tSqlExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); }
yymsp[-3].minor.yy166 = yylhsminor.yy166; yymsp[-3].minor.yy166 = yylhsminor.yy166;
break; break;
case 242: /* expr ::= expr IS NULL */ case 240: /* expr ::= expr IS NULL */
{yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, NULL, TK_ISNULL);} {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, NULL, TK_ISNULL);}
yymsp[-2].minor.yy166 = yylhsminor.yy166; yymsp[-2].minor.yy166 = yylhsminor.yy166;
break; break;
case 243: /* expr ::= expr IS NOT NULL */ case 241: /* expr ::= expr IS NOT NULL */
{yylhsminor.yy166 = tSqlExprCreate(yymsp[-3].minor.yy166, NULL, TK_NOTNULL);} {yylhsminor.yy166 = tSqlExprCreate(yymsp[-3].minor.yy166, NULL, TK_NOTNULL);}
yymsp[-3].minor.yy166 = yylhsminor.yy166; yymsp[-3].minor.yy166 = yylhsminor.yy166;
break; break;
case 244: /* expr ::= expr LT expr */ case 242: /* expr ::= expr LT expr */
{yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_LT);} {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_LT);}
yymsp[-2].minor.yy166 = yylhsminor.yy166; yymsp[-2].minor.yy166 = yylhsminor.yy166;
break; break;
case 245: /* expr ::= expr GT expr */ case 243: /* expr ::= expr GT expr */
{yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_GT);} {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_GT);}
yymsp[-2].minor.yy166 = yylhsminor.yy166; yymsp[-2].minor.yy166 = yylhsminor.yy166;
break; break;
case 246: /* expr ::= expr LE expr */ case 244: /* expr ::= expr LE expr */
{yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_LE);} {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_LE);}
yymsp[-2].minor.yy166 = yylhsminor.yy166; yymsp[-2].minor.yy166 = yylhsminor.yy166;
break; break;
case 247: /* expr ::= expr GE expr */ case 245: /* expr ::= expr GE expr */
{yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_GE);} {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_GE);}
yymsp[-2].minor.yy166 = yylhsminor.yy166; yymsp[-2].minor.yy166 = yylhsminor.yy166;
break; break;
case 248: /* expr ::= expr NE expr */ case 246: /* expr ::= expr NE expr */
{yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_NE);} {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_NE);}
yymsp[-2].minor.yy166 = yylhsminor.yy166; yymsp[-2].minor.yy166 = yylhsminor.yy166;
break; break;
case 249: /* expr ::= expr EQ expr */ case 247: /* expr ::= expr EQ expr */
{yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_EQ);} {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_EQ);}
yymsp[-2].minor.yy166 = yylhsminor.yy166; yymsp[-2].minor.yy166 = yylhsminor.yy166;
break; break;
case 250: /* expr ::= expr BETWEEN expr AND expr */ case 248: /* expr ::= expr BETWEEN expr AND expr */
{ tSqlExpr* X2 = tSqlExprClone(yymsp[-4].minor.yy166); yylhsminor.yy166 = tSqlExprCreate(tSqlExprCreate(yymsp[-4].minor.yy166, yymsp[-2].minor.yy166, TK_GE), tSqlExprCreate(X2, yymsp[0].minor.yy166, TK_LE), TK_AND);} { tSqlExpr* X2 = tSqlExprClone(yymsp[-4].minor.yy166); yylhsminor.yy166 = tSqlExprCreate(tSqlExprCreate(yymsp[-4].minor.yy166, yymsp[-2].minor.yy166, TK_GE), tSqlExprCreate(X2, yymsp[0].minor.yy166, TK_LE), TK_AND);}
yymsp[-4].minor.yy166 = yylhsminor.yy166; yymsp[-4].minor.yy166 = yylhsminor.yy166;
break; break;
case 251: /* expr ::= expr AND expr */ case 249: /* expr ::= expr AND expr */
{yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_AND);} {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_AND);}
yymsp[-2].minor.yy166 = yylhsminor.yy166; yymsp[-2].minor.yy166 = yylhsminor.yy166;
break; break;
case 252: /* expr ::= expr OR expr */ case 250: /* expr ::= expr OR expr */
{yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_OR); } {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_OR); }
yymsp[-2].minor.yy166 = yylhsminor.yy166; yymsp[-2].minor.yy166 = yylhsminor.yy166;
break; break;
case 253: /* expr ::= expr PLUS expr */ case 251: /* expr ::= expr PLUS expr */
{yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_PLUS); } {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_PLUS); }
yymsp[-2].minor.yy166 = yylhsminor.yy166; yymsp[-2].minor.yy166 = yylhsminor.yy166;
break; break;
case 254: /* expr ::= expr MINUS expr */ case 252: /* expr ::= expr MINUS expr */
{yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_MINUS); } {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_MINUS); }
yymsp[-2].minor.yy166 = yylhsminor.yy166; yymsp[-2].minor.yy166 = yylhsminor.yy166;
break; break;
case 255: /* expr ::= expr STAR expr */ case 253: /* expr ::= expr STAR expr */
{yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_STAR); } {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_STAR); }
yymsp[-2].minor.yy166 = yylhsminor.yy166; yymsp[-2].minor.yy166 = yylhsminor.yy166;
break; break;
case 256: /* expr ::= expr SLASH expr */ case 254: /* expr ::= expr SLASH expr */
{yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_DIVIDE);} {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_DIVIDE);}
yymsp[-2].minor.yy166 = yylhsminor.yy166; yymsp[-2].minor.yy166 = yylhsminor.yy166;
break; break;
case 257: /* expr ::= expr REM expr */ case 255: /* expr ::= expr REM expr */
{yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_REM); } {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_REM); }
yymsp[-2].minor.yy166 = yylhsminor.yy166; yymsp[-2].minor.yy166 = yylhsminor.yy166;
break; break;
case 258: /* expr ::= expr LIKE expr */ case 256: /* expr ::= expr LIKE expr */
{yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_LIKE); } {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_LIKE); }
yymsp[-2].minor.yy166 = yylhsminor.yy166; yymsp[-2].minor.yy166 = yylhsminor.yy166;
break; break;
case 259: /* expr ::= expr IN LP exprlist RP */ case 257: /* expr ::= expr IN LP exprlist RP */
{yylhsminor.yy166 = tSqlExprCreate(yymsp[-4].minor.yy166, (tSqlExpr*)yymsp[-1].minor.yy441, TK_IN); } {yylhsminor.yy166 = tSqlExprCreate(yymsp[-4].minor.yy166, (tSqlExpr*)yymsp[-1].minor.yy441, TK_IN); }
yymsp[-4].minor.yy166 = yylhsminor.yy166; yymsp[-4].minor.yy166 = yylhsminor.yy166;
break; break;
case 260: /* exprlist ::= exprlist COMMA expritem */ case 258: /* exprlist ::= exprlist COMMA expritem */
{yylhsminor.yy441 = tSqlExprListAppend(yymsp[-2].minor.yy441,yymsp[0].minor.yy166,0, 0);} {yylhsminor.yy441 = tSqlExprListAppend(yymsp[-2].minor.yy441,yymsp[0].minor.yy166,0, 0);}
yymsp[-2].minor.yy441 = yylhsminor.yy441; yymsp[-2].minor.yy441 = yylhsminor.yy441;
break; break;
case 261: /* exprlist ::= expritem */ case 259: /* exprlist ::= expritem */
{yylhsminor.yy441 = tSqlExprListAppend(0,yymsp[0].minor.yy166,0, 0);} {yylhsminor.yy441 = tSqlExprListAppend(0,yymsp[0].minor.yy166,0, 0);}
yymsp[0].minor.yy441 = yylhsminor.yy441; yymsp[0].minor.yy441 = yylhsminor.yy441;
break; break;
case 262: /* expritem ::= expr */ case 260: /* expritem ::= expr */
{yylhsminor.yy166 = yymsp[0].minor.yy166;} {yylhsminor.yy166 = yymsp[0].minor.yy166;}
yymsp[0].minor.yy166 = yylhsminor.yy166; yymsp[0].minor.yy166 = yylhsminor.yy166;
break; break;
case 264: /* cmd ::= RESET QUERY CACHE */ case 262: /* cmd ::= RESET QUERY CACHE */
{ setDCLSqlElems(pInfo, TSDB_SQL_RESET_CACHE, 0);} { setDCLSqlElems(pInfo, TSDB_SQL_RESET_CACHE, 0);}
break; break;
case 265: /* cmd ::= SYNCDB ids REPLICA */ case 263: /* cmd ::= SYNCDB ids REPLICA */
{ setDCLSqlElems(pInfo, TSDB_SQL_SYNC_DB_REPLICA, 1, &yymsp[-1].minor.yy0);} { setDCLSqlElems(pInfo, TSDB_SQL_SYNC_DB_REPLICA, 1, &yymsp[-1].minor.yy0);}
break; break;
case 266: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ case 264: /* 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;
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy441, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, -1); SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy441, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, -1);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
} }
break; break;
case 267: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ case 265: /* 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;
...@@ -3095,21 +3089,21 @@ static void yy_reduce( ...@@ -3095,21 +3089,21 @@ static void yy_reduce(
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
} }
break; break;
case 268: /* cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ case 266: /* cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */
{ {
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy441, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, -1); SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy441, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, -1);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
} }
break; break;
case 269: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ case 267: /* 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;
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy441, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, -1); SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy441, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, -1);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
} }
break; break;
case 270: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ case 268: /* 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;
...@@ -3120,7 +3114,7 @@ static void yy_reduce( ...@@ -3120,7 +3114,7 @@ static void yy_reduce(
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
} }
break; break;
case 271: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ case 269: /* 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;
...@@ -3134,7 +3128,7 @@ static void yy_reduce( ...@@ -3134,7 +3128,7 @@ static void yy_reduce(
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
} }
break; break;
case 272: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ case 270: /* 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;
...@@ -3146,21 +3140,21 @@ static void yy_reduce( ...@@ -3146,21 +3140,21 @@ static void yy_reduce(
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
} }
break; break;
case 273: /* cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ case 271: /* cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */
{ {
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy441, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, -1); SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy441, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, -1);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
} }
break; break;
case 274: /* cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ case 272: /* cmd ::= ALTER STABLE 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;
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy441, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, TSDB_SUPER_TABLE); SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy441, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, TSDB_SUPER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
} }
break; break;
case 275: /* cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ case 273: /* cmd ::= ALTER STABLE 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;
...@@ -3171,21 +3165,21 @@ static void yy_reduce( ...@@ -3171,21 +3165,21 @@ static void yy_reduce(
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
} }
break; break;
case 276: /* cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ case 274: /* cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */
{ {
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy441, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, TSDB_SUPER_TABLE); SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy441, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, TSDB_SUPER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
} }
break; break;
case 277: /* cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ case 275: /* cmd ::= ALTER STABLE 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;
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy441, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, TSDB_SUPER_TABLE); SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy441, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, TSDB_SUPER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
} }
break; break;
case 278: /* cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ case 276: /* cmd ::= ALTER STABLE 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;
...@@ -3196,7 +3190,7 @@ static void yy_reduce( ...@@ -3196,7 +3190,7 @@ static void yy_reduce(
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
} }
break; break;
case 279: /* cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ case 277: /* cmd ::= ALTER STABLE 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;
...@@ -3210,7 +3204,7 @@ static void yy_reduce( ...@@ -3210,7 +3204,7 @@ static void yy_reduce(
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
} }
break; break;
case 280: /* cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ case 278: /* cmd ::= ALTER STABLE 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;
...@@ -3222,20 +3216,20 @@ static void yy_reduce( ...@@ -3222,20 +3216,20 @@ static void yy_reduce(
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
} }
break; break;
case 281: /* cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ case 279: /* cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */
{ {
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy441, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, TSDB_SUPER_TABLE); SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy441, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, TSDB_SUPER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
} }
break; break;
case 282: /* cmd ::= KILL CONNECTION INTEGER */ case 280: /* 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 283: /* cmd ::= KILL STREAM INTEGER COLON INTEGER */ case 281: /* 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 284: /* cmd ::= KILL QUERY INTEGER COLON INTEGER */ case 282: /* 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:
......
...@@ -12,7 +12,7 @@ static void prepare_data(TAOS* taos) { ...@@ -12,7 +12,7 @@ static void prepare_data(TAOS* taos) {
result = taos_query(taos, "drop database if exists test;"); result = taos_query(taos, "drop database if exists test;");
taos_free_result(result); taos_free_result(result);
usleep(100000); usleep(100000);
result = taos_query(taos, "create database test;"); result = taos_query(taos, "create database test precision 'us';");
taos_free_result(result); taos_free_result(result);
usleep(100000); usleep(100000);
taos_select_db(taos, "test"); taos_select_db(taos, "test");
...@@ -949,13 +949,45 @@ void verify_stream(TAOS* taos) { ...@@ -949,13 +949,45 @@ void verify_stream(TAOS* taos) {
taos_close_stream(strm); taos_close_stream(strm);
} }
int32_t verify_schema_less(TAOS* taos) {
TAOS_RES *result;
result = taos_query(taos, "drop database if exists test;");
taos_free_result(result);
usleep(100000);
result = taos_query(taos, "create database test precision 'us';");
taos_free_result(result);
usleep(100000);
taos_select_db(taos, "test");
result = taos_query(taos, "create stable ste(ts timestamp, f int) tags(t1 bigint)");
taos_free_result(result);
usleep(100000);
char* lines[] = {
"st,t1=3i,t2=4,t3=\"t3\" c1=3i,c3=L\"passit\",c2=false,c4=4 1626006833639000000",
"st,t1=4i,t3=\"t4\",t2=5,t4=5 c1=3i,c3=L\"passitagin\",c2=true,c4=5,c5=5 1626006833640000000",
"ste,t2=5,t3=L\"ste\" c1=true,c2=4,c3=\"iam\" 1626056811823316532",
"st,t1=4i,t2=5,t3=\"t4\" c1=3i,c3=L\"passitagain\",c2=true,c4=5 1626006833642000000",
"ste,t2=5,t3=L\"ste2\" c3=\"iamszhou\",c4=false 1626056811843316532",
"ste,t2=5,t3=L\"ste2\" c3=\"iamszhou\",c4=false,c5=32b,c6=64s,c7=32w,c8=88.88f 1626056812843316532",
"st,t1=4i,t3=\"t4\",t2=5,t4=5 c1=3i,c3=L\"passitagin\",c2=true,c4=5,c5=5,c6=7u 1626006933640000000",
"stf,t1=4i,t3=\"t4\",t2=5,t4=5 c1=3i,c3=L\"passitagin\",c2=true,c4=5,c5=5,c6=7u 1626006933640000000",
"stf,t1=4i,t3=\"t4\",t2=5,t4=5 c1=3i,c3=L\"passitagin_stf\",c2=false,c5=5,c6=7u 1626006933641a"
};
// int code = taos_insert_lines(taos, lines , sizeof(lines)/sizeof(char*));
int code = taos_insert_lines(taos, &lines[0], 1);
code = taos_insert_lines(taos, &lines[1], 1);
return code;
}
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
const char* host = "127.0.0.1"; const char* host = "127.0.0.1";
const char* user = "root"; const char* user = "root";
const char* passwd = "taosdata"; const char* passwd = "taosdata";
taos_options(TSDB_OPTION_TIMEZONE, "GMT-8"); taos_options(TSDB_OPTION_TIMEZONE, "GMT-8");
TAOS* taos = taos_connect(host, user, passwd, "", 0); TAOS* taos = taos_connect(host, user, passwd, "", 0);
if (taos == NULL) { if (taos == NULL) {
printf("\033[31mfailed to connect to db, reason:%s\033[0m\n", taos_errstr(taos)); printf("\033[31mfailed to connect to db, reason:%s\033[0m\n", taos_errstr(taos));
...@@ -967,6 +999,12 @@ int main(int argc, char *argv[]) { ...@@ -967,6 +999,12 @@ int main(int argc, char *argv[]) {
info = taos_get_client_info(taos); info = taos_get_client_info(taos);
printf("client info: %s\n", info); printf("client info: %s\n", info);
printf("************ verify shemaless *************\n");
int code = verify_schema_less(taos);
if (code == 0) {
return code;
}
printf("************ verify query *************\n"); printf("************ verify query *************\n");
verify_query(taos); verify_query(taos);
......
...@@ -236,9 +236,10 @@ python3 ./test.py -f query/queryTscomputWithNow.py ...@@ -236,9 +236,10 @@ python3 ./test.py -f query/queryTscomputWithNow.py
python3 ./test.py -f query/computeErrorinWhere.py python3 ./test.py -f query/computeErrorinWhere.py
python3 ./test.py -f query/queryTsisNull.py python3 ./test.py -f query/queryTsisNull.py
python3 ./test.py -f query/subqueryFilter.py python3 ./test.py -f query/subqueryFilter.py
# python3 ./test.py -f query/nestedQuery/queryInterval.py python3 ./test.py -f query/nestedQuery/queryInterval.py
python3 ./test.py -f query/queryStateWindow.py python3 ./test.py -f query/queryStateWindow.py
python3 ./test.py -f query/nestedQuery/queryWithOrderLimit.py python3 ./test.py -f query/nestedQuery/queryWithOrderLimit.py
python3 ./test.py -f query/nestquery_last_row.py
#stream #stream
......
...@@ -27,6 +27,7 @@ class TDTestCase: ...@@ -27,6 +27,7 @@ class TDTestCase:
self.rowNum = 100 self.rowNum = 100
self.ts = 1537146000000 self.ts = 1537146000000
self.ts1 = 1537146000000000 self.ts1 = 1537146000000000
self.ts2 = 1597146000000
def run(self): def run(self):
...@@ -35,6 +36,8 @@ class TDTestCase: ...@@ -35,6 +36,8 @@ class TDTestCase:
tdSql.execute('''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, tdSql.execute('''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(loc nchar(20), tag1 int)''') col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(loc nchar(20), tag1 int)''')
tdSql.execute("create table test1 using test tags('beijing', 10)") tdSql.execute("create table test1 using test tags('beijing', 10)")
tdSql.execute("create table test2 using test tags('tianjing', 20)")
tdSql.execute("create table test3 using test tags('shanghai', 20)")
tdSql.execute("create table gtest1 (ts timestamp, col1 float)") tdSql.execute("create table gtest1 (ts timestamp, col1 float)")
tdSql.execute("create table gtest2 (ts timestamp, col1 tinyint)") tdSql.execute("create table gtest2 (ts timestamp, col1 tinyint)")
tdSql.execute("create table gtest3 (ts timestamp, col1 tinyint)") tdSql.execute("create table gtest3 (ts timestamp, col1 tinyint)")
...@@ -48,6 +51,10 @@ class TDTestCase: ...@@ -48,6 +51,10 @@ class TDTestCase:
for i in range(self.rowNum): for i in range(self.rowNum):
tdSql.execute("insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" tdSql.execute("insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)"
% (self.ts + i*1000, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) % (self.ts + i*1000, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1))
tdSql.execute("insert into test2 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)"
% (self.ts2 + i*1000, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1))
tdSql.execute("insert into test3 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)"
% (self.ts2 + i*1000, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1))
tdSql.execute("insert into gtest1 values(1537146000000,0);") tdSql.execute("insert into gtest1 values(1537146000000,0);")
tdSql.execute("insert into gtest1 values(1537146001100,1.2);") tdSql.execute("insert into gtest1 values(1537146001100,1.2);")
...@@ -69,7 +76,7 @@ class TDTestCase: ...@@ -69,7 +76,7 @@ class TDTestCase:
tdSql.execute("insert into gtest8 values(1537146000002,4);") tdSql.execute("insert into gtest8 values(1537146000002,4);")
tdSql.execute("insert into gtest8 values(1537146002202,4);") tdSql.execute("insert into gtest8 values(1537146002202,4);")
# irate verifacation # irate verifacation --child table'query
tdSql.query("select irate(col1) from test1;") tdSql.query("select irate(col1) from test1;")
tdSql.checkData(0, 0, 1) tdSql.checkData(0, 0, 1)
tdSql.query("select irate(col1) from test1 interval(10s);") tdSql.query("select irate(col1) from test1 interval(10s);")
...@@ -99,6 +106,32 @@ class TDTestCase: ...@@ -99,6 +106,32 @@ class TDTestCase:
tdSql.query("select irate(col2) from test1;") tdSql.query("select irate(col2) from test1;")
tdSql.checkData(0, 0, 1) tdSql.checkData(0, 0, 1)
# irate verifacation --super table'query
tdSql.query("select irate(col1) from test group by tbname,loc,tag1;")
tdSql.checkData(0, 0, 1)
tdSql.checkData(1, 1, "test2")
tdSql.checkData(2, 2, "shanghai")
# add function testcase of twa: query from super table
tdSql.query("select twa(col1) from test group by tbname,loc,tag1;")
tdSql.checkData(0, 0, 50.5)
tdSql.checkData(1, 1, "test2")
tdSql.checkData(2, 2, "shanghai")
# error: function of irate and twa has invalid operation
tdSql.error("select irate(col7) from test group by tbname,loc,tag1;")
tdSql.error("select irate(col7) from test group by tbname;")
tdSql.error("select irate(col1) from test group by loc,tbname,tag1;")
# tdSql.error("select irate(col1) from test group by tbname,col7;")
tdSql.error("select irate(col1) from test group by col7,tbname;")
tdSql.error("select twa(col7) from test group by tbname,loc,tag1;")
tdSql.error("select twa(col7) from test group by tbname;")
tdSql.error("select twa(col1) from test group by loc,tbname,tag1;")
# tdSql.error("select twa(col1) from test group by tbname,col7;")
tdSql.error("select twa(col1) from test group by col7,tbname;")
# general table'query
tdSql.query("select irate(col1) from gtest1;") tdSql.query("select irate(col1) from gtest1;")
tdSql.checkData(0, 0, 1.2/1.1) tdSql.checkData(0, 0, 1.2/1.1)
tdSql.query("select irate(col1) from gtest2;") tdSql.query("select irate(col1) from gtest2;")
......
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import sys
import taos
from util.log import tdLog
from util.cases import tdCases
from util.sql import tdSql
import random
class TDTestCase:
def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
self.ts = 1600000000000
self.num = 10
def run(self):
tdSql.prepare()
# test case for https://jira.taosdata.com:18080/browse/TD-4735
tdSql.execute('''create stable stable_1
(ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint,
q_bool bool , q_binary binary(20) , q_nchar nchar(20) ,
q_float float , q_double double , q_ts timestamp)
tags(loc nchar(20) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint,
t_bool bool , t_binary binary(20) , t_nchar nchar(20) ,
t_float float , t_double double , t_ts timestamp);''')
tdSql.execute('''create table table_0 using stable_1
tags('table_0' , '0' , '0' , '0' , '0' , 0 , '0' , '0' , '0' , '0' ,'0')''')
tdSql.execute('''create table table_1 using stable_1
tags('table_1' , '2147483647' , '9223372036854775807' , '32767' , '127' , 1 ,
'binary1' , 'nchar1' , '1' , '11' , \'1999-09-09 09:09:09.090\')''')
tdSql.execute('''create table table_2 using stable_1
tags('table_2' , '-2147483647' , '-9223372036854775807' , '-32767' , '-127' , false ,
'binary2' , 'nchar2nchar2' , '-2.2' , '-22.22' , \'2099-09-09 09:09:09.090\')''')
tdSql.execute('''create table table_3 using stable_1
tags('table_3' , '3' , '3' , '3' , '3' , true , 'binary3' , 'nchar3' , '33.33' , '3333.3333' , '0')''')
tdSql.execute('''create table table_4 using stable_1
tags('table_4' , '4' , '4' , '4' , '4' , false , 'binary4' , 'nchar4' , '-444.444' , '-444444.444444' , '0')''')
tdSql.execute('''create table table_5 using stable_1
tags('table_5' , '5' , '5' , '5' , '5' , true , 'binary5' , 'nchar5' , '5555.5555' , '55555555.55555555' , '0')''')
#regular table
tdSql.execute('''create table regular_table_1
(ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint,
q_bool bool , q_binary binary(20) , q_nchar nchar(20) ,
q_float float , q_double double , q_ts timestamp) ;''')
for i in range(self.num):
tdSql.execute('''insert into table_0 values(%d, %d, %d, %d, %d, 0, 'binary.%s', 'nchar.%s', %f, %f, %d)'''
% (self.ts + i, i, i, i, i, i, i, i, i, self.ts + i))
tdSql.execute('''insert into table_1 values(%d, %d, %d, %d, %d, 1, 'binary1.%s', 'nchar1.%s', %f, %f, %d)'''
% (self.ts + i, 2147483647-i, 9223372036854775807-i, 32767-i, 127-i,
i, i, random.random(), random.random(), 1262304000001 + i))
tdSql.execute('''insert into table_2 values(%d, %d, %d, %d, %d, true, 'binary2.%s', 'nchar2nchar2.%s', %f, %f, %d)'''
% (self.ts + i, -2147483647+i, -9223372036854775807+i, -32767+i, -127+i,
i, i, random.uniform(-1,0), random.uniform(-1,0), 1577836800001 + i))
tdSql.execute('''insert into table_3 values(%d, %d, %d, %d, %d, false, 'binary3.%s', 'nchar3.%s', %f, %f, %d)'''
% (self.ts + i, random.randint(-2147483647, 2147483647),
random.randint(-9223372036854775807, 9223372036854775807), random.randint(-32767, 32767),
random.randint(-127, 127), random.randint(-100, 100), random.randint(-10000, 10000),
random.uniform(-100000,100000), random.uniform(-1000000000,1000000000), self.ts + i))
tdSql.execute('''insert into table_4 values(%d, %d, %d, %d, %d, true, 'binary4.%s', 'nchar4.%s', %f, %f, %d)'''
% (self.ts + i, i, i, i, i, i, i, i, i, self.ts + i))
tdSql.execute('''insert into table_5 values(%d, %d, %d, %d, %d, false, 'binary5.%s', 'nchar5.%s', %f, %f, %d)'''
% (self.ts + i, i, i, i, i, i, i, i, i, self.ts + i))
tdSql.execute('''insert into regular_table_1 values(%d, %d, %d, %d, %d, 0, 'binary.%s', 'nchar.%s', %f, %f, %d)'''
% (self.ts + i, i, i, i, i, i, i, i, i, self.ts + i))
tdSql.execute('''insert into regular_table_1 values(%d, %d, %d, %d, %d, 1, 'binary1.%s', 'nchar1.%s', %f, %f, %d)'''
% (self.ts + 100 + i, 2147483647-i, 9223372036854775807-i, 32767-i, 127-i,
i, i, random.random(), random.random(), 1262304000001 + i))
tdSql.execute('''insert into regular_table_1 values(%d, %d, %d, %d, %d, true, 'binary2.%s', 'nchar2nchar2.%s', %f, %f, %d)'''
% (self.ts + 200 + i, -2147483647+i, -9223372036854775807+i, -32767+i, -127+i,
i, i, random.uniform(-1,0), random.uniform(-1,0), 1577836800001 + i))
tdSql.execute('''insert into regular_table_1 values(%d, %d, %d, %d, %d, false, 'binary3.%s', 'nchar3.%s', %f, %f, %d)'''
% (self.ts + 300 + i, random.randint(-2147483647, 2147483647),
random.randint(-9223372036854775807, 9223372036854775807), random.randint(-32767, 32767),
random.randint(-127, 127), random.randint(-100, 100), random.randint(-10000, 10000),
random.uniform(-100000,100000), random.uniform(-1000000000,1000000000), self.ts + i))
tdSql.execute('''insert into regular_table_1 values(%d, %d, %d, %d, %d, true, 'binary4.%s', 'nchar4.%s', %f, %f, %d)'''
% (self.ts + 400 + i, i, i, i, i, i, i, i, i, self.ts + i))
tdSql.execute('''insert into regular_table_1 values(%d, %d, %d, %d, %d, false, 'binary5.%s', 'nchar5.%s', %f, %f, %d)'''
% (self.ts + 500 + i, i, i, i, i, i, i, i, i, self.ts + i))
sql = '''select * from stable_1'''
tdSql.query(sql)
tdSql.checkRows(6*self.num)
sql = '''select * from regular_table_1'''
tdSql.query(sql)
tdSql.checkRows(6*self.num)
tdLog.info("=======last_row(*)========")
sql = '''select last_row(*) from stable_1;'''
tdSql.query(sql)
tdSql.checkData(0,1,self.num-1)
sql = '''select last_row(*) from regular_table_1;'''
tdSql.query(sql)
tdSql.checkData(0,1,self.num-1)
sql = '''select * from stable_1
where loc = 'table_0';'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select last_row(*) from
(select * from stable_1
where loc = 'table_0');'''
tdSql.query(sql)
tdSql.checkRows(1)
sql = '''select last_row(*) from
(select * from stable_1);'''
tdSql.query(sql)
tdSql.checkData(0,1,self.num-1)
tdSql.checkData(0,2,self.num-1)
tdSql.checkData(0,3,self.num-1)
tdSql.checkData(0,4,self.num-1)
tdSql.checkData(0,5,'False')
tdSql.checkData(0,6,'binary5.9')
tdSql.checkData(0,7,'nchar5.9')
tdSql.checkData(0,8,9.00000)
tdSql.checkData(0,9,9.000000000)
tdSql.checkData(0,10,'2020-09-13 20:26:40.009')
tdSql.checkData(0,11,'table_5')
tdSql.checkData(0,12,5)
tdSql.checkData(0,13,5)
tdSql.checkData(0,14,5)
tdSql.checkData(0,15,5)
tdSql.checkData(0,16,'True')
tdSql.checkData(0,17,'binary5')
tdSql.checkData(0,18,'nchar5')
tdSql.checkData(0,21,'1970-01-01 08:00:00.000')
sql = '''select * from regular_table_1 ;'''
tdSql.query(sql)
tdSql.checkRows(6*self.num)
sql = '''select last_row(*) from
(select * from regular_table_1);'''
tdSql.query(sql)
tdSql.checkRows(1)
tdSql.checkData(0,1,self.num-1)
tdSql.checkData(0,2,self.num-1)
tdSql.checkData(0,3,self.num-1)
tdSql.checkData(0,4,self.num-1)
tdSql.checkData(0,5,'False')
tdSql.checkData(0,6,'binary5.9')
tdSql.checkData(0,7,'nchar5.9')
tdSql.checkData(0,8,9.00000)
tdSql.checkData(0,9,9.000000000)
tdSql.checkData(0,10,'2020-09-13 20:26:40.009')
sql = '''select last_row(*) from
((select * from table_0) union all
(select * from table_1) union all
(select * from table_2));'''
tdSql.query(sql)
tdSql.checkRows(1)
tdSql.checkData(0,1,self.num-1)
tdSql.checkData(0,2,self.num-1)
tdSql.checkData(0,3,self.num-1)
tdSql.checkData(0,4,self.num-1)
tdSql.checkData(0,5,'False')
tdSql.checkData(0,6,'binary.9')
tdSql.checkData(0,7,'nchar.9')
tdSql.checkData(0,8,9.00000)
tdSql.checkData(0,9,9.000000000)
tdSql.checkData(0,10,'2020-09-13 20:26:40.009')
# bug 5055
# sql = '''select last_row(*) from
# ((select * from stable_1) union all
# (select * from table_1) union all
# (select * from regular_table_1));'''
# tdSql.query(sql)
# tdSql.checkData(0,1,self.num-1)
sql = '''select last_row(*) from
((select last_row(*) from table_0) union all
(select last_row(*) from table_1) union all
(select last_row(*) from table_2));'''
tdSql.query(sql)
tdSql.checkRows(1)
tdSql.checkData(0,1,self.num-1)
tdSql.checkData(0,2,self.num-1)
tdSql.checkData(0,3,self.num-1)
tdSql.checkData(0,4,self.num-1)
tdSql.checkData(0,5,'False')
tdSql.checkData(0,6,'binary.9')
tdSql.checkData(0,7,'nchar.9')
tdSql.checkData(0,8,9.00000)
tdSql.checkData(0,9,9.000000000)
tdSql.checkData(0,10,'2020-09-13 20:26:40.009')
# bug 5055
# sql = '''select last_row(*) from
# ((select last_row(*) from stable_1) union all
# (select last_row(*) from table_1) union all
# (select last_row(*) from regular_table_1));'''
# tdSql.query(sql)
# tdSql.checkData(0,1,self.num-1)
sql = '''select last_row(*) from
((select * from table_0 limit 5 offset 5) union all
(select * from table_1 limit 5 offset 5) union all
(select * from regular_table_1 limit 5 offset 5));'''
tdSql.query(sql)
tdSql.checkRows(1)
tdSql.checkData(0,1,self.num-1)
tdSql.checkData(0,2,self.num-1)
tdSql.checkData(0,3,self.num-1)
tdSql.checkData(0,4,self.num-1)
tdSql.checkData(0,5,'False')
tdSql.checkData(0,6,'binary.9')
tdSql.checkData(0,7,'nchar.9')
tdSql.checkData(0,8,9.00000)
tdSql.checkData(0,9,9.000000000)
tdSql.checkData(0,10,'2020-09-13 20:26:40.009')
sql = '''select last_row(*) from
(select * from stable_1)
having q_int>5;'''
tdLog.info(sql)
tdSql.error(sql)
try:
tdSql.execute(sql)
tdLog.exit(" having only works with group by")
except Exception as e:
tdLog.info(repr(e))
tdLog.info("invalid operation: having only works with group by")
#bug 5057
# sql = '''select last_row(*) from
# (select * from (select * from stable_1))'''
# tdLog.info(sql)
# tdSql.error(sql)
# try:
# tdSql.execute(sql)
# tdLog.exit(" core dumped")
# except Exception as e:
# tdLog.info(repr(e))
# tdLog.info("core dumped")
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
\ No newline at end of file
...@@ -51,7 +51,7 @@ class TDTestCase: ...@@ -51,7 +51,7 @@ class TDTestCase:
else: else:
tdLog.info("taosdemo found in %s" % buildPath) tdLog.info("taosdemo found in %s" % buildPath)
binPath = buildPath + "/build/bin/" binPath = buildPath + "/build/bin/"
os.system("%staosdemo -y -t %d -n %d" % os.system("%staosdemo -y -t %d -n %d -b INT,INT,INT,INT" %
(binPath, self.numberOfTables, self.numberOfRecords)) (binPath, self.numberOfTables, self.numberOfRecords))
tdSql.execute("use test") tdSql.execute("use test")
......
...@@ -54,7 +54,7 @@ class TDTestCase: ...@@ -54,7 +54,7 @@ class TDTestCase:
binPath = buildPath + "/build/bin/" binPath = buildPath + "/build/bin/"
if(threadID == 0): if(threadID == 0):
os.system("%staosdemo -y -t %d -n %d" % os.system("%staosdemo -y -t %d -n %d -b INT,INT,INT,INT -m t" %
(binPath, self.numberOfTables, self.numberOfRecords)) (binPath, self.numberOfTables, self.numberOfRecords))
if(threadID == 1): if(threadID == 1):
time.sleep(2) time.sleep(2)
......
...@@ -60,7 +60,7 @@ class TDTestCase: ...@@ -60,7 +60,7 @@ class TDTestCase:
tdSql.execute("use test") tdSql.execute("use test")
tdSql.query( tdSql.query(
"select count(*) from test.t%d" % (self.numberOfTables -1)) "select count(*) from test.d%d" % (self.numberOfTables -1))
tdSql.checkData(0, 0, self.numberOfRecords) tdSql.checkData(0, 0, self.numberOfRecords)
def stop(self): def stop(self):
......
...@@ -28,6 +28,7 @@ class TDTestCase: ...@@ -28,6 +28,7 @@ class TDTestCase:
tdSql.init(conn.cursor(), logSql) tdSql.init(conn.cursor(), logSql)
def getBuildPath(self): def getBuildPath(self):
global selfPath
selfPath = os.path.dirname(os.path.realpath(__file__)) selfPath = os.path.dirname(os.path.realpath(__file__))
if ("community" in selfPath): if ("community" in selfPath):
...@@ -53,7 +54,7 @@ class TDTestCase: ...@@ -53,7 +54,7 @@ class TDTestCase:
tdLog.info("taosd found in %s" % buildPath) tdLog.info("taosd found in %s" % buildPath)
binPath = buildPath+ "/build/bin/" binPath = buildPath+ "/build/bin/"
testPath = buildPath[:buildPath.find("debug")] testPath = selfPath+ "/../../../"
walFilePath = testPath + "/sim/dnode1/data/mnode_bak/wal/" walFilePath = testPath + "/sim/dnode1/data/mnode_bak/wal/"
#new db and insert data #new db and insert data
......
...@@ -86,6 +86,18 @@ class TwoClients: ...@@ -86,6 +86,18 @@ class TwoClients:
tdSql.execute("alter table stb2_0 add column col2 binary(4)") tdSql.execute("alter table stb2_0 add column col2 binary(4)")
tdSql.execute("alter table stb2_0 drop column col1") tdSql.execute("alter table stb2_0 drop column col1")
tdSql.execute("insert into stb2_0 values(1614218422000,8638,'R')") tdSql.execute("insert into stb2_0 values(1614218422000,8638,'R')")
tdSql.execute("drop dnode 10")
sleep(10)
os.system("rm -rf /var/lib/taos/*")
print("clear dnode chenhaoran02'data files")
os.system("nohup /usr/bin/taosd > /dev/null 2>&1 &")
print("start taosd")
sleep(10)
tdSql.execute("reset query cache ;")
tdSql.execute("create dnode chenhaoran02 ;")
# stop taosd and compact wal file # stop taosd and compact wal file
......
...@@ -198,29 +198,25 @@ if $data12_db != 1 then ...@@ -198,29 +198,25 @@ if $data12_db != 1 then
return -1 return -1
endi endi
sql alter database db wal 1 sql_error alter database db wal 1
sql show databases
print wal $data12_db
if $data12_db != 1 then
return -1
endi
sql alter database db wal 1 sql_error alter database db wal 1
sql alter database db wal 2 sql_error alter database db wal 2
sql alter database db wal 1 sql_error alter database db wal 1
sql alter database db wal 2 sql_error alter database db wal 2
sql alter database db wal 0 sql_error alter database db wal 0
sql_error alter database db wal 3 sql_error alter database db wal 3
sql_error alter database db wal 4 sql_error alter database db wal 4
sql_error alter database db wal -1 sql_error alter database db wal -1
sql_error alter database db wal 1000 sql_error alter database db wal 1000
print ============== step fsync print ============== step fsync
sql alter database db fsync 0 sql_error alter database db fsync 0
sql alter database db fsync 1 sql_error alter database db fsync 1
sql alter database db fsync 3600 sql_error alter database db fsync 3600
sql alter database db fsync 18000 sql_error alter database db fsync 18000
sql alter database db fsync 180000 sql_error alter database db fsync 180000
sql_error alter database db fsync 180001 sql_error alter database db fsync 180001
sql_error alter database db fsync -1 sql_error alter database db fsync -1
......
...@@ -495,18 +495,13 @@ if $data12_db != 1 then ...@@ -495,18 +495,13 @@ if $data12_db != 1 then
endi endi
sql_error alter topic db wal 1 sql_error alter topic db wal 1
sql alter database db wal 1 sql_error alter database db wal 1
sql show databases
print wal $data12_db
if $data12_db != 1 then
return -1
endi
sql alter database db wal 1 sql_error alter database db wal 1
sql alter database db wal 2 sql_error alter database db wal 2
sql alter database db wal 1 sql_error alter database db wal 1
sql alter database db wal 2 sql_error alter database db wal 2
sql alter database db wal 0 sql_error alter database db wal 0
sql_error alter database db wal 3 sql_error alter database db wal 3
sql_error alter database db wal 4 sql_error alter database db wal 4
sql_error alter database db wal -1 sql_error alter database db wal -1
...@@ -523,11 +518,11 @@ sql_error alter topic db wal -1 ...@@ -523,11 +518,11 @@ sql_error alter topic db wal -1
sql_error alter topic db wal 1000 sql_error alter topic db wal 1000
print ============== step fsync print ============== step fsync
sql alter database db fsync 0 sql_error alter database db fsync 0
sql alter database db fsync 1 sql_error alter database db fsync 1
sql alter database db fsync 3600 sql_error alter database db fsync 3600
sql alter database db fsync 18000 sql_error alter database db fsync 18000
sql alter database db fsync 180000 sql_error alter database db fsync 180000
sql_error alter database db fsync 180001 sql_error alter database db fsync 180001
sql_error alter database db fsync -1 sql_error alter database db fsync -1
...@@ -615,17 +610,6 @@ if $rows != 1 then ...@@ -615,17 +610,6 @@ if $rows != 1 then
return -1 return -1
endi endi
sql alter database d1 fsync 0
sql show topics;
if $rows != 0 then
return -1
endi
sql show databases;
if $rows != 1 then
return -1
endi
sql drop database d1 sql drop database d1
sql show topics; sql show topics;
if $rows != 0 then if $rows != 0 then
...@@ -649,17 +633,6 @@ if $rows != 1 then ...@@ -649,17 +633,6 @@ if $rows != 1 then
return -1 return -1
endi endi
sql alter database d1 fsync 0
sql show topics;
if $rows != 1 then
return -1
endi
sql show databases;
if $rows != 1 then
return -1
endi
sql drop database d1 sql drop database d1
sql show topics; sql show topics;
if $rows != 0 then if $rows != 0 then
......
...@@ -237,7 +237,42 @@ sql_error create database $db ctime 29 ...@@ -237,7 +237,42 @@ sql_error create database $db ctime 29
sql_error create database $db ctime 40961 sql_error create database $db ctime 40961
# wal {0, 2} # wal {0, 2}
#sql_error create database $db wal 0 sql create database testwal wal 0
sql show databases
if $rows != 1 then
return -1
endi
sql show databases
print wallevel $data12_testwal
if $data12_testwal != 0 then
return -1
endi
sql drop database testwal
sql create database testwal wal 1
sql show databases
if $rows != 1 then
return -1
endi
sql show databases
print wallevel $data12_testwal
if $data12_testwal != 1 then
return -1
endi
sql drop database testwal
sql create database testwal wal 2
sql show databases
if $rows != 1 then
return -1
endi
print wallevel $data12_testwal
if $data12_testwal != 2 then
return -1
endi
sql drop database testwal
sql_error create database $db wal -1 sql_error create database $db wal -1
sql_error create database $db wal 3 sql_error create database $db wal 3
......
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/exec.sh -n dnode1 -s start
sleep 2000
sql connect
print =============== step1
$db = testlp
$mte = ste
$mt = st
sql drop database $db -x step1
step1:
sql create database $db precision 'us'
sql use $db
sql create stable $mte (ts timestamp, f int) TAGS(t1 bigint)
line_insert st,t1=3i,t2=4,t3="t3" c1=3i,c3=L"passit",c2=false,c4=4 1626006833639000000
line_insert st,t1=4i,t3="t41",t2=5 c1=3i,c3=L"passiT",c2=true,c4=5 1626006833640000000
line_insert stf,t1=4i,t2=5,t3="t4" c1=3i,c3=L"passitagain",c2=true,c4=5 1626006833642000000
line_insert ste,t2=5,t3=L"ste" c1=true,c2=4,c3="iam" 1626056811823316532
sql select * from st
if $rows != 2 then
return -1
endi
if $data00 != @21-07-11 20:33:53.639000@ then
return -1
endi
if $data03 != @passit@ then
return -1
endi
sql select * from stf
if $rows != 1 then
return -1
endi
sql select * from ste
if $rows != 1 then
return -1
endi
#print =============== clear
sql drop database $db
sql show databases
if $rows != 0 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
...@@ -450,4 +450,44 @@ if $data11 != 1 then ...@@ -450,4 +450,44 @@ if $data11 != 1 then
return -1 return -1
endi endi
print =====================>TD-5157
sql select twa(c1) from nest_tb1 interval(19a);
if $rows != 10000 then
return -1
endi
if $data00 != @20-09-14 23:59:59.992@ then
return -1
endi
if $data01 != 0.000083333 then
return -1
endi
print =================>us database interval query, TD-5039
sql create database test precision 'us';
sql use test;
sql create table t1(ts timestamp, k int);
sql insert into t1 values('2020-01-01 01:01:01.000', 1) ('2020-01-01 01:02:00.000', 2);
sql select avg(k) from (select avg(k) k from t1 interval(1s)) interval(1m);
if $rows != 2 then
return -1
endi
if $data00 != @20-01-01 01:01:00.000000@ then
return -1
endi
if $data01 != 1.000000000 then
return -1
endi
if $data10 != @20-01-01 01:02:00.000000@ then
return -1
endi
if $data11 != 2.000000000 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/exec.sh -n dnode1 -s start
sleep 100
sql connect
sleep 100
print ========== sub_in_from.sim
$i = 0
$dbPrefix = subdb
$tbPrefix = sub_tb
$stbPrefix = sub_stb
$tbNum = 10
$rowNum = 1000
$totalNum = $tbNum * $rowNum
$loops = 200000
$log = 10000
$ts0 = 1537146000000
$delta = 600000
$i = 0
$db = $dbPrefix . $i
$stb = $stbPrefix . $i
sql drop database $db -x step1
step1:
sql create database $db cache 16 maxrows 4096 keep 36500
print ====== create tables
sql use $db
sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int)
$i = 0
$ts = $ts0
$halfNum = $tbNum / 2
while $i < $halfNum
$tbId = $i + $halfNum
$tb = $tbPrefix . $i
$tb1 = $tbPrefix . $tbId
sql create table $tb using $stb tags( $i )
sql create table $tb1 using $stb tags( $tbId )
$x = 0
while $x < $rowNum
$xs = $x * $delta
$ts = $ts0 + $xs
$c = $x / 10
$c = $c * 10
$c = $x - $c
$binary = 'binary . $c
$binary = $binary . '
$nchar = 'nchar . $c
$nchar = $nchar . '
sql insert into $tb values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar )
sql insert into $tb1 values ( $ts , $c , NULL , $c , NULL , $c , $c , true, $binary , $nchar )
$x = $x + 1
endw
$i = $i + 1
endw
print ====== tables created
sql_error select count(*) from (select count(*) from abc.sub_stb0)
sql_error select val + 20 from (select count(*) from sub_stb0 interval(10h))
sql_error select abc+20 from (select count(*) from sub_stb0 interval(1s))
sql select count(*) from (select count(*) from sub_stb0 interval(10h))
if $rows != 1 then
return -1
endi
if $data00 != 18 then
print expect 18, actual: $data00
return -1
endi
sql select ts from (select count(*) from sub_stb0 interval(10h))
if $rows != 18 then
return -1
endi
if $data00 != @18-09-17 04:00:00.000@ then
return -1
endi
if $data01 != @18-09-17 14:00:00.000@ then
return -1
endi
sql select val + 20, val from (select count(*) as val from sub_stb0 interval(10h))
if $rows != 18 then
return -1
endi
if $data00 != 320.000000 then
return -1
endi
if $data01 != 300 then
return -1
endi
if $data10 != 620 then
return -1
endi
if $data11 != 600 then
return -1
endi
if $data20 != 620 then
return -1
endi
if $data21 != 600 then
return -1
endi
sql select max(val), min(val), max(val) - min(val) from (select count(*) val from sub_stb0 interval(10h))
if $rows != 1 then
return -1
endi
if $data00 != 600 then
return -1
endi
if $data01 != 100 then
return -1
endi
if $data02 != 500.000000 then
return -1
endi
sql select first(ts,val),last(ts,val) from (select count(*) val from sub_stb0 interval(10h))
sql select top(val, 5) from (select count(*) val from sub_stb0 interval(10h))
sql select diff(val) from (select count(*) val from sub_stb0 interval(10h))
sql select apercentile(val, 50) from (select count(*) val from sub_stb0 interval(10h))
# not support yet
sql select percentile(val, 50) from (select count(*) val from sub_stb0 interval(10h))
sql select stddev(val) from (select count(*) val from sub_stb0 interval(10h))
print ====================>complex query
...@@ -87,6 +87,8 @@ enum { ...@@ -87,6 +87,8 @@ enum {
SIM_CMD_RESTFUL, SIM_CMD_RESTFUL,
SIM_CMD_TEST, SIM_CMD_TEST,
SIM_CMD_RETURN, SIM_CMD_RETURN,
SIM_CMD_LINE_INSERT,
SIM_CMD_LINE_INSERT_ERROR,
SIM_CMD_END SIM_CMD_END
}; };
...@@ -172,6 +174,8 @@ bool simExecuteSqlCmd(SScript *script, char *option); ...@@ -172,6 +174,8 @@ bool simExecuteSqlCmd(SScript *script, char *option);
bool simExecuteSqlErrorCmd(SScript *script, char *rest); bool simExecuteSqlErrorCmd(SScript *script, char *rest);
bool simExecuteSqlSlowCmd(SScript *script, char *option); bool simExecuteSqlSlowCmd(SScript *script, char *option);
bool simExecuteRestfulCmd(SScript *script, char *rest); bool simExecuteRestfulCmd(SScript *script, char *rest);
bool simExecuteLineInsertCmd(SScript *script, char *option);
bool simExecuteLineInsertErrorCmd(SScript *script, char *option);
void simVisuallizeOption(SScript *script, char *src, char *dst); void simVisuallizeOption(SScript *script, char *src, char *dst);
#endif #endif
\ No newline at end of file
...@@ -1067,3 +1067,49 @@ bool simExecuteSqlErrorCmd(SScript *script, char *rest) { ...@@ -1067,3 +1067,49 @@ bool simExecuteSqlErrorCmd(SScript *script, char *rest) {
return false; return false;
} }
bool simExecuteLineInsertCmd(SScript *script, char *rest) {
char buf[TSDB_MAX_BINARY_LEN];
simVisuallizeOption(script, rest, buf);
rest = buf;
SCmdLine *line = &script->lines[script->linePos];
simInfo("script:%s, %s", script->fileName, rest);
simLogSql(buf, true);
char * lines[] = {rest};
int32_t ret = taos_insert_lines(script->taos, lines, 1);
if (ret == TSDB_CODE_SUCCESS) {
simDebug("script:%s, taos:%p, %s executed. success.", script->fileName, script->taos, rest);
script->linePos++;
return true;
} else {
sprintf(script->error, "lineNum: %d. line: %s failed, ret:%d:%s", line->lineNum, rest,
ret & 0XFFFF, tstrerror(ret));
return false;
}
}
bool simExecuteLineInsertErrorCmd(SScript *script, char *rest) {
char buf[TSDB_MAX_BINARY_LEN];
simVisuallizeOption(script, rest, buf);
rest = buf;
SCmdLine *line = &script->lines[script->linePos];
simInfo("script:%s, %s", script->fileName, rest);
simLogSql(buf, true);
char * lines[] = {rest};
int32_t ret = taos_insert_lines(script->taos, lines, 1);
if (ret == TSDB_CODE_SUCCESS) {
sprintf(script->error, "script:%s, taos:%p, %s executed. expect failed, but success.", script->fileName, script->taos, rest);
script->linePos++;
return false;
} else {
simDebug("lineNum: %d. line: %s failed, ret:%d:%s. Expect failed, so success", line->lineNum, rest,
ret & 0XFFFF, tstrerror(ret));
return true;
}
}
...@@ -838,6 +838,38 @@ bool simParseRunBackCmd(char *rest, SCommand *pCmd, int32_t lineNum) { ...@@ -838,6 +838,38 @@ bool simParseRunBackCmd(char *rest, SCommand *pCmd, int32_t lineNum) {
return true; return true;
} }
bool simParseLineInsertCmd(char* rest, SCommand* pCmd, int32_t lineNum) {
int32_t expLen;
rest++;
cmdLine[numOfLines].cmdno = SIM_CMD_LINE_INSERT;
cmdLine[numOfLines].lineNum = lineNum;
cmdLine[numOfLines].optionOffset = optionOffset;
expLen = (int32_t)strlen(rest);
memcpy(optionBuffer + optionOffset, rest, expLen);
optionOffset += expLen + 1;
*(optionBuffer + optionOffset - 1) = 0;
numOfLines++;
return true;
}
bool simParseLineInsertErrorCmd(char* rest, SCommand* pCmd, int32_t lineNum) {
int32_t expLen;
rest++;
cmdLine[numOfLines].cmdno = SIM_CMD_LINE_INSERT;
cmdLine[numOfLines].lineNum = lineNum;
cmdLine[numOfLines].optionOffset = optionOffset;
expLen = (int32_t)strlen(rest);
memcpy(optionBuffer + optionOffset, rest, expLen);
optionOffset += expLen + 1;
*(optionBuffer + optionOffset - 1) = 0;
numOfLines++;
return true;
}
void simInitsimCmdList() { void simInitsimCmdList() {
int32_t cmdno; int32_t cmdno;
memset(simCmdList, 0, SIM_CMD_END * sizeof(SCommand)); memset(simCmdList, 0, SIM_CMD_END * sizeof(SCommand));
...@@ -1049,4 +1081,20 @@ void simInitsimCmdList() { ...@@ -1049,4 +1081,20 @@ void simInitsimCmdList() {
simCmdList[cmdno].parseCmd = simParseReturnCmd; simCmdList[cmdno].parseCmd = simParseReturnCmd;
simCmdList[cmdno].executeCmd = simExecuteReturnCmd; simCmdList[cmdno].executeCmd = simExecuteReturnCmd;
simAddCmdIntoHash(&(simCmdList[cmdno])); simAddCmdIntoHash(&(simCmdList[cmdno]));
cmdno = SIM_CMD_LINE_INSERT;
simCmdList[cmdno].cmdno = cmdno;
strcpy(simCmdList[cmdno].name, "line_insert");
simCmdList[cmdno].nlen = (int16_t)strlen(simCmdList[cmdno].name);
simCmdList[cmdno].parseCmd = simParseLineInsertCmd;
simCmdList[cmdno].executeCmd = simExecuteLineInsertCmd;
simAddCmdIntoHash(&(simCmdList[cmdno]));
cmdno = SIM_CMD_LINE_INSERT_ERROR;
simCmdList[cmdno].cmdno = cmdno;
strcpy(simCmdList[cmdno].name, "line_insert_error");
simCmdList[cmdno].nlen = (int16_t)strlen(simCmdList[cmdno].name);
simCmdList[cmdno].parseCmd = simParseLineInsertErrorCmd;
simCmdList[cmdno].executeCmd = simExecuteLineInsertErrorCmd;
simAddCmdIntoHash(&(simCmdList[cmdno]));
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册