Merge branch 'develop' into compress_float
This commit is contained in:
commit
efdb71325b
|
@ -68,6 +68,8 @@ CMakeError.log
|
|||
*.o
|
||||
version.c
|
||||
taos.rc
|
||||
src/connector/jdbc/.classpath
|
||||
src/connector/jdbc/.project
|
||||
src/connector/jdbc/.settings/
|
||||
tests/comparisonTest/cassandra/cassandratest/.classpath
|
||||
tests/comparisonTest/cassandra/cassandratest/.project
|
||||
|
|
|
@ -185,9 +185,10 @@ cmake .. && cmake --build .
|
|||
|
||||
# 安装
|
||||
|
||||
如果你不想安装,可以直接在shell中运行。生成完成后,安装 TDengine:
|
||||
生成完成后,安装 TDengine(下文给出的指令以 Linux 为例,如果是在 Windows 下,那么对应的指令会是 `nmake install`):
|
||||
|
||||
```bash
|
||||
make install
|
||||
sudo make install
|
||||
```
|
||||
|
||||
用户可以在[文件目录结构](https://www.taosdata.com/cn/documentation/administrator#directories)中了解更多在操作系统中生成的目录或文件。
|
||||
|
@ -195,7 +196,7 @@ make install
|
|||
安装成功后,在终端中启动 TDengine 服务:
|
||||
|
||||
```bash
|
||||
taosd
|
||||
sudo systemctl start taosd
|
||||
```
|
||||
|
||||
用户可以使用 TDengine Shell 来连接 TDengine 服务,在终端中,输入:
|
||||
|
@ -208,7 +209,7 @@ taos
|
|||
|
||||
## 快速运行
|
||||
|
||||
TDengine 生成后,在终端执行以下命令:
|
||||
如果不希望以服务方式运行 TDengine,也可以在终端中直接运行它。也即在生成完成后,执行以下命令(在 Windows 下,生成的可执行文件会带有 .exe 后缀,例如会名为 taosd.exe ):
|
||||
|
||||
```bash
|
||||
./build/bin/taosd -c test/cfg
|
||||
|
|
|
@ -175,7 +175,7 @@ cmake .. && cmake --build .
|
|||
|
||||
# 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
|
||||
sudo make install
|
||||
```
|
||||
|
@ -197,7 +197,7 @@ If TDengine shell connects the server successfully, welcome messages and version
|
|||
|
||||
## 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
|
||||
./build/bin/taosd -c test/cfg
|
||||
```
|
||||
|
|
|
@ -7,8 +7,9 @@ set -e
|
|||
cpuType=amd64 # [armv6l | arm64 | amd64 | 386]
|
||||
osType=linux # [linux | darwin | windows]
|
||||
version=""
|
||||
verType=stable # [stable, beta]
|
||||
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
|
||||
case $arg in
|
||||
c)
|
||||
|
@ -23,6 +24,10 @@ do
|
|||
#echo "version=$OPTARG"
|
||||
version=$(echo $OPTARG)
|
||||
;;
|
||||
V)
|
||||
#echo "verType=$OPTARG"
|
||||
verType=$(echo $OPTARG)
|
||||
;;
|
||||
h)
|
||||
echo "Usage: `basename $0` -c [armv6l | arm64 | amd64 | 386] -o [linux | darwin | windows]"
|
||||
exit 0
|
||||
|
@ -55,6 +60,22 @@ cp alert alert.cfg install_driver.sh ./TDengine-alert/.
|
|||
cp ../../../debug/build/lib/libtaos.so.${version} ./TDengine-alert/driver/.
|
||||
chmod 777 ./TDengine-alert/install_driver.sh
|
||||
|
||||
tar -I 'gzip -9' -cf ${startdir}/TDengine-alert-${version}-${osType^}-${archMap[${cpuType}]}.tar.gz TDengine-alert/
|
||||
tar -I 'gzip -9' -cf ${scriptdir}/TDengine-alert-${version}-${osType^}-${archMap[${cpuType}]}.tar.gz 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)
|
|||
IF (DEFINED VERNUMBER)
|
||||
SET(TD_VER_NUMBER ${VERNUMBER})
|
||||
ELSE ()
|
||||
SET(TD_VER_NUMBER "2.1.3.0")
|
||||
SET(TD_VER_NUMBER "2.1.4.1")
|
||||
ENDIF ()
|
||||
|
||||
IF (DEFINED VERCOMPATIBLE)
|
||||
|
|
|
@ -123,8 +123,8 @@ taosd -C
|
|||
- minRows:文件块中记录的最小条数。单位为条,默认值:100。
|
||||
- maxRows:文件块中记录的最大条数。单位为条,默认值:4096。
|
||||
- comp:文件压缩标志位。0:关闭;1:一阶段压缩;2:两阶段压缩。默认值:2。(可通过 alter database 修改)
|
||||
- wal:WAL级别。1:写wal,但不执行fsync;2:写wal, 而且执行fsync。默认值:1。(在 taos.cfg 中参数名需要写作 walLevel)(可通过 alter database 修改)
|
||||
- fsync:当wal设置为2时,执行fsync的周期。设置为0,表示每次写入,立即执行fsync。单位为毫秒,默认值:3000。(可通过 alter database 修改)
|
||||
- wal:WAL级别。1:写wal,但不执行fsync;2:写wal, 而且执行fsync。默认值:1。(在 taos.cfg 中参数名需要写作 walLevel)
|
||||
- fsync:当wal设置为2时,执行fsync的周期。设置为0,表示每次写入,立即执行fsync。单位为毫秒,默认值:3000。
|
||||
- cache:内存块的大小。单位为兆字节(MB),默认值:16。
|
||||
- blocks:每个VNODE(TSDB)中有多少cache大小的内存块。因此一个VNODE的用的内存大小粗略为(cache * blocks)。单位为块,默认值:4。(可通过 alter database 修改)
|
||||
- replica:副本个数。取值范围:1-3,单位为个,默认值:1。(可通过 alter 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]。)
|
||||
说明:缓存最近行,将显著改善 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 版本开始,修改这些参数后无需重启服务器即可生效。
|
||||
|
||||
- **显示系统所有数据库**
|
||||
|
@ -372,77 +362,82 @@ TDengine 缺省的时间戳是毫秒精度,但通过在 CREATE DATABASE 时传
|
|||
|
||||
## <a class="anchor" id="insert"></a>数据写入
|
||||
|
||||
- **插入一条记录**
|
||||
```mysql
|
||||
INSERT INTO tb_name VALUES (field_value, ...);
|
||||
```
|
||||
向表tb_name中插入一条记录。
|
||||
### 写入语法:
|
||||
|
||||
- **插入一条记录,数据对应到指定的列**
|
||||
```mysql
|
||||
INSERT INTO tb_name (field1_name, ...) VALUES (field1_value1, ...);
|
||||
```
|
||||
向表tb_name中插入一条记录,数据对应到指定的列。SQL语句中没有出现的列,数据库将自动填充为NULL。主键(时间戳)不能为NULL。
|
||||
```mysql
|
||||
INSERT INTO
|
||||
tb_name
|
||||
[USING stb_name [(tag1_name, ...)] TAGS (tag1_value, ...)]
|
||||
[(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
|
||||
...];
|
||||
```
|
||||
|
||||
- **插入多条记录**
|
||||
```mysql
|
||||
INSERT INTO tb_name VALUES (field1_value1, ...) (field1_value2, ...) ...;
|
||||
```
|
||||
向表tb_name中插入多条记录。
|
||||
**注意**:在使用“插入多条记录”方式写入数据时,不能把第一列的时间戳取值都设为now,否则会导致语句中的多条记录使用相同的时间戳,于是就可能出现相互覆盖以致这些数据行无法全部被正确保存。
|
||||
### 详细描述及示例:
|
||||
|
||||
- **按指定的列插入多条记录**
|
||||
- **插入一条或多条记录**
|
||||
指定已经创建好的数据子表的表名,并通过 VALUES 关键字提供一行或多行数据,即可向数据库写入这些数据。例如,执行如下语句可以写入一行记录:
|
||||
```mysql
|
||||
INSERT INTO tb_name (field1_name, ...) VALUES (field1_value1, ...) (field1_value2, ...) ...;
|
||||
INSERT INTO d1001 VALUES (NOW, 10.2, 219, 0.32);
|
||||
```
|
||||
向表tb_name中按指定的列插入多条记录。
|
||||
|
||||
- **向多个表插入多条记录**
|
||||
或者,可以通过如下语句写入两行记录:
|
||||
```mysql
|
||||
INSERT INTO tb1_name VALUES (field1_value1, ...) (field1_value2, ...) ...
|
||||
tb2_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);
|
||||
```
|
||||
同时向表tb1_name和tb2_name中分别插入多条记录。
|
||||
**注意:**
|
||||
1)在第二个例子中,两行记录的首列时间戳使用了不同格式的写法。其中字符串格式的时间戳写法不受所在 DATABASE 的时间精度设置影响;而长整形格式的时间戳写法会受到所在 DATABASE 的时间精度设置影响——例子中的时间戳在毫秒精度下可以写作 1626164208000,而如果是在微秒精度设置下就需要写为 1626164208000000。
|
||||
2)在使用“插入多条记录”方式写入数据时,不能把第一列的时间戳取值都设为 NOW,否则会导致语句中的多条记录使用相同的时间戳,于是就可能出现相互覆盖以致这些数据行无法全部被正确保存。其原因在于,NOW 函数在执行中会被解析为所在 SQL 语句的实际执行时间,出现在同一语句中的多个 NOW 标记也就会被替换为完全相同的时间戳取值。
|
||||
3)允许插入的最老记录的时间戳,是相对于当前服务器时间,减去配置的 keep 值(数据保留的天数);允许插入的最新记录的时间戳,是相对于当前服务器时间,加上配置的 days 值(数据文件存储数据的时间跨度,单位为天)。keep 和 days 都是可以在创建数据库时指定的,缺省值分别是 3650 天和 10 天。
|
||||
|
||||
- **同时向多个表按列插入多条记录**
|
||||
- **插入记录,数据对应到指定的列**
|
||||
向数据子表中插入记录时,无论插入一行还是多行,都可以让数据对应到指定的列。对于 SQL 语句中没有出现的列,数据库将自动填充为 NULL。主键(时间戳)不能为 NULL。例如:
|
||||
```mysql
|
||||
INSERT INTO tb1_name (tb1_field1_name, ...) VALUES (field1_value1, ...) (field1_value2, ...) ...
|
||||
tb2_name (tb2_field1_name, ...) VALUES (field1_value1, ...) (field1_value2, ...) ...;
|
||||
INSERT INTO d1001 (ts, current, phase) VALUES ('2021-07-13 14:06:33.196', 10.27, 0.31);
|
||||
```
|
||||
同时向表tb1_name和tb2_name中按列分别插入多条记录。
|
||||
**说明:**如果不指定列,也即使用全列模式——那么在 VALUES 部分提供的数据,必须为数据表的每个列都显式地提供数据。全列模式写入速度会远快于指定列,因此建议尽可能采用全列写入方式,此时空列可以填入 NULL。
|
||||
|
||||
注意:
|
||||
1) 如果时间戳为now,系统将自动使用客户端当前时间作为该记录的时间戳;
|
||||
2) 允许插入的最老记录的时间戳,是相对于当前服务器时间,减去配置的keep值(数据保留的天数),允许插入的最新记录的时间戳,是相对于当前服务器时间,加上配置的days值(数据文件存储数据的时间跨度,单位为天)。keep和days都是可以在创建数据库时指定的,缺省值分别是3650天和10天。
|
||||
- **向多个表插入记录**
|
||||
可以在一条语句中,分别向多个表插入一条或多条记录,并且也可以在插入过程中指定列。例如:
|
||||
```mysql
|
||||
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)
|
||||
d1002 (ts, current, phase) VALUES ('2021-07-13 14:06:34.255', 10.27, 0.31);
|
||||
```
|
||||
|
||||
- <a class="anchor" id="auto_create_table"></a>**插入记录时自动建表**
|
||||
如果用户在写数据时并不确定某个表是否存在,此时可以在写入数据时使用自动建表语法来创建不存在的表,若该表已存在则不会建立新表。自动建表时,要求必须以超级表为模板,并写明数据表的 TAGS 取值。例如:
|
||||
```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。例如:
|
||||
```mysql
|
||||
INSERT INTO d21001 USING meters (groupdId) TAGS (2) VALUES ('2021-07-13 14:06:33.196', 10.15, 217, 0.33);
|
||||
```
|
||||
自动建表语法也支持在一条语句中向多个表插入记录。例如:
|
||||
```mysql
|
||||
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)
|
||||
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 语句中混用,否则会报语法错误。
|
||||
|
||||
- **插入记录时自动建表,并指定具体的 TAGS 列**
|
||||
```mysql
|
||||
INSERT INTO tb_name USING stb_name (tag_name1, ...) TAGS (tag_value1, ...) VALUES (field_value1, ...);
|
||||
- **插入来自文件的数据记录**
|
||||
除了使用 VALUES 关键字插入一行或多行数据外,也可以把要写入的数据放在 CSV 文件中(英文逗号分隔、英文单引号括住每个值)供 SQL 指令读取。其中 CSV 文件无需表头。例如,如果 /tmp/csvfile.csv 文件的内容为:
|
||||
```
|
||||
在自动建表时,可以只是指定部分 TAGS 列的取值,未被指定的 TAGS 列将取为空值。
|
||||
|
||||
- **同时向多个表按列插入多条记录,自动建表**
|
||||
```mysql
|
||||
INSERT INTO tb1_name (tb1_field1_name, ...) [USING stb1_name TAGS (tag_value1, ...)] VALUES (field1_value1, ...) (field1_value2, ...) ...
|
||||
tb2_name (tb2_field1_name, ...) [USING stb2_name TAGS (tag_value2, ...)] VALUES (field1_value1, ...) (field1_value2, ...) ...;
|
||||
'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
|
||||
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完全一样。
|
||||
|
||||
说明:针对 insert 类型的 SQL 语句,我们采用的流式解析策略,在发现后面的错误之前,前面正确的部分SQL仍会执行。下面的sql中,insert语句是无效的,但是d1001仍会被创建。
|
||||
**说明:**针对 insert 类型的 SQL 语句,我们采用的流式解析策略,在发现后面的错误之前,前面正确的部分 SQL 仍会执行。下面的 SQL 中,INSERT 语句是无效的,但是 d1001 仍会被创建。
|
||||
|
||||
```mysql
|
||||
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
|
|||
- 在聚合查询中,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 取值相等的时候,滑动窗口即为翻转窗口。
|
||||
* 从 2.1.5.0 版本开始,INTERVAL 语句允许的最短时间间隔调整为 1 微秒(1u),当然如果所查询的 DATABASE 的时间精度设置为毫秒级,那么允许的最短时间间隔为 1 毫秒(1a)。
|
||||
2. 状态窗口:使用整数(布尔值)或字符串来标识产生记录时设备的状态量,产生的记录如果具有相同的状态量取值则归属于同一个状态窗口,数值改变后该窗口关闭。状态量所对应的列作为 STATE_WINDOW 语句的参数来指定。
|
||||
3. 会话窗口:时间戳所在的列由 SESSION 语句的 ts_col 参数指定,会话窗口根据相邻两条记录的时间戳差值来确定是否属于同一个会话——如果时间戳差异在 tol_val 以内,则认为记录仍属于同一个窗口;如果时间变化超过 tol_val,则自动开启下一个窗口。
|
||||
- WHERE 语句可以指定查询的起止时间和其他过滤条件。
|
||||
|
|
|
@ -149,6 +149,8 @@ keepColumnName 1
|
|||
|
||||
# system time zone
|
||||
# timezone Asia/Shanghai (CST, +0800)
|
||||
# system time zone (for windows 10)
|
||||
# timezone UTC-8
|
||||
|
||||
# system locale
|
||||
# locale en_US.UTF-8
|
||||
|
|
|
@ -123,7 +123,7 @@ else
|
|||
fi
|
||||
|
||||
if [ "$verType" == "beta" ]; then
|
||||
debname=${debname}-${verType}".deb"
|
||||
debname="TDengine-server-"${tdengine_ver}-${verType}-${osType}-${cpuType}".deb"
|
||||
elif [ "$verType" == "stable" ]; then
|
||||
debname=${debname}".deb"
|
||||
else
|
||||
|
@ -131,6 +131,8 @@ else
|
|||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
|
||||
# make deb package
|
||||
dpkg -b ${pkg_dir} $debname
|
||||
echo "make deb package success!"
|
||||
|
|
|
@ -5,22 +5,28 @@ set -e
|
|||
# dockerbuild.sh
|
||||
# -n [version number]
|
||||
# -p [xxxx]
|
||||
# -V [stable | beta]
|
||||
|
||||
# set parameters by default value
|
||||
verNumber=""
|
||||
version=""
|
||||
passWord=""
|
||||
verType=""
|
||||
|
||||
while getopts "hn:p:" arg
|
||||
while getopts "hn:p:V:" arg
|
||||
do
|
||||
case $arg in
|
||||
n)
|
||||
#echo "verNumber=$OPTARG"
|
||||
verNumber=$(echo $OPTARG)
|
||||
#echo "version=$OPTARG"
|
||||
version=$(echo $OPTARG)
|
||||
;;
|
||||
p)
|
||||
#echo "passWord=$OPTARG"
|
||||
passWord=$(echo $OPTARG)
|
||||
;;
|
||||
V)
|
||||
#echo "verType=$OPTARG"
|
||||
verType=$(echo $OPTARG)
|
||||
;;
|
||||
h)
|
||||
echo "Usage: `basename $0` -n [version number] "
|
||||
echo " -p [password for docker hub] "
|
||||
|
@ -33,13 +39,34 @@ do
|
|||
esac
|
||||
done
|
||||
|
||||
echo "verNumber=${verNumber}"
|
||||
echo "version=${version}"
|
||||
|
||||
#docker manifest create -a tdengine/tdengine:${verNumber} tdengine/tdengine-amd64:${verNumber} tdengine/tdengine-aarch64:${verNumber} tdengine/tdengine-aarch32:${verNumber}
|
||||
docker manifest create -a tdengine/tdengine:latest tdengine/tdengine-amd64:latest tdengine/tdengine-aarch64:latest tdengine/tdengine-aarch32:latest
|
||||
#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}
|
||||
|
||||
docker login -u tdengine -p ${passWord} #replace the docker registry username and password
|
||||
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}
|
||||
|
||||
docker manifest push tdengine/tdengine:latest
|
||||
else
|
||||
echo "unknow verType, nor stabel or beta"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# how set latest version ???
|
||||
# docker manifest create -a tdengine/${dockername}:${version} tdengine/tdengine-amd64:${version} tdengine/tdengine-aarch64:${version} tdengine/tdengine-aarch32:${version}
|
||||
# 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 manifest push tdengine/tdengine:latest
|
||||
|
||||
# # how set latest version ???
|
||||
|
|
|
@ -1,20 +1,24 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
|
||||
set -e
|
||||
#set -x
|
||||
|
||||
# dockerbuild.sh
|
||||
# -c [aarch32 | aarch64 | amd64 | x86 | mips64 ...]
|
||||
# -f [pkg file]
|
||||
# -n [version number]
|
||||
# -p [password for docker hub]
|
||||
# -V [stable | beta]
|
||||
# -f [pkg file]
|
||||
|
||||
# set parameters by default value
|
||||
cpuType=amd64
|
||||
verNumber=""
|
||||
cpuType=""
|
||||
version=""
|
||||
passWord=""
|
||||
pkgFile=""
|
||||
verType="stable"
|
||||
|
||||
while getopts "hc:n:p:f:" arg
|
||||
while getopts "hc:n:p:f:V:" arg
|
||||
do
|
||||
case $arg in
|
||||
c)
|
||||
|
@ -22,8 +26,8 @@ do
|
|||
cpuType=$(echo $OPTARG)
|
||||
;;
|
||||
n)
|
||||
#echo "verNumber=$OPTARG"
|
||||
verNumber=$(echo $OPTARG)
|
||||
#echo "version=$OPTARG"
|
||||
version=$(echo $OPTARG)
|
||||
;;
|
||||
p)
|
||||
#echo "passWord=$OPTARG"
|
||||
|
@ -33,11 +37,17 @@ do
|
|||
#echo "pkgFile=$OPTARG"
|
||||
pkgFile=$(echo $OPTARG)
|
||||
;;
|
||||
V)
|
||||
#echo "verType=$OPTARG"
|
||||
verType=$(echo $OPTARG)
|
||||
;;
|
||||
h)
|
||||
echo "Usage: `basename $0` -c [aarch32 | aarch64 | amd64 | x86 | mips64 ...] "
|
||||
echo " -f [pkg file] "
|
||||
echo " -n [version number] "
|
||||
echo " -p [password for docker hub] "
|
||||
echo " -V [stable | beta] "
|
||||
echo " -f [pkg file] "
|
||||
|
||||
exit 0
|
||||
;;
|
||||
?) #unknow option
|
||||
|
@ -47,17 +57,44 @@ do
|
|||
esac
|
||||
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 "====NOTES: ${pkgFile} must be in the same directory as dockerbuild.sh===="
|
||||
|
||||
dirName=${pkgFile%-Linux*}
|
||||
#echo "dirName=${dirName}"
|
||||
scriptDir=$(dirname $(readlink -f $0))
|
||||
comunityArchiveDir=/nas/TDengine/v$version/community # community version’package directory
|
||||
cd ${scriptDir}
|
||||
cp -f ${comunityArchiveDir}/${pkgFile} .
|
||||
|
||||
docker build --rm -f "Dockerfile" -t tdengine/tdengine-${cpuType}:${verNumber} "." --build-arg pkgFile=${pkgFile} --build-arg dirName=${dirName}
|
||||
dirName=${pkgFile%-Linux*}
|
||||
echo "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 push tdengine/tdengine-${cpuType}:${verNumber}
|
||||
docker push tdengine/tdengine-${dockername}:${version}
|
||||
|
||||
# set this version to latest version
|
||||
docker tag tdengine/tdengine-${cpuType}:${verNumber} tdengine/tdengine-${cpuType}:latest
|
||||
docker push tdengine/tdengine-${cpuType}:latest
|
||||
docker tag tdengine/tdengine-${dockername}:${version} tdengine/tdengine-${dockername}:latest
|
||||
docker push tdengine/tdengine-${dockername}:latest
|
||||
|
||||
|
||||
rm -f ${pkgFile}
|
|
@ -73,7 +73,7 @@ else
|
|||
fi
|
||||
|
||||
if [ "$verType" == "beta" ]; then
|
||||
rpmname=${rpmname}-${verType}".rpm"
|
||||
rpmname="TDengine-server-"${tdengine_ver}-${verType}-${osType}-${cpuType}".rpm"
|
||||
elif [ "$verType" == "stable" ]; then
|
||||
rpmname=${rpmname}".rpm"
|
||||
else
|
||||
|
|
|
@ -47,17 +47,20 @@ mkdir -p ${install_dir}/init.d && cp ${init_file_tarbitrator_rpm} ${install_dir}
|
|||
|
||||
cd ${release_dir}
|
||||
|
||||
if [ "$verMode" == "cluster" ]; then
|
||||
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
|
||||
# install_dir has been distinguishes cluster from edege, so comments this code
|
||||
pkg_name=${install_dir}-${osType}-${cpuType}
|
||||
|
||||
# if [ "$verMode" == "cluster" ]; then
|
||||
# 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 [ "$verType" == "beta" ]; then
|
||||
pkg_name=${pkg_name}-${verType}
|
||||
pkg_name=${install_dir}-${verType}-${osType}-${cpuType}
|
||||
elif [ "$verType" == "stable" ]; then
|
||||
pkg_name=${pkg_name}
|
||||
else
|
||||
|
@ -65,6 +68,7 @@ else
|
|||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
tar -zcv -f "$(basename ${pkg_name}).tar.gz" $(basename ${install_dir}) --remove-files || :
|
||||
exitcode=$?
|
||||
if [ "$exitcode" != "0" ]; then
|
||||
|
|
|
@ -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}/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}
|
||||
|
||||
if [ "$osType" != "Darwin" ]; then
|
||||
|
@ -137,12 +170,24 @@ fi
|
|||
|
||||
cd ${release_dir}
|
||||
|
||||
if [ "$verMode" == "cluster" ]; then
|
||||
pkg_name=${install_dir}-${osType}-${cpuType}
|
||||
elif [ "$verMode" == "edge" ]; then
|
||||
pkg_name=${install_dir}-${osType}-${cpuType}
|
||||
# install_dir has been distinguishes cluster from edege, so comments this code
|
||||
pkg_name=${install_dir}-${osType}-${cpuType}
|
||||
|
||||
# if [ "$verMode" == "cluster" ]; then
|
||||
# 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 [ "$verType" == "beta" ]; then
|
||||
pkg_name=${install_dir}-${verType}-${osType}-${cpuType}
|
||||
elif [ "$verType" == "stable" ]; then
|
||||
pkg_name=${pkg_name}
|
||||
else
|
||||
echo "unknow verMode, nor cluster or edge"
|
||||
echo "unknow verType, nor stabel or beta"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -150,15 +195,6 @@ if [ "$pagMode" == "lite" ]; then
|
|||
pkg_name=${pkg_name}-Lite
|
||||
fi
|
||||
|
||||
if [ "$verType" == "beta" ]; then
|
||||
pkg_name=${pkg_name}-${verType}
|
||||
elif [ "$verType" == "stable" ]; then
|
||||
pkg_name=${pkg_name}
|
||||
else
|
||||
echo "unknow verType, nor stable or beta"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$osType" != "Darwin" ]; then
|
||||
tar -zcv -f "$(basename ${pkg_name}).tar.gz" $(basename ${install_dir}) --remove-files || :
|
||||
else
|
||||
|
|
|
@ -91,6 +91,39 @@ else
|
|||
fi
|
||||
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}
|
||||
|
||||
if [ "$osType" != "Darwin" ]; then
|
||||
|
|
|
@ -91,6 +91,39 @@ else
|
|||
fi
|
||||
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}
|
||||
|
||||
if [ "$osType" != "Darwin" ]; then
|
||||
|
|
|
@ -203,21 +203,20 @@ fi
|
|||
|
||||
cd ${release_dir}
|
||||
|
||||
if [ "$verMode" == "cluster" ]; then
|
||||
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
|
||||
# install_dir has been distinguishes cluster from edege, so comments this code
|
||||
pkg_name=${install_dir}-${osType}-${cpuType}
|
||||
|
||||
if [ "$pagMode" == "lite" ]; then
|
||||
pkg_name=${pkg_name}-Lite
|
||||
fi
|
||||
# if [ "$verMode" == "cluster" ]; then
|
||||
# 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 [ "$verType" == "beta" ]; then
|
||||
pkg_name=${pkg_name}-${verType}
|
||||
pkg_name=${install_dir}-${verType}-${osType}-${cpuType}
|
||||
elif [ "$verType" == "stable" ]; then
|
||||
pkg_name=${pkg_name}
|
||||
else
|
||||
|
@ -225,6 +224,10 @@ else
|
|||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$pagMode" == "lite" ]; then
|
||||
pkg_name=${pkg_name}-Lite
|
||||
fi
|
||||
|
||||
tar -zcv -f "$(basename ${pkg_name}).tar.gz" $(basename ${install_dir}) --remove-files || :
|
||||
exitcode=$?
|
||||
if [ "$exitcode" != "0" ]; then
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
name: tdengine
|
||||
base: core18
|
||||
version: '2.1.3.0'
|
||||
version: '2.1.4.1'
|
||||
icon: snap/gui/t-dengine.svg
|
||||
summary: an open-source big data platform designed and optimized for IoT.
|
||||
description: |
|
||||
|
@ -72,7 +72,7 @@ parts:
|
|||
- usr/bin/taosd
|
||||
- usr/bin/taos
|
||||
- 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
|
||||
|
||||
|
|
|
@ -1129,6 +1129,7 @@ int tsParseInsertSql(SSqlObj *pSql) {
|
|||
SSqlCmd *pCmd = &pSql->cmd;
|
||||
|
||||
SInsertStatementParam* pInsertParam = &pCmd->insertParam;
|
||||
pInsertParam->objectId = pSql->self;
|
||||
char* str = pInsertParam->sql;
|
||||
|
||||
int32_t totalNum = 0;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1200,9 +1200,11 @@ static int insertBatchStmtExecute(STscStmt* pStmt) {
|
|||
// wait for the callback function to post the semaphore
|
||||
tsem_wait(&pStmt->pSql->rspSem);
|
||||
|
||||
code = pStmt->pSql->res.code;
|
||||
|
||||
insertBatchClean(pStmt);
|
||||
|
||||
return pStmt->pSql->res.code;
|
||||
return code;
|
||||
}
|
||||
|
||||
int stmtParseInsertTbTags(SSqlObj* pSql, STscStmt* pStmt) {
|
||||
|
@ -1470,6 +1472,7 @@ int taos_stmt_prepare(TAOS_STMT* stmt, const char* sql, unsigned long length) {
|
|||
pSql->fetchFp = waitForQueryRsp;
|
||||
|
||||
pCmd->insertParam.insertType = TSDB_QUERY_TYPE_STMT_INSERT;
|
||||
pCmd->insertParam.objectId = pSql->self;
|
||||
|
||||
pSql->sqlstr = realloc(pSql->sqlstr, sqlLen + 1);
|
||||
|
||||
|
@ -1646,7 +1649,11 @@ int taos_stmt_close(TAOS_STMT* stmt) {
|
|||
} else {
|
||||
if (pStmt->multiTbInsert) {
|
||||
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);
|
||||
pStmt->pSql->cmd.insertParam.pTableBlockHashList = NULL;
|
||||
taosArrayDestroy(pStmt->mtb.tags);
|
||||
|
|
|
@ -7802,26 +7802,34 @@ static int32_t doLoadAllTableMeta(SSqlObj* pSql, SQueryInfo* pQueryInfo, SSqlNod
|
|||
}
|
||||
|
||||
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;
|
||||
|
||||
STableComInfo *info = &meta->tableInfo;
|
||||
info->numOfColumns = numOfColumns;
|
||||
info->precision = pUpstreamTableMetaInfo->pTableMeta->tableInfo.precision;
|
||||
info->numOfTags = 0;
|
||||
|
||||
int32_t n = 0;
|
||||
for(int32_t i = 0; i < numOfColumns; ++i) {
|
||||
SInternalField* pField = tscFieldInfoGetInternalField(&pUpstream->fieldsInfo, i);
|
||||
if (pField->visible) {
|
||||
if (!pField->visible) {
|
||||
continue;
|
||||
}
|
||||
|
||||
meta->schema[n].bytes = pField->field.bytes;
|
||||
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);
|
||||
info->rowSize += meta->schema[n].bytes;
|
||||
|
||||
n += 1;
|
||||
}
|
||||
}
|
||||
|
||||
return meta;
|
||||
}
|
||||
|
|
|
@ -3342,6 +3342,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, __async_cb_func_t
|
|||
pnCmd->insertParam.numOfTables = 0;
|
||||
pnCmd->insertParam.pTableNameList = NULL;
|
||||
pnCmd->insertParam.pTableBlockHashList = NULL;
|
||||
pnCmd->insertParam.objectId = pNew->self;
|
||||
|
||||
memset(&pnCmd->insertParam.tagData, 0, sizeof(STagData));
|
||||
|
||||
|
@ -3608,6 +3609,7 @@ void executeQuery(SSqlObj* pSql, SQueryInfo* pQueryInfo) {
|
|||
pNew->signature = pNew;
|
||||
pNew->sqlstr = strdup(pSql->sqlstr); // todo refactor
|
||||
pNew->fp = tscSubqueryCompleteCallback;
|
||||
tsem_init(&pNew->rspSem, 0, 0);
|
||||
|
||||
SRetrieveSupport* ps = calloc(1, sizeof(SRetrieveSupport)); // todo use object id
|
||||
ps->pParentSql = pSql;
|
||||
|
|
|
@ -57,8 +57,8 @@ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStat
|
|||
parameterCnt++;
|
||||
}
|
||||
}
|
||||
parameters = new Object[parameterCnt];
|
||||
}
|
||||
parameters = new Object[parameterCnt];
|
||||
|
||||
if (parameterCnt > 1) {
|
||||
// the table name is also a parameter, so ignore it.
|
||||
|
|
|
@ -22,16 +22,16 @@ public class RestfulPreparedStatement extends RestfulStatement implements Prepar
|
|||
super(conn, database);
|
||||
this.rawSql = sql;
|
||||
|
||||
if (sql.contains("?")) {
|
||||
int parameterCnt = 0;
|
||||
if (sql.contains("?")) {
|
||||
for (int i = 0; i < sql.length(); i++) {
|
||||
if ('?' == sql.charAt(i)) {
|
||||
parameterCnt++;
|
||||
}
|
||||
}
|
||||
parameters = new Object[parameterCnt];
|
||||
this.isPrepared = true;
|
||||
}
|
||||
parameters = new Object[parameterCnt];
|
||||
|
||||
// build parameterMetaData
|
||||
this.parameterMetaData = new RestfulParameterMetaData(parameters);
|
||||
|
|
|
@ -15,6 +15,8 @@ public class RestfulPreparedStatementTest {
|
|||
private static PreparedStatement pstmt_insert;
|
||||
private static final String sql_select = "select * from t1 where ts > ? and ts <= ? and f1 >= ?";
|
||||
private static PreparedStatement pstmt_select;
|
||||
private static final String sql_without_parameters = "select count(*) from t1";
|
||||
private static PreparedStatement pstmt_without_parameters;
|
||||
|
||||
@Test
|
||||
public void executeQuery() throws SQLException {
|
||||
|
@ -237,6 +239,7 @@ public class RestfulPreparedStatementTest {
|
|||
@Test
|
||||
public void clearParameters() throws SQLException {
|
||||
pstmt_insert.clearParameters();
|
||||
pstmt_without_parameters.clearParameters();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -382,6 +385,7 @@ public class RestfulPreparedStatementTest {
|
|||
|
||||
pstmt_insert = conn.prepareStatement(sql_insert);
|
||||
pstmt_select = conn.prepareStatement(sql_select);
|
||||
pstmt_without_parameters = conn.prepareStatement(sql_without_parameters);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -394,6 +398,8 @@ public class RestfulPreparedStatementTest {
|
|||
pstmt_insert.close();
|
||||
if (pstmt_select != null)
|
||||
pstmt_select.close();
|
||||
if (pstmt_without_parameters != null)
|
||||
pstmt_without_parameters.close();
|
||||
if (conn != null)
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
|
|
|
@ -15,36 +15,18 @@ const { NULL_POINTER } = require('ref-napi');
|
|||
|
||||
module.exports = CTaosInterface;
|
||||
|
||||
function convertMillisecondsToDatetime(time) {
|
||||
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;
|
||||
}
|
||||
function convertTimestamp(data, num_of_rows, nbytes = 0, offset = 0, precision = 0) {
|
||||
data = ref.reinterpret(data.deref(), nbytes * num_of_rows, offset);
|
||||
let res = [];
|
||||
let currOffset = 0;
|
||||
while (currOffset < data.length) {
|
||||
let queue = [];
|
||||
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);
|
||||
}
|
||||
let time = data.readInt64LE(currOffset);
|
||||
currOffset += nbytes;
|
||||
res.push(timestampConverter(time));
|
||||
res.push(new TaosObjects.TaosTimestamp(time, precision));
|
||||
}
|
||||
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);
|
||||
let res = new Array(data.length);
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
|
@ -60,7 +42,7 @@ function convertBool(data, num_of_rows, nbytes = 0, offset = 0, micro = false) {
|
|||
}
|
||||
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);
|
||||
let res = [];
|
||||
let currOffset = 0;
|
||||
|
@ -71,7 +53,7 @@ function convertTinyint(data, num_of_rows, nbytes = 0, offset = 0, micro = false
|
|||
}
|
||||
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);
|
||||
let res = [];
|
||||
let currOffset = 0;
|
||||
|
@ -82,7 +64,7 @@ function convertSmallint(data, num_of_rows, nbytes = 0, offset = 0, micro = fals
|
|||
}
|
||||
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);
|
||||
let res = [];
|
||||
let currOffset = 0;
|
||||
|
@ -93,7 +75,7 @@ function convertInt(data, num_of_rows, nbytes = 0, offset = 0, micro = false) {
|
|||
}
|
||||
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);
|
||||
let res = [];
|
||||
let currOffset = 0;
|
||||
|
@ -104,7 +86,7 @@ function convertBigint(data, num_of_rows, nbytes = 0, offset = 0, micro = false)
|
|||
}
|
||||
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);
|
||||
let res = [];
|
||||
let currOffset = 0;
|
||||
|
@ -115,7 +97,7 @@ function convertFloat(data, num_of_rows, nbytes = 0, offset = 0, micro = false)
|
|||
}
|
||||
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);
|
||||
let res = [];
|
||||
let currOffset = 0;
|
||||
|
@ -127,7 +109,7 @@ function convertDouble(data, num_of_rows, nbytes = 0, offset = 0, micro = false)
|
|||
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);
|
||||
let res = [];
|
||||
|
||||
|
@ -272,7 +254,7 @@ CTaosInterface.prototype.config = function config() {
|
|||
CTaosInterface.prototype.connect = function connect(host = null, user = "root", password = "taosdata", db = null, port = 0) {
|
||||
let _host, _user, _password, _db, _port;
|
||||
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) {
|
||||
throw "Attribute Error: host is expected as a str";
|
||||
|
@ -290,7 +272,7 @@ CTaosInterface.prototype.connect = function connect(host = null, user = "root",
|
|||
throw "Attribute Error: password is expected as a str";
|
||||
}
|
||||
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) {
|
||||
throw "Attribute Error: db is expected as a str";
|
||||
|
@ -345,8 +327,7 @@ CTaosInterface.prototype.fetchBlock = function fetchBlock(result, fields) {
|
|||
}
|
||||
|
||||
var fieldL = this.libtaos.taos_fetch_lengths(result);
|
||||
|
||||
let isMicro = (this.libtaos.taos_result_precision(result) == FieldTypes.C_TIMESTAMP_MICRO);
|
||||
let precision = this.libtaos.taos_result_precision(result);
|
||||
|
||||
var fieldlens = [];
|
||||
|
||||
|
@ -373,7 +354,7 @@ CTaosInterface.prototype.fetchBlock = function fetchBlock(result, fields) {
|
|||
if (!convertFunctions[fields[i]['type']]) {
|
||||
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 }
|
||||
|
@ -423,7 +404,7 @@ CTaosInterface.prototype.fetch_rows_a = function fetch_rows_a(result, callback,
|
|||
let row = cti.libtaos.taos_fetch_row(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);
|
||||
blocks.fill(null);
|
||||
numOfRows2 = Math.abs(numOfRows2);
|
||||
|
@ -449,7 +430,7 @@ CTaosInterface.prototype.fetch_rows_a = function fetch_rows_a(result, callback,
|
|||
let prow = ref.reinterpret(row, 8, i * 8);
|
||||
prow = prow.readPointer();
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -572,7 +553,7 @@ CTaosInterface.prototype.openStream = function openStream(connection, sql, callb
|
|||
var cti = this;
|
||||
let asyncCallbackWrapper = function (param2, result2, row) {
|
||||
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);
|
||||
blocks.fill(null);
|
||||
let numOfRows2 = 1;
|
||||
|
@ -582,7 +563,7 @@ CTaosInterface.prototype.openStream = function openStream(connection, sql, callb
|
|||
if (!convertFunctions[fields[i]['type']]) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const FieldTypes = require('./constants');
|
||||
|
||||
const util = require('util');
|
||||
/**
|
||||
* Various objects such as TaosRow and TaosColumn that help make parsing data easier
|
||||
* @module TaosObjects
|
||||
|
@ -14,7 +14,7 @@ const FieldTypes = require('./constants');
|
|||
* var trow = new TaosRow(row);
|
||||
* console.log(trow.data);
|
||||
*/
|
||||
function TaosRow (row) {
|
||||
function TaosRow(row) {
|
||||
this.data = row;
|
||||
this.length = row.length;
|
||||
return this;
|
||||
|
@ -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
|
||||
*/
|
||||
class TaosTimestamp extends Date {
|
||||
constructor(date, micro = false) {
|
||||
super(date);
|
||||
this._type = 'TaosTimestamp';
|
||||
if (micro) {
|
||||
this.microTime = date - Math.floor(date);
|
||||
constructor(date, precision = 0) {
|
||||
if (precision === 1) {
|
||||
super(Math.floor(date / 1000));
|
||||
this.precisionExtras = date % 1000;
|
||||
} 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
|
||||
* @return {string} A Taos Timestamp String
|
||||
*/
|
||||
toTaosString(){
|
||||
toTaosString() {
|
||||
var tzo = -this.getTimezoneOffset(),
|
||||
dif = tzo >= 0 ? '+' : '-',
|
||||
pad = function(num) {
|
||||
pad = function (num) {
|
||||
var norm = Math.floor(Math.abs(num));
|
||||
return (norm < 10 ? '0' : '') + norm;
|
||||
},
|
||||
pad2 = function(num) {
|
||||
pad2 = function (num) {
|
||||
var norm = Math.floor(Math.abs(num));
|
||||
if (norm < 10) return '00' + norm;
|
||||
if (norm < 100) return '0' + norm;
|
||||
|
@ -73,8 +133,19 @@ class TaosTimestamp extends Date {
|
|||
':' + pad(this.getMinutes()) +
|
||||
':' + pad(this.getSeconds()) +
|
||||
'.' + 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 }
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
{
|
||||
"name": "td2.0-connector",
|
||||
"version": "2.0.8",
|
||||
"version": "2.0.9",
|
||||
"description": "A Node.js connector for TDengine.",
|
||||
"main": "tdengine.js",
|
||||
"directories": {
|
||||
"test": "test"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node test/test.js"
|
||||
"test": "node test/test.js && node test/testMicroseconds.js && node test/testNanoseconds.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
var TDengineConnection = require('./nodetaos/connection.js')
|
||||
module.exports.connect = function (connection=null) {
|
||||
module.exports.connect = function (connection={}) {
|
||||
return new TDengineConnection(connection);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
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();
|
||||
let stime = new Date();
|
||||
let interval = 1000;
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
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);
|
|
@ -0,0 +1,49 @@
|
|||
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);
|
|||
|
||||
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
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -236,6 +236,7 @@ typedef struct SArguments_S {
|
|||
char ** arg_list;
|
||||
uint64_t totalInsertRows;
|
||||
uint64_t totalAffectedRows;
|
||||
bool demo_mode; // use default column name and semi-random data
|
||||
} SArguments;
|
||||
|
||||
typedef struct SColumn_S {
|
||||
|
@ -552,6 +553,8 @@ static int postProceSql(char *host, struct sockaddr_in *pServAddr,
|
|||
uint16_t port, char* sqlstr, threadInfo *pThreadInfo);
|
||||
static int64_t getTSRandTail(int64_t timeStampStep, int32_t seq,
|
||||
int disorderRatio, int disorderRange);
|
||||
static bool getInfoFromJsonFile(char* file);
|
||||
static void init_rand_data();
|
||||
|
||||
/* ************ Global variables ************ */
|
||||
|
||||
|
@ -569,16 +572,16 @@ SArguments g_args = {
|
|||
6030, // port
|
||||
TAOSC_IFACE, // iface
|
||||
"root", // user
|
||||
#ifdef _TD_POWER_
|
||||
#ifdef _TD_POWER_
|
||||
"powerdb", // password
|
||||
#elif (_TD_TQ_ == true)
|
||||
#elif (_TD_TQ_ == true)
|
||||
"tqueue", // password
|
||||
#else
|
||||
#else
|
||||
"taosdata", // password
|
||||
#endif
|
||||
#endif
|
||||
"test", // database
|
||||
1, // replica
|
||||
"t", // tb_prefix
|
||||
"d", // tb_prefix
|
||||
NULL, // sqlFile
|
||||
true, // use_metric
|
||||
true, // drop_database
|
||||
|
@ -590,10 +593,9 @@ SArguments g_args = {
|
|||
"./output.txt", // output_file
|
||||
0, // mode : sync or async
|
||||
{
|
||||
"FLOAT", // datatype
|
||||
"INT", // datatype
|
||||
"INT", // datatype
|
||||
"INT", // datatype
|
||||
"INT", // datatype
|
||||
"FLOAT", // datatype
|
||||
},
|
||||
16, // len_of_binary
|
||||
4, // num_of_CPR
|
||||
|
@ -609,7 +611,10 @@ SArguments g_args = {
|
|||
0, // disorderRatio
|
||||
1000, // disorderRange
|
||||
1, // method_of_delete
|
||||
NULL // arg_list
|
||||
NULL, // arg_list
|
||||
0, // totalInsertRows;
|
||||
0, // totalAffectedRows;
|
||||
true, // demo_mode;
|
||||
};
|
||||
|
||||
|
||||
|
@ -709,7 +714,7 @@ static void printHelp() {
|
|||
printf("%s%s%s%s\n", indent, "-a", indent,
|
||||
"Set the replica parameters of the database, Default 1, min: 1, max: 3.");
|
||||
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, "-N", indent, "Use normal table flag.");
|
||||
printf("%s%s%s%s\n", indent, "-o", indent,
|
||||
|
@ -717,11 +722,11 @@ static void printHelp() {
|
|||
printf("%s%s%s%s\n", indent, "-q", indent,
|
||||
"Query mode -- 0: SYNC, 1: ASYNC. Default is SYNC.");
|
||||
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,
|
||||
"The length of data_type 'BINARY' or 'NCHAR'. Default is 16");
|
||||
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);
|
||||
printf("%s%s%s%s\n", indent, "-T", indent,
|
||||
"The number of threads. Default is 10.");
|
||||
|
@ -733,6 +738,10 @@ static void printHelp() {
|
|||
"The number of tables. Default is 10000.");
|
||||
printf("%s%s%s%s\n", indent, "-n", indent,
|
||||
"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, "-y", indent, "Default input yes for prompt.");
|
||||
printf("%s%s%s%s\n", indent, "-O", indent,
|
||||
|
@ -745,8 +754,8 @@ static void printHelp() {
|
|||
"Print version info.");
|
||||
printf("%s%s%s%s\n", indent, "--help\t", indent,
|
||||
"Print command line arguments list info.");
|
||||
/* printf("%s%s%s%s\n", indent, "-D", indent,
|
||||
"if elete database if exists. 0: no, 1: yes, default is 1");
|
||||
/* printf("%s%s%s%s\n", indent, "-D", indent,
|
||||
"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) {
|
|||
|
||||
for (int i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-f") == 0) {
|
||||
arguments->demo_mode = false;
|
||||
arguments->metaFile = argv[++i];
|
||||
} else if (strcmp(argv[i], "-c") == 0) {
|
||||
if (argc == i+1) {
|
||||
|
@ -911,6 +921,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
|
|||
}
|
||||
arguments->database = argv[++i];
|
||||
} else if (strcmp(argv[i], "-l") == 0) {
|
||||
arguments->demo_mode = false;
|
||||
if (argc == i+1) {
|
||||
if (!isStringNumber(argv[i+1])) {
|
||||
printHelp();
|
||||
|
@ -931,6 +942,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
|
|||
}
|
||||
|
||||
} else if (strcmp(argv[i], "-b") == 0) {
|
||||
arguments->demo_mode = false;
|
||||
if (argc == i+1) {
|
||||
printHelp();
|
||||
errorPrint("%s", "\n\t-b need valid string following!\n");
|
||||
|
@ -1000,6 +1012,8 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
|
|||
arguments->tb_prefix = argv[++i];
|
||||
} else if (strcmp(argv[i], "-N") == 0) {
|
||||
arguments->use_metric = false;
|
||||
} else if (strcmp(argv[i], "-M") == 0) {
|
||||
arguments->demo_mode = false;
|
||||
} else if (strcmp(argv[i], "-x") == 0) {
|
||||
arguments->insert_only = false;
|
||||
} else if (strcmp(argv[i], "-y") == 0) {
|
||||
|
@ -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) {
|
||||
if (NULL != fp) {
|
||||
fclose(fp);
|
||||
|
@ -1231,7 +1243,8 @@ static void fetchResult(TAOS_RES *res, threadInfo* pThreadInfo) {
|
|||
//printf("query result:%s\n", temp);
|
||||
memcpy(databuf + totalLen, temp, 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",
|
||||
|
@ -1314,6 +1327,27 @@ static float rand_float(){
|
|||
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
|
||||
static const char charNum[] = "0123456789";
|
||||
|
||||
|
@ -1351,7 +1385,6 @@ static double rand_double() {
|
|||
cursor++;
|
||||
cursor = cursor % MAX_PREPARED_RAND;
|
||||
return randdouble[cursor];
|
||||
|
||||
}
|
||||
|
||||
static void init_rand_data() {
|
||||
|
@ -1386,6 +1419,11 @@ static void init_rand_data() {
|
|||
static int printfInsertMeta() {
|
||||
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",
|
||||
(g_args.iface==TAOSC_IFACE)?"taosc":(g_args.iface==REST_IFACE)?"rest":"stmt");
|
||||
printf("host: \033[33m%s:%u\033[0m\n",
|
||||
|
@ -1519,7 +1557,7 @@ static int printfInsertMeta() {
|
|||
}
|
||||
printf(" insertRows: \033[33m%"PRId64"\033[0m\n",
|
||||
g_Dbs.db[i].superTbls[j].insertRows);
|
||||
/*
|
||||
/*
|
||||
if (0 == g_Dbs.db[i].superTbls[j].multiThreadWriteOneTbl) {
|
||||
printf(" multiThreadWriteOneTbl: \033[33mno\033[0m\n");
|
||||
}else {
|
||||
|
@ -1707,7 +1745,7 @@ static void printfInsertMetaToFile(FILE* fp) {
|
|||
fprintf(fp, " stable insert interval: %"PRIu64"\n",
|
||||
g_Dbs.db[i].superTbls[j].insertInterval);
|
||||
}
|
||||
/*
|
||||
/*
|
||||
if (0 == g_Dbs.db[i].superTbls[j].multiThreadWriteOneTbl) {
|
||||
fprintf(fp, " multiThreadWriteOneTbl: no\n");
|
||||
}else {
|
||||
|
@ -1863,7 +1901,7 @@ static char* formatTimestamp(char* buf, int64_t val, int precision) {
|
|||
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,
|
||||
need to find a better solution.
|
||||
if (tt < 0) {
|
||||
|
@ -1943,7 +1981,8 @@ static int xDumpResultToFile(const char* fname, TAOS_RES* tres) {
|
|||
|
||||
FILE* fp = fopen(fname, "at");
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -1966,7 +2005,8 @@ static int xDumpResultToFile(const char* fname, TAOS_RES* tres) {
|
|||
if (i > 0) {
|
||||
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);
|
||||
|
||||
|
@ -1988,7 +2028,8 @@ static int getDbFromServer(TAOS * taos, SDbInfo** dbInfos) {
|
|||
int32_t code = taos_errno(res);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -2318,8 +2359,10 @@ static char* generateTagVaulesForStb(SSuperTable* stbInfo, int32_t tableSeq) {
|
|||
int dataLen = 0;
|
||||
dataLen += snprintf(dataBuf + dataLen, TSDB_MAX_SQL_LEN - dataLen, "(");
|
||||
for (int i = 0; i < stbInfo->tagCount; i++) {
|
||||
if ((0 == strncasecmp(stbInfo->tags[i].dataType, "binary", strlen("binary")))
|
||||
|| (0 == strncasecmp(stbInfo->tags[i].dataType, "nchar", strlen("nchar")))) {
|
||||
if ((0 == strncasecmp(stbInfo->tags[i].dataType,
|
||||
"binary", strlen("binary")))
|
||||
|| (0 == strncasecmp(stbInfo->tags[i].dataType,
|
||||
"nchar", strlen("nchar")))) {
|
||||
if (stbInfo->tags[i].dataLen > TSDB_MAX_BINARY_LEN) {
|
||||
printf("binary or nchar length overflow, max size:%u\n",
|
||||
(uint32_t)TSDB_MAX_BINARY_LEN);
|
||||
|
@ -2664,13 +2707,20 @@ static int createSuperTable(
|
|||
superTbl->columns[colIndex].dataLen);
|
||||
lenOfOneRow += superTbl->columns[colIndex].dataLen + 3;
|
||||
} 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");
|
||||
}
|
||||
lenOfOneRow += 11;
|
||||
} 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;
|
||||
} 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;
|
||||
} else if (strcasecmp(dataType, "TINYINT") == 0) {
|
||||
len += snprintf(cols + len, STRING_LEN - len, ", col%d %s", colIndex, "TINYINT");
|
||||
|
@ -2679,13 +2729,24 @@ static int createSuperTable(
|
|||
len += snprintf(cols + len, STRING_LEN - len, ", col%d %s", colIndex, "BOOL");
|
||||
lenOfOneRow += 6;
|
||||
} 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");
|
||||
}
|
||||
|
||||
lenOfOneRow += 22;
|
||||
} 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;
|
||||
} 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;
|
||||
} else {
|
||||
taos_close(taos);
|
||||
|
@ -2696,7 +2757,6 @@ static int createSuperTable(
|
|||
}
|
||||
|
||||
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
|
||||
superTbl->colsOfCreateChildTable = (char*)calloc(len+20, 1);
|
||||
|
@ -4746,15 +4806,16 @@ static void postFreeResource() {
|
|||
|
||||
static int getRowDataFromSample(
|
||||
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) {
|
||||
/* int ret = readSampleFromCsvFileToMem(superTblInfo);
|
||||
/* int ret = readSampleFromCsvFileToMem(superTblInfo);
|
||||
if (0 != ret) {
|
||||
tmfree(superTblInfo->sampleDataBuf);
|
||||
superTblInfo->sampleDataBuf = NULL;
|
||||
return -1;
|
||||
}
|
||||
*/
|
||||
*/
|
||||
*sampleUsePos = 0;
|
||||
}
|
||||
|
||||
|
@ -4763,7 +4824,9 @@ static int getRowDataFromSample(
|
|||
dataLen += snprintf(dataBuf + dataLen, maxLen - dataLen,
|
||||
"(%" PRId64 ", ", timestamp);
|
||||
dataLen += snprintf(dataBuf + dataLen, maxLen - dataLen,
|
||||
"%s", superTblInfo->sampleDataBuf + superTblInfo->lenOfOneRow * (*sampleUsePos));
|
||||
"%s",
|
||||
superTblInfo->sampleDataBuf
|
||||
+ superTblInfo->lenOfOneRow * (*sampleUsePos));
|
||||
dataLen += snprintf(dataBuf + dataLen, maxLen - dataLen, ")");
|
||||
|
||||
(*sampleUsePos)++;
|
||||
|
@ -4803,16 +4866,31 @@ static int64_t generateStbRowData(
|
|||
tmfree(buf);
|
||||
} else if (0 == strncasecmp(stbInfo->columns[i].dataType,
|
||||
"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,
|
||||
"%d,", rand_int());
|
||||
}
|
||||
} else if (0 == strncasecmp(stbInfo->columns[i].dataType,
|
||||
"BIGINT", strlen("BIGINT"))) {
|
||||
dataLen += snprintf(pstr + dataLen, maxLen - dataLen,
|
||||
"%"PRId64",", rand_bigint());
|
||||
} else if (0 == strncasecmp(stbInfo->columns[i].dataType,
|
||||
"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,
|
||||
"%f,", rand_float());
|
||||
}
|
||||
} else if (0 == strncasecmp(stbInfo->columns[i].dataType,
|
||||
"DOUBLE", strlen("DOUBLE"))) {
|
||||
dataLen += snprintf(pstr + dataLen, maxLen - dataLen,
|
||||
|
@ -6008,8 +6086,10 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
|
|||
errorPrint("[%d] %s() LN%d Failed to insert records of batch %d\n",
|
||||
pThreadInfo->threadID, __func__, __LINE__,
|
||||
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",
|
||||
batchPerTbl, maxSqlLen / batchPerTbl);
|
||||
}
|
||||
errorPrint("\tPlease check if the buffer length(%"PRId64") or batch(%d) is set with proper value!\n",
|
||||
maxSqlLen, batchPerTbl);
|
||||
goto free_of_interlace;
|
||||
|
|
|
@ -124,6 +124,9 @@ typedef struct {
|
|||
|
||||
extern char version[];
|
||||
|
||||
#define DB_PRECISION_LEN 8
|
||||
#define DB_STATUS_LEN 16
|
||||
|
||||
typedef struct {
|
||||
char name[TSDB_DB_NAME_LEN];
|
||||
char create_time[32];
|
||||
|
@ -144,9 +147,9 @@ typedef struct {
|
|||
int32_t fsync;
|
||||
int8_t comp;
|
||||
int8_t cachelast;
|
||||
char precision[8]; // time resolution
|
||||
char precision[DB_PRECISION_LEN]; // time resolution
|
||||
int8_t update;
|
||||
char status[16];
|
||||
char status[DB_STATUS_LEN];
|
||||
} SDbInfo;
|
||||
|
||||
typedef struct {
|
||||
|
@ -542,7 +545,8 @@ static void parse_precision_first(
|
|||
free(tmp);
|
||||
exit(-1);
|
||||
}
|
||||
strncpy(g_args.precision, tmp, strlen(tmp));
|
||||
strncpy(g_args.precision, tmp,
|
||||
min(DB_PRECISION_LEN - 1, strlen(tmp)));
|
||||
free(tmp);
|
||||
}
|
||||
}
|
||||
|
@ -1596,6 +1600,7 @@ static void taosStartDumpOutWorkThreads(int32_t numOfThread, char *dbName)
|
|||
NULL, g_args.port);
|
||||
if (pThread->taosCon == NULL) {
|
||||
errorPrint("Failed to connect to TDengine server %s\n", g_args.host);
|
||||
free(threadObj);
|
||||
return;
|
||||
}
|
||||
pthread_attr_init(&thattr);
|
||||
|
@ -2607,6 +2612,7 @@ static void taosStartDumpInWorkThreads()
|
|||
NULL, g_args.port);
|
||||
if (pThread->taosCon == NULL) {
|
||||
errorPrint("Failed to connect to TDengine server %s\n", g_args.host);
|
||||
free(threadObj);
|
||||
return;
|
||||
}
|
||||
pthread_attr_init(&thattr);
|
||||
|
|
|
@ -105,8 +105,7 @@ typedef struct SResultRowInfo {
|
|||
int16_t type:8; // data type for hash key
|
||||
int32_t size:24; // number of result set
|
||||
int32_t capacity; // max capacity
|
||||
SResultRow* current; // current start active index
|
||||
int64_t prevSKey; // previous (not completed) sliding window start key
|
||||
int32_t curPos; // current active result row index of pResult list
|
||||
} SResultRowInfo;
|
||||
|
||||
typedef struct SColumnFilterElem {
|
||||
|
@ -277,6 +276,7 @@ typedef struct SQueryRuntimeEnv {
|
|||
bool enableGroupData;
|
||||
SDiskbasedResultBuf* pResultBuf; // query result buffer based on blocked-wised disk file
|
||||
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
|
||||
SResultRowPool* pool; // window result object pool
|
||||
char** prevRow;
|
||||
|
@ -423,7 +423,7 @@ typedef struct STagScanInfo {
|
|||
SColumnInfo* pCols;
|
||||
SSDataBlock* pRes;
|
||||
int32_t totalTables;
|
||||
int32_t currentIndex;
|
||||
int32_t curPos;
|
||||
} STagScanInfo;
|
||||
|
||||
typedef struct SOptrBasicInfo {
|
||||
|
|
|
@ -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) 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) 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) 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}
|
||||
|
||||
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
|
|||
if (size <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t orderId = pRuntimeEnv->pQueryAttr->order.orderColId;
|
||||
if (orderId <= 0) {
|
||||
return;
|
||||
|
@ -410,25 +411,10 @@ static void prepareResultListBuffer(SResultRowInfo* pResultRowInfo, SQueryRuntim
|
|||
pResultRowInfo->capacity = (int32_t)newCapacity;
|
||||
}
|
||||
|
||||
static int32_t ascResultRowCompareFn(const void* p1, const void* p2) {
|
||||
SResultRow* pRow1 = *(SResultRow**)p1;
|
||||
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) {
|
||||
static SResultRow* doSetResultOutBufByKey(SQueryRuntimeEnv* pRuntimeEnv, SResultRowInfo* pResultRowInfo, int64_t tid,
|
||||
char* pData, int16_t bytes, bool masterscan, uint64_t tableGroupId) {
|
||||
bool existed = false;
|
||||
SET_RES_WINDOW_KEY(pRuntimeEnv->keyBuf, pData, bytes, uid);
|
||||
SET_RES_WINDOW_KEY(pRuntimeEnv->keyBuf, pData, bytes, tableGroupId);
|
||||
|
||||
SResultRow **p1 =
|
||||
(SResultRow **)taosHashGet(pRuntimeEnv->pResultRowHashTable, pRuntimeEnv->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes));
|
||||
|
@ -440,22 +426,26 @@ static SResultRow *doPrepareResultRowFromKey(SQueryRuntimeEnv *pRuntimeEnv, SRes
|
|||
}
|
||||
|
||||
if (p1 != NULL) {
|
||||
pResultRowInfo->current = (*p1);
|
||||
|
||||
if (pResultRowInfo->size == 0) {
|
||||
existed = false;
|
||||
assert(pResultRowInfo->curPos == -1);
|
||||
} else if (pResultRowInfo->size == 1) {
|
||||
existed = (pResultRowInfo->pResult[0] == (*p1));
|
||||
} else {
|
||||
__compar_fn_t fn = QUERY_IS_ASC_QUERY(pRuntimeEnv->pQueryAttr)? ascResultRowCompareFn:descResultRowCompareFn;
|
||||
void* ptr = taosbsearch(p1, pResultRowInfo->pResult, pResultRowInfo->size, POINTER_BYTES, fn, TD_EQ);
|
||||
if (ptr != NULL) {
|
||||
pResultRowInfo->curPos = 0;
|
||||
} else { // check if current pResultRowInfo contains the existed pResultRow
|
||||
SET_RES_WINDOW_KEY(pRuntimeEnv->keyBuf, pData, bytes, tid);
|
||||
int64_t* index = taosHashGet(pRuntimeEnv->pResultRowListSet, pRuntimeEnv->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes));
|
||||
if (index != NULL) {
|
||||
pResultRowInfo->curPos = (int32_t) *index;
|
||||
existed = true;
|
||||
} else {
|
||||
existed = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
|
@ -477,8 +467,12 @@ static SResultRow *doPrepareResultRowFromKey(SQueryRuntimeEnv *pRuntimeEnv, SRes
|
|||
pResult = *p1;
|
||||
}
|
||||
|
||||
pResultRowInfo->curPos = pResultRowInfo->size;
|
||||
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
|
||||
|
@ -486,7 +480,7 @@ static SResultRow *doPrepareResultRowFromKey(SQueryRuntimeEnv *pRuntimeEnv, SRes
|
|||
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) {
|
||||
|
@ -517,13 +511,8 @@ static void getInitialStartTimeWindow(SQueryAttr* pQueryAttr, TSKEY ts, STimeWin
|
|||
static STimeWindow getActiveTimeWindow(SResultRowInfo * pResultRowInfo, int64_t ts, SQueryAttr *pQueryAttr) {
|
||||
STimeWindow w = {0};
|
||||
|
||||
if (pResultRowInfo->current == NULL) { // the first window, from the previous stored value
|
||||
if (pResultRowInfo->prevSKey == TSKEY_INITIAL_VAL) {
|
||||
if (pResultRowInfo->curPos == -1) { // the first window, from the previous stored value
|
||||
getInitialStartTimeWindow(pQueryAttr, ts, &w);
|
||||
pResultRowInfo->prevSKey = w.skey;
|
||||
} else {
|
||||
w.skey = pResultRowInfo->prevSKey;
|
||||
}
|
||||
|
||||
if (pQueryAttr->interval.intervalUnit == 'n' || pQueryAttr->interval.intervalUnit == 'y') {
|
||||
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
|
|||
w.ekey = w.skey + pQueryAttr->interval.interval - 1;
|
||||
}
|
||||
} else {
|
||||
// int32_t slot = curTimeWindowIndex(pResultRowInfo);
|
||||
// SResultRow* pWindowRes = getResultRow(pResultRowInfo, slot);
|
||||
SResultRow* pWindowRes = pResultRowInfo->current;
|
||||
w = pWindowRes->win;
|
||||
w = getResultRow(pResultRowInfo, pResultRowInfo->curPos)->win;
|
||||
}
|
||||
|
||||
if (w.skey > ts || w.ekey < ts) {
|
||||
|
@ -614,13 +600,13 @@ static int32_t addNewWindowResultBuf(SResultRow *pWindowRes, SDiskbasedResultBuf
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int32_t setWindowOutputBufByKey(SQueryRuntimeEnv *pRuntimeEnv, SResultRowInfo *pResultRowInfo, STimeWindow *win,
|
||||
bool masterscan, SResultRow **pResult, int64_t groupId, SQLFunctionCtx* pCtx,
|
||||
static int32_t setResultOutputBufByKey(SQueryRuntimeEnv *pRuntimeEnv, SResultRowInfo *pResultRowInfo, int64_t tid, STimeWindow *win,
|
||||
bool masterscan, SResultRow **pResult, int64_t tableGroupId, SQLFunctionCtx* pCtx,
|
||||
int32_t numOfOutput, int32_t* rowCellInfoOffset) {
|
||||
assert(win->skey <= win->ekey);
|
||||
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) {
|
||||
*pResult = NULL;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -628,7 +614,7 @@ static int32_t setWindowOutputBufByKey(SQueryRuntimeEnv *pRuntimeEnv, SResultRow
|
|||
|
||||
// not assign result buffer yet, add new result buffer
|
||||
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) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -721,9 +707,10 @@ static void doUpdateResultRowIndex(SResultRowInfo*pResultRowInfo, TSKEY lastKey,
|
|||
if (skey == TSKEY_INITIAL_VAL) {
|
||||
if (pResultRowInfo->size == 0) {
|
||||
// assert(pResultRowInfo->current == NULL);
|
||||
pResultRowInfo->current = NULL;
|
||||
assert(pResultRowInfo->curPos == -1);
|
||||
pResultRowInfo->curPos = -1;
|
||||
} else {
|
||||
pResultRowInfo->current = pResultRowInfo->pResult[pResultRowInfo->size - 1];
|
||||
pResultRowInfo->curPos = pResultRowInfo->size - 1;
|
||||
}
|
||||
} else {
|
||||
|
||||
|
@ -735,12 +722,10 @@ static void doUpdateResultRowIndex(SResultRowInfo*pResultRowInfo, TSKEY lastKey,
|
|||
}
|
||||
|
||||
if (i == pResultRowInfo->size - 1) {
|
||||
pResultRowInfo->current = pResultRowInfo->pResult[i];
|
||||
pResultRowInfo->curPos = i;
|
||||
} 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
|
|||
bool ascQuery = QUERY_IS_ASC_QUERY(pQueryAttr);
|
||||
if ((lastKey > pQueryAttr->window.ekey && ascQuery) || (lastKey < pQueryAttr->window.ekey && (!ascQuery))) {
|
||||
closeAllResultRows(pResultRowInfo);
|
||||
pResultRowInfo->current = pResultRowInfo->pResult[pResultRowInfo->size - 1];
|
||||
pResultRowInfo->curPos = pResultRowInfo->size - 1;
|
||||
} else {
|
||||
int32_t step = ascQuery ? 1 : -1;
|
||||
doUpdateResultRowIndex(pResultRowInfo, lastKey - step, ascQuery, pQueryAttr->timeWindowInterpo);
|
||||
|
@ -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;
|
||||
|
||||
SQueryRuntimeEnv* pRuntimeEnv = pOperatorInfo->pRuntimeEnv;
|
||||
|
@ -1257,8 +1242,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
|
|||
int32_t step = GET_FORWARD_DIRECTION_FACTOR(pQueryAttr->order.order);
|
||||
bool ascQuery = QUERY_IS_ASC_QUERY(pQueryAttr);
|
||||
|
||||
SResultRow* prevRow = pResultRowInfo->current;
|
||||
// int32_t prevIndex = curTimeWindowIndex(pResultRowInfo);
|
||||
int32_t prevIndex = pResultRowInfo->curPos;
|
||||
|
||||
TSKEY* tsCols = NULL;
|
||||
if (pSDataBlock->pDataBlock != NULL) {
|
||||
|
@ -1275,7 +1259,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
|
|||
bool masterScan = IS_MASTER_SCAN(pRuntimeEnv);
|
||||
|
||||
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);
|
||||
if (ret != TSDB_CODE_SUCCESS || pResult == NULL) {
|
||||
longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
|
@ -1287,33 +1271,26 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
|
|||
getNumOfRowsInTimeWindow(pRuntimeEnv, &pSDataBlock->info, tsCols, startPos, ekey, binarySearchForKey, true);
|
||||
|
||||
// prev time window not interpolation yet.
|
||||
// int32_t curIndex = curTimeWindowIndex(pResultRowInfo);
|
||||
// if (prevIndex != -1 && prevIndex < curIndex && pQueryAttr->timeWindowInterpo) {
|
||||
// for (int32_t j = prevIndex; j < curIndex; ++j) { // previous time window may be all closed already.
|
||||
if (prevRow != NULL && prevRow != pResultRowInfo->current && pQueryAttr->timeWindowInterpo) {
|
||||
int32_t j = 0;
|
||||
while(pResultRowInfo->pResult[j] != prevRow) {
|
||||
j++;
|
||||
}
|
||||
|
||||
for(; pResultRowInfo->pResult[j] != pResultRowInfo->current; ++j) {
|
||||
SResultRow* pRes = pResultRowInfo->pResult[j];
|
||||
int32_t curIndex = pResultRowInfo->curPos;
|
||||
if (prevIndex != -1 && prevIndex < curIndex && pQueryAttr->timeWindowInterpo) {
|
||||
for (int32_t j = prevIndex; j < curIndex; ++j) { // previous time window may be all closed already.
|
||||
SResultRow* pRes = getResultRow(pResultRowInfo, j);
|
||||
if (pRes->closed) {
|
||||
assert(resultRowInterpolated(pRes, RESULT_ROW_START_INTERP) && resultRowInterpolated(pRes, RESULT_ROW_END_INTERP));
|
||||
continue;
|
||||
}
|
||||
|
||||
STimeWindow w = pRes->win;
|
||||
ret = setWindowOutputBufByKey(pRuntimeEnv, pResultRowInfo, &w, masterScan, &pResult, groupId, pInfo->pCtx,
|
||||
numOfOutput, pInfo->rowCellInfoOffset);
|
||||
ret = setResultOutputBufByKey(pRuntimeEnv, pResultRowInfo, pSDataBlock->info.tid, &w, masterScan, &pResult,
|
||||
tableGroupId, pInfo->pCtx, numOfOutput, pInfo->rowCellInfoOffset);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
assert(!resultRowInterpolated(pResult, RESULT_ROW_END_INTERP));
|
||||
|
||||
doTimeWindowInterpolation(pOperatorInfo, pInfo, pSDataBlock->pDataBlock, *(TSKEY *)pRuntimeEnv->prevRow[0],
|
||||
-1, tsCols[startPos], startPos, w.ekey, RESULT_ROW_END_INTERP);
|
||||
doTimeWindowInterpolation(pOperatorInfo, pInfo, pSDataBlock->pDataBlock, *(TSKEY*)pRuntimeEnv->prevRow[0], -1,
|
||||
tsCols[startPos], startPos, w.ekey, RESULT_ROW_END_INTERP);
|
||||
|
||||
setResultRowInterpo(pResult, RESULT_ROW_END_INTERP);
|
||||
setNotInterpoWindowKey(pInfo->pCtx, pQueryAttr->numOfOutput, RESULT_ROW_START_INTERP);
|
||||
|
@ -1322,7 +1299,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
|
|||
}
|
||||
|
||||
// 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);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
|
@ -1342,7 +1319,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
|
|||
}
|
||||
|
||||
// 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);
|
||||
if (code != TSDB_CODE_SUCCESS || pResult == NULL) {
|
||||
longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
|
@ -1483,7 +1460,7 @@ static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSWindowOperatorInf
|
|||
SResultRow* pResult = NULL;
|
||||
|
||||
pInfo->curWindow.ekey = pInfo->curWindow.skey;
|
||||
int32_t ret = setWindowOutputBufByKey(pRuntimeEnv, &pBInfo->resultRowInfo, &pInfo->curWindow, masterScan,
|
||||
int32_t ret = setResultOutputBufByKey(pRuntimeEnv, &pBInfo->resultRowInfo, pSDataBlock->info.tid, &pInfo->curWindow, masterScan,
|
||||
&pResult, item->groupIndex, pBInfo->pCtx, pOperator->numOfOutput,
|
||||
pBInfo->rowCellInfoOffset);
|
||||
if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code
|
||||
|
@ -1504,7 +1481,7 @@ static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSWindowOperatorInf
|
|||
SResultRow* pResult = NULL;
|
||||
|
||||
pInfo->curWindow.ekey = pInfo->curWindow.skey;
|
||||
int32_t ret = setWindowOutputBufByKey(pRuntimeEnv, &pBInfo->resultRowInfo, &pInfo->curWindow, masterScan,
|
||||
int32_t ret = setResultOutputBufByKey(pRuntimeEnv, &pBInfo->resultRowInfo, pSDataBlock->info.tid, &pInfo->curWindow, masterScan,
|
||||
&pResult, item->groupIndex, pBInfo->pCtx, pOperator->numOfOutput,
|
||||
pBInfo->rowCellInfoOffset);
|
||||
if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code
|
||||
|
@ -1547,7 +1524,8 @@ static int32_t setGroupResultOutputBuf(SQueryRuntimeEnv *pRuntimeEnv, SOptrBasic
|
|||
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);
|
||||
|
||||
setResultRowKey(pResultRow, pData, type);
|
||||
|
@ -1811,6 +1789,7 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int32_t numOf
|
|||
pRuntimeEnv->pQueryAttr = pQueryAttr;
|
||||
|
||||
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->pool = initResultRowPool(getResultRowSize(pRuntimeEnv));
|
||||
|
||||
|
@ -2060,6 +2039,9 @@ static void teardownQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv) {
|
|||
taosHashCleanup(pRuntimeEnv->pTableRetrieveTsMap);
|
||||
pRuntimeEnv->pTableRetrieveTsMap = NULL;
|
||||
|
||||
taosHashCleanup(pRuntimeEnv->pResultRowListSet);
|
||||
pRuntimeEnv->pResultRowListSet = NULL;
|
||||
|
||||
destroyOperatorInfo(pRuntimeEnv->proot);
|
||||
|
||||
pRuntimeEnv->pool = destroyResultRowPool(pRuntimeEnv->pool);
|
||||
|
@ -2790,7 +2772,7 @@ int32_t loadDataBlockOnDemand(SQueryRuntimeEnv* pRuntimeEnv, STableScanInfo* pTa
|
|||
TSKEY k = ascQuery? pBlock->info.window.skey : pBlock->info.window.ekey;
|
||||
|
||||
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->rowCellInfoOffset) != TSDB_CODE_SUCCESS) {
|
||||
longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
|
@ -2836,7 +2818,7 @@ int32_t loadDataBlockOnDemand(SQueryRuntimeEnv* pRuntimeEnv, STableScanInfo* pTa
|
|||
TSKEY k = ascQuery? pBlock->info.window.skey : pBlock->info.window.ekey;
|
||||
|
||||
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->rowCellInfoOffset) != TSDB_CODE_SUCCESS) {
|
||||
longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
|
@ -3192,11 +3174,11 @@ static void updateTableQueryInfoForReverseScan(STableQueryInfo *pTableQueryInfo)
|
|||
pTableQueryInfo->cur.vgroupIndex = -1;
|
||||
|
||||
// set the index to be the end slot of result rows array
|
||||
SResultRowInfo* pResRowInfo = &pTableQueryInfo->resInfo;
|
||||
if (pResRowInfo->size > 0) {
|
||||
pResRowInfo->current = pResRowInfo->pResult[pResRowInfo->size - 1];
|
||||
SResultRowInfo* pResultRowInfo = &pTableQueryInfo->resInfo;
|
||||
if (pResultRowInfo->size > 0) {
|
||||
pResultRowInfo->curPos = pResultRowInfo->size - 1;
|
||||
} else {
|
||||
pResRowInfo->current = NULL;
|
||||
pResultRowInfo->curPos = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3250,8 +3232,8 @@ void setDefaultOutputBuf(SQueryRuntimeEnv *pRuntimeEnv, SOptrBasicInfo *pInfo, i
|
|||
int32_t* rowCellInfoOffset = pInfo->rowCellInfoOffset;
|
||||
SResultRowInfo* pResultRowInfo = &pInfo->resultRowInfo;
|
||||
|
||||
int32_t tid = 0;
|
||||
SResultRow* pRow = doPrepareResultRowFromKey(pRuntimeEnv, pResultRowInfo, (char *)&tid, sizeof(tid), true, uid);
|
||||
int64_t tid = 0;
|
||||
SResultRow* pRow = doSetResultOutBufByKey(pRuntimeEnv, pResultRowInfo, tid, (char *)&tid, sizeof(tid), true, uid);
|
||||
|
||||
for (int32_t i = 0; i < pDataBlock->info.numOfCols; ++i) {
|
||||
SColumnInfoData* pData = taosArrayGet(pDataBlock->pDataBlock, i);
|
||||
|
@ -3482,10 +3464,13 @@ void setResultRowOutputBufInitCtx(SQueryRuntimeEnv *pRuntimeEnv, SResultRow *pRe
|
|||
}
|
||||
|
||||
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 tid = 0;
|
||||
|
||||
SResultRow* pResultRow =
|
||||
doPrepareResultRowFromKey(pRuntimeEnv, pResultRowInfo, (char*)&groupIndex, sizeof(groupIndex), true, uid);
|
||||
doSetResultOutBufByKey(pRuntimeEnv, pResultRowInfo, tid, (char*)&tableGroupId, sizeof(tableGroupId), true, uid);
|
||||
assert (pResultRow != NULL);
|
||||
|
||||
/*
|
||||
|
@ -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
|
||||
*/
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
|
@ -3502,20 +3487,20 @@ void doSetTableGroupOutputBuf(SQueryRuntimeEnv* pRuntimeEnv, SResultRowInfo* pRe
|
|||
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) {
|
||||
STableQueryInfo *pTableQueryInfo = pRuntimeEnv->current;
|
||||
|
||||
// lastKey needs to be updated
|
||||
pTableQueryInfo->lastKey = nextKey;
|
||||
if (pRuntimeEnv->prevGroupId != INT32_MIN && pRuntimeEnv->prevGroupId == groupIndex) {
|
||||
if (pRuntimeEnv->prevGroupId != INT32_MIN && pRuntimeEnv->prevGroupId == tableGroupId) {
|
||||
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
|
||||
pRuntimeEnv->prevGroupId = groupIndex;
|
||||
pRuntimeEnv->prevGroupId = tableGroupId;
|
||||
}
|
||||
|
||||
void setResultOutputBuf(SQueryRuntimeEnv *pRuntimeEnv, SResultRow *pResult, SQLFunctionCtx* pCtx,
|
||||
|
@ -3686,9 +3671,9 @@ void setParamForStableStddevByColData(SQueryRuntimeEnv* pRuntimeEnv, SQLFunction
|
|||
void setIntervalQueryRange(SQueryRuntimeEnv *pRuntimeEnv, TSKEY key) {
|
||||
SQueryAttr *pQueryAttr = pRuntimeEnv->pQueryAttr;
|
||||
STableQueryInfo *pTableQueryInfo = pRuntimeEnv->current;
|
||||
SResultRowInfo *pWindowResInfo = &pTableQueryInfo->resInfo;
|
||||
SResultRowInfo *pResultRowInfo = &pTableQueryInfo->resInfo;
|
||||
|
||||
if (pWindowResInfo->prevSKey != TSKEY_INITIAL_VAL) {
|
||||
if (pResultRowInfo->curPos != -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3707,13 +3692,13 @@ void setIntervalQueryRange(SQueryRuntimeEnv *pRuntimeEnv, TSKEY key) {
|
|||
TSKEY ek = MAX(win.skey, win.ekey);
|
||||
getAlignQueryTimeWindow(pQueryAttr, win.skey, sk, ek, &w);
|
||||
|
||||
if (pWindowResInfo->prevSKey == TSKEY_INITIAL_VAL) {
|
||||
if (!QUERY_IS_ASC_QUERY(pQueryAttr)) {
|
||||
assert(win.ekey == pQueryAttr->window.ekey);
|
||||
}
|
||||
|
||||
pWindowResInfo->prevSKey = w.skey;
|
||||
}
|
||||
// if (pResultRowInfo->prevSKey == TSKEY_INITIAL_VAL) {
|
||||
// if (!QUERY_IS_ASC_QUERY(pQueryAttr)) {
|
||||
// assert(win.ekey == pQueryAttr->window.ekey);
|
||||
// }
|
||||
//
|
||||
// pResultRowInfo->prevSKey = w.skey;
|
||||
// }
|
||||
|
||||
pTableQueryInfo->lastKey = pTableQueryInfo->win.skey;
|
||||
}
|
||||
|
@ -4613,8 +4598,7 @@ static SSDataBlock* doTableScan(void* param, bool *newgroup) {
|
|||
}
|
||||
|
||||
if (pResultRowInfo->size > 0) {
|
||||
pResultRowInfo->current = pResultRowInfo->pResult[0];
|
||||
pResultRowInfo->prevSKey = pResultRowInfo->pResult[0]->win.skey;
|
||||
pResultRowInfo->curPos = 0;
|
||||
}
|
||||
|
||||
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) {
|
|||
pTableScanInfo->order = cond.order;
|
||||
|
||||
if (pResultRowInfo->size > 0) {
|
||||
pResultRowInfo->current = pResultRowInfo->pResult[pResultRowInfo->size - 1];
|
||||
pResultRowInfo->prevSKey = pResultRowInfo->current->win.skey;
|
||||
pResultRowInfo->curPos = pResultRowInfo->size - 1;
|
||||
}
|
||||
|
||||
p = doTableScanImpl(pOperator, newgroup);
|
||||
|
@ -5500,7 +5483,7 @@ static void doStateWindowAggImpl(SOperatorInfo* pOperator, SStateWindowOperatorI
|
|||
} else {
|
||||
SResultRow* pResult = NULL;
|
||||
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,
|
||||
pBInfo->rowCellInfoOffset);
|
||||
if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code
|
||||
|
@ -5517,10 +5500,11 @@ static void doStateWindowAggImpl(SOperatorInfo* pOperator, SStateWindowOperatorI
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
SResultRow* pResult = NULL;
|
||||
|
||||
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,
|
||||
pBInfo->rowCellInfoOffset);
|
||||
if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code
|
||||
|
@ -6298,8 +6282,8 @@ static SSDataBlock* doTagScan(void* param, bool* newgroup) {
|
|||
|
||||
SColumnInfoData* pColInfo = taosArrayGet(pRes->pDataBlock, 0);
|
||||
|
||||
while(pInfo->currentIndex < pInfo->totalTables && count < maxNumOfTables) {
|
||||
int32_t i = pInfo->currentIndex++;
|
||||
while(pInfo->curPos < pInfo->totalTables && count < maxNumOfTables) {
|
||||
int32_t i = pInfo->curPos++;
|
||||
STableQueryInfo *item = taosArrayGetP(pa, i);
|
||||
|
||||
char *output = pColInfo->pData + count * rsize;
|
||||
|
@ -6343,8 +6327,8 @@ static SSDataBlock* doTagScan(void* param, bool* newgroup) {
|
|||
SExprInfo* pExprInfo = pOperator->pExpr; // todo use the column list instead of exprinfo
|
||||
|
||||
count = 0;
|
||||
while(pInfo->currentIndex < pInfo->totalTables && count < maxNumOfTables) {
|
||||
int32_t i = pInfo->currentIndex++;
|
||||
while(pInfo->curPos < pInfo->totalTables && count < maxNumOfTables) {
|
||||
int32_t i = pInfo->curPos++;
|
||||
|
||||
STableQueryInfo* item = taosArrayGetP(pa, i);
|
||||
|
||||
|
@ -6373,7 +6357,7 @@ static SSDataBlock* doTagScan(void* param, bool* newgroup) {
|
|||
count += 1;
|
||||
}
|
||||
|
||||
if (pInfo->currentIndex >= pInfo->totalTables) {
|
||||
if (pInfo->curPos >= pInfo->totalTables) {
|
||||
pOperator->status = OP_EXEC_DONE;
|
||||
}
|
||||
|
||||
|
@ -6392,7 +6376,7 @@ SOperatorInfo* createTagScanOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SExprInf
|
|||
assert(numOfGroup == 0 || numOfGroup == 1);
|
||||
|
||||
pInfo->totalTables = pRuntimeEnv->tableqinfoGroupInfo.numOfTables;
|
||||
pInfo->currentIndex = 0;
|
||||
pInfo->curPos = 0;
|
||||
|
||||
SOperatorInfo* pOperator = calloc(1, sizeof(SOperatorInfo));
|
||||
pOperator->name = "SeqTableTagScan";
|
||||
|
|
|
@ -44,8 +44,7 @@ int32_t getOutputInterResultBufSize(SQueryAttr* pQueryAttr) {
|
|||
int32_t initResultRowInfo(SResultRowInfo *pResultRowInfo, int32_t size, int16_t type) {
|
||||
pResultRowInfo->type = type;
|
||||
pResultRowInfo->size = 0;
|
||||
pResultRowInfo->prevSKey = TSKEY_INITIAL_VAL;
|
||||
pResultRowInfo->current = NULL;
|
||||
pResultRowInfo->curPos = -1;
|
||||
pResultRowInfo->capacity = size;
|
||||
|
||||
pResultRowInfo->pResult = calloc(pResultRowInfo->capacity, POINTER_BYTES);
|
||||
|
@ -92,8 +91,7 @@ void resetResultRowInfo(SQueryRuntimeEnv *pRuntimeEnv, SResultRowInfo *pResultRo
|
|||
}
|
||||
|
||||
pResultRowInfo->size = 0;
|
||||
pResultRowInfo->current = NULL;
|
||||
pResultRowInfo->prevSKey = TSKEY_INITIAL_VAL;
|
||||
pResultRowInfo->curPos = -1;
|
||||
}
|
||||
|
||||
int32_t numOfClosedResultRows(SResultRowInfo *pResultRowInfo) {
|
||||
|
|
1434
src/query/src/sql.c
1434
src/query/src/sql.c
File diff suppressed because it is too large
Load Diff
|
@ -12,7 +12,7 @@ static void prepare_data(TAOS* taos) {
|
|||
result = taos_query(taos, "drop database if exists test;");
|
||||
taos_free_result(result);
|
||||
usleep(100000);
|
||||
result = taos_query(taos, "create database test;");
|
||||
result = taos_query(taos, "create database test precision 'us';");
|
||||
taos_free_result(result);
|
||||
usleep(100000);
|
||||
taos_select_db(taos, "test");
|
||||
|
@ -949,13 +949,45 @@ void verify_stream(TAOS* taos) {
|
|||
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[]) {
|
||||
const char* host = "127.0.0.1";
|
||||
const char* user = "root";
|
||||
const char* passwd = "taosdata";
|
||||
|
||||
taos_options(TSDB_OPTION_TIMEZONE, "GMT-8");
|
||||
|
||||
TAOS* taos = taos_connect(host, user, passwd, "", 0);
|
||||
if (taos == NULL) {
|
||||
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[]) {
|
|||
info = taos_get_client_info(taos);
|
||||
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");
|
||||
verify_query(taos);
|
||||
|
||||
|
|
|
@ -236,9 +236,10 @@ python3 ./test.py -f query/queryTscomputWithNow.py
|
|||
python3 ./test.py -f query/computeErrorinWhere.py
|
||||
python3 ./test.py -f query/queryTsisNull.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/nestedQuery/queryWithOrderLimit.py
|
||||
python3 ./test.py -f query/nestquery_last_row.py
|
||||
|
||||
|
||||
#stream
|
||||
|
|
|
@ -27,6 +27,7 @@ class TDTestCase:
|
|||
self.rowNum = 100
|
||||
self.ts = 1537146000000
|
||||
self.ts1 = 1537146000000000
|
||||
self.ts2 = 1597146000000
|
||||
|
||||
|
||||
def run(self):
|
||||
|
@ -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,
|
||||
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 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 gtest2 (ts timestamp, col1 tinyint)")
|
||||
tdSql.execute("create table gtest3 (ts timestamp, col1 tinyint)")
|
||||
|
@ -48,6 +51,10 @@ class TDTestCase:
|
|||
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)"
|
||||
% (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(1537146001100,1.2);")
|
||||
|
@ -69,7 +76,7 @@ class TDTestCase:
|
|||
tdSql.execute("insert into gtest8 values(1537146000002,4);")
|
||||
tdSql.execute("insert into gtest8 values(1537146002202,4);")
|
||||
|
||||
# irate verifacation
|
||||
# irate verifacation --child table'query
|
||||
tdSql.query("select irate(col1) from test1;")
|
||||
tdSql.checkData(0, 0, 1)
|
||||
tdSql.query("select irate(col1) from test1 interval(10s);")
|
||||
|
@ -99,6 +106,32 @@ class TDTestCase:
|
|||
tdSql.query("select irate(col2) from test1;")
|
||||
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.checkData(0, 0, 1.2/1.1)
|
||||
tdSql.query("select irate(col1) from gtest2;")
|
||||
|
|
|
@ -0,0 +1,263 @@
|
|||
###################################################################
|
||||
# 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())
|
|
@ -51,7 +51,7 @@ class TDTestCase:
|
|||
else:
|
||||
tdLog.info("taosdemo found in %s" % buildPath)
|
||||
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))
|
||||
|
||||
tdSql.execute("use test")
|
||||
|
|
|
@ -54,7 +54,7 @@ class TDTestCase:
|
|||
binPath = buildPath + "/build/bin/"
|
||||
|
||||
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))
|
||||
if(threadID == 1):
|
||||
time.sleep(2)
|
||||
|
|
|
@ -60,7 +60,7 @@ class TDTestCase:
|
|||
|
||||
tdSql.execute("use test")
|
||||
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)
|
||||
|
||||
def stop(self):
|
||||
|
|
|
@ -28,6 +28,7 @@ class TDTestCase:
|
|||
tdSql.init(conn.cursor(), logSql)
|
||||
|
||||
def getBuildPath(self):
|
||||
global selfPath
|
||||
selfPath = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
if ("community" in selfPath):
|
||||
|
@ -53,7 +54,7 @@ class TDTestCase:
|
|||
tdLog.info("taosd found in %s" % buildPath)
|
||||
|
||||
binPath = buildPath+ "/build/bin/"
|
||||
testPath = buildPath[:buildPath.find("debug")]
|
||||
testPath = selfPath+ "/../../../"
|
||||
walFilePath = testPath + "/sim/dnode1/data/mnode_bak/wal/"
|
||||
|
||||
#new db and insert data
|
||||
|
|
|
@ -86,6 +86,18 @@ class TwoClients:
|
|||
tdSql.execute("alter table stb2_0 add column col2 binary(4)")
|
||||
tdSql.execute("alter table stb2_0 drop column col1")
|
||||
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
|
||||
|
|
|
@ -198,29 +198,25 @@ if $data12_db != 1 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
sql alter database db wal 1
|
||||
sql show databases
|
||||
print wal $data12_db
|
||||
if $data12_db != 1 then
|
||||
return -1
|
||||
endi
|
||||
sql_error alter database db wal 1
|
||||
|
||||
sql alter database db wal 1
|
||||
sql alter database db wal 2
|
||||
sql alter database db wal 1
|
||||
sql alter database db wal 2
|
||||
sql alter database db wal 0
|
||||
|
||||
sql_error alter database db wal 1
|
||||
sql_error alter database db wal 2
|
||||
sql_error alter database db wal 1
|
||||
sql_error alter database db wal 2
|
||||
sql_error alter database db wal 0
|
||||
sql_error alter database db wal 3
|
||||
sql_error alter database db wal 4
|
||||
sql_error alter database db wal -1
|
||||
sql_error alter database db wal 1000
|
||||
|
||||
print ============== step fsync
|
||||
sql alter database db fsync 0
|
||||
sql alter database db fsync 1
|
||||
sql alter database db fsync 3600
|
||||
sql alter database db fsync 18000
|
||||
sql alter database db fsync 180000
|
||||
sql_error alter database db fsync 0
|
||||
sql_error alter database db fsync 1
|
||||
sql_error alter database db fsync 3600
|
||||
sql_error alter database db fsync 18000
|
||||
sql_error alter database db fsync 180000
|
||||
sql_error alter database db fsync 180001
|
||||
sql_error alter database db fsync -1
|
||||
|
||||
|
|
|
@ -495,18 +495,13 @@ if $data12_db != 1 then
|
|||
endi
|
||||
|
||||
sql_error alter topic db wal 1
|
||||
sql alter database db wal 1
|
||||
sql show databases
|
||||
print wal $data12_db
|
||||
if $data12_db != 1 then
|
||||
return -1
|
||||
endi
|
||||
sql_error alter database db wal 1
|
||||
|
||||
sql alter database db wal 1
|
||||
sql alter database db wal 2
|
||||
sql alter database db wal 1
|
||||
sql alter database db wal 2
|
||||
sql alter database db wal 0
|
||||
sql_error alter database db wal 1
|
||||
sql_error alter database db wal 2
|
||||
sql_error alter database db wal 1
|
||||
sql_error alter database db wal 2
|
||||
sql_error alter database db wal 0
|
||||
sql_error alter database db wal 3
|
||||
sql_error alter database db wal 4
|
||||
sql_error alter database db wal -1
|
||||
|
@ -523,11 +518,11 @@ sql_error alter topic db wal -1
|
|||
sql_error alter topic db wal 1000
|
||||
|
||||
print ============== step fsync
|
||||
sql alter database db fsync 0
|
||||
sql alter database db fsync 1
|
||||
sql alter database db fsync 3600
|
||||
sql alter database db fsync 18000
|
||||
sql alter database db fsync 180000
|
||||
sql_error alter database db fsync 0
|
||||
sql_error alter database db fsync 1
|
||||
sql_error alter database db fsync 3600
|
||||
sql_error alter database db fsync 18000
|
||||
sql_error alter database db fsync 180000
|
||||
sql_error alter database db fsync 180001
|
||||
sql_error alter database db fsync -1
|
||||
|
||||
|
@ -615,17 +610,6 @@ if $rows != 1 then
|
|||
return -1
|
||||
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 show topics;
|
||||
if $rows != 0 then
|
||||
|
@ -649,17 +633,6 @@ if $rows != 1 then
|
|||
return -1
|
||||
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 show topics;
|
||||
if $rows != 0 then
|
||||
|
|
|
@ -237,7 +237,42 @@ sql_error create database $db ctime 29
|
|||
sql_error create database $db ctime 40961
|
||||
|
||||
# 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 3
|
||||
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
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
|
|||
return -1
|
||||
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
|
|
@ -1,147 +0,0 @@
|
|||
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 {
|
|||
SIM_CMD_RESTFUL,
|
||||
SIM_CMD_TEST,
|
||||
SIM_CMD_RETURN,
|
||||
SIM_CMD_LINE_INSERT,
|
||||
SIM_CMD_LINE_INSERT_ERROR,
|
||||
SIM_CMD_END
|
||||
};
|
||||
|
||||
|
@ -172,6 +174,8 @@ bool simExecuteSqlCmd(SScript *script, char *option);
|
|||
bool simExecuteSqlErrorCmd(SScript *script, char *rest);
|
||||
bool simExecuteSqlSlowCmd(SScript *script, char *option);
|
||||
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);
|
||||
|
||||
#endif
|
|
@ -1067,3 +1067,49 @@ bool simExecuteSqlErrorCmd(SScript *script, char *rest) {
|
|||
|
||||
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) {
|
|||
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() {
|
||||
int32_t cmdno;
|
||||
memset(simCmdList, 0, SIM_CMD_END * sizeof(SCommand));
|
||||
|
@ -1049,4 +1081,20 @@ void simInitsimCmdList() {
|
|||
simCmdList[cmdno].parseCmd = simParseReturnCmd;
|
||||
simCmdList[cmdno].executeCmd = simExecuteReturnCmd;
|
||||
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]));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue