Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
1613b43f
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
1613b43f
编写于
11月 04, 2022
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add test
上级
9610efbd
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
279 addition
and
295 deletion
+279
-295
examples/c/CMakeLists.txt
examples/c/CMakeLists.txt
+19
-0
examples/c/apitest.c
examples/c/apitest.c
+259
-292
source/client/src/clientSml.c
source/client/src/clientSml.c
+1
-3
未找到文件。
examples/c/CMakeLists.txt
浏览文件 @
1613b43f
...
@@ -15,6 +15,7 @@ IF (TD_LINUX)
...
@@ -15,6 +15,7 @@ IF (TD_LINUX)
add_executable
(
tmq
""
)
add_executable
(
tmq
""
)
add_executable
(
stream_demo
""
)
add_executable
(
stream_demo
""
)
add_executable
(
demoapi
""
)
add_executable
(
demoapi
""
)
add_executable
(
api_reqid
""
)
target_sources
(
tmq
target_sources
(
tmq
PRIVATE
PRIVATE
...
@@ -31,6 +32,12 @@ IF (TD_LINUX)
...
@@ -31,6 +32,12 @@ IF (TD_LINUX)
"demoapi.c"
"demoapi.c"
)
)
target_sources
(
api_reqid
PRIVATE
"api_with_reqid_test.c"
)
target_link_libraries
(
tmq
target_link_libraries
(
tmq
taos_static
taos_static
)
)
...
@@ -43,6 +50,11 @@ IF (TD_LINUX)
...
@@ -43,6 +50,11 @@ IF (TD_LINUX)
taos_static
taos_static
)
)
target_link_libraries
(
api_reqid
taos_static
)
target_include_directories
(
tmq
target_include_directories
(
tmq
PUBLIC
"
${
TD_SOURCE_DIR
}
/include/os"
PUBLIC
"
${
TD_SOURCE_DIR
}
/include/os"
PRIVATE
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/inc"
PRIVATE
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/inc"
...
@@ -58,9 +70,16 @@ IF (TD_LINUX)
...
@@ -58,9 +70,16 @@ IF (TD_LINUX)
PRIVATE
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/inc"
PRIVATE
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/inc"
)
)
target_include_directories
(
api_reqid
PUBLIC
"
${
TD_SOURCE_DIR
}
/include/client"
PUBLIC
"
${
TD_SOURCE_DIR
}
/include/os"
PRIVATE
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/inc"
)
SET_TARGET_PROPERTIES
(
tmq PROPERTIES OUTPUT_NAME tmq
)
SET_TARGET_PROPERTIES
(
tmq PROPERTIES OUTPUT_NAME tmq
)
SET_TARGET_PROPERTIES
(
stream_demo PROPERTIES OUTPUT_NAME stream_demo
)
SET_TARGET_PROPERTIES
(
stream_demo PROPERTIES OUTPUT_NAME stream_demo
)
SET_TARGET_PROPERTIES
(
demoapi PROPERTIES OUTPUT_NAME demoapi
)
SET_TARGET_PROPERTIES
(
demoapi PROPERTIES OUTPUT_NAME demoapi
)
SET_TARGET_PROPERTIES
(
api_reqid PROPERTIES OUTPUT_NAME api_reqid
)
ENDIF
()
ENDIF
()
IF
(
TD_DARWIN
)
IF
(
TD_DARWIN
)
INCLUDE_DIRECTORIES
(
.
${
TD_SOURCE_DIR
}
/src/inc
${
TD_SOURCE_DIR
}
/src/client/inc
${
TD_SOURCE_DIR
}
/inc
)
INCLUDE_DIRECTORIES
(
.
${
TD_SOURCE_DIR
}
/src/inc
${
TD_SOURCE_DIR
}
/src/client/inc
${
TD_SOURCE_DIR
}
/inc
)
...
...
examples/c/apitest.c
浏览文件 @
1613b43f
// sample code to verify all TDengine API
// sample code to verify all TDengine API
// to compile: gcc -o apitest apitest.c -ltaos
// to compile: gcc -o apitest apitest.c -ltaos
#include "taoserror.h"
#include "cJSON.h"
#include "cJSON.h"
#include "taoserror.h"
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
#include "../../../include/client/taos.h"
#include "../../../include/client/taos.h"
static
void
prepare_data
(
TAOS
*
taos
)
{
static
void
prepare_data
(
TAOS
*
taos
)
{
TAOS_RES
*
result
;
TAOS_RES
*
result
;
result
=
taos_query
(
taos
,
"drop database if exists test;"
);
result
=
taos_query
(
taos
,
"drop database if exists test;"
);
taos_free_result
(
result
);
taos_free_result
(
result
);
usleep
(
100000
);
usleep
(
100000
);
...
@@ -44,24 +44,25 @@ static void prepare_data(TAOS* taos) {
...
@@ -44,24 +44,25 @@ static void prepare_data(TAOS* taos) {
result
=
taos_query
(
taos
,
"create table t9 using meters tags(9);"
);
result
=
taos_query
(
taos
,
"create table t9 using meters tags(9);"
);
taos_free_result
(
result
);
taos_free_result
(
result
);
result
=
taos_query
(
taos
,
"insert into t0 values('2020-01-01 00:00:00.000', 0)"
result
=
taos_query
(
taos
,
" ('2020-01-01 00:01:00.000', 0)"
"insert into t0 values('2020-01-01 00:00:00.000', 0)"
" ('2020-01-01 00:02:00.000', 0)"
" ('2020-01-01 00:01:00.000', 0)"
" t1 values('2020-01-01 00:00:00.000', 0)"
" ('2020-01-01 00:02:00.000', 0)"
" ('2020-01-01 00:01:00.000', 0)"
" t1 values('2020-01-01 00:00:00.000', 0)"
" ('2020-01-01 00:02:00.000', 0)"
" ('2020-01-01 00:01:00.000', 0)"
" ('2020-01-01 00:03:00.000', 0)"
" ('2020-01-01 00:02:00.000', 0)"
" t2 values('2020-01-01 00:00:00.000', 0)"
" ('2020-01-01 00:03:00.000', 0)"
" ('2020-01-01 00:01:00.000', 0)"
" t2 values('2020-01-01 00:00:00.000', 0)"
" ('2020-01-01 00:01:01.000', 0)"
" ('2020-01-01 00:01:00.000', 0)"
" ('2020-01-01 00:01:02.000', 0)"
" ('2020-01-01 00:01:01.000', 0)"
" t3 values('2020-01-01 00:01:02.000', 0)"
" ('2020-01-01 00:01:02.000', 0)"
" t4 values('2020-01-01 00:01:02.000', 0)"
" t3 values('2020-01-01 00:01:02.000', 0)"
" t5 values('2020-01-01 00:01:02.000', 0)"
" t4 values('2020-01-01 00:01:02.000', 0)"
" t6 values('2020-01-01 00:01:02.000', 0)"
" t5 values('2020-01-01 00:01:02.000', 0)"
" t7 values('2020-01-01 00:01:02.000', 0)"
" t6 values('2020-01-01 00:01:02.000', 0)"
" t8 values('2020-01-01 00:01:02.000', 0)"
" t7 values('2020-01-01 00:01:02.000', 0)"
" t9 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
(
result
);
int
affected
=
taos_affected_rows
(
result
);
if
(
affected
!=
18
)
{
if
(
affected
!=
18
)
{
printf
(
"
\033
[31m%d rows affected by last insert statement, but it should be 18
\033
[0m
\n
"
,
affected
);
printf
(
"
\033
[31m%d rows affected by last insert statement, but it should be 18
\033
[0m
\n
"
,
affected
);
...
@@ -80,11 +81,11 @@ static int print_result(TAOS_RES* res, int blockFetch) {
...
@@ -80,11 +81,11 @@ static int print_result(TAOS_RES* res, int blockFetch) {
if
(
blockFetch
)
{
if
(
blockFetch
)
{
int
rows
=
0
;
int
rows
=
0
;
while
((
rows
=
taos_fetch_block
(
res
,
&
row
)))
{
while
((
rows
=
taos_fetch_block
(
res
,
&
row
)))
{
//for (int i = 0; i < rows; i++) {
//
for (int i = 0; i < rows; i++) {
// char temp[256];
//
char temp[256];
// taos_print_row(temp, row + i, fields, num_fields);
//
taos_print_row(temp, row + i, fields, num_fields);
// puts(temp);
//
puts(temp);
//}
//
}
nRows
+=
rows
;
nRows
+=
rows
;
}
}
}
else
{
}
else
{
...
@@ -127,32 +128,32 @@ static void verify_query(TAOS* taos) {
...
@@ -127,32 +128,32 @@ static void verify_query(TAOS* taos) {
printf
(
"
\033
[31mimpossible, the table does exists: 0x%08x
\033
[0m
\n
"
,
code
);
printf
(
"
\033
[31mimpossible, the table does exists: 0x%08x
\033
[0m
\n
"
,
code
);
}
}
TAOS_RES
*
res
=
taos_query
(
taos
,
"select * from meters"
);
TAOS_RES
*
res
=
taos_query
_with_reqid
(
taos
,
"select * from meters"
,
genReqid
()
);
check_row_count
(
__LINE__
,
res
,
18
);
check_row_count
(
__LINE__
,
res
,
18
);
printf
(
"result precision is: %d
\n
"
,
taos_result_precision
(
res
));
printf
(
"result precision is: %d
\n
"
,
taos_result_precision
(
res
));
int
c
=
taos_field_count
(
res
);
int
c
=
taos_field_count
(
res
);
printf
(
"field count is: %d
\n
"
,
c
);
printf
(
"field count is: %d
\n
"
,
c
);
int
*
lengths
=
taos_fetch_lengths
(
res
);
int
*
lengths
=
taos_fetch_lengths
(
res
);
for
(
int
i
=
0
;
i
<
c
;
i
++
)
{
for
(
int
i
=
0
;
i
<
c
;
i
++
)
{
printf
(
"length of column %d is %d
\n
"
,
i
,
lengths
[
i
]);
printf
(
"length of column %d is %d
\n
"
,
i
,
lengths
[
i
]);
}
}
taos_free_result
(
res
);
taos_free_result
(
res
);
res
=
taos_query
(
taos
,
"select * from t0"
);
res
=
taos_query
_with_reqid
(
taos
,
"select * from t0"
,
genReqid
()
);
check_row_count
(
__LINE__
,
res
,
3
);
check_row_count
(
__LINE__
,
res
,
3
);
taos_free_result
(
res
);
taos_free_result
(
res
);
res
=
taos_query
(
taos
,
"select * from nonexisttable"
);
res
=
taos_query
_with_reqid
(
taos
,
"select * from nonexisttable"
,
genReqid
()
);
code
=
taos_errno
(
res
);
code
=
taos_errno
(
res
);
printf
(
"code=%d, error msg=%s
\n
"
,
code
,
taos_errstr
(
res
));
printf
(
"code=%d, error msg=%s
\n
"
,
code
,
taos_errstr
(
res
));
taos_free_result
(
res
);
taos_free_result
(
res
);
res
=
taos_query
(
taos
,
"select * from meters"
);
res
=
taos_query
_with_reqid
(
taos
,
"select * from meters"
,
genReqid
()
);
taos_stop_query
(
res
);
taos_stop_query
(
res
);
taos_free_result
(
res
);
taos_free_result
(
res
);
}
}
void
subscribe_callback
(
TAOS_SUB
*
tsub
,
TAOS_RES
*
res
,
void
*
param
,
int
code
)
{
void
subscribe_callback
(
TAOS_SUB
*
tsub
,
TAOS_RES
*
res
,
void
*
param
,
int
code
)
{
int
rows
=
print_result
(
res
,
*
(
int
*
)
param
);
int
rows
=
print_result
(
res
,
*
(
int
*
)
param
);
printf
(
"%d rows consumed in subscribe_callback
\n
"
,
rows
);
printf
(
"%d rows consumed in subscribe_callback
\n
"
,
rows
);
}
}
...
@@ -167,7 +168,7 @@ static void verify_subscribe(TAOS* taos) {
...
@@ -167,7 +168,7 @@ static void verify_subscribe(TAOS* taos) {
res
=
taos_consume
(
tsub
);
res
=
taos_consume
(
tsub
);
check_row_count
(
__LINE__
,
res
,
0
);
check_row_count
(
__LINE__
,
res
,
0
);
TAOS_RES
*
result
;
TAOS_RES
*
result
;
result
=
taos_query
(
taos
,
"insert into t0 values('2020-01-01 00:02:00.001', 0);"
);
result
=
taos_query
(
taos
,
"insert into t0 values('2020-01-01 00:02:00.001', 0);"
);
taos_free_result
(
result
);
taos_free_result
(
result
);
result
=
taos_query
(
taos
,
"insert into t8 values('2020-01-01 00:01:03.000', 0);"
);
result
=
taos_query
(
taos
,
"insert into t8 values('2020-01-01 00:01:03.000', 0);"
);
...
@@ -253,8 +254,10 @@ void verify_prepare(TAOS* taos) {
...
@@ -253,8 +254,10 @@ void verify_prepare(TAOS* taos) {
taos_select_db
(
taos
,
"test"
);
taos_select_db
(
taos
,
"test"
);
// 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
=
result
=
taos_query
(
taos
,
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))"
;
result
=
taos_query_with_reqid
(
taos
,
sql
,
genReqid
());
code
=
taos_errno
(
result
);
code
=
taos_errno
(
result
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
printf
(
"
\033
[31mfailed to create table, reason:%s
\033
[0m
\n
"
,
taos_errstr
(
result
));
printf
(
"
\033
[31mfailed to create table, reason:%s
\033
[0m
\n
"
,
taos_errstr
(
result
));
...
@@ -265,20 +268,20 @@ void verify_prepare(TAOS* taos) {
...
@@ -265,20 +268,20 @@ void verify_prepare(TAOS* taos) {
// insert 10 records
// insert 10 records
struct
{
struct
{
int64_t
ts
;
int64_t
ts
;
int8_t
b
;
int8_t
b
;
int8_t
v1
;
int8_t
v1
;
int16_t
v2
;
int16_t
v2
;
int32_t
v4
;
int32_t
v4
;
int64_t
v8
;
int64_t
v8
;
float
f4
;
float
f4
;
double
f8
;
double
f8
;
char
bin
[
40
];
char
bin
[
40
];
char
blob
[
80
];
char
blob
[
80
];
}
v
=
{
0
};
}
v
=
{
0
};
TAOS_STMT
*
stmt
=
taos_stmt_init
(
taos
);
TAOS_STMT
*
stmt
=
taos_stmt_init
(
taos
);
TAOS_BIND
params
[
10
];
TAOS_BIND
params
[
10
];
params
[
0
].
buffer_type
=
TSDB_DATA_TYPE_TIMESTAMP
;
params
[
0
].
buffer_type
=
TSDB_DATA_TYPE_TIMESTAMP
;
params
[
0
].
buffer_length
=
sizeof
(
v
.
ts
);
params
[
0
].
buffer_length
=
sizeof
(
v
.
ts
);
params
[
0
].
buffer
=
&
v
.
ts
;
params
[
0
].
buffer
=
&
v
.
ts
;
...
@@ -344,7 +347,7 @@ void verify_prepare(TAOS* taos) {
...
@@ -344,7 +347,7 @@ void verify_prepare(TAOS* taos) {
sql
=
"insert into m1 values(?,?,?,?,?,?,?,?,?,?)"
;
sql
=
"insert into m1 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
));
taos_stmt_close
(
stmt
);
taos_stmt_close
(
stmt
);
return
;
return
;
...
@@ -393,7 +396,7 @@ void verify_prepare(TAOS* taos) {
...
@@ -393,7 +396,7 @@ void verify_prepare(TAOS* taos) {
TAOS_ROW
row
;
TAOS_ROW
row
;
int
rows
=
0
;
int
rows
=
0
;
int
num_fields
=
taos_num_fields
(
result
);
int
num_fields
=
taos_num_fields
(
result
);
TAOS_FIELD
*
fields
=
taos_fetch_fields
(
result
);
TAOS_FIELD
*
fields
=
taos_fetch_fields
(
result
);
// fetch the records row by row
// fetch the records row by row
while
((
row
=
taos_fetch_row
(
result
)))
{
while
((
row
=
taos_fetch_row
(
result
)))
{
...
@@ -425,7 +428,9 @@ void verify_prepare2(TAOS* taos) {
...
@@ -425,7 +428,9 @@ void verify_prepare2(TAOS* taos) {
taos_select_db
(
taos
,
"test"
);
taos_select_db
(
taos
,
"test"
);
// 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))"
;
result
=
taos_query
(
taos
,
sql
);
result
=
taos_query
(
taos
,
sql
);
code
=
taos_errno
(
result
);
code
=
taos_errno
(
result
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
...
@@ -437,31 +442,31 @@ void verify_prepare2(TAOS* taos) {
...
@@ -437,31 +442,31 @@ void verify_prepare2(TAOS* taos) {
// insert 10 records
// insert 10 records
struct
{
struct
{
int64_t
ts
[
10
];
int64_t
ts
[
10
];
int8_t
b
[
10
];
int8_t
b
[
10
];
int8_t
v1
[
10
];
int8_t
v1
[
10
];
int16_t
v2
[
10
];
int16_t
v2
[
10
];
int32_t
v4
[
10
];
int32_t
v4
[
10
];
int64_t
v8
[
10
];
int64_t
v8
[
10
];
float
f4
[
10
];
float
f4
[
10
];
double
f8
[
10
];
double
f8
[
10
];
char
bin
[
10
][
40
];
char
bin
[
10
][
40
];
char
blob
[
10
][
80
];
char
blob
[
10
][
80
];
}
v
;
}
v
;
int32_t
*
t8_len
=
malloc
(
sizeof
(
int32_t
)
*
10
);
int32_t
*
t8_len
=
malloc
(
sizeof
(
int32_t
)
*
10
);
int32_t
*
t16_len
=
malloc
(
sizeof
(
int32_t
)
*
10
);
int32_t
*
t16_len
=
malloc
(
sizeof
(
int32_t
)
*
10
);
int32_t
*
t32_len
=
malloc
(
sizeof
(
int32_t
)
*
10
);
int32_t
*
t32_len
=
malloc
(
sizeof
(
int32_t
)
*
10
);
int32_t
*
t64_len
=
malloc
(
sizeof
(
int32_t
)
*
10
);
int32_t
*
t64_len
=
malloc
(
sizeof
(
int32_t
)
*
10
);
int32_t
*
float_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
*
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
);
TAOS_STMT
*
stmt
=
taos_stmt_init
(
taos
);
TAOS_STMT
*
stmt
=
taos_stmt_init
(
taos
);
TAOS_MULTI_BIND
params
[
10
];
TAOS_MULTI_BIND
params
[
10
];
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
;
params
[
0
].
buffer_length
=
sizeof
(
v
.
ts
[
0
]);
params
[
0
].
buffer_length
=
sizeof
(
v
.
ts
[
0
]);
params
[
0
].
buffer
=
v
.
ts
;
params
[
0
].
buffer
=
v
.
ts
;
...
@@ -541,12 +546,12 @@ void verify_prepare2(TAOS* taos) {
...
@@ -541,12 +546,12 @@ void verify_prepare2(TAOS* taos) {
}
}
code
=
taos_stmt_set_tbname
(
stmt
,
"m1"
);
code
=
taos_stmt_set_tbname
(
stmt
,
"m1"
);
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
));
taos_stmt_close
(
stmt
);
taos_stmt_close
(
stmt
);
return
;
return
;
}
}
int64_t
ts
=
1591060628000
;
int64_t
ts
=
1591060628000
;
for
(
int
i
=
0
;
i
<
10
;
++
i
)
{
for
(
int
i
=
0
;
i
<
10
;
++
i
)
{
v
.
ts
[
i
]
=
ts
++
;
v
.
ts
[
i
]
=
ts
++
;
...
@@ -561,7 +566,7 @@ void verify_prepare2(TAOS* taos) {
...
@@ -561,7 +566,7 @@ void verify_prepare2(TAOS* taos) {
v
.
f8
[
i
]
=
(
double
)(
i
*
80
);
v
.
f8
[
i
]
=
(
double
)(
i
*
80
);
for
(
int
j
=
0
;
j
<
sizeof
(
v
.
bin
[
0
]);
++
j
)
{
for
(
int
j
=
0
;
j
<
sizeof
(
v
.
bin
[
0
]);
++
j
)
{
v
.
bin
[
i
][
j
]
=
(
char
)(
i
+
'0'
);
v
.
bin
[
i
][
j
]
=
(
char
)(
i
+
'0'
);
}
}
strcpy
(
v
.
blob
[
i
],
"一二三四五六七八九十"
);
strcpy
(
v
.
blob
[
i
],
"一二三四五六七八九十"
);
t8_len
[
i
]
=
sizeof
(
int8_t
);
t8_len
[
i
]
=
sizeof
(
int8_t
);
...
@@ -576,7 +581,7 @@ void verify_prepare2(TAOS* taos) {
...
@@ -576,7 +581,7 @@ void verify_prepare2(TAOS* taos) {
taos_stmt_bind_param_batch
(
stmt
,
params
);
taos_stmt_bind_param_batch
(
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
));
taos_stmt_close
(
stmt
);
taos_stmt_close
(
stmt
);
...
@@ -590,7 +595,7 @@ void verify_prepare2(TAOS* taos) {
...
@@ -590,7 +595,7 @@ void verify_prepare2(TAOS* taos) {
taos_stmt_prepare
(
stmt
,
"SELECT * FROM m1 WHERE v1 > ? AND v2 < ?"
,
0
);
taos_stmt_prepare
(
stmt
,
"SELECT * FROM m1 WHERE v1 > ? AND v2 < ?"
,
0
);
TAOS_BIND
qparams
[
2
];
TAOS_BIND
qparams
[
2
];
int8_t
v1
=
5
;
int8_t
v1
=
5
;
int16_t
v2
=
15
;
int16_t
v2
=
15
;
qparams
[
0
].
buffer_type
=
TSDB_DATA_TYPE_TINYINT
;
qparams
[
0
].
buffer_type
=
TSDB_DATA_TYPE_TINYINT
;
qparams
[
0
].
buffer_length
=
sizeof
(
v1
);
qparams
[
0
].
buffer_length
=
sizeof
(
v1
);
...
@@ -607,7 +612,7 @@ void verify_prepare2(TAOS* taos) {
...
@@ -607,7 +612,7 @@ void verify_prepare2(TAOS* taos) {
taos_stmt_bind_param
(
stmt
,
qparams
);
taos_stmt_bind_param
(
stmt
,
qparams
);
if
(
taos_stmt_execute
(
stmt
)
!=
0
)
{
if
(
taos_stmt_execute
(
stmt
)
!=
0
)
{
printf
(
"
\033
[31mfailed to execute select statement.error:%s
\033
[0m
\n
"
,
taos_stmt_errstr
(
stmt
));
printf
(
"
\033
[31mfailed to execute select statement.error:%s
\033
[0m
\n
"
,
taos_stmt_errstr
(
stmt
));
taos_stmt_close
(
stmt
);
taos_stmt_close
(
stmt
);
return
;
return
;
}
}
...
@@ -616,7 +621,7 @@ void verify_prepare2(TAOS* taos) {
...
@@ -616,7 +621,7 @@ void verify_prepare2(TAOS* taos) {
TAOS_ROW
row
;
TAOS_ROW
row
;
int
rows
=
0
;
int
rows
=
0
;
int
num_fields
=
taos_num_fields
(
result
);
int
num_fields
=
taos_num_fields
(
result
);
TAOS_FIELD
*
fields
=
taos_fetch_fields
(
result
);
TAOS_FIELD
*
fields
=
taos_fetch_fields
(
result
);
// fetch the records row by row
// fetch the records row by row
while
((
row
=
taos_fetch_row
(
result
)))
{
while
((
row
=
taos_fetch_row
(
result
)))
{
...
@@ -657,7 +662,9 @@ void verify_prepare3(TAOS* taos) {
...
@@ -657,7 +662,9 @@ void verify_prepare3(TAOS* taos) {
taos_select_db
(
taos
,
"test"
);
taos_select_db
(
taos
,
"test"
);
// create table
// create table
const
char
*
sql
=
"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))"
;
const
char
*
sql
=
"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))"
;
result
=
taos_query
(
taos
,
sql
);
result
=
taos_query
(
taos
,
sql
);
code
=
taos_errno
(
result
);
code
=
taos_errno
(
result
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
...
@@ -669,10 +676,10 @@ void verify_prepare3(TAOS* taos) {
...
@@ -669,10 +676,10 @@ void verify_prepare3(TAOS* taos) {
TAOS_BIND
tags
[
2
];
TAOS_BIND
tags
[
2
];
int32_t
id1
=
1
;
int32_t
id1
=
1
;
char
id2
[
40
]
=
"abcdefghijklmnopqrstuvwxyz0123456789"
;
char
id2
[
40
]
=
"abcdefghijklmnopqrstuvwxyz0123456789"
;
uintptr_t
id2_len
=
strlen
(
id2
);
uintptr_t
id2_len
=
strlen
(
id2
);
tags
[
0
].
buffer_type
=
TSDB_DATA_TYPE_INT
;
tags
[
0
].
buffer_type
=
TSDB_DATA_TYPE_INT
;
tags
[
0
].
buffer_length
=
sizeof
(
int
);
tags
[
0
].
buffer_length
=
sizeof
(
int
);
tags
[
0
].
buffer
=
&
id1
;
tags
[
0
].
buffer
=
&
id1
;
...
@@ -685,34 +692,33 @@ void verify_prepare3(TAOS* taos) {
...
@@ -685,34 +692,33 @@ void verify_prepare3(TAOS* taos) {
tags
[
1
].
length
=
&
id2_len
;
tags
[
1
].
length
=
&
id2_len
;
tags
[
1
].
is_null
=
NULL
;
tags
[
1
].
is_null
=
NULL
;
// insert 10 records
// insert 10 records
struct
{
struct
{
int64_t
ts
[
10
];
int64_t
ts
[
10
];
int8_t
b
[
10
];
int8_t
b
[
10
];
int8_t
v1
[
10
];
int8_t
v1
[
10
];
int16_t
v2
[
10
];
int16_t
v2
[
10
];
int32_t
v4
[
10
];
int32_t
v4
[
10
];
int64_t
v8
[
10
];
int64_t
v8
[
10
];
float
f4
[
10
];
float
f4
[
10
];
double
f8
[
10
];
double
f8
[
10
];
char
bin
[
10
][
40
];
char
bin
[
10
][
40
];
char
blob
[
10
][
80
];
char
blob
[
10
][
80
];
}
v
;
}
v
;
int32_t
*
t8_len
=
malloc
(
sizeof
(
int32_t
)
*
10
);
int32_t
*
t8_len
=
malloc
(
sizeof
(
int32_t
)
*
10
);
int32_t
*
t16_len
=
malloc
(
sizeof
(
int32_t
)
*
10
);
int32_t
*
t16_len
=
malloc
(
sizeof
(
int32_t
)
*
10
);
int32_t
*
t32_len
=
malloc
(
sizeof
(
int32_t
)
*
10
);
int32_t
*
t32_len
=
malloc
(
sizeof
(
int32_t
)
*
10
);
int32_t
*
t64_len
=
malloc
(
sizeof
(
int32_t
)
*
10
);
int32_t
*
t64_len
=
malloc
(
sizeof
(
int32_t
)
*
10
);
int32_t
*
float_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
*
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
);
TAOS_STMT
*
stmt
=
taos_stmt_init
(
taos
);
TAOS_STMT
*
stmt
=
taos_stmt_init
(
taos
);
TAOS_MULTI_BIND
params
[
10
];
TAOS_MULTI_BIND
params
[
10
];
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
;
params
[
0
].
buffer_length
=
sizeof
(
v
.
ts
[
0
]);
params
[
0
].
buffer_length
=
sizeof
(
v
.
ts
[
0
]);
params
[
0
].
buffer
=
v
.
ts
;
params
[
0
].
buffer
=
v
.
ts
;
...
@@ -783,27 +789,26 @@ void verify_prepare3(TAOS* taos) {
...
@@ -783,27 +789,26 @@ 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(?,?,?,?,?,?,?,?,?,?)"
;
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
));
taos_stmt_close
(
stmt
);
taos_stmt_close
(
stmt
);
return
;
return
;
}
}
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_prepare. error:%s
\033
[0m
\n
"
,
taos_stmt_errstr
(
stmt
));
taos_stmt_close
(
stmt
);
taos_stmt_close
(
stmt
);
return
;
return
;
}
}
int64_t
ts
=
1591060628000
;
int64_t
ts
=
1591060628000
;
for
(
int
i
=
0
;
i
<
10
;
++
i
)
{
for
(
int
i
=
0
;
i
<
10
;
++
i
)
{
v
.
ts
[
i
]
=
ts
++
;
v
.
ts
[
i
]
=
ts
++
;
is_null
[
i
]
=
0
;
is_null
[
i
]
=
0
;
v
.
b
[
i
]
=
(
int8_t
)
i
%
2
;
v
.
b
[
i
]
=
(
int8_t
)
i
%
2
;
v
.
v1
[
i
]
=
(
int8_t
)
i
;
v
.
v1
[
i
]
=
(
int8_t
)
i
;
v
.
v2
[
i
]
=
(
int16_t
)(
i
*
2
);
v
.
v2
[
i
]
=
(
int16_t
)(
i
*
2
);
...
@@ -813,7 +818,7 @@ void verify_prepare3(TAOS* taos) {
...
@@ -813,7 +818,7 @@ void verify_prepare3(TAOS* taos) {
v
.
f8
[
i
]
=
(
double
)(
i
*
80
);
v
.
f8
[
i
]
=
(
double
)(
i
*
80
);
for
(
int
j
=
0
;
j
<
sizeof
(
v
.
bin
[
0
]);
++
j
)
{
for
(
int
j
=
0
;
j
<
sizeof
(
v
.
bin
[
0
]);
++
j
)
{
v
.
bin
[
i
][
j
]
=
(
char
)(
i
+
'0'
);
v
.
bin
[
i
][
j
]
=
(
char
)(
i
+
'0'
);
}
}
strcpy
(
v
.
blob
[
i
],
"一二三四五六七八九十"
);
strcpy
(
v
.
blob
[
i
],
"一二三四五六七八九十"
);
t8_len
[
i
]
=
sizeof
(
int8_t
);
t8_len
[
i
]
=
sizeof
(
int8_t
);
...
@@ -828,10 +833,10 @@ void verify_prepare3(TAOS* taos) {
...
@@ -828,10 +833,10 @@ void verify_prepare3(TAOS* taos) {
taos_stmt_bind_param_batch
(
stmt
,
params
);
taos_stmt_bind_param_batch
(
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
));
taos_stmt_close
(
stmt
);
taos_stmt_close
(
stmt
);
return
;
return
;
}
}
taos_stmt_close
(
stmt
);
taos_stmt_close
(
stmt
);
...
@@ -842,7 +847,7 @@ void verify_prepare3(TAOS* taos) {
...
@@ -842,7 +847,7 @@ void verify_prepare3(TAOS* taos) {
TAOS_BIND
qparams
[
2
];
TAOS_BIND
qparams
[
2
];
int8_t
v1
=
5
;
int8_t
v1
=
5
;
int16_t
v2
=
15
;
int16_t
v2
=
15
;
qparams
[
0
].
buffer_type
=
TSDB_DATA_TYPE_TINYINT
;
qparams
[
0
].
buffer_type
=
TSDB_DATA_TYPE_TINYINT
;
qparams
[
0
].
buffer_length
=
sizeof
(
v1
);
qparams
[
0
].
buffer_length
=
sizeof
(
v1
);
...
@@ -859,7 +864,7 @@ void verify_prepare3(TAOS* taos) {
...
@@ -859,7 +864,7 @@ void verify_prepare3(TAOS* taos) {
taos_stmt_bind_param
(
stmt
,
qparams
);
taos_stmt_bind_param
(
stmt
,
qparams
);
if
(
taos_stmt_execute
(
stmt
)
!=
0
)
{
if
(
taos_stmt_execute
(
stmt
)
!=
0
)
{
printf
(
"
\033
[31mfailed to execute select statement.error:%s
\033
[0m
\n
"
,
taos_stmt_errstr
(
stmt
));
printf
(
"
\033
[31mfailed to execute select statement.error:%s
\033
[0m
\n
"
,
taos_stmt_errstr
(
stmt
));
taos_stmt_close
(
stmt
);
taos_stmt_close
(
stmt
);
return
;
return
;
}
}
...
@@ -868,7 +873,7 @@ void verify_prepare3(TAOS* taos) {
...
@@ -868,7 +873,7 @@ void verify_prepare3(TAOS* taos) {
TAOS_ROW
row
;
TAOS_ROW
row
;
int
rows
=
0
;
int
rows
=
0
;
int
num_fields
=
taos_num_fields
(
result
);
int
num_fields
=
taos_num_fields
(
result
);
TAOS_FIELD
*
fields
=
taos_fetch_fields
(
result
);
TAOS_FIELD
*
fields
=
taos_fetch_fields
(
result
);
// fetch the records row by row
// fetch the records row by row
while
((
row
=
taos_fetch_row
(
result
)))
{
while
((
row
=
taos_fetch_row
(
result
)))
{
...
@@ -891,8 +896,7 @@ void verify_prepare3(TAOS* taos) {
...
@@ -891,8 +896,7 @@ void verify_prepare3(TAOS* taos) {
free
(
blob_len
);
free
(
blob_len
);
}
}
void
retrieve_callback
(
void
*
param
,
TAOS_RES
*
tres
,
int
numOfRows
)
void
retrieve_callback
(
void
*
param
,
TAOS_RES
*
tres
,
int
numOfRows
)
{
{
if
(
numOfRows
>
0
)
{
if
(
numOfRows
>
0
)
{
printf
(
"%d rows async retrieved
\n
"
,
numOfRows
);
printf
(
"%d rows async retrieved
\n
"
,
numOfRows
);
taos_fetch_rows_a
(
tres
,
retrieve_callback
,
param
);
taos_fetch_rows_a
(
tres
,
retrieve_callback
,
param
);
...
@@ -906,8 +910,7 @@ void retrieve_callback(void *param, TAOS_RES *tres, int numOfRows)
...
@@ -906,8 +910,7 @@ void retrieve_callback(void *param, TAOS_RES *tres, int numOfRows)
}
}
}
}
void
select_callback
(
void
*
param
,
TAOS_RES
*
tres
,
int
code
)
void
select_callback
(
void
*
param
,
TAOS_RES
*
tres
,
int
code
)
{
{
if
(
code
==
0
&&
tres
)
{
if
(
code
==
0
&&
tres
)
{
taos_fetch_rows_a
(
tres
,
retrieve_callback
,
param
);
taos_fetch_rows_a
(
tres
,
retrieve_callback
,
param
);
}
else
{
}
else
{
...
@@ -921,11 +924,11 @@ void verify_async(TAOS* taos) {
...
@@ -921,11 +924,11 @@ void verify_async(TAOS* taos) {
usleep
(
1000000
);
usleep
(
1000000
);
}
}
void
stream_callback
(
void
*
param
,
TAOS_RES
*
res
,
TAOS_ROW
row
)
{
void
stream_callback
(
void
*
param
,
TAOS_RES
*
res
,
TAOS_ROW
row
)
{
if
(
res
==
NULL
||
row
==
NULL
)
{
if
(
res
==
NULL
||
row
==
NULL
)
{
return
;
return
;
}
}
int
num_fields
=
taos_num_fields
(
res
);
int
num_fields
=
taos_num_fields
(
res
);
TAOS_FIELD
*
fields
=
taos_fetch_fields
(
res
);
TAOS_FIELD
*
fields
=
taos_fetch_fields
(
res
);
...
@@ -937,14 +940,9 @@ void stream_callback(void *param, TAOS_RES *res, TAOS_ROW row) {
...
@@ -937,14 +940,9 @@ void stream_callback(void *param, TAOS_RES *res, TAOS_ROW row) {
void
verify_stream
(
TAOS
*
taos
)
{
void
verify_stream
(
TAOS
*
taos
)
{
prepare_data
(
taos
);
prepare_data
(
taos
);
TAOS_STREAM
*
strm
=
taos_open_stream
(
TAOS_STREAM
*
strm
=
taos
,
taos_open_stream
(
taos
,
"select count(*) from meters interval(1m)"
,
stream_callback
,
0
,
NULL
,
NULL
);
"select count(*) from meters interval(1m)"
,
printf
(
"waiting for stream data
\n
"
);
stream_callback
,
0
,
NULL
,
NULL
);
printf
(
"waiting for stream data
\n
"
);
usleep
(
100000
);
usleep
(
100000
);
TAOS_RES
*
result
=
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
);
taos_free_result
(
result
);
...
@@ -953,7 +951,7 @@ void verify_stream(TAOS* taos) {
...
@@ -953,7 +951,7 @@ void verify_stream(TAOS* taos) {
}
}
int32_t
verify_schema_less
(
TAOS
*
taos
)
{
int32_t
verify_schema_less
(
TAOS
*
taos
)
{
TAOS_RES
*
result
;
TAOS_RES
*
result
;
result
=
taos_query
(
taos
,
"drop database if exists test;"
);
result
=
taos_query
(
taos
,
"drop database if exists test;"
);
taos_free_result
(
result
);
taos_free_result
(
result
);
usleep
(
100000
);
usleep
(
100000
);
...
@@ -975,50 +973,52 @@ int32_t verify_schema_less(TAOS* taos) {
...
@@ -975,50 +973,52 @@ int32_t verify_schema_less(TAOS* taos) {
"st,t1=4i64,t2=5f64,t3=
\"
t4
\"
c1=3i64,c3=L
\"
passitagain
\"
,c2=true,c4=5f64 1626006833642000000ns"
,
"st,t1=4i64,t2=5f64,t3=
\"
t4
\"
c1=3i64,c3=L
\"
passitagain
\"
,c2=true,c4=5f64 1626006833642000000ns"
,
"ste,t2=5f64,t3=L
\"
ste2
\"
c3=
\"
iamszhou
\"
,c4=false 1626056811843316532ns"
,
"ste,t2=5f64,t3=L
\"
ste2
\"
c3=
\"
iamszhou
\"
,c4=false 1626056811843316532ns"
,
"ste,t2=5f64,t3=L
\"
ste2
\"
c3=
\"
iamszhou
\"
,c4=false,c5=32i8,c6=64i16,c7=32i32,c8=88.88f32 1626056812843316532ns"
,
"ste,t2=5f64,t3=L
\"
ste2
\"
c3=
\"
iamszhou
\"
,c4=false,c5=32i8,c6=64i16,c7=32i32,c8=88.88f32 1626056812843316532ns"
,
"st,t1=4i64,t3=
\"
t4
\"
,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin
\"
,c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000ns"
,
"st,t1=4i64,t3=
\"
t4
\"
,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin
\"
,c2=true,c4=5f64,c5=5f64,c6=7u64 "
"stf,t1=4i64,t3=
\"
t4
\"
,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin
\"
,c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000ns"
,
"1626006933640000000ns"
,
"stf,t1=4i64,t3=
\"
t4
\"
,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin_stf
\"
,c2=false,c5=5f64,c6=7u64 1626006933641000000ns"
"stf,t1=4i64,t3=
\"
t4
\"
,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin
\"
,c2=true,c4=5f64,c5=5f64,c6=7u64 "
};
"1626006933640000000ns"
,
"stf,t1=4i64,t3=
\"
t4
\"
,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin_stf
\"
,c2=false,c5=5f64,c6=7u64 "
"1626006933641000000ns"
};
code
=
taos_insert_lines
(
taos
,
lines
,
sizeof
(
lines
)
/
sizeof
(
char
*
));
code
=
taos_insert_lines
(
taos
,
lines
,
sizeof
(
lines
)
/
sizeof
(
char
*
));
char
*
lines2
[]
=
{
char
*
lines2
[]
=
{
"stg,t1=3i64,t2=4f64,t3=
\"
t3
\"
c1=3i64,c3=L
\"
passit
\"
,c2=false,c4=4f64 1626006833639000000ns"
,
"stg,t1=3i64,t2=4f64,t3=
\"
t3
\"
c1=3i64,c3=L
\"
passit
\"
,c2=false,c4=4f64 1626006833639000000ns"
,
"stg,t1=4i64,t3=
\"
t4
\"
,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin
\"
,c2=true,c4=5f64,c5=5f64 1626006833640000000ns"
"stg,t1=4i64,t3=
\"
t4
\"
,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin
\"
,c2=true,c4=5f64,c5=5f64 1626006833640000000ns"
};
};
code
=
taos_insert_lines
(
taos
,
&
lines2
[
0
],
1
);
code
=
taos_insert_lines
(
taos
,
&
lines2
[
0
],
1
);
code
=
taos_insert_lines
(
taos
,
&
lines2
[
1
],
1
);
code
=
taos_insert_lines
(
taos
,
&
lines2
[
1
],
1
);
char
*
lines3
[]
=
{
char
*
lines3
[]
=
{
"sth,t1=4i64,t2=5f64,t4=5f64,ID=
\"
childtable
\"
c1=3i64,c3=L
\"
passitagin_stf
\"
,c2=false,c5=5f64,c6=7u64
1626006933641ms"
,
"sth,t1=4i64,t2=5f64,t4=5f64,ID=
\"
childtable
\"
c1=3i64,c3=L
\"
passitagin_stf
\"
,c2=false,c5=5f64,c6=7u64
"
"
sth,t1=4i64,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin_stf
\"
,c2=false,c5=5f64,c6=7u64 1626006933654ms"
"
1626006933641ms"
,
};
"sth,t1=4i64,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin_stf
\"
,c2=false,c5=5f64,c6=7u64 1626006933654ms"
};
code
=
taos_insert_lines
(
taos
,
lines3
,
2
);
code
=
taos_insert_lines
(
taos
,
lines3
,
2
);
char
*
lines4
[]
=
{
char
*
lines4
[]
=
{
"st123456,t1=3i64,t2=4f64,t3=
\"
t3
\"
c1=3i64,c3=L
\"
passit
\"
,c2=false,c4=4f64 1626006833639000000ns"
,
"st123456,t1=3i64,t2=4f64,t3=
\"
t3
\"
c1=3i64,c3=L
\"
passit
\"
,c2=false,c4=4f64 1626006833639000000ns"
,
"dgtyqodr,t2=5f64,t3=L
\"
ste
\"
c1=tRue,c2=4i64,c3=
\"
iam
\"
1626056811823316532ns"
};
"dgtyqodr,t2=5f64,t3=L
\"
ste
\"
c1=tRue,c2=4i64,c3=
\"
iam
\"
1626056811823316532ns"
};
code
=
taos_insert_lines
(
taos
,
lines4
,
2
);
code
=
taos_insert_lines
(
taos
,
lines4
,
2
);
char
*
lines5
[]
=
{
char
*
lines5
[]
=
{
"zqlbgs,id=
\"
zqlbgs_39302_21680
\"
,t0=f,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=
\"
binaryTagValue
\"
,t8=L
\"
ncharTagValue
\"
c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=
\"
binaryColValue
\"
,c8=L
\"
ncharColValue
\"
,c9=7u64 1626006833639000000ns"
,
"zqlbgs,id=
\"
zqlbgs_39302_21680
\"
,t0=f,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11."
"zqlbgs,t9=f,id=
\"
zqlbgs_39302_21680
\"
,t0=f,t1=127i8,t11=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=
\"
binaryTagValue
\"
,t8=L
\"
ncharTagValue
\"
,t10=L
\"
ncharTagValue
\"
c10=f,c0=f,c1=127i8,c12=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=
\"
binaryColValue
\"
,c8=L
\"
ncharColValue
\"
,c9=7u64,c11=L
\"
ncharColValue
\"
1626006833639000000ns"
"12345f32,t6=22.123456789f64,t7=
\"
binaryTagValue
\"
,t8=L
\"
ncharTagValue
\"
"
};
"c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7="
"
\"
binaryColValue
\"
,c8=L
\"
ncharColValue
\"
,c9=7u64 1626006833639000000ns"
,
"zqlbgs,t9=f,id=
\"
zqlbgs_39302_21680
\"
,t0=f,t1=127i8,t11=127i8,t2=32767i16,t3=2147483647i32,t4="
"9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=
\"
binaryTagValue
\"
,t8=L
\"
ncharTagValue
\"
,t10="
"L
\"
ncharTagValue
\"
"
"c10=f,c0=f,c1=127i8,c12=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22."
"123456789f64,c7=
\"
binaryColValue
\"
,c8=L
\"
ncharColValue
\"
,c9=7u64,c11=L
\"
ncharColValue
\"
1626006833639000000ns"
};
code
=
taos_insert_lines
(
taos
,
&
lines5
[
0
],
1
);
code
=
taos_insert_lines
(
taos
,
&
lines5
[
0
],
1
);
code
=
taos_insert_lines
(
taos
,
&
lines5
[
1
],
1
);
code
=
taos_insert_lines
(
taos
,
&
lines5
[
1
],
1
);
char
*
lines6
[]
=
{
"st123456,t1=3i64,t2=4f64,t3=
\"
t3
\"
c1=3i64,c3=L
\"
passit
\"
,c2=false,c4=4f64 1626006833639000000ns"
,
char
*
lines6
[]
=
{
"dgtyqodr,t2=5f64,t3=L
\"
ste
\"
c1=tRue,c2=4i64,c3=
\"
iam
\"
1626056811823316532ns"
};
"st123456,t1=3i64,t2=4f64,t3=
\"
t3
\"
c1=3i64,c3=L
\"
passit
\"
,c2=false,c4=4f64 1626006833639000000ns"
,
"dgtyqodr,t2=5f64,t3=L
\"
ste
\"
c1=tRue,c2=4i64,c3=
\"
iam
\"
1626056811823316532ns"
};
code
=
taos_insert_lines
(
taos
,
lines6
,
2
);
code
=
taos_insert_lines
(
taos
,
lines6
,
2
);
return
(
code
);
return
(
code
);
}
}
void
verify_telnet_insert
(
TAOS
*
taos
)
{
void
verify_telnet_insert
(
TAOS
*
taos
)
{
TAOS_RES
*
result
;
TAOS_RES
*
result
;
result
=
taos_query
(
taos
,
"drop database if exists db;"
);
result
=
taos_query
(
taos
,
"drop database if exists db;"
);
taos_free_result
(
result
);
taos_free_result
(
result
);
...
@@ -1043,12 +1043,9 @@ void verify_telnet_insert(TAOS* taos) {
...
@@ -1043,12 +1043,9 @@ void verify_telnet_insert(TAOS* taos) {
/* timestamp */
/* timestamp */
char
*
lines1
[]
=
{
char
*
lines1
[]
=
{
"stb1 1626006833s 1i8 host=
\"
host0
\"
"
,
"stb1 1626006833s 1i8 host=
\"
host0
\"
"
,
"stb1 1626006833639000000ns 2i8 host=
\"
host0
\"
"
,
"stb1 1626006833639000000ns 2i8 host=
\"
host0
\"
"
,
"stb1 1626006833640000us 3i8 host=
\"
host0
\"
"
,
"stb1 1626006833641123 4i8 host=
\"
host0
\"
"
,
"stb1 1626006833640000us 3i8 host=
\"
host0
\"
"
,
"stb1 1626006833651ms 5i8 host=
\"
host0
\"
"
,
"stb1 0 6i8 host=
\"
host0
\"
"
,
"stb1 1626006833641123 4i8 host=
\"
host0
\"
"
,
"stb1 1626006833651ms 5i8 host=
\"
host0
\"
"
,
"stb1 0 6i8 host=
\"
host0
\"
"
,
};
};
code
=
taos_insert_telnet_lines
(
taos
,
lines1
,
6
);
code
=
taos_insert_telnet_lines
(
taos
,
lines1
,
6
);
if
(
code
)
{
if
(
code
)
{
...
@@ -1056,113 +1053,83 @@ void verify_telnet_insert(TAOS* taos) {
...
@@ -1056,113 +1053,83 @@ void verify_telnet_insert(TAOS* taos) {
}
}
/* metric value */
/* metric value */
//tinyin
// tinyin
char
*
lines2_0
[]
=
{
char
*
lines2_0
[]
=
{
"stb2_0 1626006833651ms -127i8 host=
\"
host0
\"
"
,
"stb2_0 1626006833652ms 127i8 host=
\"
host0
\"
"
};
"stb2_0 1626006833651ms -127i8 host=
\"
host0
\"
"
,
"stb2_0 1626006833652ms 127i8 host=
\"
host0
\"
"
};
code
=
taos_insert_telnet_lines
(
taos
,
lines2_0
,
2
);
code
=
taos_insert_telnet_lines
(
taos
,
lines2_0
,
2
);
if
(
code
)
{
if
(
code
)
{
printf
(
"lines2_0 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"lines2_0 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
//smallint
// smallint
char
*
lines2_1
[]
=
{
char
*
lines2_1
[]
=
{
"stb2_1 1626006833651ms -32767i16 host=
\"
host0
\"
"
,
"stb2_1 1626006833651ms -32767i16 host=
\"
host0
\"
"
,
"stb2_1 1626006833652ms 32767i16 host=
\"
host0
\"
"
};
"stb2_1 1626006833652ms 32767i16 host=
\"
host0
\"
"
};
code
=
taos_insert_telnet_lines
(
taos
,
lines2_1
,
2
);
code
=
taos_insert_telnet_lines
(
taos
,
lines2_1
,
2
);
if
(
code
)
{
if
(
code
)
{
printf
(
"lines2_1 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"lines2_1 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
//int
// int
char
*
lines2_2
[]
=
{
char
*
lines2_2
[]
=
{
"stb2_2 1626006833651ms -2147483647i32 host=
\"
host0
\"
"
,
"stb2_2 1626006833651ms -2147483647i32 host=
\"
host0
\"
"
,
"stb2_2 1626006833652ms 2147483647i32 host=
\"
host0
\"
"
};
"stb2_2 1626006833652ms 2147483647i32 host=
\"
host0
\"
"
};
code
=
taos_insert_telnet_lines
(
taos
,
lines2_2
,
2
);
code
=
taos_insert_telnet_lines
(
taos
,
lines2_2
,
2
);
if
(
code
)
{
if
(
code
)
{
printf
(
"lines2_2 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"lines2_2 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
//bigint
// bigint
char
*
lines2_3
[]
=
{
char
*
lines2_3
[]
=
{
"stb2_3 1626006833651ms -9223372036854775807i64 host=
\"
host0
\"
"
,
"stb2_3 1626006833651ms -9223372036854775807i64 host=
\"
host0
\"
"
,
"stb2_3 1626006833652ms 9223372036854775807i64 host=
\"
host0
\"
"
};
"stb2_3 1626006833652ms 9223372036854775807i64 host=
\"
host0
\"
"
};
code
=
taos_insert_telnet_lines
(
taos
,
lines2_3
,
2
);
code
=
taos_insert_telnet_lines
(
taos
,
lines2_3
,
2
);
if
(
code
)
{
if
(
code
)
{
printf
(
"lines2_3 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"lines2_3 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
//float
//
float
char
*
lines2_4
[]
=
{
char
*
lines2_4
[]
=
{
"stb2_4 1626006833610ms 3f32 host=
\"
host0
\"
"
,
"stb2_4 1626006833610ms 3f32 host=
\"
host0
\"
"
,
"stb2_4 1626006833620ms -3f32 host=
\"
host0
\"
"
,
"stb2_4 1626006833620ms -3f32 host=
\"
host0
\"
"
,
"stb2_4 1626006833630ms 3.4f32 host=
\"
host0
\"
"
,
"stb2_4 1626006833640ms -3.4f32 host=
\"
host0
\"
"
,
"stb2_4 1626006833630ms 3.4f32 host=
\"
host0
\"
"
,
"stb2_4 1626006833650ms 3.4E10f32 host=
\"
host0
\"
"
,
"stb2_4 1626006833660ms -3.4e10f32 host=
\"
host0
\"
"
,
"stb2_4 1626006833640ms -3.4f32 host=
\"
host0
\"
"
,
"stb2_4 1626006833670ms 3.4E+2f32 host=
\"
host0
\"
"
,
"stb2_4 1626006833680ms -3.4e-2f32 host=
\"
host0
\"
"
,
"stb2_4 1626006833650ms 3.4E10f32 host=
\"
host0
\"
"
,
"stb2_4 1626006833690ms 3.15 host=
\"
host0
\"
"
,
"stb2_4 1626006833700ms 3.4E38f32 host=
\"
host0
\"
"
,
"stb2_4 1626006833660ms -3.4e10f32 host=
\"
host0
\"
"
,
"stb2_4 1626006833710ms -3.4E38f32 host=
\"
host0
\"
"
};
"stb2_4 1626006833670ms 3.4E+2f32 host=
\"
host0
\"
"
,
"stb2_4 1626006833680ms -3.4e-2f32 host=
\"
host0
\"
"
,
"stb2_4 1626006833690ms 3.15 host=
\"
host0
\"
"
,
"stb2_4 1626006833700ms 3.4E38f32 host=
\"
host0
\"
"
,
"stb2_4 1626006833710ms -3.4E38f32 host=
\"
host0
\"
"
};
code
=
taos_insert_telnet_lines
(
taos
,
lines2_4
,
11
);
code
=
taos_insert_telnet_lines
(
taos
,
lines2_4
,
11
);
if
(
code
)
{
if
(
code
)
{
printf
(
"lines2_4 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"lines2_4 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
//double
//
double
char
*
lines2_5
[]
=
{
char
*
lines2_5
[]
=
{
"stb2_5 1626006833610ms 3f64 host=
\"
host0
\"
"
,
"stb2_5 1626006833610ms 3f64 host=
\"
host0
\"
"
,
"stb2_5 1626006833620ms -3f64 host=
\"
host0
\"
"
,
"stb2_5 1626006833620ms -3f64 host=
\"
host0
\"
"
,
"stb2_5 1626006833630ms 3.4f64 host=
\"
host0
\"
"
,
"stb2_5 1626006833640ms -3.4f64 host=
\"
host0
\"
"
,
"stb2_5 1626006833630ms 3.4f64 host=
\"
host0
\"
"
,
"stb2_5 1626006833650ms 3.4E10f64 host=
\"
host0
\"
"
,
"stb2_5 1626006833660ms -3.4e10f64 host=
\"
host0
\"
"
,
"stb2_5 1626006833640ms -3.4f64 host=
\"
host0
\"
"
,
"stb2_5 1626006833670ms 3.4E+2f64 host=
\"
host0
\"
"
,
"stb2_5 1626006833680ms -3.4e-2f64 host=
\"
host0
\"
"
,
"stb2_5 1626006833650ms 3.4E10f64 host=
\"
host0
\"
"
,
"stb2_5 1626006833690ms 1.7E308f64 host=
\"
host0
\"
"
,
"stb2_5 1626006833700ms -1.7E308f64 host=
\"
host0
\"
"
};
"stb2_5 1626006833660ms -3.4e10f64 host=
\"
host0
\"
"
,
"stb2_5 1626006833670ms 3.4E+2f64 host=
\"
host0
\"
"
,
"stb2_5 1626006833680ms -3.4e-2f64 host=
\"
host0
\"
"
,
"stb2_5 1626006833690ms 1.7E308f64 host=
\"
host0
\"
"
,
"stb2_5 1626006833700ms -1.7E308f64 host=
\"
host0
\"
"
};
code
=
taos_insert_telnet_lines
(
taos
,
lines2_5
,
10
);
code
=
taos_insert_telnet_lines
(
taos
,
lines2_5
,
10
);
if
(
code
)
{
if
(
code
)
{
printf
(
"lines2_5 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"lines2_5 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
//bool
// bool
char
*
lines2_6
[]
=
{
char
*
lines2_6
[]
=
{
"stb2_6 1626006833610ms t host=
\"
host0
\"
"
,
"stb2_6 1626006833620ms T host=
\"
host0
\"
"
,
"stb2_6 1626006833610ms t host=
\"
host0
\"
"
,
"stb2_6 1626006833630ms true host=
\"
host0
\"
"
,
"stb2_6 1626006833640ms True host=
\"
host0
\"
"
,
"stb2_6 1626006833620ms T host=
\"
host0
\"
"
,
"stb2_6 1626006833650ms TRUE host=
\"
host0
\"
"
,
"stb2_6 1626006833660ms f host=
\"
host0
\"
"
,
"stb2_6 1626006833630ms true host=
\"
host0
\"
"
,
"stb2_6 1626006833670ms F host=
\"
host0
\"
"
,
"stb2_6 1626006833680ms false host=
\"
host0
\"
"
,
"stb2_6 1626006833640ms True host=
\"
host0
\"
"
,
"stb2_6 1626006833690ms False host=
\"
host0
\"
"
,
"stb2_6 1626006833700ms FALSE host=
\"
host0
\"
"
};
"stb2_6 1626006833650ms TRUE host=
\"
host0
\"
"
,
"stb2_6 1626006833660ms f host=
\"
host0
\"
"
,
"stb2_6 1626006833670ms F host=
\"
host0
\"
"
,
"stb2_6 1626006833680ms false host=
\"
host0
\"
"
,
"stb2_6 1626006833690ms False host=
\"
host0
\"
"
,
"stb2_6 1626006833700ms FALSE host=
\"
host0
\"
"
};
code
=
taos_insert_telnet_lines
(
taos
,
lines2_6
,
10
);
code
=
taos_insert_telnet_lines
(
taos
,
lines2_6
,
10
);
if
(
code
)
{
if
(
code
)
{
printf
(
"lines2_6 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"lines2_6 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
//binary
// binary
char
*
lines2_7
[]
=
{
char
*
lines2_7
[]
=
{
"stb2_7 1626006833610ms
\"
binary_val.!@#$%^&*
\"
host=
\"
host0
\"
"
,
"stb2_7 1626006833610ms
\"
binary_val.!@#$%^&*
\"
host=
\"
host0
\"
"
,
"stb2_7 1626006833620ms
\"
binary_val.:;,./?|+-=
\"
host=
\"
host0
\"
"
,
"stb2_7 1626006833620ms
\"
binary_val.:;,./?|+-=
\"
host=
\"
host0
\"
"
,
"stb2_7 1626006833630ms
\"
binary_val.()[]{}<>
\"
host=
\"
host0
\"
"
};
"stb2_7 1626006833630ms
\"
binary_val.()[]{}<>
\"
host=
\"
host0
\"
"
};
code
=
taos_insert_telnet_lines
(
taos
,
lines2_7
,
3
);
code
=
taos_insert_telnet_lines
(
taos
,
lines2_7
,
3
);
if
(
code
)
{
if
(
code
)
{
printf
(
"lines2_7 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"lines2_7 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
//nchar
//
nchar
char
*
lines2_8
[]
=
{
char
*
lines2_8
[]
=
{
"stb2_8 1626006833610ms L
\"
nchar_val数值一
\"
host=
\"
host0
\"
"
,
"stb2_8 1626006833610ms L
\"
nchar_val数值一
\"
host=
\"
host0
\"
"
,
"stb2_8 1626006833620ms L
\"
nchar_val数值二
\"
host=
\"
host0
\"
"
,
"stb2_8 1626006833620ms L
\"
nchar_val数值二
\"
host=
\"
host0
\"
"
,
...
@@ -1173,22 +1140,23 @@ void verify_telnet_insert(TAOS* taos) {
...
@@ -1173,22 +1140,23 @@ void verify_telnet_insert(TAOS* taos) {
}
}
/* tags */
/* tags */
//tag value types
//
tag value types
char
*
lines3_0
[]
=
{
char
*
lines3_0
[]
=
{
"stb3_0 1626006833610ms 1 t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=3.4E38f32,t6=1.7E308f64,t7=true,t8=
\"
binary_val_1
\"
,t9=L
\"
标签值1
\"
"
,
"stb3_0 1626006833610ms 1 "
"stb3_0 1626006833610ms 2 t1=-127i8,t2=-32767i16,t3=-2147483647i32,t4=-9223372036854775807i64,t5=-3.4E38f32,t6=-1.7E308f64,t7=false,t8=
\"
binary_val_2
\"
,t9=L
\"
标签值2
\"
"
"t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=3.4E38f32,t6=1.7E308f64,t7=true,t8=
\"
binary_"
};
"val_1
\"
,t9=L
\"
标签值1
\"
"
,
"stb3_0 1626006833610ms 2 "
"t1=-127i8,t2=-32767i16,t3=-2147483647i32,t4=-9223372036854775807i64,t5=-3.4E38f32,t6=-1.7E308f64,t7=false,t8="
"
\"
binary_val_2
\"
,t9=L
\"
标签值2
\"
"
};
code
=
taos_insert_telnet_lines
(
taos
,
lines3_0
,
2
);
code
=
taos_insert_telnet_lines
(
taos
,
lines3_0
,
2
);
if
(
code
)
{
if
(
code
)
{
printf
(
"lines3_0 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"lines3_0 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
//tag ID as child table name
// tag ID as child table name
char
*
lines3_1
[]
=
{
char
*
lines3_1
[]
=
{
"stb3_1 1626006833610ms 1 id=
\"
child_table1
\"
,host=
\"
host1
\"
"
,
"stb3_1 1626006833610ms 1 id=
\"
child_table1
\"
,host=
\"
host1
\"
"
,
"stb3_1 1626006833610ms 2 host=
\"
host2
\"
,iD=
\"
child_table2
\"
"
,
"stb3_1 1626006833610ms 2 host=
\"
host2
\"
,iD=
\"
child_table2
\"
"
,
"stb3_1 1626006833610ms 3 ID=
\"
child_table3
\"
,host=
\"
host3
\"
"
};
"stb3_1 1626006833610ms 3 ID=
\"
child_table3
\"
,host=
\"
host3
\"
"
};
code
=
taos_insert_telnet_lines
(
taos
,
lines3_1
,
3
);
code
=
taos_insert_telnet_lines
(
taos
,
lines3_1
,
3
);
if
(
code
)
{
if
(
code
)
{
printf
(
"lines3_1 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"lines3_1 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
...
@@ -1198,7 +1166,7 @@ void verify_telnet_insert(TAOS* taos) {
...
@@ -1198,7 +1166,7 @@ void verify_telnet_insert(TAOS* taos) {
}
}
void
verify_json_insert
(
TAOS
*
taos
)
{
void
verify_json_insert
(
TAOS
*
taos
)
{
TAOS_RES
*
result
;
TAOS_RES
*
result
;
result
=
taos_query
(
taos
,
"drop database if exists db;"
);
result
=
taos_query
(
taos
,
"drop database if exists db;"
);
taos_free_result
(
result
);
taos_free_result
(
result
);
...
@@ -1210,8 +1178,8 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1210,8 +1178,8 @@ void verify_json_insert(TAOS* taos) {
(
void
)
taos_select_db
(
taos
,
"db"
);
(
void
)
taos_select_db
(
taos
,
"db"
);
int32_t
code
=
0
;
int32_t
code
=
0
;
char
*
message
=
char
*
message
=
"{ \
"{ \
\"
metric
\"
:
\"
cpu_load_0
\"
, \
\"
metric
\"
:
\"
cpu_load_0
\"
, \
\"
timestamp
\"
: 1626006833610123, \
\"
timestamp
\"
: 1626006833610123, \
\"
value
\"
: 55.5, \
\"
value
\"
: 55.5, \
...
@@ -1228,8 +1196,8 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1228,8 +1196,8 @@ void verify_json_insert(TAOS* taos) {
printf
(
"payload_0 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"payload_0 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
char
*
message1
=
char
*
message1
=
"[ \
"[ \
{ \
{ \
\"
metric
\"
:
\"
cpu_load_1
\"
, \
\"
metric
\"
:
\"
cpu_load_1
\"
, \
\"
timestamp
\"
: 1626006833610123, \
\"
timestamp
\"
: 1626006833610123, \
...
@@ -1259,8 +1227,8 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1259,8 +1227,8 @@ void verify_json_insert(TAOS* taos) {
printf
(
"payload_1 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"payload_1 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
char
*
message2
=
char
*
message2
=
"[ \
"[ \
{ \
{ \
\"
metric
\"
:
\"
cpu_load_3
\"
, \
\"
metric
\"
:
\"
cpu_load_3
\"
, \
\"
timestamp
\"
: \
\"
timestamp
\"
: \
...
@@ -1310,12 +1278,11 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1310,12 +1278,11 @@ void verify_json_insert(TAOS* taos) {
printf
(
"payload_2 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
printf
(
"payload_2 code: %d, %s.
\n
"
,
code
,
tstrerror
(
code
));
}
}
cJSON
*
payload
,
*
tags
;
cJSON
*
payload
,
*
tags
;
char
*
payload_str
;
char
*
payload_str
;
/* Default format */
/* Default format */
//number
//
number
payload
=
cJSON_CreateObject
();
payload
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb0_0"
);
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb0_0"
);
cJSON_AddNumberToObject
(
payload
,
"timestamp"
,
1626006833610123
);
cJSON_AddNumberToObject
(
payload
,
"timestamp"
,
1626006833610123
);
...
@@ -1327,7 +1294,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1327,7 +1294,7 @@ void verify_json_insert(TAOS* taos) {
cJSON_AddStringToObject
(
tags
,
"t4"
,
"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
);
cJSON_AddStringToObject
(
tags
,
"t4"
,
"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
);
cJSON_AddItemToObject
(
payload
,
"tags"
,
tags
);
cJSON_AddItemToObject
(
payload
,
"tags"
,
tags
);
payload_str
=
cJSON_Print
(
payload
);
payload_str
=
cJSON_Print
(
payload
);
//printf("%s\n", payload_str);
//
printf("%s\n", payload_str);
code
=
taos_insert_json_payload
(
taos
,
payload_str
);
code
=
taos_insert_json_payload
(
taos
,
payload_str
);
if
(
code
)
{
if
(
code
)
{
...
@@ -1336,7 +1303,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1336,7 +1303,7 @@ void verify_json_insert(TAOS* taos) {
free
(
payload_str
);
free
(
payload_str
);
cJSON_Delete
(
payload
);
cJSON_Delete
(
payload
);
//true
//
true
payload
=
cJSON_CreateObject
();
payload
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb0_1"
);
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb0_1"
);
cJSON_AddNumberToObject
(
payload
,
"timestamp"
,
1626006833610123
);
cJSON_AddNumberToObject
(
payload
,
"timestamp"
,
1626006833610123
);
...
@@ -1348,7 +1315,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1348,7 +1315,7 @@ void verify_json_insert(TAOS* taos) {
cJSON_AddStringToObject
(
tags
,
"t4"
,
"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
);
cJSON_AddStringToObject
(
tags
,
"t4"
,
"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
);
cJSON_AddItemToObject
(
payload
,
"tags"
,
tags
);
cJSON_AddItemToObject
(
payload
,
"tags"
,
tags
);
payload_str
=
cJSON_Print
(
payload
);
payload_str
=
cJSON_Print
(
payload
);
//printf("%s\n", payload_str);
//
printf("%s\n", payload_str);
code
=
taos_insert_json_payload
(
taos
,
payload_str
);
code
=
taos_insert_json_payload
(
taos
,
payload_str
);
if
(
code
)
{
if
(
code
)
{
...
@@ -1357,7 +1324,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1357,7 +1324,7 @@ void verify_json_insert(TAOS* taos) {
free
(
payload_str
);
free
(
payload_str
);
cJSON_Delete
(
payload
);
cJSON_Delete
(
payload
);
//false
//
false
payload
=
cJSON_CreateObject
();
payload
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb0_2"
);
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb0_2"
);
cJSON_AddNumberToObject
(
payload
,
"timestamp"
,
1626006833610123
);
cJSON_AddNumberToObject
(
payload
,
"timestamp"
,
1626006833610123
);
...
@@ -1369,7 +1336,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1369,7 +1336,7 @@ void verify_json_insert(TAOS* taos) {
cJSON_AddStringToObject
(
tags
,
"t4"
,
"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
);
cJSON_AddStringToObject
(
tags
,
"t4"
,
"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
);
cJSON_AddItemToObject
(
payload
,
"tags"
,
tags
);
cJSON_AddItemToObject
(
payload
,
"tags"
,
tags
);
payload_str
=
cJSON_Print
(
payload
);
payload_str
=
cJSON_Print
(
payload
);
//printf("%s\n", payload_str);
//
printf("%s\n", payload_str);
code
=
taos_insert_json_payload
(
taos
,
payload_str
);
code
=
taos_insert_json_payload
(
taos
,
payload_str
);
if
(
code
)
{
if
(
code
)
{
...
@@ -1378,7 +1345,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1378,7 +1345,7 @@ void verify_json_insert(TAOS* taos) {
free
(
payload_str
);
free
(
payload_str
);
cJSON_Delete
(
payload
);
cJSON_Delete
(
payload
);
//string
//
string
payload
=
cJSON_CreateObject
();
payload
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb0_3"
);
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb0_3"
);
cJSON_AddNumberToObject
(
payload
,
"timestamp"
,
1626006833610123
);
cJSON_AddNumberToObject
(
payload
,
"timestamp"
,
1626006833610123
);
...
@@ -1390,7 +1357,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1390,7 +1357,7 @@ void verify_json_insert(TAOS* taos) {
cJSON_AddStringToObject
(
tags
,
"t4"
,
"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
);
cJSON_AddStringToObject
(
tags
,
"t4"
,
"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
);
cJSON_AddItemToObject
(
payload
,
"tags"
,
tags
);
cJSON_AddItemToObject
(
payload
,
"tags"
,
tags
);
payload_str
=
cJSON_Print
(
payload
);
payload_str
=
cJSON_Print
(
payload
);
//printf("%s\n", payload_str);
//
printf("%s\n", payload_str);
code
=
taos_insert_json_payload
(
taos
,
payload_str
);
code
=
taos_insert_json_payload
(
taos
,
payload_str
);
if
(
code
)
{
if
(
code
)
{
...
@@ -1399,7 +1366,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1399,7 +1366,7 @@ void verify_json_insert(TAOS* taos) {
free
(
payload_str
);
free
(
payload_str
);
cJSON_Delete
(
payload
);
cJSON_Delete
(
payload
);
//timestamp 0 -> current time
//
timestamp 0 -> current time
payload
=
cJSON_CreateObject
();
payload
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb0_4"
);
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb0_4"
);
cJSON_AddNumberToObject
(
payload
,
"timestamp"
,
0
);
cJSON_AddNumberToObject
(
payload
,
"timestamp"
,
0
);
...
@@ -1411,7 +1378,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1411,7 +1378,7 @@ void verify_json_insert(TAOS* taos) {
cJSON_AddStringToObject
(
tags
,
"t4"
,
"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
);
cJSON_AddStringToObject
(
tags
,
"t4"
,
"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
);
cJSON_AddItemToObject
(
payload
,
"tags"
,
tags
);
cJSON_AddItemToObject
(
payload
,
"tags"
,
tags
);
payload_str
=
cJSON_Print
(
payload
);
payload_str
=
cJSON_Print
(
payload
);
//printf("%s\n", payload_str);
//
printf("%s\n", payload_str);
code
=
taos_insert_json_payload
(
taos
,
payload_str
);
code
=
taos_insert_json_payload
(
taos
,
payload_str
);
if
(
code
)
{
if
(
code
)
{
...
@@ -1420,7 +1387,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1420,7 +1387,7 @@ void verify_json_insert(TAOS* taos) {
free
(
payload_str
);
free
(
payload_str
);
cJSON_Delete
(
payload
);
cJSON_Delete
(
payload
);
//ID
//
ID
payload
=
cJSON_CreateObject
();
payload
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb0_5"
);
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb0_5"
);
cJSON_AddNumberToObject
(
payload
,
"timestamp"
,
0
);
cJSON_AddNumberToObject
(
payload
,
"timestamp"
,
0
);
...
@@ -1435,7 +1402,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1435,7 +1402,7 @@ void verify_json_insert(TAOS* taos) {
cJSON_AddStringToObject
(
tags
,
"id"
,
"tb555"
);
cJSON_AddStringToObject
(
tags
,
"id"
,
"tb555"
);
cJSON_AddItemToObject
(
payload
,
"tags"
,
tags
);
cJSON_AddItemToObject
(
payload
,
"tags"
,
tags
);
payload_str
=
cJSON_Print
(
payload
);
payload_str
=
cJSON_Print
(
payload
);
//printf("%s\n", payload_str);
//
printf("%s\n", payload_str);
code
=
taos_insert_json_payload
(
taos
,
payload_str
);
code
=
taos_insert_json_payload
(
taos
,
payload_str
);
if
(
code
)
{
if
(
code
)
{
...
@@ -1445,9 +1412,9 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1445,9 +1412,9 @@ void verify_json_insert(TAOS* taos) {
cJSON_Delete
(
payload
);
cJSON_Delete
(
payload
);
/* Nested format */
/* Nested format */
//timestamp
//
timestamp
cJSON
*
timestamp
;
cJSON
*
timestamp
;
//seconds
//
seconds
payload
=
cJSON_CreateObject
();
payload
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb1_0"
);
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb1_0"
);
...
@@ -1464,7 +1431,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1464,7 +1431,7 @@ void verify_json_insert(TAOS* taos) {
cJSON_AddStringToObject
(
tags
,
"t4"
,
"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
);
cJSON_AddStringToObject
(
tags
,
"t4"
,
"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
);
cJSON_AddItemToObject
(
payload
,
"tags"
,
tags
);
cJSON_AddItemToObject
(
payload
,
"tags"
,
tags
);
payload_str
=
cJSON_Print
(
payload
);
payload_str
=
cJSON_Print
(
payload
);
//printf("%s\n", payload_str);
//
printf("%s\n", payload_str);
code
=
taos_insert_json_payload
(
taos
,
payload_str
);
code
=
taos_insert_json_payload
(
taos
,
payload_str
);
if
(
code
)
{
if
(
code
)
{
...
@@ -1473,7 +1440,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1473,7 +1440,7 @@ void verify_json_insert(TAOS* taos) {
free
(
payload_str
);
free
(
payload_str
);
cJSON_Delete
(
payload
);
cJSON_Delete
(
payload
);
//milleseconds
//
milleseconds
payload
=
cJSON_CreateObject
();
payload
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb1_1"
);
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb1_1"
);
...
@@ -1490,7 +1457,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1490,7 +1457,7 @@ void verify_json_insert(TAOS* taos) {
cJSON_AddStringToObject
(
tags
,
"t4"
,
"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
);
cJSON_AddStringToObject
(
tags
,
"t4"
,
"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
);
cJSON_AddItemToObject
(
payload
,
"tags"
,
tags
);
cJSON_AddItemToObject
(
payload
,
"tags"
,
tags
);
payload_str
=
cJSON_Print
(
payload
);
payload_str
=
cJSON_Print
(
payload
);
//printf("%s\n", payload_str);
//
printf("%s\n", payload_str);
code
=
taos_insert_json_payload
(
taos
,
payload_str
);
code
=
taos_insert_json_payload
(
taos
,
payload_str
);
if
(
code
)
{
if
(
code
)
{
...
@@ -1499,7 +1466,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1499,7 +1466,7 @@ void verify_json_insert(TAOS* taos) {
free
(
payload_str
);
free
(
payload_str
);
cJSON_Delete
(
payload
);
cJSON_Delete
(
payload
);
//microseconds
//
microseconds
payload
=
cJSON_CreateObject
();
payload
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb1_2"
);
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb1_2"
);
...
@@ -1516,7 +1483,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1516,7 +1483,7 @@ void verify_json_insert(TAOS* taos) {
cJSON_AddStringToObject
(
tags
,
"t4"
,
"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
);
cJSON_AddStringToObject
(
tags
,
"t4"
,
"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
);
cJSON_AddItemToObject
(
payload
,
"tags"
,
tags
);
cJSON_AddItemToObject
(
payload
,
"tags"
,
tags
);
payload_str
=
cJSON_Print
(
payload
);
payload_str
=
cJSON_Print
(
payload
);
//printf("%s\n", payload_str);
//
printf("%s\n", payload_str);
code
=
taos_insert_json_payload
(
taos
,
payload_str
);
code
=
taos_insert_json_payload
(
taos
,
payload_str
);
if
(
code
)
{
if
(
code
)
{
...
@@ -1525,7 +1492,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1525,7 +1492,7 @@ void verify_json_insert(TAOS* taos) {
free
(
payload_str
);
free
(
payload_str
);
cJSON_Delete
(
payload
);
cJSON_Delete
(
payload
);
//nanoseconds
//
nanoseconds
payload
=
cJSON_CreateObject
();
payload
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb1_3"
);
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb1_3"
);
...
@@ -1542,7 +1509,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1542,7 +1509,7 @@ void verify_json_insert(TAOS* taos) {
cJSON_AddStringToObject
(
tags
,
"t4"
,
"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
);
cJSON_AddStringToObject
(
tags
,
"t4"
,
"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
);
cJSON_AddItemToObject
(
payload
,
"tags"
,
tags
);
cJSON_AddItemToObject
(
payload
,
"tags"
,
tags
);
payload_str
=
cJSON_Print
(
payload
);
payload_str
=
cJSON_Print
(
payload
);
//printf("%s\n", payload_str);
//
printf("%s\n", payload_str);
code
=
taos_insert_json_payload
(
taos
,
payload_str
);
code
=
taos_insert_json_payload
(
taos
,
payload_str
);
if
(
code
)
{
if
(
code
)
{
...
@@ -1551,7 +1518,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1551,7 +1518,7 @@ void verify_json_insert(TAOS* taos) {
free
(
payload_str
);
free
(
payload_str
);
cJSON_Delete
(
payload
);
cJSON_Delete
(
payload
);
//now
//
now
payload
=
cJSON_CreateObject
();
payload
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb1_4"
);
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb1_4"
);
...
@@ -1568,7 +1535,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1568,7 +1535,7 @@ void verify_json_insert(TAOS* taos) {
cJSON_AddStringToObject
(
tags
,
"t4"
,
"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
);
cJSON_AddStringToObject
(
tags
,
"t4"
,
"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
);
cJSON_AddItemToObject
(
payload
,
"tags"
,
tags
);
cJSON_AddItemToObject
(
payload
,
"tags"
,
tags
);
payload_str
=
cJSON_Print
(
payload
);
payload_str
=
cJSON_Print
(
payload
);
//printf("%s\n", payload_str);
//
printf("%s\n", payload_str);
code
=
taos_insert_json_payload
(
taos
,
payload_str
);
code
=
taos_insert_json_payload
(
taos
,
payload_str
);
if
(
code
)
{
if
(
code
)
{
...
@@ -1577,9 +1544,9 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1577,9 +1544,9 @@ void verify_json_insert(TAOS* taos) {
free
(
payload_str
);
free
(
payload_str
);
cJSON_Delete
(
payload
);
cJSON_Delete
(
payload
);
//metric value
//
metric value
cJSON
*
metric_val
;
cJSON
*
metric_val
;
//bool
//
bool
payload
=
cJSON_CreateObject
();
payload
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb2_0"
);
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb2_0"
);
...
@@ -1600,7 +1567,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1600,7 +1567,7 @@ void verify_json_insert(TAOS* taos) {
cJSON_AddStringToObject
(
tags
,
"t4"
,
"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
);
cJSON_AddStringToObject
(
tags
,
"t4"
,
"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
);
cJSON_AddItemToObject
(
payload
,
"tags"
,
tags
);
cJSON_AddItemToObject
(
payload
,
"tags"
,
tags
);
payload_str
=
cJSON_Print
(
payload
);
payload_str
=
cJSON_Print
(
payload
);
//printf("%s\n", payload_str);
//
printf("%s\n", payload_str);
code
=
taos_insert_json_payload
(
taos
,
payload_str
);
code
=
taos_insert_json_payload
(
taos
,
payload_str
);
if
(
code
)
{
if
(
code
)
{
...
@@ -1609,7 +1576,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1609,7 +1576,7 @@ void verify_json_insert(TAOS* taos) {
free
(
payload_str
);
free
(
payload_str
);
cJSON_Delete
(
payload
);
cJSON_Delete
(
payload
);
//tinyint
//
tinyint
payload
=
cJSON_CreateObject
();
payload
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb2_1"
);
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb2_1"
);
...
@@ -1630,7 +1597,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1630,7 +1597,7 @@ void verify_json_insert(TAOS* taos) {
cJSON_AddStringToObject
(
tags
,
"t4"
,
"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
);
cJSON_AddStringToObject
(
tags
,
"t4"
,
"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
);
cJSON_AddItemToObject
(
payload
,
"tags"
,
tags
);
cJSON_AddItemToObject
(
payload
,
"tags"
,
tags
);
payload_str
=
cJSON_Print
(
payload
);
payload_str
=
cJSON_Print
(
payload
);
//printf("%s\n", payload_str);
//
printf("%s\n", payload_str);
code
=
taos_insert_json_payload
(
taos
,
payload_str
);
code
=
taos_insert_json_payload
(
taos
,
payload_str
);
if
(
code
)
{
if
(
code
)
{
...
@@ -1639,7 +1606,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1639,7 +1606,7 @@ void verify_json_insert(TAOS* taos) {
free
(
payload_str
);
free
(
payload_str
);
cJSON_Delete
(
payload
);
cJSON_Delete
(
payload
);
//smallint
//
smallint
payload
=
cJSON_CreateObject
();
payload
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb2_2"
);
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb2_2"
);
...
@@ -1660,7 +1627,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1660,7 +1627,7 @@ void verify_json_insert(TAOS* taos) {
cJSON_AddStringToObject
(
tags
,
"t4"
,
"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
);
cJSON_AddStringToObject
(
tags
,
"t4"
,
"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
);
cJSON_AddItemToObject
(
payload
,
"tags"
,
tags
);
cJSON_AddItemToObject
(
payload
,
"tags"
,
tags
);
payload_str
=
cJSON_Print
(
payload
);
payload_str
=
cJSON_Print
(
payload
);
//printf("%s\n", payload_str);
//
printf("%s\n", payload_str);
code
=
taos_insert_json_payload
(
taos
,
payload_str
);
code
=
taos_insert_json_payload
(
taos
,
payload_str
);
if
(
code
)
{
if
(
code
)
{
...
@@ -1669,7 +1636,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1669,7 +1636,7 @@ void verify_json_insert(TAOS* taos) {
free
(
payload_str
);
free
(
payload_str
);
cJSON_Delete
(
payload
);
cJSON_Delete
(
payload
);
//int
//
int
payload
=
cJSON_CreateObject
();
payload
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb2_3"
);
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb2_3"
);
...
@@ -1690,7 +1657,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1690,7 +1657,7 @@ void verify_json_insert(TAOS* taos) {
cJSON_AddStringToObject
(
tags
,
"t4"
,
"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
);
cJSON_AddStringToObject
(
tags
,
"t4"
,
"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
);
cJSON_AddItemToObject
(
payload
,
"tags"
,
tags
);
cJSON_AddItemToObject
(
payload
,
"tags"
,
tags
);
payload_str
=
cJSON_Print
(
payload
);
payload_str
=
cJSON_Print
(
payload
);
//printf("%s\n", payload_str);
//
printf("%s\n", payload_str);
code
=
taos_insert_json_payload
(
taos
,
payload_str
);
code
=
taos_insert_json_payload
(
taos
,
payload_str
);
if
(
code
)
{
if
(
code
)
{
...
@@ -1699,7 +1666,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1699,7 +1666,7 @@ void verify_json_insert(TAOS* taos) {
free
(
payload_str
);
free
(
payload_str
);
cJSON_Delete
(
payload
);
cJSON_Delete
(
payload
);
//bigint
//
bigint
payload
=
cJSON_CreateObject
();
payload
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb2_4"
);
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb2_4"
);
...
@@ -1720,7 +1687,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1720,7 +1687,7 @@ void verify_json_insert(TAOS* taos) {
cJSON_AddStringToObject
(
tags
,
"t4"
,
"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
);
cJSON_AddStringToObject
(
tags
,
"t4"
,
"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
);
cJSON_AddItemToObject
(
payload
,
"tags"
,
tags
);
cJSON_AddItemToObject
(
payload
,
"tags"
,
tags
);
payload_str
=
cJSON_Print
(
payload
);
payload_str
=
cJSON_Print
(
payload
);
//printf("%s\n", payload_str);
//
printf("%s\n", payload_str);
code
=
taos_insert_json_payload
(
taos
,
payload_str
);
code
=
taos_insert_json_payload
(
taos
,
payload_str
);
if
(
code
)
{
if
(
code
)
{
...
@@ -1729,7 +1696,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1729,7 +1696,7 @@ void verify_json_insert(TAOS* taos) {
free
(
payload_str
);
free
(
payload_str
);
cJSON_Delete
(
payload
);
cJSON_Delete
(
payload
);
//float
//
float
payload
=
cJSON_CreateObject
();
payload
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb2_5"
);
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb2_5"
);
...
@@ -1750,7 +1717,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1750,7 +1717,7 @@ void verify_json_insert(TAOS* taos) {
cJSON_AddStringToObject
(
tags
,
"t4"
,
"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
);
cJSON_AddStringToObject
(
tags
,
"t4"
,
"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
);
cJSON_AddItemToObject
(
payload
,
"tags"
,
tags
);
cJSON_AddItemToObject
(
payload
,
"tags"
,
tags
);
payload_str
=
cJSON_Print
(
payload
);
payload_str
=
cJSON_Print
(
payload
);
//printf("%s\n", payload_str);
//
printf("%s\n", payload_str);
code
=
taos_insert_json_payload
(
taos
,
payload_str
);
code
=
taos_insert_json_payload
(
taos
,
payload_str
);
if
(
code
)
{
if
(
code
)
{
...
@@ -1759,7 +1726,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1759,7 +1726,7 @@ void verify_json_insert(TAOS* taos) {
free
(
payload_str
);
free
(
payload_str
);
cJSON_Delete
(
payload
);
cJSON_Delete
(
payload
);
//double
//
double
payload
=
cJSON_CreateObject
();
payload
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb2_6"
);
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb2_6"
);
...
@@ -1780,7 +1747,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1780,7 +1747,7 @@ void verify_json_insert(TAOS* taos) {
cJSON_AddStringToObject
(
tags
,
"t4"
,
"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
);
cJSON_AddStringToObject
(
tags
,
"t4"
,
"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
);
cJSON_AddItemToObject
(
payload
,
"tags"
,
tags
);
cJSON_AddItemToObject
(
payload
,
"tags"
,
tags
);
payload_str
=
cJSON_Print
(
payload
);
payload_str
=
cJSON_Print
(
payload
);
//printf("%s\n", payload_str);
//
printf("%s\n", payload_str);
code
=
taos_insert_json_payload
(
taos
,
payload_str
);
code
=
taos_insert_json_payload
(
taos
,
payload_str
);
if
(
code
)
{
if
(
code
)
{
...
@@ -1789,7 +1756,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1789,7 +1756,7 @@ void verify_json_insert(TAOS* taos) {
free
(
payload_str
);
free
(
payload_str
);
cJSON_Delete
(
payload
);
cJSON_Delete
(
payload
);
//binary
//
binary
payload
=
cJSON_CreateObject
();
payload
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb2_7"
);
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb2_7"
);
...
@@ -1810,7 +1777,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1810,7 +1777,7 @@ void verify_json_insert(TAOS* taos) {
cJSON_AddStringToObject
(
tags
,
"t4"
,
"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
);
cJSON_AddStringToObject
(
tags
,
"t4"
,
"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
);
cJSON_AddItemToObject
(
payload
,
"tags"
,
tags
);
cJSON_AddItemToObject
(
payload
,
"tags"
,
tags
);
payload_str
=
cJSON_Print
(
payload
);
payload_str
=
cJSON_Print
(
payload
);
//printf("%s\n", payload_str);
//
printf("%s\n", payload_str);
code
=
taos_insert_json_payload
(
taos
,
payload_str
);
code
=
taos_insert_json_payload
(
taos
,
payload_str
);
if
(
code
)
{
if
(
code
)
{
...
@@ -1819,7 +1786,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1819,7 +1786,7 @@ void verify_json_insert(TAOS* taos) {
free
(
payload_str
);
free
(
payload_str
);
cJSON_Delete
(
payload
);
cJSON_Delete
(
payload
);
//nchar
//
nchar
payload
=
cJSON_CreateObject
();
payload
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb2_8"
);
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb2_8"
);
...
@@ -1840,7 +1807,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1840,7 +1807,7 @@ void verify_json_insert(TAOS* taos) {
cJSON_AddStringToObject
(
tags
,
"t4"
,
"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
);
cJSON_AddStringToObject
(
tags
,
"t4"
,
"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>"
);
cJSON_AddItemToObject
(
payload
,
"tags"
,
tags
);
cJSON_AddItemToObject
(
payload
,
"tags"
,
tags
);
payload_str
=
cJSON_Print
(
payload
);
payload_str
=
cJSON_Print
(
payload
);
//printf("%s\n", payload_str);
//
printf("%s\n", payload_str);
code
=
taos_insert_json_payload
(
taos
,
payload_str
);
code
=
taos_insert_json_payload
(
taos
,
payload_str
);
if
(
code
)
{
if
(
code
)
{
...
@@ -1849,8 +1816,8 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1849,8 +1816,8 @@ void verify_json_insert(TAOS* taos) {
free
(
payload_str
);
free
(
payload_str
);
cJSON_Delete
(
payload
);
cJSON_Delete
(
payload
);
//tag value
//
tag value
cJSON
*
tag
;
cJSON
*
tag
;
payload
=
cJSON_CreateObject
();
payload
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb3_0"
);
cJSON_AddStringToObject
(
payload
,
"metric"
,
"stb3_0"
);
...
@@ -1920,7 +1887,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1920,7 +1887,7 @@ void verify_json_insert(TAOS* taos) {
cJSON_AddItemToObject
(
payload
,
"tags"
,
tags
);
cJSON_AddItemToObject
(
payload
,
"tags"
,
tags
);
payload_str
=
cJSON_Print
(
payload
);
payload_str
=
cJSON_Print
(
payload
);
//printf("%s\n", payload_str);
//
printf("%s\n", payload_str);
code
=
taos_insert_json_payload
(
taos
,
payload_str
);
code
=
taos_insert_json_payload
(
taos
,
payload_str
);
if
(
code
)
{
if
(
code
)
{
...
@@ -1930,7 +1897,7 @@ void verify_json_insert(TAOS* taos) {
...
@@ -1930,7 +1897,7 @@ void verify_json_insert(TAOS* taos) {
cJSON_Delete
(
payload
);
cJSON_Delete
(
payload
);
}
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
const
char
*
host
=
"127.0.0.1"
;
const
char
*
host
=
"127.0.0.1"
;
const
char
*
user
=
"root"
;
const
char
*
user
=
"root"
;
const
char
*
passwd
=
"taosdata"
;
const
char
*
passwd
=
"taosdata"
;
...
...
source/client/src/clientSml.c
浏览文件 @
1613b43f
...
@@ -2654,9 +2654,7 @@ end:
...
@@ -2654,9 +2654,7 @@ end:
* 0 - influxDB line protocol
* 0 - influxDB line protocol
* 1 - OpenTSDB telnet line protocol
* 1 - OpenTSDB telnet line protocol
* 2 - OpenTSDB JSON format protocol
* 2 - OpenTSDB JSON format protocol
* @return return zero for successful insertion. Otherwise return none-zero error code of
* @return TAOS_RES
* failure reason.
*
*/
*/
TAOS_RES
*
taos_schemaless_insert
(
TAOS
*
taos
,
char
*
lines
[],
int
numLines
,
int
protocol
,
int
precision
)
{
TAOS_RES
*
taos_schemaless_insert
(
TAOS
*
taos
,
char
*
lines
[],
int
numLines
,
int
protocol
,
int
precision
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录