Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
哥们要飞
TDengine
提交
73b23e8b
T
TDengine
项目概览
哥们要飞
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
73b23e8b
编写于
11月 06, 2020
作者:
H
Hui Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-1961]<fix> modify return when call taos_query()
上级
d553f408
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
47 addition
and
12 deletion
+47
-12
tests/examples/c/demo.c
tests/examples/c/demo.c
+47
-12
未找到文件。
tests/examples/c/demo.c
浏览文件 @
73b23e8b
...
...
@@ -22,6 +22,34 @@
#include <inttypes.h>
#include <taos.h> // TAOS header file
static
void
queryDB
(
TAOS
*
taos
,
char
*
command
)
{
int
i
;
TAOS_RES
*
pSql
=
NULL
;
int32_t
code
=
-
1
;
for
(
i
=
0
;
i
<
5
;
i
++
)
{
if
(
NULL
!=
pSql
)
{
taos_free_result
(
pSql
);
pSql
=
NULL
;
}
pSql
=
taos_query
(
taos
,
command
);
code
=
taos_errno
(
pSql
);
if
(
0
==
code
)
{
break
;
}
}
if
(
code
!=
0
)
{
fprintf
(
stderr
,
"Failed to run %s, reason: %s
\n
"
,
command
,
taos_errstr
(
pSql
));
taos_free_result
(
pSql
);
taos_close
(
taos
);
exit
(
EXIT_FAILURE
);
}
taos_free_result
(
pSql
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
TAOS
*
taos
;
char
qstr
[
1024
];
...
...
@@ -44,22 +72,26 @@ int main(int argc, char *argv[]) {
printf
(
"success to connect to server
\n
"
);
taos_query
(
taos
,
"drop database demo"
);
//taos_query(taos, "drop database demo");
queryDB
(
taos
,
"drop database if exists demo"
);
result
=
taos_query
(
taos
,
"create database demo"
);
if
(
result
==
NULL
)
{
printf
(
"failed to create database, reason:%s
\n
"
,
"null result"
/*taos_errstr(taos)*/
);
exit
(
1
);
}
//result = taos_query(taos, "create database demo");
//if (result == NULL) {
// printf("failed to create database, reason:%s\n", "null result"/*taos_errstr(taos)*/);
// exit(1);
//}
queryDB
(
taos
,
"create database demo"
);
printf
(
"success to create database
\n
"
);
taos_query
(
taos
,
"use demo"
);
//taos_query(taos, "use demo");
queryDB
(
taos
,
"use demo"
);
// create table
if
(
taos_query
(
taos
,
"create table m1 (ts timestamp, ti tinyint, si smallint, i int, bi bigint, f float, d double, b binary(10))"
)
==
0
)
{
printf
(
"failed to create table, reason:%s
\n
"
,
taos_errstr
(
result
));
exit
(
1
);
}
//if (taos_query(taos, "create table m1 (ts timestamp, ti tinyint, si smallint, i int, bi bigint, f float, d double, b binary(10))") == 0) {
// printf("failed to create table, reason:%s\n", taos_errstr(result));
// exit(1);
//}
queryDB
(
taos
,
"create table m1 (ts timestamp, ti tinyint, si smallint, i int, bi bigint, f float, d double, b binary(10))"
);
printf
(
"success to create table
\n
"
);
// sleep for one second to make sure table is created on data node
...
...
@@ -80,8 +112,10 @@ int main(int argc, char *argv[]) {
printf
(
"insert row: %i
\n
"
,
i
);
}
else
{
printf
(
"failed to insert row: %i, reason:%s
\n
"
,
i
,
"null result"
/*taos_errstr(result)*/
);
taos_free_result
(
result
);
exit
(
1
);
}
taos_free_result
(
result
);
//sleep(1);
}
...
...
@@ -91,7 +125,8 @@ int main(int argc, char *argv[]) {
sprintf
(
qstr
,
"SELECT * FROM m1"
);
result
=
taos_query
(
taos
,
qstr
);
if
(
result
==
NULL
||
taos_errno
(
result
)
!=
0
)
{
printf
(
"failed to select, reason:%s
\n
"
,
taos_errstr
(
result
));
printf
(
"failed to select, reason:%s
\n
"
,
taos_errstr
(
result
));
taos_free_result
(
result
);
exit
(
1
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录