Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yiicenne
TDengine
提交
66e8c5fd
TDengine
项目概览
yiicenne
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
66e8c5fd
编写于
7月 13, 2021
作者:
S
shenglian zhou
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' into feature/szhou/sync_home_office
上级
81b60d96
764ac999
变更
20
展开全部
隐藏空白更改
内联
并排
Showing
20 changed file
with
2960 addition
and
2584 deletion
+2960
-2584
documentation20/cn/11.administrator/docs.md
documentation20/cn/11.administrator/docs.md
+2
-2
documentation20/cn/12.taos-sql/docs.md
documentation20/cn/12.taos-sql/docs.md
+52
-56
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+12
-6
src/kit/taosdemo/taosdemo.c
src/kit/taosdemo/taosdemo.c
+1739
-1661
src/query/inc/qExecutor.h
src/query/inc/qExecutor.h
+2
-2
src/query/inc/sql.y
src/query/inc/sql.y
+4
-2
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+58
-70
src/query/src/qUtil.c
src/query/src/qUtil.c
+2
-4
src/query/src/sql.c
src/query/src/sql.c
+714
-720
tests/pytest/fulltest.sh
tests/pytest/fulltest.sh
+2
-1
tests/pytest/functions/function_irate.py
tests/pytest/functions/function_irate.py
+34
-1
tests/pytest/query/nestquery_last_row.py
tests/pytest/query/nestquery_last_row.py
+263
-0
tests/pytest/tools/taosdemoTest.py
tests/pytest/tools/taosdemoTest.py
+1
-1
tests/pytest/tools/taosdemoTestTblAlt.py
tests/pytest/tools/taosdemoTestTblAlt.py
+1
-1
tests/pytest/tools/taosdemoTestWithoutMetric.py
tests/pytest/tools/taosdemoTestWithoutMetric.py
+1
-1
tests/pytest/wal/sdbComp.py
tests/pytest/wal/sdbComp.py
+2
-1
tests/pytest/wal/sdbCompClusterReplica2.py
tests/pytest/wal/sdbCompClusterReplica2.py
+12
-0
tests/script/general/db/alter_option.sim
tests/script/general/db/alter_option.sim
+12
-16
tests/script/general/db/topic1.sim
tests/script/general/db/topic1.sim
+11
-38
tests/script/general/parser/create_db.sim
tests/script/general/parser/create_db.sim
+36
-1
未找到文件。
documentation20/cn/11.administrator/docs.md
浏览文件 @
66e8c5fd
...
...
@@ -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 修改)
...
...
documentation20/cn/12.taos-sql/docs.md
浏览文件 @
66e8c5fd
...
...
@@ -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
[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
...];
```
### 详细描述及示例:
-
**插入一条记录,数据对应到指定的列**
-
**插入一条或多条记录**
指定已经创建好的数据子表的表名,并通过 VALUES 关键字提供一行或多行数据,即可向数据库写入这些数据。例如,执行如下语句可以写入一行记录:
```
mysql
INSERT INTO
tb_name (field1_name, ...) VALUES (field1_value1, ...
);
INSERT INTO
d1001 VALUES (NOW, 10.2, 219, 0.32
);
```
向表tb_name中插入一条记录,数据对应到指定的列。SQL语句中没有出现的列,数据库将自动填充为NULL。主键(时间戳)不能为NULL。
-
**插入多条记录**
或者,可以通过如下语句写入两行记录:
```
mysql
INSERT INTO
tb_name VALUES (field1_value1, ...) (field1_value2, ...) ...
;
INSERT INTO
d1001 VALUES ('2021-07-13 14:06:32.272', 10.2, 219, 0.32) (1626164208000, 10.15, 217, 0.33)
;
```
向表tb_name中插入多条记录。
**注意**
:在使用“插入多条记录”方式写入数据时,不能把第一列的时间戳取值都设为now,否则会导致语句中的多条记录使用相同的时间戳,于是就可能出现相互覆盖以致这些数据行无法全部被正确保存。
**注意:**
1)在第二个例子中,两行记录的首列时间戳使用了不同格式的写法。其中字符串格式的时间戳写法不受所在 DATABASE 的时间精度设置影响;而长整形格式的时间戳写法会受到所在 DATABASE 的时间精度设置影响——例子中的时间戳在毫秒精度下可以写作 1626164208000,而如果是在微秒精度设置下就需要写为 1626164208000000。
2)在使用“插入多条记录”方式写入数据时,不能把第一列的时间戳取值都设为 NOW,否则会导致语句中的多条记录使用相同的时间戳,于是就可能出现相互覆盖以致这些数据行无法全部被正确保存。其原因在于,NOW 函数在执行中会被解析为所在 SQL 语句的实际执行时间,出现在同一语句中的多个 NOW 标记也就会被替换为完全相同的时间戳取值。
3)允许插入的最老记录的时间戳,是相对于当前服务器时间,减去配置的 keep 值(数据保留的天数);允许插入的最新记录的时间戳,是相对于当前服务器时间,加上配置的 days 值(数据文件存储数据的时间跨度,单位为天)。keep 和 days 都是可以在创建数据库时指定的,缺省值分别是 3650 天和 10 天。
-
**按指定的列插入多条记录**
-
**插入记录,数据对应到指定的列**
向数据子表中插入记录时,无论插入一行还是多行,都可以让数据对应到指定的列。对于 SQL 语句中没有出现的列,数据库将自动填充为 NULL。主键(时间戳)不能为 NULL。例如:
```
mysql
INSERT INTO
tb_name (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)
;
```
向表tb_name中按指定的列插入多条记录
。
**说明:**
如果不指定列,也即使用全列模式——那么在 VALUES 部分提供的数据,必须为数据表的每个列都显式地提供数据。全列模式写入速度会远快于指定列,因此建议尽可能采用全列写入方式,此时空列可以填入 NULL
。
-
**向多个表插入多条记录**
-
**向多个表插入记录**
可以在一条语句中,分别向多个表插入一条或多条记录,并且也可以在插入过程中指定列。例如:
```
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: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)
;
```
同时向表tb1_name和tb2_name中分别插入多条记录。
-
**同时向多个表按列插入多条记录**
-
<a
class=
"anchor"
id=
"auto_create_table"
></a>
**插入记录时自动建表**
如果用户在写数据时并不确定某个表是否存在,此时可以在写入数据时使用自动建表语法来创建不存在的表,若该表已存在则不会建立新表。自动建表时,要求必须以超级表为模板,并写明数据表的 TAGS 取值。例如:
```
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 d21001 USING meters TAGS ('Beijing.Chaoyang', 2) VALUES ('2021-07-13 14:06:32.272', 10.2, 219, 0.32);
```
同时向表tb1_name和tb2_name中按列分别插入多条记录。
注意:
1) 如果时间戳为now,系统将自动使用客户端当前时间作为该记录的时间戳;
2) 允许插入的最老记录的时间戳,是相对于当前服务器时间,减去配置的keep值(数据保留的天数),允许插入的最新记录的时间戳,是相对于当前服务器时间,加上配置的days值(数据文件存储数据的时间跨度,单位为天)。keep和days都是可以在创建数据库时指定的,缺省值分别是3650天和10天。
-
<a
class=
"anchor"
id=
"auto_create_table"
></a>
**插入记录时自动建表**
也可以在自动建表时,只是指定部分 TAGS 列的取值,未被指定的 TAGS 列将置为 NULL。例如:
```
mysql
INSERT INTO
tb_name USING stb_name TAGS (tag_value1, ...) VALUES (field_value1, ...
);
INSERT INTO
d21001 USING meters (groupdId) TAGS (2) VALUES ('2021-07-13 14:06:33.196', 10.15, 217, 0.33
);
```
如果用户在写数据时并不确定某个表是否存在,此时可以在写入数据时使用自动建表语法来创建不存在的表,若该表已存在则不会建立新表。自动建表时,要求必须以超级表为模板,并写明数据表的 TAGS 取值。
-
**插入记录时自动建表,并指定具体的 TAGS 列**
自动建表语法也支持在一条语句中向多个表插入记录。例如:
```
mysql
INSERT INTO tb_name USING stb_name (tag_name1, ...) TAGS (tag_value1, ...) VALUES (field_value1, ...);
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);
```
在自动建表时,可以只是指定部分 TAGS 列的取值,未被指定的 TAGS 列将取为空值
。
**说明:**
在 2.0.20.5 版本之前,在使用自动建表语法并指定列时,子表的列名必须紧跟在子表名称后面,而不能如例子里那样放在 TAGS 和 VALUES 之间。从 2.0.20.5 版本开始,两种写法都可以,但不能在一条 SQL 语句中混用,否则会报语法错误
。
-
**同时向多个表按列插入多条记录,自动建表**
```
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, ...) ...;
-
**插入来自文件的数据记录**
除了使用 VALUES 关键字插入一行或多行数据外,也可以把要写入的数据放在 CSV 文件中(英文逗号分隔、英文单引号括住每个值)供 SQL 指令读取。其中 CSV 文件无需表头。例如,如果 /tmp/csvfile.csv 文件的内容为:
```
'2021-07-13 14:07:34.630', '10.2', '219', '0.32'
'2021-07-13 14:07:35.779', '10.15', '217', '0.33'
```
以自动建表的方式,同时向表tb1_name和tb2_name中按列分别插入多条记录。
说明:
`(tb1_field1_name, ...)`
的部分可以省略掉,这样就是使用全列模式写入——也即在 VALUES 部分提供的数据,必须为数据表的每个列都显式地提供数据。全列写入速度会远快于指定列,因此建议尽可能采用全列写入方式,此时空列可以填入NULL。
从 2.0.20.5 版本开始,子表的列名可以不跟在子表名称后面,而是可以放在 TAGS 和 VALUES 之间,例如像下面这样写:
那么通过如下指令可以把这个文件中的数据写入子表中:
```
mysql
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 语句可以指定查询的起止时间和其他过滤条件。
...
...
src/client/src/tscSQLParser.c
浏览文件 @
66e8c5fd
...
...
@@ -7816,13 +7816,19 @@ static STableMeta* extractTempTableMetaFromSubquery(SQueryInfo* pUpstream) {
int32_t
n
=
0
;
for
(
int32_t
i
=
0
;
i
<
numOfColumns
;
++
i
)
{
SInternalField
*
pField
=
tscFieldInfoGetInternalField
(
&
pUpstream
->
fieldsInfo
,
i
);
if
(
pField
->
visible
)
{
meta
->
schema
[
n
].
bytes
=
pField
->
field
.
bytes
;
meta
->
schema
[
n
].
type
=
pField
->
field
.
type
;
meta
->
schema
[
n
].
colId
=
pField
->
pExpr
->
base
.
resColId
;
tstrncpy
(
meta
->
schema
[
n
].
name
,
pField
->
pExpr
->
base
.
aliasName
,
TSDB_COL_NAME_LEN
);
n
+=
1
;
if
(
!
pField
->
visible
)
{
continue
;
}
meta
->
schema
[
n
].
bytes
=
pField
->
field
.
bytes
;
meta
->
schema
[
n
].
type
=
pField
->
field
.
type
;
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
;
...
...
src/kit/taosdemo/taosdemo.c
浏览文件 @
66e8c5fd
此差异已折叠。
点击以展开。
src/query/inc/qExecutor.h
浏览文件 @
66e8c5fd
...
...
@@ -105,7 +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 active result row
int32_t
curPos
;
// current active result row index of pResult list
}
SResultRowInfo
;
typedef
struct
SColumnFilterElem
{
...
...
@@ -423,7 +423,7 @@ typedef struct STagScanInfo {
SColumnInfo
*
pCols
;
SSDataBlock
*
pRes
;
int32_t
totalTables
;
int32_t
cur
rentIndex
;
int32_t
cur
Pos
;
}
STagScanInfo
;
typedef
struct
SOptrBasicInfo
{
...
...
src/query/inc/sql.y
浏览文件 @
66e8c5fd
...
...
@@ -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; }
...
...
src/query/src/qExecutor.c
浏览文件 @
66e8c5fd
此差异已折叠。
点击以展开。
src/query/src/qUtil.c
浏览文件 @
66e8c5fd
...
...
@@ -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
)
{
...
...
src/query/src/sql.c
浏览文件 @
66e8c5fd
此差异已折叠。
点击以展开。
tests/pytest/fulltest.sh
浏览文件 @
66e8c5fd
...
...
@@ -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
...
...
tests/pytest/functions/function_irate.py
浏览文件 @
66e8c5fd
...
...
@@ -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;"
)
...
...
tests/pytest/query/nestquery_last_row.py
0 → 100644
浏览文件 @
66e8c5fd
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import
sys
import
taos
from
util.log
import
tdLog
from
util.cases
import
tdCases
from
util.sql
import
tdSql
import
random
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
(),
logSql
)
self
.
ts
=
1600000000000
self
.
num
=
10
def
run
(
self
):
tdSql
.
prepare
()
# test case for https://jira.taosdata.com:18080/browse/TD-4735
tdSql
.
execute
(
'''create stable stable_1
(ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint,
q_bool bool , q_binary binary(20) , q_nchar nchar(20) ,
q_float float , q_double double , q_ts timestamp)
tags(loc nchar(20) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint,
t_bool bool , t_binary binary(20) , t_nchar nchar(20) ,
t_float float , t_double double , t_ts timestamp);'''
)
tdSql
.
execute
(
'''create table table_0 using stable_1
tags('table_0' , '0' , '0' , '0' , '0' , 0 , '0' , '0' , '0' , '0' ,'0')'''
)
tdSql
.
execute
(
'''create table table_1 using stable_1
tags('table_1' , '2147483647' , '9223372036854775807' , '32767' , '127' , 1 ,
'binary1' , 'nchar1' , '1' , '11' ,
\'
1999-09-09 09:09:09.090
\'
)'''
)
tdSql
.
execute
(
'''create table table_2 using stable_1
tags('table_2' , '-2147483647' , '-9223372036854775807' , '-32767' , '-127' , false ,
'binary2' , 'nchar2nchar2' , '-2.2' , '-22.22' ,
\'
2099-09-09 09:09:09.090
\'
)'''
)
tdSql
.
execute
(
'''create table table_3 using stable_1
tags('table_3' , '3' , '3' , '3' , '3' , true , 'binary3' , 'nchar3' , '33.33' , '3333.3333' , '0')'''
)
tdSql
.
execute
(
'''create table table_4 using stable_1
tags('table_4' , '4' , '4' , '4' , '4' , false , 'binary4' , 'nchar4' , '-444.444' , '-444444.444444' , '0')'''
)
tdSql
.
execute
(
'''create table table_5 using stable_1
tags('table_5' , '5' , '5' , '5' , '5' , true , 'binary5' , 'nchar5' , '5555.5555' , '55555555.55555555' , '0')'''
)
#regular table
tdSql
.
execute
(
'''create table regular_table_1
(ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint,
q_bool bool , q_binary binary(20) , q_nchar nchar(20) ,
q_float float , q_double double , q_ts timestamp) ;'''
)
for
i
in
range
(
self
.
num
):
tdSql
.
execute
(
'''insert into table_0 values(%d, %d, %d, %d, %d, 0, 'binary.%s', 'nchar.%s', %f, %f, %d)'''
%
(
self
.
ts
+
i
,
i
,
i
,
i
,
i
,
i
,
i
,
i
,
i
,
self
.
ts
+
i
))
tdSql
.
execute
(
'''insert into table_1 values(%d, %d, %d, %d, %d, 1, 'binary1.%s', 'nchar1.%s', %f, %f, %d)'''
%
(
self
.
ts
+
i
,
2147483647
-
i
,
9223372036854775807
-
i
,
32767
-
i
,
127
-
i
,
i
,
i
,
random
.
random
(),
random
.
random
(),
1262304000001
+
i
))
tdSql
.
execute
(
'''insert into table_2 values(%d, %d, %d, %d, %d, true, 'binary2.%s', 'nchar2nchar2.%s', %f, %f, %d)'''
%
(
self
.
ts
+
i
,
-
2147483647
+
i
,
-
9223372036854775807
+
i
,
-
32767
+
i
,
-
127
+
i
,
i
,
i
,
random
.
uniform
(
-
1
,
0
),
random
.
uniform
(
-
1
,
0
),
1577836800001
+
i
))
tdSql
.
execute
(
'''insert into table_3 values(%d, %d, %d, %d, %d, false, 'binary3.%s', 'nchar3.%s', %f, %f, %d)'''
%
(
self
.
ts
+
i
,
random
.
randint
(
-
2147483647
,
2147483647
),
random
.
randint
(
-
9223372036854775807
,
9223372036854775807
),
random
.
randint
(
-
32767
,
32767
),
random
.
randint
(
-
127
,
127
),
random
.
randint
(
-
100
,
100
),
random
.
randint
(
-
10000
,
10000
),
random
.
uniform
(
-
100000
,
100000
),
random
.
uniform
(
-
1000000000
,
1000000000
),
self
.
ts
+
i
))
tdSql
.
execute
(
'''insert into table_4 values(%d, %d, %d, %d, %d, true, 'binary4.%s', 'nchar4.%s', %f, %f, %d)'''
%
(
self
.
ts
+
i
,
i
,
i
,
i
,
i
,
i
,
i
,
i
,
i
,
self
.
ts
+
i
))
tdSql
.
execute
(
'''insert into table_5 values(%d, %d, %d, %d, %d, false, 'binary5.%s', 'nchar5.%s', %f, %f, %d)'''
%
(
self
.
ts
+
i
,
i
,
i
,
i
,
i
,
i
,
i
,
i
,
i
,
self
.
ts
+
i
))
tdSql
.
execute
(
'''insert into regular_table_1 values(%d, %d, %d, %d, %d, 0, 'binary.%s', 'nchar.%s', %f, %f, %d)'''
%
(
self
.
ts
+
i
,
i
,
i
,
i
,
i
,
i
,
i
,
i
,
i
,
self
.
ts
+
i
))
tdSql
.
execute
(
'''insert into regular_table_1 values(%d, %d, %d, %d, %d, 1, 'binary1.%s', 'nchar1.%s', %f, %f, %d)'''
%
(
self
.
ts
+
100
+
i
,
2147483647
-
i
,
9223372036854775807
-
i
,
32767
-
i
,
127
-
i
,
i
,
i
,
random
.
random
(),
random
.
random
(),
1262304000001
+
i
))
tdSql
.
execute
(
'''insert into regular_table_1 values(%d, %d, %d, %d, %d, true, 'binary2.%s', 'nchar2nchar2.%s', %f, %f, %d)'''
%
(
self
.
ts
+
200
+
i
,
-
2147483647
+
i
,
-
9223372036854775807
+
i
,
-
32767
+
i
,
-
127
+
i
,
i
,
i
,
random
.
uniform
(
-
1
,
0
),
random
.
uniform
(
-
1
,
0
),
1577836800001
+
i
))
tdSql
.
execute
(
'''insert into regular_table_1 values(%d, %d, %d, %d, %d, false, 'binary3.%s', 'nchar3.%s', %f, %f, %d)'''
%
(
self
.
ts
+
300
+
i
,
random
.
randint
(
-
2147483647
,
2147483647
),
random
.
randint
(
-
9223372036854775807
,
9223372036854775807
),
random
.
randint
(
-
32767
,
32767
),
random
.
randint
(
-
127
,
127
),
random
.
randint
(
-
100
,
100
),
random
.
randint
(
-
10000
,
10000
),
random
.
uniform
(
-
100000
,
100000
),
random
.
uniform
(
-
1000000000
,
1000000000
),
self
.
ts
+
i
))
tdSql
.
execute
(
'''insert into regular_table_1 values(%d, %d, %d, %d, %d, true, 'binary4.%s', 'nchar4.%s', %f, %f, %d)'''
%
(
self
.
ts
+
400
+
i
,
i
,
i
,
i
,
i
,
i
,
i
,
i
,
i
,
self
.
ts
+
i
))
tdSql
.
execute
(
'''insert into regular_table_1 values(%d, %d, %d, %d, %d, false, 'binary5.%s', 'nchar5.%s', %f, %f, %d)'''
%
(
self
.
ts
+
500
+
i
,
i
,
i
,
i
,
i
,
i
,
i
,
i
,
i
,
self
.
ts
+
i
))
sql
=
'''select * from stable_1'''
tdSql
.
query
(
sql
)
tdSql
.
checkRows
(
6
*
self
.
num
)
sql
=
'''select * from regular_table_1'''
tdSql
.
query
(
sql
)
tdSql
.
checkRows
(
6
*
self
.
num
)
tdLog
.
info
(
"=======last_row(*)========"
)
sql
=
'''select last_row(*) from stable_1;'''
tdSql
.
query
(
sql
)
tdSql
.
checkData
(
0
,
1
,
self
.
num
-
1
)
sql
=
'''select last_row(*) from regular_table_1;'''
tdSql
.
query
(
sql
)
tdSql
.
checkData
(
0
,
1
,
self
.
num
-
1
)
sql
=
'''select * from stable_1
where loc = 'table_0';'''
tdSql
.
query
(
sql
)
tdSql
.
checkRows
(
self
.
num
)
sql
=
'''select last_row(*) from
(select * from stable_1
where loc = 'table_0');'''
tdSql
.
query
(
sql
)
tdSql
.
checkRows
(
1
)
sql
=
'''select last_row(*) from
(select * from stable_1);'''
tdSql
.
query
(
sql
)
tdSql
.
checkData
(
0
,
1
,
self
.
num
-
1
)
tdSql
.
checkData
(
0
,
2
,
self
.
num
-
1
)
tdSql
.
checkData
(
0
,
3
,
self
.
num
-
1
)
tdSql
.
checkData
(
0
,
4
,
self
.
num
-
1
)
tdSql
.
checkData
(
0
,
5
,
'False'
)
tdSql
.
checkData
(
0
,
6
,
'binary5.9'
)
tdSql
.
checkData
(
0
,
7
,
'nchar5.9'
)
tdSql
.
checkData
(
0
,
8
,
9.00000
)
tdSql
.
checkData
(
0
,
9
,
9.000000000
)
tdSql
.
checkData
(
0
,
10
,
'2020-09-13 20:26:40.009'
)
tdSql
.
checkData
(
0
,
11
,
'table_5'
)
tdSql
.
checkData
(
0
,
12
,
5
)
tdSql
.
checkData
(
0
,
13
,
5
)
tdSql
.
checkData
(
0
,
14
,
5
)
tdSql
.
checkData
(
0
,
15
,
5
)
tdSql
.
checkData
(
0
,
16
,
'True'
)
tdSql
.
checkData
(
0
,
17
,
'binary5'
)
tdSql
.
checkData
(
0
,
18
,
'nchar5'
)
tdSql
.
checkData
(
0
,
21
,
'1970-01-01 08:00:00.000'
)
sql
=
'''select * from regular_table_1 ;'''
tdSql
.
query
(
sql
)
tdSql
.
checkRows
(
6
*
self
.
num
)
sql
=
'''select last_row(*) from
(select * from regular_table_1);'''
tdSql
.
query
(
sql
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
1
,
self
.
num
-
1
)
tdSql
.
checkData
(
0
,
2
,
self
.
num
-
1
)
tdSql
.
checkData
(
0
,
3
,
self
.
num
-
1
)
tdSql
.
checkData
(
0
,
4
,
self
.
num
-
1
)
tdSql
.
checkData
(
0
,
5
,
'False'
)
tdSql
.
checkData
(
0
,
6
,
'binary5.9'
)
tdSql
.
checkData
(
0
,
7
,
'nchar5.9'
)
tdSql
.
checkData
(
0
,
8
,
9.00000
)
tdSql
.
checkData
(
0
,
9
,
9.000000000
)
tdSql
.
checkData
(
0
,
10
,
'2020-09-13 20:26:40.009'
)
sql
=
'''select last_row(*) from
((select * from table_0) union all
(select * from table_1) union all
(select * from table_2));'''
tdSql
.
query
(
sql
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
1
,
self
.
num
-
1
)
tdSql
.
checkData
(
0
,
2
,
self
.
num
-
1
)
tdSql
.
checkData
(
0
,
3
,
self
.
num
-
1
)
tdSql
.
checkData
(
0
,
4
,
self
.
num
-
1
)
tdSql
.
checkData
(
0
,
5
,
'False'
)
tdSql
.
checkData
(
0
,
6
,
'binary.9'
)
tdSql
.
checkData
(
0
,
7
,
'nchar.9'
)
tdSql
.
checkData
(
0
,
8
,
9.00000
)
tdSql
.
checkData
(
0
,
9
,
9.000000000
)
tdSql
.
checkData
(
0
,
10
,
'2020-09-13 20:26:40.009'
)
# bug 5055
# sql = '''select last_row(*) from
# ((select * from stable_1) union all
# (select * from table_1) union all
# (select * from regular_table_1));'''
# tdSql.query(sql)
# tdSql.checkData(0,1,self.num-1)
sql
=
'''select last_row(*) from
((select last_row(*) from table_0) union all
(select last_row(*) from table_1) union all
(select last_row(*) from table_2));'''
tdSql
.
query
(
sql
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
1
,
self
.
num
-
1
)
tdSql
.
checkData
(
0
,
2
,
self
.
num
-
1
)
tdSql
.
checkData
(
0
,
3
,
self
.
num
-
1
)
tdSql
.
checkData
(
0
,
4
,
self
.
num
-
1
)
tdSql
.
checkData
(
0
,
5
,
'False'
)
tdSql
.
checkData
(
0
,
6
,
'binary.9'
)
tdSql
.
checkData
(
0
,
7
,
'nchar.9'
)
tdSql
.
checkData
(
0
,
8
,
9.00000
)
tdSql
.
checkData
(
0
,
9
,
9.000000000
)
tdSql
.
checkData
(
0
,
10
,
'2020-09-13 20:26:40.009'
)
# bug 5055
# sql = '''select last_row(*) from
# ((select last_row(*) from stable_1) union all
# (select last_row(*) from table_1) union all
# (select last_row(*) from regular_table_1));'''
# tdSql.query(sql)
# tdSql.checkData(0,1,self.num-1)
sql
=
'''select last_row(*) from
((select * from table_0 limit 5 offset 5) union all
(select * from table_1 limit 5 offset 5) union all
(select * from regular_table_1 limit 5 offset 5));'''
tdSql
.
query
(
sql
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
1
,
self
.
num
-
1
)
tdSql
.
checkData
(
0
,
2
,
self
.
num
-
1
)
tdSql
.
checkData
(
0
,
3
,
self
.
num
-
1
)
tdSql
.
checkData
(
0
,
4
,
self
.
num
-
1
)
tdSql
.
checkData
(
0
,
5
,
'False'
)
tdSql
.
checkData
(
0
,
6
,
'binary.9'
)
tdSql
.
checkData
(
0
,
7
,
'nchar.9'
)
tdSql
.
checkData
(
0
,
8
,
9.00000
)
tdSql
.
checkData
(
0
,
9
,
9.000000000
)
tdSql
.
checkData
(
0
,
10
,
'2020-09-13 20:26:40.009'
)
sql
=
'''select last_row(*) from
(select * from stable_1)
having q_int>5;'''
tdLog
.
info
(
sql
)
tdSql
.
error
(
sql
)
try
:
tdSql
.
execute
(
sql
)
tdLog
.
exit
(
" having only works with group by"
)
except
Exception
as
e
:
tdLog
.
info
(
repr
(
e
))
tdLog
.
info
(
"invalid operation: having only works with group by"
)
#bug 5057
# sql = '''select last_row(*) from
# (select * from (select * from stable_1))'''
# tdLog.info(sql)
# tdSql.error(sql)
# try:
# tdSql.execute(sql)
# tdLog.exit(" core dumped")
# except Exception as e:
# tdLog.info(repr(e))
# tdLog.info("core dumped")
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
\ No newline at end of file
tests/pytest/tools/taosdemoTest.py
浏览文件 @
66e8c5fd
...
...
@@ -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"
)
...
...
tests/pytest/tools/taosdemoTestTblAlt.py
浏览文件 @
66e8c5fd
...
...
@@ -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
)
...
...
tests/pytest/tools/taosdemoTestWithoutMetric.py
浏览文件 @
66e8c5fd
...
...
@@ -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
):
...
...
tests/pytest/wal/sdbComp.py
浏览文件 @
66e8c5fd
...
...
@@ -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
...
...
tests/pytest/wal/sdbCompClusterReplica2.py
浏览文件 @
66e8c5fd
...
...
@@ -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
...
...
tests/script/general/db/alter_option.sim
浏览文件 @
66e8c5fd
...
...
@@ -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
...
...
tests/script/general/db/topic1.sim
浏览文件 @
66e8c5fd
...
...
@@ -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
...
...
tests/script/general/parser/create_db.sim
浏览文件 @
66e8c5fd
...
...
@@ -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
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录