Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
86041893
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
86041893
编写于
11月 06, 2020
作者:
H
Hui Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-1961]<fix> modify return when call taos_query()
上级
73b23e8b
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
51 addition
and
25 deletion
+51
-25
tests/examples/c/apitest.c
tests/examples/c/apitest.c
+51
-25
未找到文件。
tests/examples/c/apitest.c
浏览文件 @
86041893
...
...
@@ -9,26 +9,40 @@
static
void
prepare_data
(
TAOS
*
taos
)
{
taos_query
(
taos
,
"drop database if exists test;"
);
TAOS_RES
*
result
;
result
=
taos_query
(
taos
,
"drop database if exists test;"
);
taos_free_result
(
result
);
usleep
(
100000
);
taos_query
(
taos
,
"create database test;"
);
result
=
taos_query
(
taos
,
"create database test;"
);
taos_free_result
(
result
);
usleep
(
100000
);
taos_select_db
(
taos
,
"test"
);
taos_query
(
taos
,
"create table meters(ts timestamp, a int) tags(area int);"
);
result
=
taos_query
(
taos
,
"create table meters(ts timestamp, a int) tags(area int);"
);
taos_free_result
(
result
);
taos_query
(
taos
,
"create table t0 using meters tags(0);"
);
taos_query
(
taos
,
"create table t1 using meters tags(1);"
);
taos_query
(
taos
,
"create table t2 using meters tags(2);"
);
taos_query
(
taos
,
"create table t3 using meters tags(3);"
);
taos_query
(
taos
,
"create table t4 using meters tags(4);"
);
taos_query
(
taos
,
"create table t5 using meters tags(5);"
);
taos_query
(
taos
,
"create table t6 using meters tags(6);"
);
taos_query
(
taos
,
"create table t7 using meters tags(7);"
);
taos_query
(
taos
,
"create table t8 using meters tags(8);"
);
taos_query
(
taos
,
"create table t9 using meters tags(9);"
);
result
=
taos_query
(
taos
,
"create table t0 using meters tags(0);"
);
taos_free_result
(
result
);
result
=
taos_query
(
taos
,
"create table t1 using meters tags(1);"
);
taos_free_result
(
result
);
result
=
taos_query
(
taos
,
"create table t2 using meters tags(2);"
);
taos_free_result
(
result
);
result
=
taos_query
(
taos
,
"create table t3 using meters tags(3);"
);
taos_free_result
(
result
);
result
=
taos_query
(
taos
,
"create table t4 using meters tags(4);"
);
taos_free_result
(
result
);
result
=
taos_query
(
taos
,
"create table t5 using meters tags(5);"
);
taos_free_result
(
result
);
result
=
taos_query
(
taos
,
"create table t6 using meters tags(6);"
);
taos_free_result
(
result
);
result
=
taos_query
(
taos
,
"create table t7 using meters tags(7);"
);
taos_free_result
(
result
);
result
=
taos_query
(
taos
,
"create table t8 using meters tags(8);"
);
taos_free_result
(
result
);
result
=
taos_query
(
taos
,
"create table t9 using meters tags(9);"
);
taos_free_result
(
result
);
TAOS_RES
*
res
=
taos_query
(
taos
,
"insert into t0 values('2020-01-01 00:00:00.000', 0)"
result
=
taos_query
(
taos
,
"insert into t0 values('2020-01-01 00:00:00.000', 0)"
" ('2020-01-01 00:01:00.000', 0)"
" ('2020-01-01 00:02:00.000', 0)"
" t1 values('2020-01-01 00:00:00.000', 0)"
...
...
@@ -46,10 +60,11 @@ static void prepare_data(TAOS* taos) {
" t7 values('2020-01-01 00:01:02.000', 0)"
" t8 values('2020-01-01 00:01:02.000', 0)"
" t9 values('2020-01-01 00:01:02.000', 0)"
);
int
affected
=
taos_affected_rows
(
res
);
int
affected
=
taos_affected_rows
(
res
ult
);
if
(
affected
!=
18
)
{
printf
(
"
\033
[31m%d rows affected by last insert statement, but it should be 18
\033
[0m
\n
"
,
affected
);
}
taos_free_result
(
result
);
// super tables subscription
usleep
(
1000000
);
}
...
...
@@ -153,23 +168,30 @@ static void verify_subscribe(TAOS* taos) {
res
=
taos_consume
(
tsub
);
check_row_count
(
__LINE__
,
res
,
0
);
taos_query
(
taos
,
"insert into t0 values('2020-01-01 00:02:00.001', 0);"
);
taos_query
(
taos
,
"insert into t8 values('2020-01-01 00:01:03.000', 0);"
);
TAOS_RES
*
result
;
result
=
taos_query
(
taos
,
"insert into t0 values('2020-01-01 00:02:00.001', 0);"
);
taos_free_result
(
result
);
result
=
taos_query
(
taos
,
"insert into t8 values('2020-01-01 00:01:03.000', 0);"
);
taos_free_result
(
result
);
res
=
taos_consume
(
tsub
);
check_row_count
(
__LINE__
,
res
,
2
);
taos_query
(
taos
,
"insert into t2 values('2020-01-01 00:01:02.001', 0);"
);
taos_query
(
taos
,
"insert into t1 values('2020-01-01 00:03:00.001', 0);"
);
result
=
taos_query
(
taos
,
"insert into t2 values('2020-01-01 00:01:02.001', 0);"
);
taos_free_result
(
result
);
result
=
taos_query
(
taos
,
"insert into t1 values('2020-01-01 00:03:00.001', 0);"
);
taos_free_result
(
result
);
res
=
taos_consume
(
tsub
);
check_row_count
(
__LINE__
,
res
,
2
);
taos_query
(
taos
,
"insert into t1 values('2020-01-01 00:03:00.002', 0);"
);
result
=
taos_query
(
taos
,
"insert into t1 values('2020-01-01 00:03:00.002', 0);"
);
taos_free_result
(
result
);
res
=
taos_consume
(
tsub
);
check_row_count
(
__LINE__
,
res
,
1
);
// keep progress information and restart subscription
taos_unsubscribe
(
tsub
,
1
);
taos_query
(
taos
,
"insert into t0 values('2020-01-01 00:04:00.000', 0);"
);
result
=
taos_query
(
taos
,
"insert into t0 values('2020-01-01 00:04:00.000', 0);"
);
taos_free_result
(
result
);
tsub
=
taos_subscribe
(
taos
,
1
,
"test"
,
"select * from meters;"
,
NULL
,
NULL
,
0
);
res
=
taos_consume
(
tsub
);
check_row_count
(
__LINE__
,
res
,
24
);
...
...
@@ -196,7 +218,8 @@ static void verify_subscribe(TAOS* taos) {
res
=
taos_consume
(
tsub
);
check_row_count
(
__LINE__
,
res
,
0
);
taos_query
(
taos
,
"insert into t0 values('2020-01-01 00:04:00.001', 0);"
);
result
=
taos_query
(
taos
,
"insert into t0 values('2020-01-01 00:04:00.001', 0);"
);
taos_free_result
(
result
);
res
=
taos_consume
(
tsub
);
check_row_count
(
__LINE__
,
res
,
1
);
...
...
@@ -205,7 +228,8 @@ static void verify_subscribe(TAOS* taos) {
int
blockFetch
=
0
;
tsub
=
taos_subscribe
(
taos
,
1
,
"test"
,
"select * from meters;"
,
subscribe_callback
,
&
blockFetch
,
1000
);
usleep
(
2000000
);
taos_query
(
taos
,
"insert into t0 values('2020-01-01 00:05:00.001', 0);"
);
result
=
taos_query
(
taos
,
"insert into t0 values('2020-01-01 00:05:00.001', 0);"
);
taos_free_result
(
result
);
usleep
(
2000000
);
taos_unsubscribe
(
tsub
,
0
);
}
...
...
@@ -213,8 +237,9 @@ static void verify_subscribe(TAOS* taos) {
void
verify_prepare
(
TAOS
*
taos
)
{
TAOS_RES
*
result
=
taos_query
(
taos
,
"drop database if exists test;"
);
taos_free_result
(
result
);
usleep
(
100000
);
taos_query
(
taos
,
"create database test;"
);
result
=
taos_query
(
taos
,
"create database test;"
);
int
code
=
taos_errno
(
result
);
if
(
code
!=
0
)
{
...
...
@@ -429,7 +454,8 @@ void verify_stream(TAOS* taos) {
NULL
);
printf
(
"waiting for stream data
\n
"
);
usleep
(
100000
);
taos_query
(
taos
,
"insert into t0 values(now, 0)(now+5s,1)(now+10s, 2);"
);
TAOS_RES
*
result
=
taos_query
(
taos
,
"insert into t0 values(now, 0)(now+5s,1)(now+10s, 2);"
);
taos_free_result
(
result
);
usleep
(
200000000
);
taos_close_stream
(
strm
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录