Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c309bd00
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
c309bd00
编写于
1月 08, 2021
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' into feature/TD-1925_new
上级
b87d3daf
7f57f0e1
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
203 addition
and
105 deletion
+203
-105
.travis.yml
.travis.yml
+6
-5
README.md
README.md
+7
-1
documentation20/webdocs/markdowndocs/TAOS SQL-ch.md
documentation20/webdocs/markdowndocs/TAOS SQL-ch.md
+61
-47
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+1
-1
src/query/src/qAggMain.c
src/query/src/qAggMain.c
+1
-1
src/query/src/qHistogram.c
src/query/src/qHistogram.c
+3
-0
src/query/tests/histogramTest.cpp
src/query/tests/histogramTest.cpp
+52
-35
src/vnode/src/vnodeStatus.c
src/vnode/src/vnodeStatus.c
+18
-10
tests/Jenkinsfile
tests/Jenkinsfile
+9
-1
tests/pytest/functions/all_null_value.py
tests/pytest/functions/all_null_value.py
+2
-2
tests/pytest/query/query.py
tests/pytest/query/query.py
+16
-0
tests/pytest/query/queryInterval.py
tests/pytest/query/queryInterval.py
+17
-1
tests/pytest/stream/history.py
tests/pytest/stream/history.py
+4
-0
tests/pytest/tools/taosdemoTest.py
tests/pytest/tools/taosdemoTest.py
+3
-1
tests/script/general/parser/tags_filter.sim
tests/script/general/parser/tags_filter.sim
+3
-0
未找到文件。
.travis.yml
浏览文件 @
c309bd00
...
...
@@ -146,7 +146,7 @@ matrix:
branch_pattern
:
coverity_scan
-
os
:
linux
dist
:
xenial
dist
:
trusty
language
:
c
git
:
-
depth
:
1
...
...
@@ -156,8 +156,9 @@ matrix:
packages
:
-
build-essential
-
cmake
-
binutils-2.26
env
:
-
DESC="
xenial
build"
-
DESC="
trusty/gcc-4.8/bintuils-2.26
build"
before_script
:
-
export TZ=Asia/Harbin
...
...
@@ -168,7 +169,7 @@ matrix:
script
:
-
cmake .. > /dev/null
-
make
-
export PATH=/usr/lib/binutils-2.26/bin:$PATH &&
make
-
os
:
linux
dist
:
bionic
...
...
@@ -200,7 +201,7 @@ matrix:
dist
:
bionic
language
:
c
compiler
:
clang
env
:
DESC="linux/clang build"
env
:
DESC="
arm64
linux/clang build"
git
:
-
depth
:
1
...
...
@@ -238,7 +239,7 @@ matrix:
-
build-essential
-
cmake
env
:
-
DESC="xenial build"
-
DESC="
arm64
xenial build"
before_script
:
-
export TZ=Asia/Harbin
...
...
README.md
浏览文件 @
c309bd00
...
...
@@ -33,11 +33,17 @@ To build TDengine, use [CMake](https://cmake.org/) 3.5 or higher versions in the
## Install tools
### Ubuntu & Debian:
### Ubuntu
16.04 and above
& Debian:
```
bash
sudo
apt-get
install
-y
gcc cmake build-essential git
```
### Ubuntu 14.04:
```
bash
sudo
apt-get
install
-y
gcc cmake3 build-essential git binutils-2.26
export
PATH
=
/usr/lib/binutils-2.26/bin:
$PATH
```
To compile and package the JDBC driver source code, you should have a Java jdk-8 or higher and Apache Maven 2.7 or higher installed.
To install openjdk-8:
```
bash
...
...
documentation20/webdocs/markdowndocs/TAOS SQL-ch.md
浏览文件 @
c309bd00
...
...
@@ -148,7 +148,7 @@ TDengine缺省的时间戳是毫秒精度,但通过修改配置参数enableMic
SHOW TABLES [LIKE tb_name_wildcar];
```
显示当前数据库下的所有数据表信息。说明:可在
like中使用通配符进行名称的匹配。 通配符匹配:1)’%’ (百分号)匹配0到任意个字符;2)’_’下划线
匹配一个字符。
显示当前数据库下的所有数据表信息。说明:可在
like 中使用通配符进行名称的匹配。 通配符匹配:1)“%”(百分号)匹配 0 到任意个字符;2)“\_”(下划线)
匹配一个字符。
-
**在线修改显示字符宽度**
...
...
@@ -263,33 +263,33 @@ TDengine缺省的时间戳是毫秒精度,但通过修改配置参数enableMic
-
**插入一条记录,数据对应到指定的列**
```
mysql
INSERT INTO tb_name (field1_name, ...) VALUES(field1_value, ...)
INSERT INTO tb_name (field1_name, ...) VALUES
(field1_value, ...)
```
向表tb_name中插入一条记录,数据对应到指定的列。SQL语句中没有出现的列,数据库将自动填充为NULL。主键(时间戳)不能为NULL。
-
**插入多条记录**
```
mysql
INSERT INTO tb_name VALUES (field1_value1, ...) (field1_value2, ...)...;
INSERT INTO tb_name VALUES (field1_value1, ...) (field1_value2, ...)
...;
```
向表tb_name中插入多条记录
-
**按指定的列插入多条记录**
```
mysql
INSERT INTO tb_name (field1_name, ...) VALUES
(field1_value1, ...) (field1_value2, ...)
INSERT INTO tb_name (field1_name, ...) VALUES
(field1_value1, ...) (field1_value2, ...) ...;
```
向表tb_name中按指定的列插入多条记录
-
**向多个表插入多条记录**
```
mysql
INSERT INTO tb1_name VALUES (field1_value1, ...)
(field1_value2, ...)
...
tb2_name VALUES (field1_value1, ...)
(field1_value2, ...)
...;
INSERT INTO tb1_name VALUES (field1_value1, ...)
(field1_value2, ...)
...
tb2_name VALUES (field1_value1, ...)
(field1_value2, ...)
...;
```
同时向表tb1_name和tb2_name中分别插入多条记录
-
**同时向多个表按列插入多条记录**
```
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 tb1_name (tb1_field1_name, ...) VALUES (field1_value1, ...) (field1_value2, ...)
...
tb2_name (tb2_field1_name, ...) VALUES (field1_value1, ...) (field1_value2, ...)
...
;
```
同时向表tb1_name和tb2_name中按列分别插入多条记录
...
...
@@ -318,23 +318,23 @@ SELECT select_expr [, select_expr ...]
```
说明:针对 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
);
taos>
CREATE TABLE meters(ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS(location BINARY(30), groupId INT
);
Query OK, 0 row(s) affected (0.008245s)
taos>
show stables
;
taos>
SHOW STABLES
;
name | created_time | columns | tags | tables |
============================================================================================
meters | 2020-08-06 17:50:27.831 | 4 | 2 | 0 |
Query OK, 1 row(s) in set (0.001029s)
taos>
show tables
;
taos>
SHOW TABLES
;
Query OK, 0 row(s) in set (0.000946s)
taos>
insert into d1001 using meters tags
('Beijing.Chaoyang', 2);
taos>
INSERT INTO d1001 USING meters TAGS
('Beijing.Chaoyang', 2);
DB error: invalid SQL: keyword VALUES or FILE required
taos>
show tables
;
taos>
SHOW TABLES
;
table_name | created_time | columns | stable_name |
======================================================================================================
d1001 | 2020-08-06 17:52:02.097 | 4 | meters |
...
...
@@ -397,27 +397,41 @@ Query OK, 1 row(s) in set (0.020443s)
在使用SQL函数来进行查询过程中,部分SQL函数支持通配符操作。其中的区别在于:
```
count(\*)```函数只返回一列。```first```、```last```、```last_row```函数则是返回全部列。
```
taos>
select count(
*
) from
d1001;
```
mysql
taos>
SELECT COUNT(
*
) FROM
d1001;
count(*) |
========================
3 |
Query OK, 1 row(s) in set (0.001035s)
```
```
taos>
select first(
*
) from
d1001;
```
mysql
taos>
SELECT FIRST(
*
) FROM
d1001;
first(ts) | first(current) | first(voltage) | first(phase) |
=========================================================================================
2018-10-03 14:38:05.000 | 10.30000 | 219 | 0.31000 |
Query OK, 1 row(s) in set (0.000849s)
```
##### 标签列
从 2.0.14 版本开始,支持在普通表的查询中指定 _标签列_,且标签列的值会与普通列的数据一起返回。
```
mysql
taos> SELECT location, groupid, current FROM d1001 LIMIT 2;
location | groupid | current |
======================================================================
Beijing.Chaoyang | 2 | 10.30000 |
Beijing.Chaoyang | 2 | 12.60000 |
Query OK, 2 row(s) in set (0.003112s)
```
注意:普通表的通配符 * 中并不包含 _标签列_。
#### 结果集列名
```
SELECT
```子句中,如果不指定返回结果集合的列名,结果集列名称默认使用```
SELECT
```子句中的表达式名称作为列名称。此外,用户可使用```
AS
```来重命名返回结果集合中列的名称。例如:
```
taos>
select ts, ts as primary_key_ts from
d1001;
```
mysql
taos>
SELECT ts, ts AS primary_key_ts FROM
d1001;
ts | primary_key_ts |
====================================================
2018-10-03 14:38:05.000 | 2018-10-03 14:38:05.000 |
...
...
@@ -434,53 +448,53 @@ Query OK, 3 row(s) in set (0.001191s)
FROM关键字后面可以是若干个表(超级表)列表,也可以是子查询的结果。
如果没有指定用户的当前数据库,可以在表名称之前使用数据库的名称来指定表所属的数据库。例如:```
power.d1001
``` 方式来跨库使用表。
```
```
mysql
SELECT * FROM power.d1001;
------------------------------
use
power;
USE
power;
SELECT
*
FROM d1001;
```
#### 特殊功能
部分特殊的查询功能可以不使用FROM子句执行。获取当前所在的数据库 database()
```
taos> SELECT
database
();
```
mysql
taos> SELECT
DATABASE
();
database() |
=================================
power |
Query OK, 1 row(s) in set (0.000079s)
```
如果登录的时候没有指定默认数据库,且没有使用```use```命令切换数据,则返回NULL。
```
taos> SELECT
database
();
```
mysql
taos> SELECT
DATABASE
();
database() |
=================================
NULL |
Query OK, 1 row(s) in set (0.000184s)
```
获取服务器和客户端版本号:
```
taos> SELECT
client_version
();
```
mysql
taos> SELECT
CLIENT_VERSION
();
client_version() |
===================
2.
0.0.0 |
Query OK, 1 row(s) in set (0.000070s)
taos> SELECT
server_version
();
taos> SELECT
SERVER_VERSION
();
server_version() |
===================
2.
0.0.0 |
Query OK, 1 row(s) in set (0.000077s)
```
服务器状态检测语句。如果服务器正常,返回一个数字(例如 1)。如果服务器异常,返回error code。该SQL语法能兼容连接池对于TDengine状态的检查及第三方工具对于数据库服务器状态的检查。并可以避免出现使用了错误的心跳检测SQL语句导致的连接池连接丢失的问题。
```
taos> SELECT
server_status
();
```
mysql
taos> SELECT
SERVER_STATUS
();
server_status() |
==================
1 |
Query OK, 1 row(s) in set (0.000074s)
taos> SELECT
server_status() as
status;
taos> SELECT
SERVER_STATUS() AS
status;
status |
==============
1 |
...
...
@@ -493,15 +507,15 @@ Query OK, 1 row(s) in set (0.000081s)
#### 小技巧
获取一个超级表所有的子表名及相关的标签信息:
```
```
mysql
SELECT TBNAME, location FROM meters;
```
统计超级表下辖子表数量:
```
```
mysql
SELECT COUNT(TBNAME) FROM meters;
```
以上两个查询均只支持在Where条件子句中添加针对标签(TAGS)的过滤条件。例如:
```
```
mysql
taos> SELECT TBNAME, location FROM meters;
tbname | location |
==================================================================
...
...
@@ -511,7 +525,7 @@ taos> SELECT TBNAME, location FROM meters;
d1001 | Beijing.Chaoyang |
Query OK, 4 row(s) in set (0.000881s)
taos> SELECT
count
(tbname) FROM meters WHERE groupId > 2;
taos> SELECT
COUNT
(tbname) FROM meters WHERE groupId > 2;
count(tbname) |
========================
2 |
...
...
@@ -545,7 +559,7 @@ Query OK, 1 row(s) in set (0.001091s)
- 对于下面的例子,表tb1用以下语句创建
```mysql
CREATE TABLE tb1 (ts
timestamp, col1 int, col2 float, col3 binary
(50));
CREATE TABLE tb1 (ts
TIMESTAMP, col1 INT, col2 FLOAT, col3 BINARY
(50));
```
- 查询tb1刚过去的一个小时的所有记录
...
...
@@ -563,7 +577,7 @@ Query OK, 1 row(s) in set (0.001091s)
- 查询col1与col2的和,并取名complex, 时间大于2018-06-01 08:00:00.000, col2大于1.2,结果输出仅仅10条记录,从第5条开始
```mysql
SELECT (col1 + col2) AS 'complex' FROM tb1 WHERE ts > '2018-06-01 08:00:00.000'
and
col2 > 1.2 LIMIT 10 OFFSET 5;
SELECT (col1 + col2) AS 'complex' FROM tb1 WHERE ts > '2018-06-01 08:00:00.000'
AND
col2 > 1.2 LIMIT 10 OFFSET 5;
```
- 查询过去10分钟的记录,col2的值大于3.14,并且将结果输出到文件 `/home/testoutpu.csv`.
...
...
@@ -590,13 +604,13 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数
示例:
```mysql
taos> SELECT COUNT(*), COUNT(
VOLTAGE
) FROM meters;
taos> SELECT COUNT(*), COUNT(
voltage
) FROM meters;
count(*) | count(voltage) |
================================================
9 | 9 |
Query OK, 1 row(s) in set (0.004475s)
taos> SELECT COUNT(*), COUNT(
VOLTAGE
) FROM d1001;
taos> SELECT COUNT(*), COUNT(
voltage
) FROM d1001;
count(*) | count(voltage) |
================================================
3 | 3 |
...
...
@@ -620,7 +634,7 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数
11.466666751 | 220.444444444 | 0.293333333 |
Query OK, 1 row(s) in set (0.004135s)
taos> SELECT AVG(current), AVG(voltage), AVG(phase)
from
d1001;
taos> SELECT AVG(current), AVG(voltage), AVG(phase)
FROM
d1001;
avg(current) | avg(voltage) | avg(phase) |
====================================================================================
11.733333588 | 219.333333333 | 0.316666673 |
...
...
@@ -648,13 +662,13 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数
示例:
```mysql
taos> SELECT SUM(current), SUM(voltage), SUM(phase)
from
meters;
taos> SELECT SUM(current), SUM(voltage), SUM(phase)
FROM
meters;
sum(current) | sum(voltage) | sum(phase) |
================================================================================
103.200000763 | 1984 | 2.640000001 |
Query OK, 1 row(s) in set (0.001702s)
taos> SELECT SUM(current), SUM(voltage), SUM(phase)
from
d1001;
taos> SELECT SUM(current), SUM(voltage), SUM(phase)
FROM
d1001;
sum(current) | sum(voltage) | sum(phase) |
================================================================================
35.200000763 | 658 | 0.950000018 |
...
...
@@ -753,7 +767,7 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数
功能说明:统计表/超级表中某列的值最先写入的非NULL值。
返回结果数据类型:同应用的字段。
应用字段:所有字段。
说明:1)如果要返回各个列的首个(时间戳最小)非NULL值,可以使用FIRST(*);2) 如果结果集中的某列全部为NULL值,则该列的返回结果也是NULL;3) 如果结果集中所有列全部为NULL值,则不返回结果。
说明:1)如果要返回各个列的首个(时间戳最小)非NULL值,可以使用FIRST(
\
*);2) 如果结果集中的某列全部为NULL值,则该列的返回结果也是NULL;3) 如果结果集中所有列全部为NULL值,则不返回结果。
示例:
```mysql
...
...
@@ -777,7 +791,7 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数
功能说明:统计表/超级表中某列的值最后写入的非NULL值。
返回结果数据类型:同应用的字段。
应用字段:所有字段。
说明:1)如果要返回各个列的最后(时间戳最大)一个非NULL值,可以使用LAST(*);2)如果结果集中的某列全部为NULL值,则该列的返回结果也是NULL;如果结果集中所有列全部为NULL值,则不返回结果。
说明:1)如果要返回各个列的最后(时间戳最大)一个非NULL值,可以使用LAST(
\
*);2)如果结果集中的某列全部为NULL值,则该列的返回结果也是NULL;如果结果集中所有列全部为NULL值,则不返回结果。
示例:
```mysql
...
...
@@ -1004,15 +1018,15 @@ SELECT function_list FROM stb_name
**示例:** 智能电表的建表语句如下:
```
mysql
CREATE TABLE meters (ts
timestamp, current float, voltage int, phase float) TAGS (location binary(64), groupId int
);
CREATE TABLE meters (ts
TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT
);
```
针对智能电表采集的数据,以10分钟为一个阶段,计算过去24小时的电流数据的平均值、最大值、电流的中位数、以及随着时间变化的电流走势拟合直线。如果没有计算值,用前一个非NULL值填充。
使用的查询语句如下:
```
mysql
SELECT AVG(current),
MAX(current),
LEASTSQUARES(current, start_val, step_val), PERCENTILE(current, 50) FROM meters
WHERE
TS
>=NOW-1d
SELECT AVG(current),
MAX(current),
LEASTSQUARES(current, start_val, step_val), PERCENTILE(current, 50) FROM meters
WHERE
ts
>=NOW-1d
INTERVAL(10m)
FILL(PREV);
```
...
...
src/client/src/tscSQLParser.c
浏览文件 @
c309bd00
...
...
@@ -4598,7 +4598,7 @@ static void setDefaultOrderInfo(SQueryInfo* pQueryInfo) {
int32_t
parseOrderbyClause
(
SSqlCmd
*
pCmd
,
SQueryInfo
*
pQueryInfo
,
SQuerySQL
*
pQuerySql
,
SSchema
*
pSchema
)
{
const
char
*
msg0
=
"only support order by primary timestamp"
;
const
char
*
msg1
=
"invalid column name"
;
const
char
*
msg2
=
"only support order by primary timestamp or
queried column
"
;
const
char
*
msg2
=
"only support order by primary timestamp or
first tag in groupby clause allowed
"
;
const
char
*
msg3
=
"invalid column in order by clause, only primary timestamp or first tag in groupby clause allowed"
;
setDefaultOrderInfo
(
pQueryInfo
);
...
...
src/query/src/qAggMain.c
浏览文件 @
c309bd00
...
...
@@ -1328,7 +1328,7 @@ static void stddev_function_f(SQLFunctionCtx *pCtx, int32_t index) {
/* the first stage is to calculate average value */
if
(
pStd
->
stage
==
0
)
{
avg_function_f
(
pCtx
,
index
);
}
else
{
}
else
if
(
pStd
->
num
>
0
)
{
double
avg
=
pStd
->
avg
;
void
*
pData
=
GET_INPUT_DATA
(
pCtx
,
index
);
...
...
src/query/src/qHistogram.c
浏览文件 @
c309bd00
...
...
@@ -143,6 +143,9 @@ SHistogramInfo* tHistogramCreateFrom(void* pBuf, int32_t numOfBins) {
SHistogramInfo
*
pHisto
=
(
SHistogramInfo
*
)
pBuf
;
pHisto
->
elems
=
(
SHistBin
*
)((
char
*
)
pBuf
+
sizeof
(
SHistogramInfo
));
for
(
int32_t
i
=
0
;
i
<
numOfBins
;
++
i
)
{
pHisto
->
elems
[
i
].
val
=
-
DBL_MAX
;
}
pHisto
->
maxEntries
=
numOfBins
;
...
...
src/query/tests/histogramTest.cpp
浏览文件 @
c309bd00
...
...
@@ -4,42 +4,9 @@
#include <iostream>
#include "taos.h"
#include "tsdb.h"
#include "tstoken.h"
#include "tutil.h"
#include "qHistogram.h"
/* test validate the names for table/database */
TEST
(
testCase
,
histogram_binary_search
)
{
SHistogramInfo
*
pHisto
=
tHistogramCreate
(
MAX_HISTOGRAM_BIN
);
pHisto
->
numOfEntries
=
10
;
for
(
int32_t
i
=
0
;
i
<
10
;
++
i
)
{
pHisto
->
elems
[
i
].
num
=
1
;
pHisto
->
elems
[
i
].
val
=
i
;
}
int32_t
idx
=
histoBinarySearch
(
pHisto
->
elems
,
pHisto
->
numOfEntries
,
1
);
assert
(
idx
==
1
);
idx
=
histoBinarySearch
(
pHisto
->
elems
,
pHisto
->
numOfEntries
,
9
);
assert
(
idx
==
9
);
idx
=
histoBinarySearch
(
pHisto
->
elems
,
pHisto
->
numOfEntries
,
20
);
assert
(
idx
==
10
);
idx
=
histoBinarySearch
(
pHisto
->
elems
,
pHisto
->
numOfEntries
,
-
1
);
assert
(
idx
==
0
);
idx
=
histoBinarySearch
(
pHisto
->
elems
,
pHisto
->
numOfEntries
,
3.9
);
assert
(
idx
==
4
);
free
(
pHisto
);
}
TEST
(
testCase
,
histogram_add
)
{
namespace
{
void
doHistogramAddTest
()
{
SHistogramInfo
*
pHisto
=
NULL
;
/**
...
...
@@ -99,6 +66,56 @@ TEST(testCase, histogram_add) {
tHistogramDestroy
(
&
pRes
);
free
(
res
);
}
void
doHistogramRepeatTest
()
{
SHistogramInfo
*
pHisto
=
NULL
;
struct
timeval
systemTime
;
gettimeofday
(
&
systemTime
,
NULL
);
int64_t
st
=
(
int64_t
)
systemTime
.
tv_sec
*
1000L
+
(
uint64_t
)
systemTime
.
tv_usec
/
1000
;
for
(
int32_t
i
=
0
;
i
<
1000
;
++
i
)
{
tHistogramAdd
(
&
pHisto
,
-
24
+
i
);
// tHistogramPrint(pHisto);
}
tHistogramDestroy
(
&
pHisto
);
}
}
/* test validate the names for table/database */
TEST
(
testCase
,
histogram_binary_search
)
{
SHistogramInfo
*
pHisto
=
tHistogramCreate
(
MAX_HISTOGRAM_BIN
);
pHisto
->
numOfEntries
=
10
;
for
(
int32_t
i
=
0
;
i
<
10
;
++
i
)
{
pHisto
->
elems
[
i
].
num
=
1
;
pHisto
->
elems
[
i
].
val
=
i
;
}
int32_t
idx
=
histoBinarySearch
(
pHisto
->
elems
,
pHisto
->
numOfEntries
,
1
);
assert
(
idx
==
1
);
idx
=
histoBinarySearch
(
pHisto
->
elems
,
pHisto
->
numOfEntries
,
9
);
assert
(
idx
==
9
);
idx
=
histoBinarySearch
(
pHisto
->
elems
,
pHisto
->
numOfEntries
,
20
);
assert
(
idx
==
10
);
idx
=
histoBinarySearch
(
pHisto
->
elems
,
pHisto
->
numOfEntries
,
-
1
);
assert
(
idx
==
0
);
idx
=
histoBinarySearch
(
pHisto
->
elems
,
pHisto
->
numOfEntries
,
3.9
);
assert
(
idx
==
4
);
free
(
pHisto
);
}
TEST
(
testCase
,
histogram_add
)
{
doHistogramAddTest
();
doHistogramRepeatTest
();
}
TEST
(
testCase
,
heapsort
)
{
// int32_t num = 20;
...
...
src/vnode/src/vnodeStatus.c
浏览文件 @
c309bd00
...
...
@@ -56,7 +56,7 @@ static bool vnodeSetClosingStatusImp(SVnodeObj* pVnode) {
bool
set
=
false
;
pthread_mutex_lock
(
&
pVnode
->
statusMutex
);
if
(
pVnode
->
status
==
TAOS_VN_STATUS_READY
)
{
if
(
pVnode
->
status
==
TAOS_VN_STATUS_READY
||
pVnode
->
status
==
TAOS_VN_STATUS_INIT
)
{
pVnode
->
status
=
TAOS_VN_STATUS_CLOSING
;
set
=
true
;
}
else
{
...
...
@@ -68,13 +68,10 @@ static bool vnodeSetClosingStatusImp(SVnodeObj* pVnode) {
}
bool
vnodeSetClosingStatus
(
SVnodeObj
*
pVnode
)
{
if
(
!
vnodeInInitStatus
(
pVnode
))
{
// it may be in updating or reset state, then it shall wait
int32_t
i
=
0
;
while
(
!
vnodeSetClosingStatusImp
(
pVnode
))
{
if
(
++
i
%
1000
==
0
)
{
sched_yield
();
}
int32_t
i
=
0
;
while
(
!
vnodeSetClosingStatusImp
(
pVnode
))
{
if
(
++
i
%
1000
==
0
)
{
sched_yield
();
}
}
...
...
@@ -96,11 +93,11 @@ bool vnodeSetUpdatingStatus(SVnodeObj* pVnode) {
return
set
;
}
bool
vnodeSetResetStatus
(
SVnodeObj
*
pVnode
)
{
static
bool
vnodeSetResetStatusImp
(
SVnodeObj
*
pVnode
)
{
bool
set
=
false
;
pthread_mutex_lock
(
&
pVnode
->
statusMutex
);
if
(
pVnode
->
status
!=
TAOS_VN_STATUS_CLOSING
&&
pVnode
->
status
!
=
TAOS_VN_STATUS_INIT
)
{
if
(
pVnode
->
status
==
TAOS_VN_STATUS_READY
||
pVnode
->
status
=
=
TAOS_VN_STATUS_INIT
)
{
pVnode
->
status
=
TAOS_VN_STATUS_RESET
;
set
=
true
;
}
else
{
...
...
@@ -111,6 +108,17 @@ bool vnodeSetResetStatus(SVnodeObj* pVnode) {
return
set
;
}
bool
vnodeSetResetStatus
(
SVnodeObj
*
pVnode
)
{
int32_t
i
=
0
;
while
(
!
vnodeSetResetStatusImp
(
pVnode
))
{
if
(
++
i
%
1000
==
0
)
{
sched_yield
();
}
}
return
true
;
}
bool
vnodeInInitStatus
(
SVnodeObj
*
pVnode
)
{
bool
in
=
false
;
pthread_mutex_lock
(
&
pVnode
->
statusMutex
);
...
...
tests/Jenkinsfile
浏览文件 @
c309bd00
...
...
@@ -98,7 +98,15 @@ pipeline {
sh
'''
cd ${WKC}/tests/examples/JDBC/JDBCDemo/
mvn clean package assembly:single -DskipTests >/dev/null
java -jar target/jdbcChecker-SNAPSHOT-jar-with-dependencies.jar -host 127.0.0.1
java -jar target/JDBCDemo-SNAPSHOT-jar-with-dependencies.jar -host 127.0.0.1
'''
}
catchError
(
buildResult:
'SUCCESS'
,
stageResult:
'FAILURE'
)
{
sh
'''
cd ${WKC}/src/connector/jdbc
mvn clean package -Dmaven.test.skip=true >/dev/null
cd ${WKC}/tests/examples/JDBC/JDBCDemo/
java --class-path=../../../../src/connector/jdbc/target:$JAVA_HOME/jre/lib/ext -jar target/JDBCDemo-SNAPSHOT-jar-with-dependencies.jar -host 127.0.0.1
'''
}
catchError
(
buildResult:
'SUCCESS'
,
stageResult:
'FAILURE'
)
{
...
...
tests/pytest/functions/all_null_value.py
浏览文件 @
c309bd00
...
...
@@ -73,8 +73,8 @@ class TDTestCase:
tdSql
.
query
(
"select spread(c1) from st"
)
tdSql
.
checkRows
(
0
)
#
tdSql.query("select stddev(c1) from st")
#
tdSql.checkRows(0)
tdSql
.
query
(
"select stddev(c1) from st"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select sum(c1) from st"
)
tdSql
.
checkRows
(
0
)
...
...
tests/pytest/query/query.py
浏览文件 @
c309bd00
...
...
@@ -44,6 +44,20 @@ class TDTestCase:
tdSql
.
query
(
"select * from db.st where ts='2020-05-13 10:00:00.000'"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select tbname, dev from dev_001"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
'dev_001'
)
tdSql
.
checkData
(
0
,
1
,
'dev_01'
)
tdSql
.
query
(
"select tbname, dev, tagtype from dev_001"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
'dev_001'
)
tdSql
.
checkData
(
0
,
1
,
'dev_01'
)
tdSql
.
checkData
(
0
,
2
,
1
)
tdSql
.
checkData
(
1
,
0
,
'dev_001'
)
tdSql
.
checkData
(
1
,
1
,
'dev_01'
)
tdSql
.
checkData
(
1
,
2
,
1
)
## test case for https://jira.taosdata.com:18080/browse/TD-2488
tdSql
.
execute
(
"create table m1(ts timestamp, k int) tags(a int)"
)
tdSql
.
execute
(
"create table t1 using m1 tags(1)"
)
...
...
@@ -63,6 +77,8 @@ class TDTestCase:
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
1
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
...
...
tests/pytest/query/queryInterval.py
浏览文件 @
c309bd00
...
...
@@ -100,7 +100,23 @@ class TDTestCase:
tdSql
.
checkData
(
1
,
1
,
None
)
tdSql
.
checkData
(
2
,
1
,
None
)
# test case for https://jira.taosdata.com:18080/browse/TD-2659, https://jira.taosdata.com:18080/browse/TD-2660
tdSql
.
execute
(
"create database test3"
)
tdSql
.
execute
(
"use test3"
)
tdSql
.
execute
(
"create table tb(ts timestamp, c int)"
)
tdSql
.
execute
(
"insert into tb values('2020-10-30 18:11:56.680', -111)"
)
tdSql
.
execute
(
"insert into tb values('2020-11-19 18:11:45.773', null)"
)
tdSql
.
execute
(
"insert into tb values('2020-12-09 18:11:17.098', null)"
)
tdSql
.
execute
(
"insert into tb values('2020-12-29 11:00:49.412', 1)"
)
tdSql
.
execute
(
"insert into tb values('2020-12-29 11:00:50.412', 2)"
)
tdSql
.
execute
(
"insert into tb values('2020-12-29 11:00:52.412', 3)"
)
tdSql
.
query
(
"select first(ts),twa(c) from tb interval(14a)"
)
tdSql
.
checkRows
(
6
)
tdSql
.
query
(
"select twa(c) from tb group by c"
)
tdSql
.
checkRows
(
4
)
def
stop
(
self
):
tdSql
.
close
()
...
...
tests/pytest/stream/history.py
浏览文件 @
c309bd00
...
...
@@ -48,12 +48,16 @@ class TDTestCase:
tdSql
.
execute
(
"insert into car3 values('2019-01-01 00:00:01.389', 1)"
)
tdSql
.
execute
(
"insert into car4 values('2019-01-01 00:00:01.829', 1)"
)
tdSql
.
error
(
"create table strm as select count(*) from cars"
)
tdSql
.
execute
(
"create table strm as select count(*) from cars interval(4s)"
)
tdSql
.
waitedQuery
(
"select * from strm"
,
2
,
100
)
tdSql
.
checkData
(
0
,
1
,
11
)
tdSql
.
checkData
(
1
,
1
,
2
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
...
...
tests/pytest/tools/taosdemoTest.py
浏览文件 @
c309bd00
...
...
@@ -49,7 +49,7 @@ class TDTestCase:
else
:
tdLog
.
info
(
"taosd found in %s"
%
buildPath
)
binPath
=
buildPath
+
"/build/bin/"
os
.
system
(
"yes | %staosdemo -t %d -n %d"
%
(
binPath
,
self
.
numberOfTables
,
self
.
numberOfRecords
))
os
.
system
(
"yes | %staosdemo -t %d -n %d
-x
"
%
(
binPath
,
self
.
numberOfTables
,
self
.
numberOfRecords
))
tdSql
.
execute
(
"use test"
)
tdSql
.
query
(
"select count(*) from meters"
)
...
...
@@ -61,6 +61,8 @@ class TDTestCase:
tdSql
.
query
(
"select apercentile(f1, 1) from test.meters interval(10s)"
)
tdSql
.
checkRows
(
11
)
tdSql
.
error
(
"select loc, count(loc) from test.meters"
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
...
...
tests/script/general/parser/tags_filter.sim
浏览文件 @
c309bd00
...
...
@@ -73,6 +73,9 @@ endi
sql select * from stb where t1 > '1'
sql select * from stb where t1 > 'a'
print =====================> TD-2685
sql_error select t1, count(t1) from stb;
## wildcard '%'
#sql select * from stb where t1 like '%'
#if $rows != 1 then
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录