Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f7a18273
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
f7a18273
编写于
6月 04, 2020
作者:
H
Hui Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[modify]
上级
36d91237
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
28 addition
and
20 deletion
+28
-20
src/client/src/tscPrepare.c
src/client/src/tscPrepare.c
+2
-5
tests/examples/c/prepare.c
tests/examples/c/prepare.c
+26
-15
未找到文件。
src/client/src/tscPrepare.c
浏览文件 @
f7a18273
...
@@ -614,11 +614,8 @@ int taos_stmt_execute(TAOS_STMT* stmt) {
...
@@ -614,11 +614,8 @@ int taos_stmt_execute(TAOS_STMT* stmt) {
tfree
(
pStmt
->
pSql
->
sqlstr
);
tfree
(
pStmt
->
pSql
->
sqlstr
);
pStmt
->
pSql
->
sqlstr
=
sql
;
pStmt
->
pSql
->
sqlstr
=
sql
;
SSqlObj
*
pSql
=
taos_query
((
TAOS
*
)
pStmt
->
taos
,
pStmt
->
pSql
->
sqlstr
);
SSqlObj
*
pSql
=
taos_query
((
TAOS
*
)
pStmt
->
taos
,
pStmt
->
pSql
->
sqlstr
);
if
(
pSql
!=
NULL
)
{
ret
=
taos_errno
(
pSql
);
ret
=
pSql
->
res
.
code
;
taos_free_result
(
pSql
);
}
else
{
ret
=
terrno
;
}
}
}
}
}
return
ret
;
return
ret
;
...
...
tests/examples/c/prepare.c
浏览文件 @
f7a18273
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
// # #include "taos.h" // TAOS header file
#include "taos.h"
#include "taos.h"
...
@@ -14,38 +15,49 @@ int main(int argc, char *argv[])
...
@@ -14,38 +15,49 @@ int main(int argc, char *argv[])
{
{
TAOS
*
taos
;
TAOS
*
taos
;
TAOS_RES
*
result
;
TAOS_RES
*
result
;
int
code
;
TAOS_STMT
*
stmt
;
TAOS_STMT
*
stmt
;
// connect to server
// connect to server
if
(
argc
<
2
)
{
//
if (argc < 2) {
printf
(
"please input server ip
\n
"
);
//
printf("please input server ip \n");
return
0
;
//
return 0;
}
//
}
// init TAOS
// init TAOS
taos_init
();
taos_init
();
taos
=
taos_connect
(
argv
[
1
]
,
"root"
,
"taosdata"
,
NULL
,
0
);
taos
=
taos_connect
(
"127.0.0.1"
,
"root"
,
"taosdata"
,
NULL
,
0
);
if
(
taos
==
NULL
)
{
if
(
taos
==
NULL
)
{
printf
(
"failed to connect to db, reason:%s
\n
"
,
taos_errstr
(
taos
));
printf
(
"failed to connect to db, reason:%s
\n
"
,
taos_errstr
(
taos
));
exit
(
1
);
exit
(
1
);
}
}
taos_query
(
taos
,
"drop database demo"
);
result
=
taos_query
(
taos
,
"drop database demo"
);
if
(
taos_query
(
taos
,
"create database demo"
)
!=
0
)
{
taos_free_result
(
result
);
printf
(
"failed to create database, reason:%s
\n
"
,
taos_errstr
(
taos
));
result
=
taos_query
(
taos
,
"create database demo"
);
code
=
taos_errno
(
result
);
if
(
code
!=
0
)
{
printf
(
"failed to create database, reason:%s
\n
"
,
taos_errstr
(
result
));
taos_free_result
(
result
);
exit
(
1
);
exit
(
1
);
}
}
taos_free_result
(
result
);
taos_query
(
taos
,
"use demo"
);
result
=
taos_query
(
taos
,
"use demo"
);
taos_free_result
(
result
);
// create table
// create table
const
char
*
sql
=
"create table m1 (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, bin binary(40), blob nchar(10))"
;
const
char
*
sql
=
"create table m1 (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, bin binary(40), blob nchar(10))"
;
if
(
taos_query
(
taos
,
sql
)
!=
0
)
{
result
=
taos_query
(
taos
,
sql
);
printf
(
"failed to create table, reason:%s
\n
"
,
taos_errstr
(
taos
));
code
=
taos_errno
(
result
);
if
(
code
!=
0
)
{
printf
(
"failed to create table, reason:%s
\n
"
,
taos_errstr
(
result
));
taos_free_result
(
result
);
exit
(
1
);
exit
(
1
);
}
}
taos_free_result
(
result
);
// sleep for one second to make sure table is created on data node
// sleep for one second to make sure table is created on data node
// taosMsleep(1000);
// taosMsleep(1000);
...
@@ -130,7 +142,7 @@ int main(int argc, char *argv[])
...
@@ -130,7 +142,7 @@ int main(int argc, char *argv[])
int
is_null
=
1
;
int
is_null
=
1
;
sql
=
"insert into m1 values(?,?,?,?,?,?,?,?,?,?)"
;
sql
=
"insert into m1 values(?,?,?,?,?,?,?,?,?,?)"
;
int
code
=
taos_stmt_prepare
(
stmt
,
sql
,
0
);
code
=
taos_stmt_prepare
(
stmt
,
sql
,
0
);
if
(
code
!=
0
){
if
(
code
!=
0
){
printf
(
"failed to execute taos_stmt_prepare. code:0x%x
\n
"
,
code
);
printf
(
"failed to execute taos_stmt_prepare. code:0x%x
\n
"
,
code
);
}
}
...
@@ -159,7 +171,6 @@ int main(int argc, char *argv[])
...
@@ -159,7 +171,6 @@ int main(int argc, char *argv[])
exit
(
1
);
exit
(
1
);
}
}
taos_stmt_close
(
stmt
);
taos_stmt_close
(
stmt
);
printf
(
"==== success inset data ====.
\n
"
);
// query the records
// query the records
stmt
=
taos_stmt_init
(
taos
);
stmt
=
taos_stmt_init
(
taos
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录