Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a69c1aa4
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a69c1aa4
编写于
8月 26, 2021
作者:
Z
zhaoyanggh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add more tag test
上级
98f476d8
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
274 addition
and
135 deletion
+274
-135
tests/examples/c/makefile
tests/examples/c/makefile
+1
-0
tests/examples/c/prepare.c
tests/examples/c/prepare.c
+273
-135
未找到文件。
tests/examples/c/makefile
浏览文件 @
a69c1aa4
...
@@ -7,6 +7,7 @@ LFLAGS = '-Wl,-rpath,/usr/local/taos/driver/' -ltaos -lpthread -lm -lrt
...
@@ -7,6 +7,7 @@ LFLAGS = '-Wl,-rpath,/usr/local/taos/driver/' -ltaos -lpthread -lm -lrt
CFLAGS
=
-O3
-g
-Wall
-Wno-deprecated
-fPIC
-Wno-unused-result
-Wconversion
\
CFLAGS
=
-O3
-g
-Wall
-Wno-deprecated
-fPIC
-Wno-unused-result
-Wconversion
\
-Wno-char-subscripts
-D_REENTRANT
-Wno-format
-D_REENTRANT
-DLINUX
\
-Wno-char-subscripts
-D_REENTRANT
-Wno-format
-D_REENTRANT
-DLINUX
\
-Wno-unused-function
-D_M_X64
-I
/usr/local/taos/include
-std
=
gnu99
-Wno-unused-function
-D_M_X64
-I
/usr/local/taos/include
-std
=
gnu99
-fsanitize
=
address
-fsanitize
=
undefined
-fno-sanitize-recover
=
all
-fsanitize
=
float-divide-by-zero
-fsanitize
=
float-cast-overflow
-fno-sanitize
=
null
-fno-sanitize
=
alignment
all
:
$(TARGET)
all
:
$(TARGET)
...
...
tests/examples/c/prepare.c
浏览文件 @
a69c1aa4
...
@@ -237,7 +237,7 @@ void verify_prepare2(TAOS* taos) {
...
@@ -237,7 +237,7 @@ void verify_prepare2(TAOS* taos) {
// create table
// create table
const
char
*
sql
=
const
char
*
sql
=
"create table m1 (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, bin "
"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))"
;
"binary(40), blob nchar(10)
, u1 tinyint unsigned, u2 smallint unsigned, u4 int unsigned, u8 bigint unsigned
)"
;
result
=
taos_query
(
taos
,
sql
);
result
=
taos_query
(
taos
,
sql
);
code
=
taos_errno
(
result
);
code
=
taos_errno
(
result
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
...
@@ -249,102 +249,110 @@ void verify_prepare2(TAOS* taos) {
...
@@ -249,102 +249,110 @@ void verify_prepare2(TAOS* taos) {
// insert 10 records
// insert 10 records
struct
{
struct
{
int64_t
ts
[
10
];
int64_t
ts
;
int8_t
b
[
10
];
int8_t
b
;
int8_t
v1
[
10
];
int8_t
v1
;
int16_t
v2
[
10
];
int16_t
v2
;
int32_t
v4
[
10
];
int32_t
v4
;
int64_t
v8
[
10
];
int64_t
v8
;
float
f4
[
10
];
float
f4
;
double
f8
[
10
];
double
f8
;
char
bin
[
10
][
40
];
char
bin
[
40
];
char
blob
[
10
][
80
];
char
blob
[
80
];
}
v
;
uint8_t
u1
;
uint16_t
u2
;
int32_t
*
t8_len
=
malloc
(
sizeof
(
int32_t
)
*
10
);
uint32_t
u4
;
int32_t
*
t16_len
=
malloc
(
sizeof
(
int32_t
)
*
10
);
uint64_t
u8
;
int32_t
*
t32_len
=
malloc
(
sizeof
(
int32_t
)
*
10
);
}
v
=
{
0
};
int32_t
*
t64_len
=
malloc
(
sizeof
(
int32_t
)
*
10
);
int32_t
*
float_len
=
malloc
(
sizeof
(
int32_t
)
*
10
);
int32_t
*
double_len
=
malloc
(
sizeof
(
int32_t
)
*
10
);
int32_t
*
bin_len
=
malloc
(
sizeof
(
int32_t
)
*
10
);
int32_t
*
blob_len
=
malloc
(
sizeof
(
int32_t
)
*
10
);
TAOS_STMT
*
stmt
=
taos_stmt_init
(
taos
);
TAOS_STMT
*
stmt
=
taos_stmt_init
(
taos
);
TAOS_MULTI_BIND
params
[
10
];
TAOS_BIND
params
[
14
];
char
is_null
[
10
]
=
{
0
};
params
[
0
].
buffer_type
=
TSDB_DATA_TYPE_TIMESTAMP
;
params
[
0
].
buffer_type
=
TSDB_DATA_TYPE_TIMESTAMP
;
params
[
0
].
buffer_length
=
sizeof
(
v
.
ts
[
0
]);
params
[
0
].
buffer_length
=
sizeof
(
v
.
ts
);
params
[
0
].
buffer
=
v
.
ts
;
params
[
0
].
buffer
=
&
v
.
ts
;
params
[
0
].
length
=
t64_len
;
params
[
0
].
length
=
&
params
[
0
].
buffer_length
;
params
[
0
].
is_null
=
is_null
;
params
[
0
].
is_null
=
NULL
;
params
[
0
].
num
=
10
;
params
[
1
].
buffer_type
=
TSDB_DATA_TYPE_BOOL
;
params
[
1
].
buffer_type
=
TSDB_DATA_TYPE_BOOL
;
params
[
1
].
buffer_length
=
sizeof
(
v
.
b
[
0
]);
params
[
1
].
buffer_length
=
sizeof
(
v
.
b
);
params
[
1
].
buffer
=
v
.
b
;
params
[
1
].
buffer
=
&
v
.
b
;
params
[
1
].
length
=
t8_len
;
params
[
1
].
length
=
&
params
[
1
].
buffer_length
;
params
[
1
].
is_null
=
is_null
;
params
[
1
].
is_null
=
NULL
;
params
[
1
].
num
=
10
;
params
[
2
].
buffer_type
=
TSDB_DATA_TYPE_TINYINT
;
params
[
2
].
buffer_type
=
TSDB_DATA_TYPE_TINYINT
;
params
[
2
].
buffer_length
=
sizeof
(
v
.
v1
[
0
]);
params
[
2
].
buffer_length
=
sizeof
(
v
.
v1
);
params
[
2
].
buffer
=
v
.
v1
;
params
[
2
].
buffer
=
&
v
.
v1
;
params
[
2
].
length
=
t8_len
;
params
[
2
].
length
=
&
params
[
2
].
buffer_length
;
params
[
2
].
is_null
=
is_null
;
params
[
2
].
is_null
=
NULL
;
params
[
2
].
num
=
10
;
params
[
3
].
buffer_type
=
TSDB_DATA_TYPE_SMALLINT
;
params
[
3
].
buffer_type
=
TSDB_DATA_TYPE_SMALLINT
;
params
[
3
].
buffer_length
=
sizeof
(
v
.
v2
[
0
]);
params
[
3
].
buffer_length
=
sizeof
(
v
.
v2
);
params
[
3
].
buffer
=
v
.
v2
;
params
[
3
].
buffer
=
&
v
.
v2
;
params
[
3
].
length
=
t16_len
;
params
[
3
].
length
=
&
params
[
3
].
buffer_length
;
params
[
3
].
is_null
=
is_null
;
params
[
3
].
is_null
=
NULL
;
params
[
3
].
num
=
10
;
params
[
4
].
buffer_type
=
TSDB_DATA_TYPE_INT
;
params
[
4
].
buffer_type
=
TSDB_DATA_TYPE_INT
;
params
[
4
].
buffer_length
=
sizeof
(
v
.
v4
[
0
]);
params
[
4
].
buffer_length
=
sizeof
(
v
.
v4
);
params
[
4
].
buffer
=
v
.
v4
;
params
[
4
].
buffer
=
&
v
.
v4
;
params
[
4
].
length
=
t32_len
;
params
[
4
].
length
=
&
params
[
4
].
buffer_length
;
params
[
4
].
is_null
=
is_null
;
params
[
4
].
is_null
=
NULL
;
params
[
4
].
num
=
10
;
params
[
5
].
buffer_type
=
TSDB_DATA_TYPE_BIGINT
;
params
[
5
].
buffer_type
=
TSDB_DATA_TYPE_BIGINT
;
params
[
5
].
buffer_length
=
sizeof
(
v
.
v8
[
0
]);
params
[
5
].
buffer_length
=
sizeof
(
v
.
v8
);
params
[
5
].
buffer
=
v
.
v8
;
params
[
5
].
buffer
=
&
v
.
v8
;
params
[
5
].
length
=
t64_len
;
params
[
5
].
length
=
&
params
[
5
].
buffer_length
;
params
[
5
].
is_null
=
is_null
;
params
[
5
].
is_null
=
NULL
;
params
[
5
].
num
=
10
;
params
[
6
].
buffer_type
=
TSDB_DATA_TYPE_FLOAT
;
params
[
6
].
buffer_type
=
TSDB_DATA_TYPE_FLOAT
;
params
[
6
].
buffer_length
=
sizeof
(
v
.
f4
[
0
]);
params
[
6
].
buffer_length
=
sizeof
(
v
.
f4
);
params
[
6
].
buffer
=
v
.
f4
;
params
[
6
].
buffer
=
&
v
.
f4
;
params
[
6
].
length
=
float_len
;
params
[
6
].
length
=
&
params
[
6
].
buffer_length
;
params
[
6
].
is_null
=
is_null
;
params
[
6
].
is_null
=
NULL
;
params
[
6
].
num
=
10
;
params
[
7
].
buffer_type
=
TSDB_DATA_TYPE_DOUBLE
;
params
[
7
].
buffer_type
=
TSDB_DATA_TYPE_DOUBLE
;
params
[
7
].
buffer_length
=
sizeof
(
v
.
f8
[
0
]);
params
[
7
].
buffer_length
=
sizeof
(
v
.
f8
);
params
[
7
].
buffer
=
v
.
f8
;
params
[
7
].
buffer
=
&
v
.
f8
;
params
[
7
].
length
=
double_len
;
params
[
7
].
length
=
&
params
[
7
].
buffer_length
;
params
[
7
].
is_null
=
is_null
;
params
[
7
].
is_null
=
NULL
;
params
[
7
].
num
=
10
;
params
[
8
].
buffer_type
=
TSDB_DATA_TYPE_BINARY
;
params
[
8
].
buffer_type
=
TSDB_DATA_TYPE_BINARY
;
params
[
8
].
buffer_length
=
sizeof
(
v
.
bin
[
0
]
);
params
[
8
].
buffer_length
=
sizeof
(
v
.
bin
);
params
[
8
].
buffer
=
v
.
bin
;
params
[
8
].
buffer
=
v
.
bin
;
params
[
8
].
length
=
bin_len
;
params
[
8
].
length
=
&
params
[
8
].
buffer_length
;
params
[
8
].
is_null
=
is_null
;
params
[
8
].
is_null
=
NULL
;
params
[
8
].
num
=
10
;
strcpy
(
v
.
blob
,
"一二三四五六七八九十"
);
params
[
9
].
buffer_type
=
TSDB_DATA_TYPE_NCHAR
;
params
[
9
].
buffer_type
=
TSDB_DATA_TYPE_NCHAR
;
params
[
9
].
buffer_length
=
s
izeof
(
v
.
blob
[
0
]
);
params
[
9
].
buffer_length
=
s
trlen
(
v
.
blob
);
params
[
9
].
buffer
=
v
.
blob
;
params
[
9
].
buffer
=
v
.
blob
;
params
[
9
].
length
=
blob_len
;
params
[
9
].
length
=
&
params
[
9
].
buffer_length
;
params
[
9
].
is_null
=
is_null
;
params
[
9
].
is_null
=
NULL
;
params
[
9
].
num
=
10
;
params
[
10
].
buffer_type
=
TSDB_DATA_TYPE_UTINYINT
;
params
[
10
].
buffer_length
=
sizeof
(
v
.
u1
);
params
[
10
].
buffer
=
&
v
.
u1
;
params
[
10
].
length
=
&
params
[
10
].
buffer_length
;
params
[
10
].
is_null
=
NULL
;
params
[
11
].
buffer_type
=
TSDB_DATA_TYPE_USMALLINT
;
params
[
11
].
buffer_length
=
sizeof
(
v
.
u2
);
params
[
11
].
buffer
=
&
v
.
u2
;
params
[
11
].
length
=
&
params
[
11
].
buffer_length
;
params
[
11
].
is_null
=
NULL
;
params
[
12
].
buffer_type
=
TSDB_DATA_TYPE_UINT
;
params
[
12
].
buffer_length
=
sizeof
(
v
.
u4
);
params
[
12
].
buffer
=
&
v
.
u4
;
params
[
12
].
length
=
&
params
[
12
].
buffer_length
;
params
[
12
].
is_null
=
NULL
;
sql
=
"insert into ? (ts, b, v1, v2, v4, v8, f4, f8, bin, blob) values(?,?,?,?,?,?,?,?,?,?)"
;
params
[
13
].
buffer_type
=
TSDB_DATA_TYPE_UBIGINT
;
params
[
13
].
buffer_length
=
sizeof
(
v
.
u8
);
params
[
13
].
buffer
=
&
v
.
u8
;
params
[
13
].
length
=
&
params
[
13
].
buffer_length
;
params
[
13
].
is_null
=
NULL
;
sql
=
"insert into ? values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
;
code
=
taos_stmt_prepare
(
stmt
,
sql
,
0
);
code
=
taos_stmt_prepare
(
stmt
,
sql
,
0
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
printf
(
"
\033
[31mfailed to execute taos_stmt_prepare. error:%s
\033
[0m
\n
"
,
taos_stmt_errstr
(
stmt
));
printf
(
"
\033
[31mfailed to execute taos_stmt_prepare. error:%s
\033
[0m
\n
"
,
taos_stmt_errstr
(
stmt
));
...
@@ -359,35 +367,32 @@ void verify_prepare2(TAOS* taos) {
...
@@ -359,35 +367,32 @@ void verify_prepare2(TAOS* taos) {
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
int64_t
ts
=
1591060628000
;
int
is_null
=
1
;
for
(
int
i
=
0
;
i
<
10
;
++
i
)
{
v
.
ts
[
i
]
=
ts
++
;
is_null
[
i
]
=
0
;
v
.
b
[
i
]
=
(
int8_t
)
i
%
2
;
v
.
ts
=
1591060628000
;
v
.
v1
[
i
]
=
(
int8_t
)
i
;
for
(
int
i
=
0
;
i
<
10
;
++
i
)
{
v
.
v2
[
i
]
=
(
int16_t
)(
i
*
2
);
v
.
ts
+=
1
;
v
.
v4
[
i
]
=
(
int32_t
)(
i
*
4
);
for
(
int
j
=
1
;
j
<
10
;
++
j
)
{
v
.
v8
[
i
]
=
(
int64_t
)(
i
*
8
);
params
[
j
].
is_null
=
((
i
==
j
)
?
&
is_null
:
0
);
v
.
f4
[
i
]
=
(
float
)(
i
*
40
);
v
.
f8
[
i
]
=
(
double
)(
i
*
80
);
for
(
int
j
=
0
;
j
<
sizeof
(
v
.
bin
[
0
]);
++
j
)
{
v
.
bin
[
i
][
j
]
=
(
char
)(
i
+
'0'
);
}
}
strcpy
(
v
.
blob
[
i
],
"一二三四五六七八九十"
);
v
.
b
=
(
int8_t
)
i
%
2
;
v
.
v1
=
(
int8_t
)
i
;
t8_len
[
i
]
=
sizeof
(
int8_t
);
v
.
v2
=
(
int16_t
)(
i
*
2
);
t16_len
[
i
]
=
sizeof
(
int16_t
);
v
.
v4
=
(
int32_t
)(
i
*
4
);
t32_len
[
i
]
=
sizeof
(
int32_t
);
v
.
v8
=
(
int64_t
)(
i
*
8
);
t64_len
[
i
]
=
sizeof
(
int64_t
);
v
.
f4
=
(
float
)(
i
*
40
);
float_len
[
i
]
=
sizeof
(
float
);
v
.
f8
=
(
double
)(
i
*
80
);
double_len
[
i
]
=
sizeof
(
double
);
for
(
int
j
=
0
;
j
<
sizeof
(
v
.
bin
);
++
j
)
{
bin_len
[
i
]
=
sizeof
(
v
.
bin
[
0
]);
v
.
bin
[
j
]
=
(
char
)(
i
+
'0'
);
blob_len
[
i
]
=
(
int32_t
)
strlen
(
v
.
blob
[
i
]);
}
}
v
.
u1
=
(
uint8_t
)
i
;
v
.
u2
=
(
uint16_t
)(
i
*
2
);
v
.
u4
=
(
uint32_t
)(
i
*
4
);
v
.
u8
=
(
uint64_t
)(
i
*
8
);
taos_stmt_bind_param_batch
(
stmt
,
params
);
taos_stmt_bind_param
(
stmt
,
params
);
taos_stmt_add_batch
(
stmt
);
taos_stmt_add_batch
(
stmt
);
}
if
(
taos_stmt_execute
(
stmt
)
!=
0
)
{
if
(
taos_stmt_execute
(
stmt
)
!=
0
)
{
printf
(
"
\033
[31mfailed to execute insert statement.error:%s
\033
[0m
\n
"
,
taos_stmt_errstr
(
stmt
));
printf
(
"
\033
[31mfailed to execute insert statement.error:%s
\033
[0m
\n
"
,
taos_stmt_errstr
(
stmt
));
...
@@ -440,15 +445,6 @@ void verify_prepare2(TAOS* taos) {
...
@@ -440,15 +445,6 @@ void verify_prepare2(TAOS* taos) {
taos_free_result
(
result
);
taos_free_result
(
result
);
taos_stmt_close
(
stmt
);
taos_stmt_close
(
stmt
);
free
(
t8_len
);
free
(
t16_len
);
free
(
t32_len
);
free
(
t64_len
);
free
(
float_len
);
free
(
double_len
);
free
(
bin_len
);
free
(
blob_len
);
}
}
void
verify_prepare3
(
TAOS
*
taos
)
{
void
verify_prepare3
(
TAOS
*
taos
)
{
...
@@ -471,7 +467,12 @@ void verify_prepare3(TAOS* taos) {
...
@@ -471,7 +467,12 @@ void verify_prepare3(TAOS* taos) {
// create table
// create table
const
char
*
sql
=
const
char
*
sql
=
"create stable st1 (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, bin "
"create stable st1 (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, bin "
"binary(40), blob nchar(10)) tags (id1 int, id2 binary(40))"
;
"binary(40), blob nchar(10), u1 tinyint unsigned, u2 smallint unsigned, u4 int unsigned, u8 bigint unsigned) "
"tags "
"(b_tag bool, v1_tag tinyint, v2_tag smallint, v4_tag int, v8_tag bigint, f4_tag float, f8_tag double, bin_tag "
"binary(40), blob_tag nchar(10), u1_tag tinyint unsigned, u2_tag smallint unsigned, u4_tag int unsigned, u8_tag "
"bigint "
"unsigned)"
;
result
=
taos_query
(
taos
,
sql
);
result
=
taos_query
(
taos
,
sql
);
code
=
taos_errno
(
result
);
code
=
taos_errno
(
result
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
...
@@ -481,24 +482,117 @@ void verify_prepare3(TAOS* taos) {
...
@@ -481,24 +482,117 @@ void verify_prepare3(TAOS* taos) {
}
}
taos_free_result
(
result
);
taos_free_result
(
result
);
TAOS_BIND
tags
[
2
];
TAOS_BIND
tags
[
13
];
int32_t
id1
=
1
;
char
id2
[
40
]
=
"abcdefghijklmnopqrstuvwxyz0123456789"
;
uintptr_t
id2_len
=
strlen
(
id2
);
tags
[
0
].
buffer_type
=
TSDB_DATA_TYPE_INT
;
struct
{
tags
[
0
].
buffer_length
=
sizeof
(
int
);
int8_t
b
;
tags
[
0
].
buffer
=
&
id1
;
int8_t
v1
;
tags
[
0
].
length
=
NULL
;
int16_t
v2
;
int32_t
v4
;
int64_t
v8
;
float
f4
;
double
f8
;
char
bin
[
40
];
char
blob
[
80
];
uint8_t
u1
;
uint16_t
u2
;
uint32_t
u4
;
uint64_t
u8
;
}
id
=
{
0
};
id
.
b
=
(
int8_t
)
1
;
id
.
v1
=
(
int8_t
)
1
;
id
.
v2
=
(
int16_t
)
2
;
id
.
v4
=
(
int32_t
)
4
;
id
.
v8
=
(
int64_t
)
8
;
id
.
f4
=
(
float
)
40
;
id
.
f8
=
(
double
)
80
;
for
(
int
j
=
0
;
j
<
sizeof
(
id
.
bin
);
++
j
)
{
id
.
bin
[
j
]
=
(
char
)(
'1'
+
'0'
);
}
strcpy
(
id
.
blob
,
"一二三四五六七八九十"
);
id
.
u1
=
(
uint8_t
)
1
;
id
.
u2
=
(
uint16_t
)
2
;
id
.
u4
=
(
uint32_t
)
4
;
id
.
u8
=
(
uint64_t
)
8
;
tags
[
0
].
buffer_type
=
TSDB_DATA_TYPE_BOOL
;
tags
[
0
].
buffer_length
=
sizeof
(
id
.
b
);
tags
[
0
].
buffer
=
&
id
.
b
;
tags
[
0
].
length
=
&
tags
[
0
].
buffer_length
;
tags
[
0
].
is_null
=
NULL
;
tags
[
0
].
is_null
=
NULL
;
tags
[
1
].
buffer_type
=
TSDB_DATA_TYPE_
BINARY
;
tags
[
1
].
buffer_type
=
TSDB_DATA_TYPE_
TINYINT
;
tags
[
1
].
buffer_length
=
sizeof
(
id
2
);
tags
[
1
].
buffer_length
=
sizeof
(
id
.
v1
);
tags
[
1
].
buffer
=
id2
;
tags
[
1
].
buffer
=
&
id
.
v1
;
tags
[
1
].
length
=
&
id2_len
;
tags
[
1
].
length
=
&
tags
[
1
].
buffer_length
;
tags
[
1
].
is_null
=
NULL
;
tags
[
1
].
is_null
=
NULL
;
tags
[
2
].
buffer_type
=
TSDB_DATA_TYPE_SMALLINT
;
tags
[
2
].
buffer_length
=
sizeof
(
id
.
v2
);
tags
[
2
].
buffer
=
&
id
.
v2
;
tags
[
2
].
length
=
&
tags
[
2
].
buffer_length
;
tags
[
2
].
is_null
=
NULL
;
tags
[
3
].
buffer_type
=
TSDB_DATA_TYPE_INT
;
tags
[
3
].
buffer_length
=
sizeof
(
id
.
v4
);
tags
[
3
].
buffer
=
&
id
.
v4
;
tags
[
3
].
length
=
&
tags
[
3
].
buffer_length
;
tags
[
3
].
is_null
=
NULL
;
tags
[
4
].
buffer_type
=
TSDB_DATA_TYPE_BIGINT
;
tags
[
4
].
buffer_length
=
sizeof
(
id
.
v8
);
tags
[
4
].
buffer
=
&
id
.
v8
;
tags
[
4
].
length
=
&
tags
[
4
].
buffer_length
;
tags
[
4
].
is_null
=
NULL
;
tags
[
5
].
buffer_type
=
TSDB_DATA_TYPE_FLOAT
;
tags
[
5
].
buffer_length
=
sizeof
(
id
.
f4
);
tags
[
5
].
buffer
=
&
id
.
f4
;
tags
[
5
].
length
=
&
tags
[
5
].
buffer_length
;
tags
[
5
].
is_null
=
NULL
;
tags
[
6
].
buffer_type
=
TSDB_DATA_TYPE_DOUBLE
;
tags
[
6
].
buffer_length
=
sizeof
(
id
.
f8
);
tags
[
6
].
buffer
=
&
id
.
f8
;
tags
[
6
].
length
=
&
tags
[
6
].
buffer_length
;
tags
[
6
].
is_null
=
NULL
;
tags
[
7
].
buffer_type
=
TSDB_DATA_TYPE_BINARY
;
tags
[
7
].
buffer_length
=
sizeof
(
id
.
bin
);
tags
[
7
].
buffer
=
&
id
.
bin
;
tags
[
7
].
length
=
&
tags
[
7
].
buffer_length
;
tags
[
7
].
is_null
=
NULL
;
tags
[
8
].
buffer_type
=
TSDB_DATA_TYPE_NCHAR
;
tags
[
8
].
buffer_length
=
strlen
(
id
.
blob
);
tags
[
8
].
buffer
=
&
id
.
blob
;
tags
[
8
].
length
=
&
tags
[
8
].
buffer_length
;
tags
[
8
].
is_null
=
NULL
;
tags
[
9
].
buffer_type
=
TSDB_DATA_TYPE_UTINYINT
;
tags
[
9
].
buffer_length
=
sizeof
(
id
.
u1
);
tags
[
9
].
buffer
=
&
id
.
u1
;
tags
[
9
].
length
=
&
tags
[
9
].
buffer_length
;
tags
[
9
].
is_null
=
NULL
;
tags
[
10
].
buffer_type
=
TSDB_DATA_TYPE_USMALLINT
;
tags
[
10
].
buffer_length
=
sizeof
(
id
.
u2
);
tags
[
10
].
buffer
=
&
id
.
u2
;
tags
[
10
].
length
=
&
tags
[
10
].
buffer_length
;
tags
[
10
].
is_null
=
NULL
;
tags
[
11
].
buffer_type
=
TSDB_DATA_TYPE_UINT
;
tags
[
11
].
buffer_length
=
sizeof
(
id
.
u4
);
tags
[
11
].
buffer
=
&
id
.
u4
;
tags
[
11
].
length
=
&
tags
[
11
].
buffer_length
;
tags
[
11
].
is_null
=
NULL
;
tags
[
12
].
buffer_type
=
TSDB_DATA_TYPE_UBIGINT
;
tags
[
12
].
buffer_length
=
sizeof
(
id
.
u8
);
tags
[
12
].
buffer
=
&
id
.
u8
;
tags
[
12
].
length
=
&
tags
[
12
].
buffer_length
;
tags
[
12
].
is_null
=
NULL
;
// insert 10 records
// insert 10 records
struct
{
struct
{
int64_t
ts
[
10
];
int64_t
ts
[
10
];
...
@@ -511,6 +605,10 @@ void verify_prepare3(TAOS* taos) {
...
@@ -511,6 +605,10 @@ void verify_prepare3(TAOS* taos) {
double
f8
[
10
];
double
f8
[
10
];
char
bin
[
10
][
40
];
char
bin
[
10
][
40
];
char
blob
[
10
][
80
];
char
blob
[
10
][
80
];
uint8_t
u1
[
10
];
uint16_t
u2
[
10
];
uint32_t
u4
[
10
];
uint64_t
u8
[
10
];
}
v
;
}
v
;
int32_t
*
t8_len
=
malloc
(
sizeof
(
int32_t
)
*
10
);
int32_t
*
t8_len
=
malloc
(
sizeof
(
int32_t
)
*
10
);
...
@@ -521,9 +619,13 @@ void verify_prepare3(TAOS* taos) {
...
@@ -521,9 +619,13 @@ void verify_prepare3(TAOS* taos) {
int32_t
*
double_len
=
malloc
(
sizeof
(
int32_t
)
*
10
);
int32_t
*
double_len
=
malloc
(
sizeof
(
int32_t
)
*
10
);
int32_t
*
bin_len
=
malloc
(
sizeof
(
int32_t
)
*
10
);
int32_t
*
bin_len
=
malloc
(
sizeof
(
int32_t
)
*
10
);
int32_t
*
blob_len
=
malloc
(
sizeof
(
int32_t
)
*
10
);
int32_t
*
blob_len
=
malloc
(
sizeof
(
int32_t
)
*
10
);
int32_t
*
u8_len
=
malloc
(
sizeof
(
int32_t
)
*
10
);
int32_t
*
u16_len
=
malloc
(
sizeof
(
int32_t
)
*
10
);
int32_t
*
u32_len
=
malloc
(
sizeof
(
int32_t
)
*
10
);
int32_t
*
u64_len
=
malloc
(
sizeof
(
int32_t
)
*
10
);
TAOS_STMT
*
stmt
=
taos_stmt_init
(
taos
);
TAOS_STMT
*
stmt
=
taos_stmt_init
(
taos
);
TAOS_MULTI_BIND
params
[
1
0
];
TAOS_MULTI_BIND
params
[
1
4
];
char
is_null
[
10
]
=
{
0
};
char
is_null
[
10
]
=
{
0
};
params
[
0
].
buffer_type
=
TSDB_DATA_TYPE_TIMESTAMP
;
params
[
0
].
buffer_type
=
TSDB_DATA_TYPE_TIMESTAMP
;
...
@@ -596,7 +698,35 @@ void verify_prepare3(TAOS* taos) {
...
@@ -596,7 +698,35 @@ void verify_prepare3(TAOS* taos) {
params
[
9
].
is_null
=
is_null
;
params
[
9
].
is_null
=
is_null
;
params
[
9
].
num
=
10
;
params
[
9
].
num
=
10
;
sql
=
"insert into ? using st1 tags(?,?) values(?,?,?,?,?,?,?,?,?,?)"
;
params
[
10
].
buffer_type
=
TSDB_DATA_TYPE_UTINYINT
;
params
[
10
].
buffer_length
=
sizeof
(
v
.
u1
[
0
]);
params
[
10
].
buffer
=
v
.
u1
;
params
[
10
].
length
=
u8_len
;
params
[
10
].
is_null
=
is_null
;
params
[
10
].
num
=
10
;
params
[
11
].
buffer_type
=
TSDB_DATA_TYPE_USMALLINT
;
params
[
11
].
buffer_length
=
sizeof
(
v
.
u2
[
0
]);
params
[
11
].
buffer
=
v
.
u2
;
params
[
11
].
length
=
u16_len
;
params
[
11
].
is_null
=
is_null
;
params
[
11
].
num
=
10
;
params
[
12
].
buffer_type
=
TSDB_DATA_TYPE_UINT
;
params
[
12
].
buffer_length
=
sizeof
(
v
.
u4
[
0
]);
params
[
12
].
buffer
=
v
.
u4
;
params
[
12
].
length
=
u32_len
;
params
[
12
].
is_null
=
is_null
;
params
[
12
].
num
=
10
;
params
[
13
].
buffer_type
=
TSDB_DATA_TYPE_UBIGINT
;
params
[
13
].
buffer_length
=
sizeof
(
v
.
u8
[
0
]);
params
[
13
].
buffer
=
v
.
u8
;
params
[
13
].
length
=
u64_len
;
params
[
13
].
is_null
=
is_null
;
params
[
13
].
num
=
10
;
sql
=
"insert into ? using st1 tags(?,?,?,?,?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
;
code
=
taos_stmt_prepare
(
stmt
,
sql
,
0
);
code
=
taos_stmt_prepare
(
stmt
,
sql
,
0
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
printf
(
"
\033
[31mfailed to execute taos_stmt_prepare. error:%s
\033
[0m
\n
"
,
taos_stmt_errstr
(
stmt
));
printf
(
"
\033
[31mfailed to execute taos_stmt_prepare. error:%s
\033
[0m
\n
"
,
taos_stmt_errstr
(
stmt
));
...
@@ -606,7 +736,7 @@ void verify_prepare3(TAOS* taos) {
...
@@ -606,7 +736,7 @@ void verify_prepare3(TAOS* taos) {
code
=
taos_stmt_set_tbname_tags
(
stmt
,
"m1"
,
tags
);
code
=
taos_stmt_set_tbname_tags
(
stmt
,
"m1"
,
tags
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
printf
(
"
\033
[31mfailed to execute taos_stmt_
prepare
. error:%s
\033
[0m
\n
"
,
taos_stmt_errstr
(
stmt
));
printf
(
"
\033
[31mfailed to execute taos_stmt_
set_tbname_tags
. error:%s
\033
[0m
\n
"
,
taos_stmt_errstr
(
stmt
));
taos_stmt_close
(
stmt
);
taos_stmt_close
(
stmt
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
...
@@ -627,6 +757,10 @@ void verify_prepare3(TAOS* taos) {
...
@@ -627,6 +757,10 @@ void verify_prepare3(TAOS* taos) {
v
.
bin
[
i
][
j
]
=
(
char
)(
i
+
'0'
);
v
.
bin
[
i
][
j
]
=
(
char
)(
i
+
'0'
);
}
}
strcpy
(
v
.
blob
[
i
],
"一二三四五六七八九十"
);
strcpy
(
v
.
blob
[
i
],
"一二三四五六七八九十"
);
v
.
u1
[
i
]
=
(
uint8_t
)
i
;
v
.
u2
[
i
]
=
(
uint16_t
)(
i
*
2
);
v
.
u4
[
i
]
=
(
uint32_t
)(
i
*
4
);
v
.
u8
[
i
]
=
(
uint64_t
)(
i
*
8
);
t8_len
[
i
]
=
sizeof
(
int8_t
);
t8_len
[
i
]
=
sizeof
(
int8_t
);
t16_len
[
i
]
=
sizeof
(
int16_t
);
t16_len
[
i
]
=
sizeof
(
int16_t
);
...
@@ -636,6 +770,10 @@ void verify_prepare3(TAOS* taos) {
...
@@ -636,6 +770,10 @@ void verify_prepare3(TAOS* taos) {
double_len
[
i
]
=
sizeof
(
double
);
double_len
[
i
]
=
sizeof
(
double
);
bin_len
[
i
]
=
sizeof
(
v
.
bin
[
0
]);
bin_len
[
i
]
=
sizeof
(
v
.
bin
[
0
]);
blob_len
[
i
]
=
(
int32_t
)
strlen
(
v
.
blob
[
i
]);
blob_len
[
i
]
=
(
int32_t
)
strlen
(
v
.
blob
[
i
]);
u8_len
[
i
]
=
sizeof
(
uint8_t
);
u16_len
[
i
]
=
sizeof
(
uint16_t
);
u32_len
[
i
]
=
sizeof
(
uint32_t
);
u64_len
[
i
]
=
sizeof
(
uint64_t
);
}
}
taos_stmt_bind_param_batch
(
stmt
,
params
);
taos_stmt_bind_param_batch
(
stmt
,
params
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录