Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c23260f9
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看板
提交
c23260f9
编写于
4月 20, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
stmt
上级
d61da445
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
540 addition
and
1514 deletion
+540
-1514
tests/script/api/batchprepare.c
tests/script/api/batchprepare.c
+540
-1514
未找到文件。
tests/script/api/batchprepare.c
浏览文件 @
c23260f9
...
...
@@ -63,31 +63,40 @@ typedef struct {
}
CaseCfg
;
CaseCfg
gCase
[]
=
{
// {"insert:MBSE1-FULL", tListLen(shortColList), shortColList, false, true, insertMBSETest1, 1, 10, 10, 0, 0, 10},
// {"insert:MBSE1-FULL", tListLen(shortColList), shortColList, false, true, insertMBSETest1, 10, 100, 10, 0, 0, 10},
// {"insert:MBSE1-FULL", tListLen(longColList), longColList, false, true, insertMBSETest1, 10, 10, 2, 0, 0, 1},
// {"insert:MBSE1-C012", tListLen(longColList), longColList, false, false, insertMBSETest1, 10, 10, 2, 12, 0, 1},
// {"insert:MBSE1-C002", tListLen(longColList), longColList, false, false, insertMBSETest1, 10, 10, 2, 2, 0, 1},
// {"insert:MBSE2-FULL", tListLen(longColList), longColList, false, true, insertMBSETest2, 10, 10, 2, 0, 0, 1},
// {"insert:MBSE2-C012", tListLen(longColList), longColList, false, false, insertMBSETest2, 10, 10, 2, 12, 0, 1},
// {"insert:MBSE2-C002", tListLen(longColList), longColList, false, false, insertMBSETest2, 10, 10, 2, 2, 0, 1},
// {"insert:MBME1-FULL", tListLen(longColList), longColList, false, true, insertMBMETest1, 10, 10, 2, 0, 0, 1},
// {"insert:MBME1-C012", tListLen(longColList), longColList, false, false, insertMBMETest1, 10, 10, 2, 12, 0, 1},
// {"insert:MBME1-C002", tListLen(longColList), longColList, false, false, insertMBMETest1, 10, 10, 2, 2, 0, 1},
// {"insert:MBME2-FULL", tListLen(longColList), longColList, false, true, insertMBMETest2, 10, 10, 2, 0, 0, 1},
// {"insert:MBME2-C012", tListLen(longColList), longColList, false, false, insertMBMETest2, 10, 10, 2, 12, 0, 1},
// {"insert:MBME2-C002", tListLen(longColList), longColList, false, false, insertMBMETest2, 10, 10, 2, 2, 0, 1},
// {"insert:MBME3-FULL", tListLen(longColList), longColList, false, true, insertMBMETest3, 10, 10, 2, 0, 0, 1},
// {"insert:MBME3-C012", tListLen(longColList), longColList, false, false, insertMBMETest3, 10, 10, 2, 12, 0, 1},
// {"insert:MBME3-C002", tListLen(longColList), longColList, false, false, insertMBMETest3, 10, 10, 2, 2, 0, 1},
// {"insert:MBME4-FULL", tListLen(longColList), longColList, false, true, insertMBMETest4, 10, 10, 2, 0, 0, 1},
// {"insert:MBME4-C012", tListLen(longColList), longColList, false, false, insertMBMETest4, 10, 10, 2, 12, 0, 1},
#if 0
{"insert:MBSE1-FULL", tListLen(shortColList), shortColList, false, true, insertMBSETest1, 1, 10, 10, 0, 0, 10},
{"insert:MBSE1-FULL", tListLen(shortColList), shortColList, false, true, insertMBSETest1, 10, 100, 10, 0, 0, 10},
{"insert:MBSE1-FULL", tListLen(longColList), longColList, false, true, insertMBSETest1, 10, 10, 2, 0, 0, 1},
{"insert:MBSE1-C012", tListLen(longColList), longColList, false, false, insertMBSETest1, 10, 10, 2, 12, 0, 1},
{"insert:MBSE1-C002", tListLen(longColList), longColList, false, false, insertMBSETest1, 10, 10, 2, 2, 0, 1},
{"insert:MBSE2-FULL", tListLen(longColList), longColList, false, true, insertMBSETest2, 10, 10, 2, 0, 0, 1},
{"insert:MBSE2-C012", tListLen(longColList), longColList, false, false, insertMBSETest2, 10, 10, 2, 12, 0, 1},
{"insert:MBSE2-C002", tListLen(longColList), longColList, false, false, insertMBSETest2, 10, 10, 2, 2, 0, 1},
{"insert:MBME1-FULL", tListLen(longColList), longColList, false, true, insertMBMETest1, 10, 10, 2, 0, 0, 1},
{"insert:MBME1-C012", tListLen(longColList), longColList, false, false, insertMBMETest1, 10, 10, 2, 12, 0, 1},
{"insert:MBME1-C002", tListLen(longColList), longColList, false, false, insertMBMETest1, 10, 10, 2, 2, 0, 1},
{"insert:MBME2-FULL", tListLen(longColList), longColList, false, true, insertMBMETest2, 10, 10, 2, 0, 0, 1},
{"insert:MBME2-C012", tListLen(longColList), longColList, false, false, insertMBMETest2, 10, 10, 2, 12, 0, 1},
{"insert:MBME2-C002", tListLen(longColList), longColList, false, false, insertMBMETest2, 10, 10, 2, 2, 0, 1},
{"insert:MBME3-FULL", tListLen(longColList), longColList, false, true, insertMBMETest3, 10, 10, 2, 0, 0, 1},
{"insert:MBME3-C012", tListLen(longColList), longColList, false, false, insertMBMETest3, 10, 10, 2, 12, 0, 1},
{"insert:MBME3-C002", tListLen(longColList), longColList, false, false, insertMBMETest3, 10, 10, 2, 2, 0, 1},
#endif
{
"insert:MBME4-FULL"
,
tListLen
(
longColList
),
longColList
,
false
,
true
,
insertMBMETest4
,
10
,
10
,
2
,
0
,
0
,
1
},
{
"insert:MBME4-C012"
,
tListLen
(
longColList
),
longColList
,
false
,
false
,
insertMBMETest4
,
10
,
10
,
2
,
12
,
0
,
1
},
{
"insert:MBME4-C002"
,
tListLen
(
longColList
),
longColList
,
false
,
false
,
insertMBMETest4
,
10
,
10
,
2
,
2
,
0
,
1
},
};
CaseCfg
*
gCurCase
=
NULL
;
int32_t
gTestNull
=
1
;
bool
gTestAutoCreate
=
false
;
int32_t
taosGetTimeOfDay
(
struct
timeval
*
tv
)
{
return
gettimeofday
(
tv
,
NULL
);
...
...
@@ -704,8 +713,8 @@ int insertMBMETest4(TAOS_STMT *stmt) {
return
0
;
}
int
stmt_
scol_
func1
(
TAOS_STMT
*
stmt
)
{
#if 0
int stmt_func1(TAOS_STMT *stmt) {
struct {
int64_t ts;
int8_t b;
...
...
@@ -718,55 +727,74 @@ int stmt_scol_func1(TAOS_STMT *stmt) {
char bin[40];
char blob[80];
} v = {0};
int32_t
len
[
10
]
=
{
sizeof
(
v
.
ts
),
sizeof
(
v
.
v1
),
sizeof
(
v
.
v2
),
sizeof
(
v
.
f4
),
sizeof
(
v
.
bin
),
sizeof
(
v
.
bin
)};
TAOS_BIND
_v2
params
[
10
];
TAOS_BIND params[10];
params[0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP;
params[0].buffer_length = sizeof(v.ts);
params[0].buffer = &v.ts;
params
[
0
].
length
=
&
len
[
0
]
;
params[0].length = &
params[0].buffer_length
;
params[0].is_null = NULL;
params
[
0
].
num
=
1
;
params
[
1
].
buffer_type
=
TSDB_DATA_TYPE_
TINYINT
;
params
[
1
].
buffer_length
=
sizeof
(
v
.
v1
);
params
[
1
].
buffer
=
&
v
.
v1
;
params
[
1
].
length
=
&
len
[
1
]
;
params[1].buffer_type = TSDB_DATA_TYPE_
BOOL
;
params[1].buffer_length = sizeof(v.
b
);
params[1].buffer = &v.
b
;
params[1].length = &
params[1].buffer_length
;
params[1].is_null = NULL;
params
[
1
].
num
=
1
;
params
[
2
].
buffer_type
=
TSDB_DATA_TYPE_
SMALL
INT
;
params
[
2
].
buffer_length
=
sizeof
(
v
.
v
2
);
params
[
2
].
buffer
=
&
v
.
v
2
;
params
[
2
].
length
=
&
len
[
2
]
;
params[2].buffer_type = TSDB_DATA_TYPE_
TINY
INT;
params[2].buffer_length = sizeof(v.v
1
);
params[2].buffer = &v.v
1
;
params[2].length = &
params[2].buffer_length
;
params[2].is_null = NULL;
params
[
2
].
num
=
1
;
params
[
3
].
buffer_type
=
TSDB_DATA_TYPE_
FLOA
T
;
params
[
3
].
buffer_length
=
sizeof
(
v
.
f4
);
params
[
3
].
buffer
=
&
v
.
f4
;
params
[
3
].
length
=
&
len
[
3
]
;
params[3].buffer_type = TSDB_DATA_TYPE_
SMALLIN
T;
params[3].buffer_length = sizeof(v.
v2
);
params[3].buffer = &v.
v2
;
params[3].length = &
params[3].buffer_length
;
params[3].is_null = NULL;
params
[
3
].
num
=
1
;
params
[
4
].
buffer_type
=
TSDB_DATA_TYPE_
BINARY
;
params
[
4
].
buffer_length
=
sizeof
(
v
.
bin
);
params
[
4
].
buffer
=
v
.
bin
;
params
[
4
].
length
=
&
len
[
4
]
;
params[4].buffer_type = TSDB_DATA_TYPE_
INT
;
params[4].buffer_length = sizeof(v.
v4
);
params[4].buffer =
&v.v4
;
params[4].length = &
params[4].buffer_length
;
params[4].is_null = NULL;
params
[
4
].
num
=
1
;
params
[
5
].
buffer_type
=
TSDB_DATA_TYPE_BI
NARY
;
params
[
5
].
buffer_length
=
sizeof
(
v
.
bin
);
params
[
5
].
buffer
=
v
.
bin
;
params
[
5
].
length
=
&
len
[
5
]
;
params[5].buffer_type = TSDB_DATA_TYPE_BI
GINT
;
params[5].buffer_length = sizeof(v.
v8
);
params[5].buffer =
&v.v8
;
params[5].length = &
params[5].buffer_length
;
params[5].is_null = NULL;
params
[
5
].
num
=
1
;
char
*
sql
=
"insert into ? (ts, v1,v2,f4,bin,bin2) values(?,?,?,?,?,?)"
;
params[6].buffer_type = TSDB_DATA_TYPE_FLOAT;
params[6].buffer_length = sizeof(v.f4);
params[6].buffer = &v.f4;
params[6].length = ¶ms[6].buffer_length;
params[6].is_null = NULL;
params[7].buffer_type = TSDB_DATA_TYPE_DOUBLE;
params[7].buffer_length = sizeof(v.f8);
params[7].buffer = &v.f8;
params[7].length = ¶ms[7].buffer_length;
params[7].is_null = NULL;
params[8].buffer_type = TSDB_DATA_TYPE_BINARY;
params[8].buffer_length = sizeof(v.bin);
params[8].buffer = v.bin;
params[8].length = ¶ms[8].buffer_length;
params[8].is_null = NULL;
params[9].buffer_type = TSDB_DATA_TYPE_BINARY;
params[9].buffer_length = sizeof(v.bin);
params[9].buffer = v.bin;
params[9].length = ¶ms[9].buffer_length;
params[9].is_null = NULL;
int is_null = 1;
char *sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?)";
int code = taos_stmt_prepare(stmt, sql, 0);
if (code != 0){
printf
(
"failed to execute taos_stmt_prepare.
error:%s
\n
"
,
taos_stmt_errstr
(
stmt
)
);
printf("failed to execute taos_stmt_prepare.
code:0x%x\n", code
);
}
for (int zz = 0; zz < 10; zz++) {
...
...
@@ -774,13 +802,14 @@ int stmt_scol_func1(TAOS_STMT *stmt) {
sprintf(buf, "m%d", zz);
code = taos_stmt_set_tbname(stmt, buf);
if (code != 0){
printf
(
"failed to execute taos_stmt_set_tbname. error:%s
\n
"
,
taos_stmt_errstr
(
stmt
));
exit
(
1
);
printf("failed to execute taos_stmt_set_tbname. code:0x%x\n", code);
}
v.ts = 1591060628000 + zz * 10;
for (int i = 0; i < 10; ++i) {
v.ts += 1;
for (int j = 1; j < 10; ++j) {
params[j].is_null = ((i == j) ? &is_null : 0);
}
v.b = (int8_t)(i+zz*10) % 2;
v.v1 = (int8_t)(i+zz*10);
v.v2 = (int16_t)((i+zz*10) * 2);
...
...
@@ -789,7 +818,7 @@ int stmt_scol_func1(TAOS_STMT *stmt) {
v.f4 = (float)((i+zz*10) * 40);
v.f8 = (double)((i+zz*10) * 80);
for (int j = 0; j < sizeof(v.bin) - 1; ++j) {
v
.
bin
[
j
]
=
(
char
)((
i
)
%
10
+
'0'
);
v.bin[j] = (char)((i
+zz
)%10 + '0');
}
taos_stmt_bind_param(stmt, params);
...
...
@@ -798,7 +827,7 @@ int stmt_scol_func1(TAOS_STMT *stmt) {
}
if (taos_stmt_execute(stmt) != 0) {
printf
(
"failed to execute insert statement
, error:%s.
\n
"
,
taos_stmt_errstr
(
stmt
)
);
printf("failed to execute insert statement
.\n"
);
exit(1);
}
...
...
@@ -806,7 +835,7 @@ int stmt_scol_func1(TAOS_STMT *stmt) {
}
int
stmt_
scol_
func2
(
TAOS_STMT
*
stmt
)
{
int stmt_func2(TAOS_STMT *stmt) {
struct {
int64_t ts;
int8_t b;
...
...
@@ -820,628 +849,105 @@ int stmt_scol_func2(TAOS_STMT *stmt) {
char blob[80];
} v = {0};
TAOS_BIND
_v2
params
[
10
];
TAOS_BIND params[10];
params[0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP;
params[0].buffer_length = sizeof(v.ts);
params[0].buffer = &v.ts;
params[0].length = ¶ms[0].buffer_length;
params[0].is_null = NULL;
params
[
0
].
num
=
1
;
params
[
1
].
buffer_type
=
TSDB_DATA_TYPE_
TINYINT
;
params
[
1
].
buffer_length
=
sizeof
(
v
.
v1
);
params
[
1
].
buffer
=
&
v
.
v1
;
params[1].buffer_type = TSDB_DATA_TYPE_
BOOL
;
params[1].buffer_length = sizeof(v.
b
);
params[1].buffer = &v.
b
;
params[1].length = ¶ms[1].buffer_length;
params[1].is_null = NULL;
params
[
1
].
num
=
1
;
params
[
2
].
buffer_type
=
TSDB_DATA_TYPE_
SMALL
INT
;
params
[
2
].
buffer_length
=
sizeof
(
v
.
v
2
);
params
[
2
].
buffer
=
&
v
.
v
2
;
params[2].buffer_type = TSDB_DATA_TYPE_
TINY
INT;
params[2].buffer_length = sizeof(v.v
1
);
params[2].buffer = &v.v
1
;
params[2].length = ¶ms[2].buffer_length;
params[2].is_null = NULL;
params
[
2
].
num
=
1
;
params
[
3
].
buffer_type
=
TSDB_DATA_TYPE_
FLOA
T
;
params
[
3
].
buffer_length
=
sizeof
(
v
.
f4
);
params
[
3
].
buffer
=
&
v
.
f4
;
params[3].buffer_type = TSDB_DATA_TYPE_
SMALLIN
T;
params[3].buffer_length = sizeof(v.
v2
);
params[3].buffer = &v.
v2
;
params[3].length = ¶ms[3].buffer_length;
params[3].is_null = NULL;
params
[
3
].
num
=
1
;
params
[
4
].
buffer_type
=
TSDB_DATA_TYPE_
BINARY
;
params
[
4
].
buffer_length
=
sizeof
(
v
.
bin
);
params
[
4
].
buffer
=
v
.
bin
;
params[4].buffer_type = TSDB_DATA_TYPE_
INT
;
params[4].buffer_length = sizeof(v.
v4
);
params[4].buffer =
&v.v4
;
params[4].length = ¶ms[4].buffer_length;
params[4].is_null = NULL;
params
[
4
].
num
=
1
;
params
[
5
].
buffer_type
=
TSDB_DATA_TYPE_BI
NARY
;
params
[
5
].
buffer_length
=
sizeof
(
v
.
bin
);
params
[
5
].
buffer
=
v
.
bin
;
params[5].buffer_type = TSDB_DATA_TYPE_BI
GINT
;
params[5].buffer_length = sizeof(v.
v8
);
params[5].buffer =
&v.v8
;
params[5].length = ¶ms[5].buffer_length;
params[5].is_null = NULL;
params
[
5
].
num
=
1
;
char
*
sql
=
"insert into m0 (ts, v1,v2,f4,bin,bin2) values(?,?,?,?,?,?)"
;
int
code
=
taos_stmt_prepare
(
stmt
,
sql
,
0
);
if
(
code
!=
0
){
printf
(
"failed to execute taos_stmt_prepare. code:0x%x
\n
"
,
code
);
}
for
(
int
zz
=
0
;
zz
<
10
;
zz
++
)
{
v
.
ts
=
1591060628000
+
zz
*
10
;
for
(
int
i
=
0
;
i
<
10
;
++
i
)
{
v
.
ts
+=
1
;
v
.
b
=
(
int8_t
)(
i
+
zz
*
10
)
%
2
;
v
.
v1
=
(
int8_t
)(
i
+
zz
*
10
);
v
.
v2
=
(
int16_t
)((
i
+
zz
*
10
)
*
2
);
v
.
v4
=
(
int32_t
)((
i
+
zz
*
10
)
*
4
);
v
.
v8
=
(
int64_t
)((
i
+
zz
*
10
)
*
8
);
v
.
f4
=
(
float
)((
i
+
zz
*
10
)
*
40
);
v
.
f8
=
(
double
)((
i
+
zz
*
10
)
*
80
);
for
(
int
j
=
0
;
j
<
sizeof
(
v
.
bin
)
-
1
;
++
j
)
{
v
.
bin
[
j
]
=
(
char
)((
i
)
%
10
+
'0'
);
}
taos_stmt_bind_param
(
stmt
,
params
);
taos_stmt_add_batch
(
stmt
);
}
}
if
(
taos_stmt_execute
(
stmt
)
!=
0
)
{
printf
(
"failed to execute insert statement.
\n
"
);
exit
(
1
);
}
return
0
;
}
//300 tables 60 records
int
stmt_scol_func3
(
TAOS_STMT
*
stmt
)
{
struct
{
int64_t
*
ts
;
int8_t
b
[
60
];
int8_t
v1
[
60
];
int16_t
v2
[
60
];
int32_t
v4
[
60
];
int64_t
v8
[
60
];
float
f4
[
60
];
double
f8
[
60
];
char
bin
[
60
][
40
];
}
v
=
{
0
};
v
.
ts
=
taosMemoryMalloc
(
sizeof
(
int64_t
)
*
900000
*
60
);
int
*
lb
=
taosMemoryMalloc
(
60
*
sizeof
(
int
));
TAOS_BIND_v2
*
params
=
taosMemoryCalloc
(
1
,
sizeof
(
TAOS_BIND_v2
)
*
900000
*
10
);
char
*
is_null
=
taosMemoryMalloc
(
sizeof
(
char
)
*
60
);
char
*
no_null
=
taosMemoryMalloc
(
sizeof
(
char
)
*
60
);
for
(
int
i
=
0
;
i
<
60
;
++
i
)
{
lb
[
i
]
=
40
;
no_null
[
i
]
=
0
;
is_null
[
i
]
=
(
i
%
10
==
2
)
?
1
:
0
;
v
.
b
[
i
]
=
(
int8_t
)(
i
%
2
);
v
.
v1
[
i
]
=
(
int8_t
)((
i
+
1
)
%
2
);
v
.
v2
[
i
]
=
(
int16_t
)
i
;
v
.
v4
[
i
]
=
(
int32_t
)(
i
+
1
);
v
.
v8
[
i
]
=
(
int64_t
)(
i
+
2
);
v
.
f4
[
i
]
=
(
float
)(
i
+
3
);
v
.
f8
[
i
]
=
(
double
)(
i
+
4
);
memset
(
v
.
bin
[
i
],
'0'
+
i
%
10
,
40
);
}
for
(
int
i
=
0
;
i
<
9000000
;
i
+=
10
)
{
params
[
i
+
0
].
buffer_type
=
TSDB_DATA_TYPE_TIMESTAMP
;
params
[
i
+
0
].
buffer_length
=
sizeof
(
int64_t
);
params
[
i
+
0
].
buffer
=
&
v
.
ts
[
10
*
i
/
10
];
params
[
i
+
0
].
length
=
NULL
;
params
[
i
+
0
].
is_null
=
no_null
;
params
[
i
+
0
].
num
=
10
;
params
[
i
+
1
].
buffer_type
=
TSDB_DATA_TYPE_TINYINT
;
params
[
i
+
1
].
buffer_length
=
sizeof
(
int8_t
);
params
[
i
+
1
].
buffer
=
v
.
v1
;
params
[
i
+
1
].
length
=
NULL
;
params
[
i
+
1
].
is_null
=
no_null
;
params
[
i
+
1
].
num
=
10
;
params
[
i
+
2
].
buffer_type
=
TSDB_DATA_TYPE_SMALLINT
;
params
[
i
+
2
].
buffer_length
=
sizeof
(
int16_t
);
params
[
i
+
2
].
buffer
=
v
.
v2
;
params
[
i
+
2
].
length
=
NULL
;
params
[
i
+
2
].
is_null
=
no_null
;
params
[
i
+
2
].
num
=
10
;
params
[
i
+
3
].
buffer_type
=
TSDB_DATA_TYPE_FLOAT
;
params
[
i
+
3
].
buffer_length
=
sizeof
(
float
);
params
[
i
+
3
].
buffer
=
v
.
f4
;
params
[
i
+
3
].
length
=
NULL
;
params
[
i
+
3
].
is_null
=
no_null
;
params
[
i
+
3
].
num
=
10
;
params[6].buffer_type = TSDB_DATA_TYPE_FLOAT;
params[6].buffer_length = sizeof(v.f4);
params[6].buffer = &v.f4;
params[6].length = ¶ms[6].buffer_length;
params[6].is_null = NULL;
params
[
i
+
4
].
buffer_type
=
TSDB_DATA_TYPE_BINARY
;
params
[
i
+
4
].
buffer_length
=
40
;
params
[
i
+
4
].
buffer
=
v
.
bin
;
params
[
i
+
4
].
length
=
lb
;
params
[
i
+
4
].
is_null
=
no_null
;
params
[
i
+
4
].
num
=
10
;
params[7].buffer_type = TSDB_DATA_TYPE_DOUBLE;
params[7].buffer_length = sizeof(v.f8);
params[7].buffer = &v.f8;
params[7].length = ¶ms[7].buffer_length;
params[7].is_null = NULL;
params
[
i
+
5
].
buffer_type
=
TSDB_DATA_TYPE_BINARY
;
params
[
i
+
5
].
buffer_length
=
40
;
params
[
i
+
5
].
buffer
=
v
.
bin
;
params
[
i
+
5
].
length
=
lb
;
params
[
i
+
5
].
is_null
=
no_null
;
params
[
i
+
5
].
num
=
10
;
}
params[8].buffer_type = TSDB_DATA_TYPE_BINARY;
params[8].buffer_length = sizeof(v.bin);
params[8].buffer = v.bin;
params[8].length = ¶ms[8].buffer_length;
params[8].is_null = NULL;
int64_t
tts
=
1591060628000
;
for
(
int
i
=
0
;
i
<
54000000
;
++
i
)
{
v
.
ts
[
i
]
=
tts
+
i
;
}
params[9].buffer_type = TSDB_DATA_TYPE_BINARY;
params[9].buffer_length = sizeof(v.bin);
params[9].buffer = v.bin;
params[9].length = ¶ms[9].buffer_length;
params[9].is_null = NULL;
int
64_t
starttime
=
taosGetTimestampUs
()
;
int
is_null = 1
;
char
*
sql
=
"insert into ?
(ts, v1,v2,f4,bin,bin2) values(
?,?,?,?,?,?)"
;
char *sql = "insert into ?
values(?,?,?,?,
?,?,?,?,?,?)";
int code = taos_stmt_prepare(stmt, sql, 0);
if (code != 0){
printf("failed to execute taos_stmt_prepare. code:0x%x\n", code);
}
int
id
=
0
;
for
(
int
l
=
0
;
l
<
2
;
l
++
)
{
for
(
int
zz
=
0
;
zz
<
300
;
zz
++
)
{
for (int l = 0; l < 100; l++) {
for (int zz = 0; zz < 10; zz++) {
char buf[32];
sprintf(buf, "m%d", zz);
code = taos_stmt_set_tbname(stmt, buf);
if (code != 0){
printf("failed to execute taos_stmt_set_tbname. code:0x%x\n", code);
}
v.ts = 1591060628000 + zz * 100 * l;
for (int i = 0; i < zz; ++i) {
v.ts += 1;
for (int j = 1; j < 10; ++j) {
params[j].is_null = ((i == j) ? &is_null : 0);
}
v.b = (int8_t)(i+zz*10) % 2;
v.v1 = (int8_t)(i+zz*10);
v.v2 = (int16_t)((i+zz*10) * 2);
v.v4 = (int32_t)((i+zz*10) * 4);
v.v8 = (int64_t)((i+zz*10) * 8);
v.f4 = (float)((i+zz*10) * 40);
v.f8 = (double)((i+zz*10) * 80);
for (int j = 0; j < sizeof(v.bin) - 1; ++j) {
v.bin[j] = (char)((i+zz)%10 + '0');
}
taos_stmt_bind_param_batch
(
stmt
,
params
+
id
*
10
);
taos_stmt_add_batch
(
stmt
);
taos_stmt_bind_param(stmt, params);
taos_stmt_add_batch(stmt);
}
}
if
(
taos_stmt_execute
(
stmt
)
!=
0
)
{
printf
(
"failed to execute insert statement.
\n
"
);
exit
(
1
);
}
++
id
;
}
int64_t
endtime
=
taosGetTimestampUs
();
printf
(
"insert total %d records, used %u seconds, avg:%u useconds
\n
"
,
3000
*
300
*
60
,
(
endtime
-
starttime
)
/
1000000UL
,
(
endtime
-
starttime
)
/
(
3000
*
300
*
60
));
taosMemoryFree
(
v
.
ts
);
taosMemoryFree
(
lb
);
taosMemoryFree
(
params
);
taosMemoryFree
(
is_null
);
taosMemoryFree
(
no_null
);
return
0
;
}
//10 tables 10 records single column bind
int
stmt_scol_func4
(
TAOS_STMT
*
stmt
)
{
struct
{
int64_t
*
ts
;
int8_t
b
[
60
];
int8_t
v1
[
60
];
int16_t
v2
[
60
];
int32_t
v4
[
60
];
int64_t
v8
[
60
];
float
f4
[
60
];
double
f8
[
60
];
char
bin
[
60
][
40
];
}
v
=
{
0
};
v
.
ts
=
taosMemoryMalloc
(
sizeof
(
int64_t
)
*
1000
*
60
);
int
*
lb
=
taosMemoryMalloc
(
60
*
sizeof
(
int
));
TAOS_BIND_v2
*
params
=
taosMemoryCalloc
(
1
,
sizeof
(
TAOS_BIND_v2
)
*
1000
*
10
);
char
*
is_null
=
taosMemoryMalloc
(
sizeof
(
char
)
*
60
);
char
*
no_null
=
taosMemoryMalloc
(
sizeof
(
char
)
*
60
);
for
(
int
i
=
0
;
i
<
60
;
++
i
)
{
lb
[
i
]
=
40
;
no_null
[
i
]
=
0
;
is_null
[
i
]
=
(
i
%
10
==
2
)
?
1
:
0
;
v
.
b
[
i
]
=
(
int8_t
)(
i
%
2
);
v
.
v1
[
i
]
=
(
int8_t
)((
i
+
1
)
%
2
);
v
.
v2
[
i
]
=
(
int16_t
)
i
;
v
.
v4
[
i
]
=
(
int32_t
)(
i
+
1
);
v
.
v8
[
i
]
=
(
int64_t
)(
i
+
2
);
v
.
f4
[
i
]
=
(
float
)(
i
+
3
);
v
.
f8
[
i
]
=
(
double
)(
i
+
4
);
memset
(
v
.
bin
[
i
],
'0'
+
i
%
10
,
40
);
}
for
(
int
i
=
0
;
i
<
10000
;
i
+=
10
)
{
params
[
i
+
0
].
buffer_type
=
TSDB_DATA_TYPE_TIMESTAMP
;
params
[
i
+
0
].
buffer_length
=
sizeof
(
int64_t
);
params
[
i
+
0
].
buffer
=
&
v
.
ts
[
10
*
i
/
10
];
params
[
i
+
0
].
length
=
NULL
;
params
[
i
+
0
].
is_null
=
no_null
;
params
[
i
+
0
].
num
=
2
;
params
[
i
+
1
].
buffer_type
=
TSDB_DATA_TYPE_BOOL
;
params
[
i
+
1
].
buffer_length
=
sizeof
(
int8_t
);
params
[
i
+
1
].
buffer
=
v
.
b
;
params
[
i
+
1
].
length
=
NULL
;
params
[
i
+
1
].
is_null
=
no_null
;
params
[
i
+
1
].
num
=
2
;
params
[
i
+
2
].
buffer_type
=
TSDB_DATA_TYPE_INT
;
params
[
i
+
2
].
buffer_length
=
sizeof
(
int32_t
);
params
[
i
+
2
].
buffer
=
v
.
v4
;
params
[
i
+
2
].
length
=
NULL
;
params
[
i
+
2
].
is_null
=
no_null
;
params
[
i
+
2
].
num
=
2
;
params
[
i
+
3
].
buffer_type
=
TSDB_DATA_TYPE_BIGINT
;
params
[
i
+
3
].
buffer_length
=
sizeof
(
int64_t
);
params
[
i
+
3
].
buffer
=
v
.
v8
;
params
[
i
+
3
].
length
=
NULL
;
params
[
i
+
3
].
is_null
=
no_null
;
params
[
i
+
3
].
num
=
2
;
params
[
i
+
4
].
buffer_type
=
TSDB_DATA_TYPE_DOUBLE
;
params
[
i
+
4
].
buffer_length
=
sizeof
(
double
);
params
[
i
+
4
].
buffer
=
v
.
f8
;
params
[
i
+
4
].
length
=
NULL
;
params
[
i
+
4
].
is_null
=
no_null
;
params
[
i
+
4
].
num
=
2
;
}
int64_t
tts
=
1591060628000
;
for
(
int
i
=
0
;
i
<
60000
;
++
i
)
{
v
.
ts
[
i
]
=
tts
+
i
;
}
int64_t
starttime
=
taosGetTimestampUs
();
char
*
sql
=
"insert into ? (ts,b,v4,v8,f8) values(?,?,?,?,?)"
;
int
code
=
taos_stmt_prepare
(
stmt
,
sql
,
0
);
if
(
code
!=
0
){
printf
(
"failed to execute taos_stmt_prepare. code:0x%x
\n
"
,
code
);
}
int
id
=
0
;
for
(
int
l
=
0
;
l
<
10
;
l
++
)
{
for
(
int
zz
=
0
;
zz
<
10
;
zz
++
)
{
char
buf
[
32
];
sprintf
(
buf
,
"m%d"
,
zz
);
code
=
taos_stmt_set_tbname
(
stmt
,
buf
);
if
(
code
!=
0
){
printf
(
"failed to execute taos_stmt_set_tbname. code:0x%x
\n
"
,
code
);
}
for
(
int
col
=
0
;
col
<
10
;
++
col
)
{
taos_stmt_bind_single_param_batch
(
stmt
,
params
+
id
++
,
col
);
}
taos_stmt_add_batch
(
stmt
);
}
if
(
taos_stmt_execute
(
stmt
)
!=
0
)
{
printf
(
"failed to execute insert statement.
\n
"
);
exit
(
1
);
}
}
int64_t
endtime
=
taosGetTimestampUs
();
printf
(
"insert total %d records, used %u seconds, avg:%u useconds
\n
"
,
3000
*
300
*
60
,
(
endtime
-
starttime
)
/
1000000UL
,
(
endtime
-
starttime
)
/
(
3000
*
300
*
60
));
taosMemoryFree
(
v
.
ts
);
taosMemoryFree
(
lb
);
taosMemoryFree
(
params
);
taosMemoryFree
(
is_null
);
taosMemoryFree
(
no_null
);
return
0
;
}
//1 tables 20 records
int
stmt_scol_func5
(
TAOS_STMT
*
stmt
)
{
int32_t
rowNum
=
gCurCase
->
rowNum
;
int32_t
bindRowNum
=
gCurCase
->
bindRowNum
;
int32_t
bindColNum
=
gCurCase
->
bindColNum
;
int32_t
nullNum
=
gCurCase
->
bindNullNum
;
BindData
data
=
{
0
};
prepareData
(
&
data
);
int64_t
starttime
=
taosGetTimestampUs
();
char
*
sql
=
"insert into ? (ts, v1,v2,f4,bin,bin2) values(?,?,?,?,?,?)"
;
int
code
=
taos_stmt_prepare
(
stmt
,
sql
,
0
);
if
(
code
!=
0
){
printf
(
"failed to execute taos_stmt_prepare. code:0x%x
\n
"
,
code
);
}
int
id
=
0
;
for
(
int
b
=
0
;
b
<
(
rowNum
/
bindRowNum
);
b
++
)
{
//for (int b = 0; b < 2; b++) {
for
(
int
zz
=
0
;
zz
<
10
;
zz
++
)
{
char
buf
[
32
];
sprintf
(
buf
,
"m%d"
,
zz
);
code
=
taos_stmt_set_tbname
(
stmt
,
buf
);
if
(
code
!=
0
){
printf
(
"failed to execute taos_stmt_set_tbname. code:0x%x
\n
"
,
code
);
}
taos_stmt_bind_param_batch
(
stmt
,
data
.
pBind
+
b
*
bindColNum
);
taos_stmt_add_batch
(
stmt
);
}
if
(
taos_stmt_execute
(
stmt
)
!=
0
)
{
printf
(
"failed to execute insert statement.
\n
"
);
exit
(
1
);
}
++
id
;
}
int64_t
endtime
=
taosGetTimestampUs
();
printf
(
"insert total %d records, used %u seconds, avg:%u useconds
\n
"
,
rowNum
,
(
endtime
-
starttime
)
/
1000000UL
,
(
endtime
-
starttime
)
/
(
3000
*
300
*
60
));
destroyData
(
&
data
);
return
0
;
}
#if 0
int stmt_func1(TAOS_STMT *stmt) {
struct {
int64_t ts;
int8_t b;
int8_t v1;
int16_t v2;
int32_t v4;
int64_t v8;
float f4;
double f8;
char bin[40];
char blob[80];
} v = {0};
TAOS_BIND params[10];
params[0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP;
params[0].buffer_length = sizeof(v.ts);
params[0].buffer = &v.ts;
params[0].length = ¶ms[0].buffer_length;
params[0].is_null = NULL;
params[1].buffer_type = TSDB_DATA_TYPE_BOOL;
params[1].buffer_length = sizeof(v.b);
params[1].buffer = &v.b;
params[1].length = ¶ms[1].buffer_length;
params[1].is_null = NULL;
params[2].buffer_type = TSDB_DATA_TYPE_TINYINT;
params[2].buffer_length = sizeof(v.v1);
params[2].buffer = &v.v1;
params[2].length = ¶ms[2].buffer_length;
params[2].is_null = NULL;
params[3].buffer_type = TSDB_DATA_TYPE_SMALLINT;
params[3].buffer_length = sizeof(v.v2);
params[3].buffer = &v.v2;
params[3].length = ¶ms[3].buffer_length;
params[3].is_null = NULL;
params[4].buffer_type = TSDB_DATA_TYPE_INT;
params[4].buffer_length = sizeof(v.v4);
params[4].buffer = &v.v4;
params[4].length = ¶ms[4].buffer_length;
params[4].is_null = NULL;
params[5].buffer_type = TSDB_DATA_TYPE_BIGINT;
params[5].buffer_length = sizeof(v.v8);
params[5].buffer = &v.v8;
params[5].length = ¶ms[5].buffer_length;
params[5].is_null = NULL;
params[6].buffer_type = TSDB_DATA_TYPE_FLOAT;
params[6].buffer_length = sizeof(v.f4);
params[6].buffer = &v.f4;
params[6].length = ¶ms[6].buffer_length;
params[6].is_null = NULL;
params[7].buffer_type = TSDB_DATA_TYPE_DOUBLE;
params[7].buffer_length = sizeof(v.f8);
params[7].buffer = &v.f8;
params[7].length = ¶ms[7].buffer_length;
params[7].is_null = NULL;
params[8].buffer_type = TSDB_DATA_TYPE_BINARY;
params[8].buffer_length = sizeof(v.bin);
params[8].buffer = v.bin;
params[8].length = ¶ms[8].buffer_length;
params[8].is_null = NULL;
params[9].buffer_type = TSDB_DATA_TYPE_BINARY;
params[9].buffer_length = sizeof(v.bin);
params[9].buffer = v.bin;
params[9].length = ¶ms[9].buffer_length;
params[9].is_null = NULL;
int is_null = 1;
char *sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?)";
int code = taos_stmt_prepare(stmt, sql, 0);
if (code != 0){
printf("failed to execute taos_stmt_prepare. code:0x%x\n", code);
}
for (int zz = 0; zz < 10; zz++) {
char buf[32];
sprintf(buf, "m%d", zz);
code = taos_stmt_set_tbname(stmt, buf);
if (code != 0){
printf("failed to execute taos_stmt_set_tbname. code:0x%x\n", code);
}
v.ts = 1591060628000 + zz * 10;
for (int i = 0; i < 10; ++i) {
v.ts += 1;
for (int j = 1; j < 10; ++j) {
params[j].is_null = ((i == j) ? &is_null : 0);
}
v.b = (int8_t)(i+zz*10) % 2;
v.v1 = (int8_t)(i+zz*10);
v.v2 = (int16_t)((i+zz*10) * 2);
v.v4 = (int32_t)((i+zz*10) * 4);
v.v8 = (int64_t)((i+zz*10) * 8);
v.f4 = (float)((i+zz*10) * 40);
v.f8 = (double)((i+zz*10) * 80);
for (int j = 0; j < sizeof(v.bin) - 1; ++j) {
v.bin[j] = (char)((i+zz)%10 + '0');
}
taos_stmt_bind_param(stmt, params);
taos_stmt_add_batch(stmt);
}
}
if (taos_stmt_execute(stmt) != 0) {
printf("failed to execute insert statement.\n");
exit(1);
}
return 0;
}
int stmt_func2(TAOS_STMT *stmt) {
struct {
int64_t ts;
int8_t b;
int8_t v1;
int16_t v2;
int32_t v4;
int64_t v8;
float f4;
double f8;
char bin[40];
char blob[80];
} v = {0};
TAOS_BIND params[10];
params[0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP;
params[0].buffer_length = sizeof(v.ts);
params[0].buffer = &v.ts;
params[0].length = ¶ms[0].buffer_length;
params[0].is_null = NULL;
params[1].buffer_type = TSDB_DATA_TYPE_BOOL;
params[1].buffer_length = sizeof(v.b);
params[1].buffer = &v.b;
params[1].length = ¶ms[1].buffer_length;
params[1].is_null = NULL;
params[2].buffer_type = TSDB_DATA_TYPE_TINYINT;
params[2].buffer_length = sizeof(v.v1);
params[2].buffer = &v.v1;
params[2].length = ¶ms[2].buffer_length;
params[2].is_null = NULL;
params[3].buffer_type = TSDB_DATA_TYPE_SMALLINT;
params[3].buffer_length = sizeof(v.v2);
params[3].buffer = &v.v2;
params[3].length = ¶ms[3].buffer_length;
params[3].is_null = NULL;
params[4].buffer_type = TSDB_DATA_TYPE_INT;
params[4].buffer_length = sizeof(v.v4);
params[4].buffer = &v.v4;
params[4].length = ¶ms[4].buffer_length;
params[4].is_null = NULL;
params[5].buffer_type = TSDB_DATA_TYPE_BIGINT;
params[5].buffer_length = sizeof(v.v8);
params[5].buffer = &v.v8;
params[5].length = ¶ms[5].buffer_length;
params[5].is_null = NULL;
params[6].buffer_type = TSDB_DATA_TYPE_FLOAT;
params[6].buffer_length = sizeof(v.f4);
params[6].buffer = &v.f4;
params[6].length = ¶ms[6].buffer_length;
params[6].is_null = NULL;
params[7].buffer_type = TSDB_DATA_TYPE_DOUBLE;
params[7].buffer_length = sizeof(v.f8);
params[7].buffer = &v.f8;
params[7].length = ¶ms[7].buffer_length;
params[7].is_null = NULL;
params[8].buffer_type = TSDB_DATA_TYPE_BINARY;
params[8].buffer_length = sizeof(v.bin);
params[8].buffer = v.bin;
params[8].length = ¶ms[8].buffer_length;
params[8].is_null = NULL;
params[9].buffer_type = TSDB_DATA_TYPE_BINARY;
params[9].buffer_length = sizeof(v.bin);
params[9].buffer = v.bin;
params[9].length = ¶ms[9].buffer_length;
params[9].is_null = NULL;
int is_null = 1;
char *sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?)";
int code = taos_stmt_prepare(stmt, sql, 0);
if (code != 0){
printf("failed to execute taos_stmt_prepare. code:0x%x\n", code);
}
for (int l = 0; l < 100; l++) {
for (int zz = 0; zz < 10; zz++) {
char buf[32];
sprintf(buf, "m%d", zz);
code = taos_stmt_set_tbname(stmt, buf);
if (code != 0){
printf("failed to execute taos_stmt_set_tbname. code:0x%x\n", code);
}
v.ts = 1591060628000 + zz * 100 * l;
for (int i = 0; i < zz; ++i) {
v.ts += 1;
for (int j = 1; j < 10; ++j) {
params[j].is_null = ((i == j) ? &is_null : 0);
}
v.b = (int8_t)(i+zz*10) % 2;
v.v1 = (int8_t)(i+zz*10);
v.v2 = (int16_t)((i+zz*10) * 2);
v.v4 = (int32_t)((i+zz*10) * 4);
v.v8 = (int64_t)((i+zz*10) * 8);
v.f4 = (float)((i+zz*10) * 40);
v.f8 = (double)((i+zz*10) * 80);
for (int j = 0; j < sizeof(v.bin) - 1; ++j) {
v.bin[j] = (char)((i+zz)%10 + '0');
}
taos_stmt_bind_param(stmt, params);
taos_stmt_add_batch(stmt);
}
}
if (taos_stmt_execute(stmt) != 0) {
printf("failed to execute insert statement.\n");
exit(1);
...
...
@@ -1509,294 +1015,81 @@ int stmt_func3(TAOS_STMT *stmt) {
params[6].buffer_type = TSDB_DATA_TYPE_FLOAT;
params[6].buffer_length = sizeof(v.f4);
params[6].buffer = &v.f4;
params[6].length = ¶ms[6].buffer_length;
params[6].is_null = NULL;
params[7].buffer_type = TSDB_DATA_TYPE_DOUBLE;
params[7].buffer_length = sizeof(v.f8);
params[7].buffer = &v.f8;
params[7].length = ¶ms[7].buffer_length;
params[7].is_null = NULL;
params[8].buffer_type = TSDB_DATA_TYPE_BINARY;
params[8].buffer_length = sizeof(v.bin);
params[8].buffer = v.bin;
params[8].length = ¶ms[8].buffer_length;
params[8].is_null = NULL;
params[9].buffer_type = TSDB_DATA_TYPE_BINARY;
params[9].buffer_length = sizeof(v.bin);
params[9].buffer = v.bin;
params[9].length = ¶ms[9].buffer_length;
params[9].is_null = NULL;
int is_null = 1;
char *sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?)";
int code = taos_stmt_prepare(stmt, sql, 0);
if (code != 0){
printf("failed to execute taos_stmt_prepare. code:0x%x\n", code);
}
for (int l = 0; l < 100; l++) {
for (int zz = 0; zz < 10; zz++) {
char buf[32];
sprintf(buf, "m%d", zz);
code = taos_stmt_set_tbname(stmt, buf);
if (code != 0){
printf("failed to execute taos_stmt_set_tbname. code:0x%x\n", code);
}
v.ts = 1591060628000 + zz * 100 * l;
for (int i = 0; i < zz; ++i) {
v.ts += 1;
for (int j = 1; j < 10; ++j) {
params[j].is_null = ((i == j) ? &is_null : 0);
}
v.b = (int8_t)(i+zz*10) % 2;
v.v1 = (int8_t)(i+zz*10);
v.v2 = (int16_t)((i+zz*10) * 2);
v.v4 = (int32_t)((i+zz*10) * 4);
v.v8 = (int64_t)((i+zz*10) * 8);
v.f4 = (float)((i+zz*10) * 40);
v.f8 = (double)((i+zz*10) * 80);
for (int j = 0; j < sizeof(v.bin) - 1; ++j) {
v.bin[j] = (char)((i+zz)%10 + '0');
}
taos_stmt_bind_param(stmt, params);
taos_stmt_add_batch(stmt);
}
}
}
if (taos_stmt_execute(stmt) != 0) {
printf("failed to execute insert statement.\n");
exit(1);
}
return 0;
}
//1 tables 10 records
int stmt_funcb_autoctb1(TAOS_STMT *stmt) {
struct {
int64_t *ts;
int8_t b[10];
int8_t v1[10];
int16_t v2[10];
int32_t v4[10];
int64_t v8[10];
float f4[10];
double f8[10];
char bin[10][40];
} v = {0};
v.ts = taosMemoryMalloc(sizeof(int64_t) * 1 * 10);
int *lb = taosMemoryMalloc(10 * sizeof(int));
TAOS_BIND *tags = taosMemoryCalloc(1, sizeof(TAOS_BIND) * 9 * 1);
TAOS_BIND_v2 *params = taosMemoryCalloc(1, sizeof(TAOS_BIND_v2) * 1*10);
// int one_null = 1;
int one_not_null = 0;
char* is_null = taosMemoryMalloc(sizeof(char) * 10);
char* no_null = taosMemoryMalloc(sizeof(char) * 10);
for (int i = 0; i < 10; ++i) {
lb[i] = 40;
no_null[i] = 0;
is_null[i] = (i % 10 == 2) ? 1 : 0;
v.b[i] = (int8_t)(i % 2);
v.v1[i] = (int8_t)((i+1) % 2);
v.v2[i] = (int16_t)i;
v.v4[i] = (int32_t)(i+1);
v.v8[i] = (int64_t)(i+2);
v.f4[i] = (float)(i+3);
v.f8[i] = (double)(i+4);
memset(v.bin[i], '0'+i%10, 40);
}
for (int i = 0; i < 10; i+=10) {
params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP;
params[i+0].buffer_length = sizeof(int64_t);
params[i+0].buffer = &v.ts[10*i/10];
params[i+0].length = NULL;
params[i+0].is_null = no_null;
params[i+0].num = 10;
params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL;
params[i+1].buffer_length = sizeof(int8_t);
params[i+1].buffer = v.b;
params[i+1].length = NULL;
params[i+1].is_null = is_null;
params[i+1].num = 10;
params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT;
params[i+2].buffer_length = sizeof(int8_t);
params[i+2].buffer = v.v1;
params[i+2].length = NULL;
params[i+2].is_null = is_null;
params[i+2].num = 10;
params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT;
params[i+3].buffer_length = sizeof(int16_t);
params[i+3].buffer = v.v2;
params[i+3].length = NULL;
params[i+3].is_null = is_null;
params[i+3].num = 10;
params[i+4].buffer_type = TSDB_DATA_TYPE_INT;
params[i+4].buffer_length = sizeof(int32_t);
params[i+4].buffer = v.v4;
params[i+4].length = NULL;
params[i+4].is_null = is_null;
params[i+4].num = 10;
params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT;
params[i+5].buffer_length = sizeof(int64_t);
params[i+5].buffer = v.v8;
params[i+5].length = NULL;
params[i+5].is_null = is_null;
params[i+5].num = 10;
params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT;
params[i+6].buffer_length = sizeof(float);
params[i+6].buffer = v.f4;
params[i+6].length = NULL;
params[i+6].is_null = is_null;
params[i+6].num = 10;
params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE;
params[i+7].buffer_length = sizeof(double);
params[i+7].buffer = v.f8;
params[i+7].length = NULL;
params[i+7].is_null = is_null;
params[i+7].num = 10;
params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY;
params[i+8].buffer_length = 40;
params[i+8].buffer = v.bin;
params[i+8].length = lb;
params[i+8].is_null = is_null;
params[i+8].num = 10;
params[i+9].buffer_type = TSDB_DATA_TYPE_BINARY;
params[i+9].buffer_length = 40;
params[i+9].buffer = v.bin;
params[i+9].length = lb;
params[i+9].is_null = is_null;
params[i+9].num = 10;
}
int64_t tts = 1591060628000;
for (int i = 0; i < 10; ++i) {
v.ts[i] = tts + i;
}
for (int i = 0; i < 1; ++i) {
tags[i+0].buffer_type = TSDB_DATA_TYPE_INT;
tags[i+0].buffer = v.v4;
tags[i+0].is_null = &one_not_null;
tags[i+0].length = NULL;
tags[i+1].buffer_type = TSDB_DATA_TYPE_BOOL;
tags[i+1].buffer = v.b;
tags[i+1].is_null = &one_not_null;
tags[i+1].length = NULL;
tags[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT;
tags[i+2].buffer = v.v1;
tags[i+2].is_null = &one_not_null;
tags[i+2].length = NULL;
tags[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT;
tags[i+3].buffer = v.v2;
tags[i+3].is_null = &one_not_null;
tags[i+3].length = NULL;
tags[i+4].buffer_type = TSDB_DATA_TYPE_BIGINT;
tags[i+4].buffer = v.v8;
tags[i+4].is_null = &one_not_null;
tags[i+4].length = NULL;
tags[i+5].buffer_type = TSDB_DATA_TYPE_FLOAT;
tags[i+5].buffer = v.f4;
tags[i+5].is_null = &one_not_null;
tags[i+5].length = NULL;
tags[i+6].buffer_type = TSDB_DATA_TYPE_DOUBLE;
tags[i+6].buffer = v.f8;
tags[i+6].is_null = &one_not_null;
tags[i+6].length = NULL;
params[6].buffer = &v.f4;
params[6].length = ¶ms[6].buffer_length;
params[6].is_null = NULL;
tags[i+7].buffer_type = TSDB_DATA_TYPE_BINARY;
tags[i+7].buffer = v.bin;
tags[i+7].is_null = &one_not_null;
tags[i+7].length = (uintptr_t *)lb;
params[7].buffer_type = TSDB_DATA_TYPE_DOUBLE;
params[7].buffer_length = sizeof(v.f8);
params[7].buffer = &v.f8;
params[7].length = ¶ms[7].buffer_length;
params[7].is_null = NULL;
tags[i+8].buffer_type = TSDB_DATA_TYPE_NCHAR
;
tags[i+8].buffer = v.bin
;
tags[i+8].is_null = &one_not_null
;
tags[i+8].length = (uintptr_t *)lb
;
}
params[8].buffer_type = TSDB_DATA_TYPE_BINARY
;
params[8].buffer_length = sizeof(v.bin)
;
params[8].buffer = v.bin
;
params[8].length = ¶ms[8].buffer_length
;
params[8].is_null = NULL;
params[9].buffer_type = TSDB_DATA_TYPE_BINARY;
params[9].buffer_length = sizeof(v.bin);
params[9].buffer = v.bin;
params[9].length = ¶ms[9].buffer_length;
params[9].is_null = NULL;
unsigned long long starttime = taosGetTimestampUs()
;
int is_null = 1
;
char *sql = "insert into ?
using stb1 tags(?,?,?,?,?,?,?,?,?)
values(?,?,?,?,?,?,?,?,?,?)";
char *sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?)";
int code = taos_stmt_prepare(stmt, sql, 0);
if (code != 0){
printf("failed to execute taos_stmt_prepare. code:0x%x\n", code);
exit(1);
}
int id = 0;
for (int zz = 0; zz < 1; zz++) {
char buf[32];
sprintf(buf, "m%d", zz);
code = taos_stmt_set_tbname_tags(stmt, buf, tags);
if (code != 0){
printf("failed to execute taos_stmt_set_tbname_tags. code:0x%x\n", code);
}
for (int l = 0; l < 100; l++) {
for (int zz = 0; zz < 10; zz++) {
char buf[32];
sprintf(buf, "m%d", zz);
code = taos_stmt_set_tbname(stmt, buf);
if (code != 0){
printf("failed to execute taos_stmt_set_tbname. code:0x%x\n", code);
}
v.ts = 1591060628000 + zz * 100 * l;
for (int i = 0; i < zz; ++i) {
v.ts += 1;
for (int j = 1; j < 10; ++j) {
params[j].is_null = ((i == j) ? &is_null : 0);
}
v.b = (int8_t)(i+zz*10) % 2;
v.v1 = (int8_t)(i+zz*10);
v.v2 = (int16_t)((i+zz*10) * 2);
v.v4 = (int32_t)((i+zz*10) * 4);
v.v8 = (int64_t)((i+zz*10) * 8);
v.f4 = (float)((i+zz*10) * 40);
v.f8 = (double)((i+zz*10) * 80);
for (int j = 0; j < sizeof(v.bin) - 1; ++j) {
v.bin[j] = (char)((i+zz)%10 + '0');
}
taos_stmt_bind_param_batch(stmt, params + id * 10);
taos_stmt_add_batch(stmt);
taos_stmt_bind_param(stmt, params);
taos_stmt_add_batch(stmt);
}
}
}
if (taos_stmt_execute(stmt) != 0) {
printf("failed to execute insert statement.\n");
exit(1);
}
++id;
unsigned long long endtime = taosGetTimestampUs();
printf("insert total %d records, used %u seconds, avg:%u useconds\n", 10, (endtime-starttime)/1000000UL, (endtime-starttime)/(10));
taosMemoryFree(v.ts);
taosMemoryFree(lb);
taosMemoryFree(params);
taosMemoryFree(is_null);
taosMemoryFree(no_null);
taosMemoryFree(tags);
return 0;
}
//1 tables 10 records
int stmt_funcb_autoctb
2
(TAOS_STMT *stmt) {
int stmt_funcb_autoctb
1
(TAOS_STMT *stmt) {
struct {
int64_t *ts;
int8_t b[10];
...
...
@@ -1965,7 +1258,7 @@ int stmt_funcb_autoctb2(TAOS_STMT *stmt) {
unsigned long long starttime = taosGetTimestampUs();
char *sql = "insert into ? using stb1 tags(
1,true,2,3,4,5.0,6.0,'a','b'
) values(?,?,?,?,?,?,?,?,?,?)";
char *sql = "insert into ? using stb1 tags(
?,?,?,?,?,?,?,?,?
) values(?,?,?,?,?,?,?,?,?,?)";
int code = taos_stmt_prepare(stmt, sql, 0);
if (code != 0){
printf("failed to execute taos_stmt_prepare. code:0x%x\n", code);
...
...
@@ -2008,9 +1301,8 @@ int stmt_funcb_autoctb2(TAOS_STMT *stmt) {
//1 tables 10 records
int stmt_funcb_autoctb
3
(TAOS_STMT *stmt) {
int stmt_funcb_autoctb
2
(TAOS_STMT *stmt) {
struct {
int64_t *ts;
int8_t b[10];
...
...
@@ -2103,179 +1395,24 @@ int stmt_funcb_autoctb3(TAOS_STMT *stmt) {
params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE;
params[i+7].buffer_length = sizeof(double);
params[i+7].buffer = v.f8;
params[i+7].length = NULL;
params[i+7].is_null = is_null;
params[i+7].num = 10;
params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY;
params[i+8].buffer_length = 40;
params[i+8].buffer = v.bin;
params[i+8].length = lb;
params[i+8].is_null = is_null;
params[i+8].num = 10;
params[i+9].buffer_type = TSDB_DATA_TYPE_BINARY;
params[i+9].buffer_length = 40;
params[i+9].buffer = v.bin;
params[i+9].length = lb;
params[i+9].is_null = is_null;
params[i+9].num = 10;
}
int64_t tts = 1591060628000;
for (int i = 0; i < 10; ++i) {
v.ts[i] = tts + i;
}
for (int i = 0; i < 1; ++i) {
tags[i+0].buffer_type = TSDB_DATA_TYPE_BOOL;
tags[i+0].buffer = v.b;
tags[i+0].is_null = &one_not_null;
tags[i+0].length = NULL;
tags[i+1].buffer_type = TSDB_DATA_TYPE_SMALLINT;
tags[i+1].buffer = v.v2;
tags[i+1].is_null = &one_not_null;
tags[i+1].length = NULL;
tags[i+2].buffer_type = TSDB_DATA_TYPE_FLOAT;
tags[i+2].buffer = v.f4;
tags[i+2].is_null = &one_not_null;
tags[i+2].length = NULL;
tags[i+3].buffer_type = TSDB_DATA_TYPE_BINARY;
tags[i+3].buffer = v.bin;
tags[i+3].is_null = &one_not_null;
tags[i+3].length = (uintptr_t *)lb;
}
unsigned long long starttime = taosGetTimestampUs();
char *sql = "insert into ? using stb1 tags(1,?,2,?,4,?,6.0,?,'b') values(?,?,?,?,?,?,?,?,?,?)";
int code = taos_stmt_prepare(stmt, sql, 0);
if (code != 0){
printf("failed to execute taos_stmt_prepare. code:0x%x\n", code);
exit(1);
}
int id = 0;
for (int zz = 0; zz < 1; zz++) {
char buf[32];
sprintf(buf, "m%d", zz);
code = taos_stmt_set_tbname_tags(stmt, buf, tags);
if (code != 0){
printf("failed to execute taos_stmt_set_tbname_tags. code:0x%x\n", code);
}
taos_stmt_bind_param_batch(stmt, params + id * 10);
taos_stmt_add_batch(stmt);
}
if (taos_stmt_execute(stmt) != 0) {
printf("failed to execute insert statement.\n");
exit(1);
}
++id;
unsigned long long endtime = taosGetTimestampUs();
printf("insert total %d records, used %u seconds, avg:%u useconds\n", 10, (endtime-starttime)/1000000UL, (endtime-starttime)/(10));
taosMemoryFree(v.ts);
taosMemoryFree(lb);
taosMemoryFree(params);
taosMemoryFree(is_null);
taosMemoryFree(no_null);
taosMemoryFree(tags);
return 0;
}
//1 tables 10 records
int stmt_funcb_autoctb4(TAOS_STMT *stmt) {
struct {
int64_t *ts;
int8_t b[10];
int8_t v1[10];
int16_t v2[10];
int32_t v4[10];
int64_t v8[10];
float f4[10];
double f8[10];
char bin[10][40];
} v = {0};
v.ts = taosMemoryMalloc(sizeof(int64_t) * 1 * 10);
int *lb = taosMemoryMalloc(10 * sizeof(int));
TAOS_BIND *tags = taosMemoryCalloc(1, sizeof(TAOS_BIND) * 9 * 1);
TAOS_BIND_v2 *params = taosMemoryCalloc(1, sizeof(TAOS_BIND_v2) * 1*5);
// int one_null = 1;
int one_not_null = 0;
char* is_null = taosMemoryMalloc(sizeof(char) * 10);
char* no_null = taosMemoryMalloc(sizeof(char) * 10);
for (int i = 0; i < 10; ++i) {
lb[i] = 40;
no_null[i] = 0;
is_null[i] = (i % 10 == 2) ? 1 : 0;
v.b[i] = (int8_t)(i % 2);
v.v1[i] = (int8_t)((i+1) % 2);
v.v2[i] = (int16_t)i;
v.v4[i] = (int32_t)(i+1);
v.v8[i] = (int64_t)(i+2);
v.f4[i] = (float)(i+3);
v.f8[i] = (double)(i+4);
memset(v.bin[i], '0'+i%10, 40);
}
for (int i = 0; i < 5; i+=5) {
params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP;
params[i+0].buffer_length = sizeof(int64_t);
params[i+0].buffer = &v.ts[10*i/10];
params[i+0].length = NULL;
params[i+0].is_null = no_null;
params[i+0].num = 10;
params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL;
params[i+1].buffer_length = sizeof(int8_t);
params[i+1].buffer = v.b;
params[i+1].length = NULL;
params[i+1].is_null = is_null;
params[i+1].num = 10;
params[i+2].buffer_type = TSDB_DATA_TYPE_INT;
params[i+2].buffer_length = sizeof(int32_t);
params[i+2].buffer = v.v4;
params[i+2].length = NULL;
params[i+2].is_null = is_null;
params[i+2].num = 10;
params[i+3].buffer_type = TSDB_DATA_TYPE_BIGINT;
params[i+3].buffer_length = sizeof(int64_t);
params[i+3].buffer = v.v8;
params[i+3].length = NULL;
params[i+3].is_null = is_null;
params[i+3].num = 10;
params[i+7].length = NULL;
params[i+7].is_null = is_null;
params[i+7].num = 10;
params[i+4].buffer_type = TSDB_DATA_TYPE_DOUBLE;
params[i+4].buffer_length = sizeof(double);
params[i+4].buffer = v.f8;
params[i+4].length = NULL;
params[i+4].is_null = is_null;
params[i+4].num = 10;
params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY;
params[i+8].buffer_length = 40;
params[i+8].buffer = v.bin;
params[i+8].length = lb;
params[i+8].is_null = is_null;
params[i+8].num = 10;
params[i+9].buffer_type = TSDB_DATA_TYPE_BINARY;
params[i+9].buffer_length = 40;
params[i+9].buffer = v.bin;
params[i+9].length = lb;
params[i+9].is_null = is_null;
params[i+9].num = 10;
}
int64_t tts = 1591060628000;
...
...
@@ -2285,31 +1422,56 @@ int stmt_funcb_autoctb4(TAOS_STMT *stmt) {
for (int i = 0; i < 1; ++i) {
tags[i+0].buffer_type = TSDB_DATA_TYPE_
BOOL
;
tags[i+0].buffer = v.
b
;
tags[i+0].buffer_type = TSDB_DATA_TYPE_
INT
;
tags[i+0].buffer = v.
v4
;
tags[i+0].is_null = &one_not_null;
tags[i+0].length = NULL;
tags[i+1].buffer_type = TSDB_DATA_TYPE_
SMALLINT
;
tags[i+1].buffer = v.
v2
;
tags[i+1].buffer_type = TSDB_DATA_TYPE_
BOOL
;
tags[i+1].buffer = v.
b
;
tags[i+1].is_null = &one_not_null;
tags[i+1].length = NULL;
tags[i+2].buffer_type = TSDB_DATA_TYPE_
FLOA
T;
tags[i+2].buffer = v.
f4
;
tags[i+2].buffer_type = TSDB_DATA_TYPE_
TINYIN
T;
tags[i+2].buffer = v.
v1
;
tags[i+2].is_null = &one_not_null;
tags[i+2].length = NULL;
tags[i+3].buffer_type = TSDB_DATA_TYPE_
BINARY
;
tags[i+3].buffer = v.
bin
;
tags[i+3].buffer_type = TSDB_DATA_TYPE_
SMALLINT
;
tags[i+3].buffer = v.
v2
;
tags[i+3].is_null = &one_not_null;
tags[i+3].length = (uintptr_t *)lb;
tags[i+3].length = NULL;
tags[i+4].buffer_type = TSDB_DATA_TYPE_BIGINT;
tags[i+4].buffer = v.v8;
tags[i+4].is_null = &one_not_null;
tags[i+4].length = NULL;
tags[i+5].buffer_type = TSDB_DATA_TYPE_FLOAT;
tags[i+5].buffer = v.f4;
tags[i+5].is_null = &one_not_null;
tags[i+5].length = NULL;
tags[i+6].buffer_type = TSDB_DATA_TYPE_DOUBLE;
tags[i+6].buffer = v.f8;
tags[i+6].is_null = &one_not_null;
tags[i+6].length = NULL;
tags[i+7].buffer_type = TSDB_DATA_TYPE_BINARY;
tags[i+7].buffer = v.bin;
tags[i+7].is_null = &one_not_null;
tags[i+7].length = (uintptr_t *)lb;
tags[i+8].buffer_type = TSDB_DATA_TYPE_NCHAR;
tags[i+8].buffer = v.bin;
tags[i+8].is_null = &one_not_null;
tags[i+8].length = (uintptr_t *)lb;
}
unsigned long long starttime = taosGetTimestampUs();
char *sql = "insert into ? using stb1 tags(1,
?,2,?,4,?,6.0,?,'b') (ts,b,v4,v8,f8) values(
?,?,?,?,?)";
char *sql = "insert into ? using stb1 tags(1,
true,2,3,4,5.0,6.0,'a','b') values(?,?,?,?,?,
?,?,?,?,?)";
int code = taos_stmt_prepare(stmt, sql, 0);
if (code != 0){
printf("failed to execute taos_stmt_prepare. code:0x%x\n", code);
...
...
@@ -2325,7 +1487,7 @@ int stmt_funcb_autoctb4(TAOS_STMT *stmt) {
printf("failed to execute taos_stmt_set_tbname_tags. code:0x%x\n", code);
}
taos_stmt_bind_param_batch(stmt, params + id *
5
);
taos_stmt_bind_param_batch(stmt, params + id *
10
);
taos_stmt_add_batch(stmt);
}
...
...
@@ -2354,7 +1516,7 @@ int stmt_funcb_autoctb4(TAOS_STMT *stmt) {
//1 tables 10 records
int stmt_funcb_autoctb
_e1
(TAOS_STMT *stmt) {
int stmt_funcb_autoctb
3
(TAOS_STMT *stmt) {
struct {
int64_t *ts;
int8_t b[10];
...
...
@@ -2498,11 +1660,11 @@ int stmt_funcb_autoctb_e1(TAOS_STMT *stmt) {
unsigned long long starttime = taosGetTimestampUs();
char *sql = "insert into ? using stb1
(id1,id2,id3,id4,id5,id6,id7,id8,id9)
tags(1,?,2,?,4,?,6.0,?,'b') values(?,?,?,?,?,?,?,?,?,?)";
char *sql = "insert into ? using stb1 tags(1,?,2,?,4,?,6.0,?,'b') values(?,?,?,?,?,?,?,?,?,?)";
int code = taos_stmt_prepare(stmt, sql, 0);
if (code != 0){
printf("failed to execute taos_stmt_prepare.
error:%s\n", taos_stmt_errstr(stmt)
);
return -1
;
printf("failed to execute taos_stmt_prepare.
code:0x%x\n", code
);
exit(1)
;
}
int id = 0;
...
...
@@ -2542,8 +1704,10 @@ int stmt_funcb_autoctb_e1(TAOS_STMT *stmt) {
//1 tables 10 records
int stmt_funcb_autoctb
_e2
(TAOS_STMT *stmt) {
int stmt_funcb_autoctb
4
(TAOS_STMT *stmt) {
struct {
int64_t *ts;
int8_t b[10];
...
...
@@ -2561,7 +1725,7 @@ int stmt_funcb_autoctb_e2(TAOS_STMT *stmt) {
int *lb = taosMemoryMalloc(10 * sizeof(int));
TAOS_BIND *tags = taosMemoryCalloc(1, sizeof(TAOS_BIND) * 9 * 1);
TAOS_BIND_v2 *params = taosMemoryCalloc(1, sizeof(TAOS_BIND_v2) * 1*
10
);
TAOS_BIND_v2 *params = taosMemoryCalloc(1, sizeof(TAOS_BIND_v2) * 1*
5
);
// int one_null = 1;
int one_not_null = 0;
...
...
@@ -2583,7 +1747,7 @@ int stmt_funcb_autoctb_e2(TAOS_STMT *stmt) {
memset(v.bin[i], '0'+i%10, 40);
}
for (int i = 0; i <
10; i+=10
) {
for (int i = 0; i <
5; i+=5
) {
params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP;
params[i+0].buffer_length = sizeof(int64_t);
params[i+0].buffer = &v.ts[10*i/10];
...
...
@@ -2598,62 +1762,26 @@ int stmt_funcb_autoctb_e2(TAOS_STMT *stmt) {
params[i+1].is_null = is_null;
params[i+1].num = 10;
params[i+2].buffer_type = TSDB_DATA_TYPE_
TINY
INT;
params[i+2].buffer_length = sizeof(int
8
_t);
params[i+2].buffer = v.v
1
;
params[i+2].buffer_type = TSDB_DATA_TYPE_INT;
params[i+2].buffer_length = sizeof(int
32
_t);
params[i+2].buffer = v.v
4
;
params[i+2].length = NULL;
params[i+2].is_null = is_null;
params[i+2].num = 10;
params[i+3].buffer_type = TSDB_DATA_TYPE_
SMALL
INT;
params[i+3].buffer_length = sizeof(int
16
_t);
params[i+3].buffer = v.v
2
;
params[i+3].buffer_type = TSDB_DATA_TYPE_
BIG
INT;
params[i+3].buffer_length = sizeof(int
64
_t);
params[i+3].buffer = v.v
8
;
params[i+3].length = NULL;
params[i+3].is_null = is_null;
params[i+3].num = 10;
params[i+4].buffer_type = TSDB_DATA_TYPE_
INT
;
params[i+4].buffer_length = sizeof(
int32_t
);
params[i+4].buffer = v.
v4
;
params[i+4].buffer_type = TSDB_DATA_TYPE_
DOUBLE
;
params[i+4].buffer_length = sizeof(
double
);
params[i+4].buffer = v.
f8
;
params[i+4].length = NULL;
params[i+4].is_null = is_null;
params[i+4].num = 10;
params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT;
params[i+5].buffer_length = sizeof(int64_t);
params[i+5].buffer = v.v8;
params[i+5].length = NULL;
params[i+5].is_null = is_null;
params[i+5].num = 10;
params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT;
params[i+6].buffer_length = sizeof(float);
params[i+6].buffer = v.f4;
params[i+6].length = NULL;
params[i+6].is_null = is_null;
params[i+6].num = 10;
params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE;
params[i+7].buffer_length = sizeof(double);
params[i+7].buffer = v.f8;
params[i+7].length = NULL;
params[i+7].is_null = is_null;
params[i+7].num = 10;
params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY;
params[i+8].buffer_length = 40;
params[i+8].buffer = v.bin;
params[i+8].length = lb;
params[i+8].is_null = is_null;
params[i+8].num = 10;
params[i+9].buffer_type = TSDB_DATA_TYPE_BINARY;
params[i+9].buffer_length = 40;
params[i+9].buffer = v.bin;
params[i+9].length = lb;
params[i+9].is_null = is_null;
params[i+9].num = 10;
}
int64_t tts = 1591060628000;
...
...
@@ -2663,56 +1791,31 @@ int stmt_funcb_autoctb_e2(TAOS_STMT *stmt) {
for (int i = 0; i < 1; ++i) {
tags[i+0].buffer_type = TSDB_DATA_TYPE_
INT
;
tags[i+0].buffer = v.
v4
;
tags[i+0].buffer_type = TSDB_DATA_TYPE_
BOOL
;
tags[i+0].buffer = v.
b
;
tags[i+0].is_null = &one_not_null;
tags[i+0].length = NULL;
tags[i+1].buffer_type = TSDB_DATA_TYPE_
BOOL
;
tags[i+1].buffer = v.
b
;
tags[i+1].buffer_type = TSDB_DATA_TYPE_
SMALLINT
;
tags[i+1].buffer = v.
v2
;
tags[i+1].is_null = &one_not_null;
tags[i+1].length = NULL;
tags[i+2].buffer_type = TSDB_DATA_TYPE_
TINYIN
T;
tags[i+2].buffer = v.
v1
;
tags[i+2].buffer_type = TSDB_DATA_TYPE_
FLOA
T;
tags[i+2].buffer = v.
f4
;
tags[i+2].is_null = &one_not_null;
tags[i+2].length = NULL;
tags[i+3].buffer_type = TSDB_DATA_TYPE_
SMALLINT
;
tags[i+3].buffer = v.
v2
;
tags[i+3].buffer_type = TSDB_DATA_TYPE_
BINARY
;
tags[i+3].buffer = v.
bin
;
tags[i+3].is_null = &one_not_null;
tags[i+3].length = NULL;
tags[i+4].buffer_type = TSDB_DATA_TYPE_BIGINT;
tags[i+4].buffer = v.v8;
tags[i+4].is_null = &one_not_null;
tags[i+4].length = NULL;
tags[i+5].buffer_type = TSDB_DATA_TYPE_FLOAT;
tags[i+5].buffer = v.f4;
tags[i+5].is_null = &one_not_null;
tags[i+5].length = NULL;
tags[i+6].buffer_type = TSDB_DATA_TYPE_DOUBLE;
tags[i+6].buffer = v.f8;
tags[i+6].is_null = &one_not_null;
tags[i+6].length = NULL;
tags[i+7].buffer_type = TSDB_DATA_TYPE_BINARY;
tags[i+7].buffer = v.bin;
tags[i+7].is_null = &one_not_null;
tags[i+7].length = (uintptr_t *)lb;
tags[i+8].buffer_type = TSDB_DATA_TYPE_NCHAR;
tags[i+8].buffer = v.bin;
tags[i+8].is_null = &one_not_null;
tags[i+8].length = (uintptr_t *)lb;
tags[i+3].length = (uintptr_t *)lb;
}
unsigned long long starttime = taosGetTimestampUs();
char *sql = "insert into ? using stb1 tags(
?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,
?,?,?,?,?)";
char *sql = "insert into ? using stb1 tags(
1,?,2,?,4,?,6.0,?,'b') (ts,b,v4,v8,f8) values(
?,?,?,?,?)";
int code = taos_stmt_prepare(stmt, sql, 0);
if (code != 0){
printf("failed to execute taos_stmt_prepare. code:0x%x\n", code);
...
...
@@ -2723,13 +1826,12 @@ int stmt_funcb_autoctb_e2(TAOS_STMT *stmt) {
for (int zz = 0; zz < 1; zz++) {
char buf[32];
sprintf(buf, "m%d", zz);
code = taos_stmt_set_tbname_tags(stmt, buf,
NULL
);
code = taos_stmt_set_tbname_tags(stmt, buf,
tags
);
if (code != 0){
printf("failed to execute taos_stmt_set_tbname_tags. code:%s\n", taos_stmt_errstr(stmt));
return -1;
printf("failed to execute taos_stmt_set_tbname_tags. code:0x%x\n", code);
}
taos_stmt_bind_param_batch(stmt, params + id *
10
);
taos_stmt_bind_param_batch(stmt, params + id *
5
);
taos_stmt_add_batch(stmt);
}
...
...
@@ -2757,10 +1859,8 @@ int stmt_funcb_autoctb_e2(TAOS_STMT *stmt) {
//1 tables 10 records
int stmt_funcb_autoctb_e
3
(TAOS_STMT *stmt) {
int stmt_funcb_autoctb_e
1
(TAOS_STMT *stmt) {
struct {
int64_t *ts;
int8_t b[10];
...
...
@@ -2880,71 +1980,44 @@ int stmt_funcb_autoctb_e3(TAOS_STMT *stmt) {
for (int i = 0; i < 1; ++i) {
tags[i+0].buffer_type = TSDB_DATA_TYPE_
INT
;
tags[i+0].buffer = v.
v4
;
tags[i+0].buffer_type = TSDB_DATA_TYPE_
BOOL
;
tags[i+0].buffer = v.
b
;
tags[i+0].is_null = &one_not_null;
tags[i+0].length = NULL;
tags[i+1].buffer_type = TSDB_DATA_TYPE_
BOOL
;
tags[i+1].buffer = v.
b
;
tags[i+1].buffer_type = TSDB_DATA_TYPE_
SMALLINT
;
tags[i+1].buffer = v.
v2
;
tags[i+1].is_null = &one_not_null;
tags[i+1].length = NULL;
tags[i+2].buffer_type = TSDB_DATA_TYPE_
TINYIN
T;
tags[i+2].buffer = v.
v1
;
tags[i+2].buffer_type = TSDB_DATA_TYPE_
FLOA
T;
tags[i+2].buffer = v.
f4
;
tags[i+2].is_null = &one_not_null;
tags[i+2].length = NULL;
tags[i+3].buffer_type = TSDB_DATA_TYPE_
SMALLINT
;
tags[i+3].buffer = v.
v2
;
tags[i+3].buffer_type = TSDB_DATA_TYPE_
BINARY
;
tags[i+3].buffer = v.
bin
;
tags[i+3].is_null = &one_not_null;
tags[i+3].length = NULL;
tags[i+4].buffer_type = TSDB_DATA_TYPE_BIGINT;
tags[i+4].buffer = v.v8;
tags[i+4].is_null = &one_not_null;
tags[i+4].length = NULL;
tags[i+5].buffer_type = TSDB_DATA_TYPE_FLOAT;
tags[i+5].buffer = v.f4;
tags[i+5].is_null = &one_not_null;
tags[i+5].length = NULL;
tags[i+6].buffer_type = TSDB_DATA_TYPE_DOUBLE;
tags[i+6].buffer = v.f8;
tags[i+6].is_null = &one_not_null;
tags[i+6].length = NULL;
tags[i+7].buffer_type = TSDB_DATA_TYPE_BINARY;
tags[i+7].buffer = v.bin;
tags[i+7].is_null = &one_not_null;
tags[i+7].length = (uintptr_t *)lb;
tags[i+8].buffer_type = TSDB_DATA_TYPE_NCHAR;
tags[i+8].buffer = v.bin;
tags[i+8].is_null = &one_not_null;
tags[i+8].length = (uintptr_t *)lb;
tags[i+3].length = (uintptr_t *)lb;
}
unsigned long long starttime = taosGetTimestampUs();
char *sql = "insert into ? using stb1 (id1,id2,id3,id4,id5,id6,id7,id8,id9) tags(
?,?,?,?,?,?,?,?,?
) values(?,?,?,?,?,?,?,?,?,?)";
char *sql = "insert into ? using stb1 (id1,id2,id3,id4,id5,id6,id7,id8,id9) tags(
1,?,2,?,4,?,6.0,?,'b'
) values(?,?,?,?,?,?,?,?,?,?)";
int code = taos_stmt_prepare(stmt, sql, 0);
if (code != 0){
printf("failed to execute taos_stmt_prepare.
code
:%s\n", taos_stmt_errstr(stmt));
printf("failed to execute taos_stmt_prepare.
error
:%s\n", taos_stmt_errstr(stmt));
return -1;
//exit(1);
}
int id = 0;
for (int zz = 0; zz < 1; zz++) {
char buf[32];
sprintf(buf, "m%d", zz);
code = taos_stmt_set_tbname_tags(stmt, buf,
NULL
);
code = taos_stmt_set_tbname_tags(stmt, buf,
tags
);
if (code != 0){
printf("failed to execute taos_stmt_set_tbname_tags. code:0x%x\n", code);
return -1;
}
taos_stmt_bind_param_batch(stmt, params + id * 10);
...
...
@@ -2974,8 +2047,9 @@ int stmt_funcb_autoctb_e3(TAOS_STMT *stmt) {
//1 tables 10 records
int stmt_funcb_autoctb_e
4
(TAOS_STMT *stmt) {
int stmt_funcb_autoctb_e
2
(TAOS_STMT *stmt) {
struct {
int64_t *ts;
int8_t b[10];
...
...
@@ -3147,7 +2221,7 @@ int stmt_funcb_autoctb_e4(TAOS_STMT *stmt) {
char *sql = "insert into ? using stb1 tags(?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?)";
int code = taos_stmt_prepare(stmt, sql, 0);
if (code != 0){
printf("failed to execute taos_stmt_prepare. code:
%s\n", taos_stmt_errstr(stmt)
);
printf("failed to execute taos_stmt_prepare. code:
0x%x\n", code
);
exit(1);
}
...
...
@@ -3155,24 +2229,13 @@ int stmt_funcb_autoctb_e4(TAOS_STMT *stmt) {
for (int zz = 0; zz < 1; zz++) {
char buf[32];
sprintf(buf, "m%d", zz);
code = taos_stmt_set_tbname_tags(stmt, buf,
tags
);
code = taos_stmt_set_tbname_tags(stmt, buf,
NULL
);
if (code != 0){
printf("failed to execute taos_stmt_set_tbname_tags.
error
:%s\n", taos_stmt_errstr(stmt));
exit(1)
;
printf("failed to execute taos_stmt_set_tbname_tags.
code
:%s\n", taos_stmt_errstr(stmt));
return -1
;
}
code = taos_stmt_bind_param_batch(stmt, params + id * 10);
if (code != 0) {
printf("failed to execute taos_stmt_bind_param_batch. error:%s\n", taos_stmt_errstr(stmt));
exit(1);
}
code = taos_stmt_bind_param_batch(stmt, params + id * 10);
if (code != 0) {
printf("failed to execute taos_stmt_bind_param_batch. error:%s\n", taos_stmt_errstr(stmt));
return -1;
}
taos_stmt_bind_param_batch(stmt, params + id * 10);
taos_stmt_add_batch(stmt);
}
...
...
@@ -3201,8 +2264,9 @@ int stmt_funcb_autoctb_e4(TAOS_STMT *stmt) {
//1 tables 10 records
int stmt_funcb_autoctb_e
5
(TAOS_STMT *stmt) {
int stmt_funcb_autoctb_e
3
(TAOS_STMT *stmt) {
struct {
int64_t *ts;
int8_t b[10];
...
...
@@ -3371,35 +2435,25 @@ int stmt_funcb_autoctb_e5(TAOS_STMT *stmt) {
unsigned long long starttime = taosGetTimestampUs();
char *sql = "insert into ? using stb1 tags(?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?)";
int code = taos_stmt_prepare(
NULL
, sql, 0);
char *sql = "insert into ? using stb1
(id1,id2,id3,id4,id5,id6,id7,id8,id9)
tags(?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?)";
int code = taos_stmt_prepare(
stmt
, sql, 0);
if (code != 0){
printf("failed to execute taos_stmt_prepare. code:%s\n", taos_stmt_errstr(
NULL
));
printf("failed to execute taos_stmt_prepare. code:%s\n", taos_stmt_errstr(
stmt
));
return -1;
//exit(1);
}
int id = 0;
for (int zz = 0; zz < 1; zz++) {
char buf[32];
sprintf(buf, "m%d", zz);
code = taos_stmt_set_tbname_tags(stmt, buf,
tags
);
code = taos_stmt_set_tbname_tags(stmt, buf,
NULL
);
if (code != 0){
printf("failed to execute taos_stmt_set_tbname_tags.
error:%s\n", taos_stmt_errstr(stmt)
);
exit(1)
;
printf("failed to execute taos_stmt_set_tbname_tags.
code:0x%x\n", code
);
return -1
;
}
code = taos_stmt_bind_param_batch(stmt, params + id * 10);
if (code != 0) {
printf("failed to execute taos_stmt_bind_param_batch. error:%s\n", taos_stmt_errstr(stmt));
exit(1);
}
code = taos_stmt_bind_param_batch(stmt, params + id * 10);
if (code != 0) {
printf("failed to execute taos_stmt_bind_param_batch. error:%s\n", taos_stmt_errstr(stmt));
return -1;
}
taos_stmt_bind_param_batch(stmt, params + id * 10);
taos_stmt_add_batch(stmt);
}
...
...
@@ -3425,29 +2479,35 @@ int stmt_funcb_autoctb_e5(TAOS_STMT *stmt) {
//300 tables 60 records
int stmt_funcb1(TAOS_STMT *stmt) {
//1 tables 10 records
int stmt_funcb_autoctb_e4(TAOS_STMT *stmt) {
struct {
int64_t *ts;
int8_t b[
6
0];
int8_t v1[
6
0];
int16_t v2[
6
0];
int32_t v4[
6
0];
int64_t v8[
6
0];
float f4[
6
0];
double f8[
6
0];
char bin[
6
0][40];
int8_t b[
1
0];
int8_t v1[
1
0];
int16_t v2[
1
0];
int32_t v4[
1
0];
int64_t v8[
1
0];
float f4[
1
0];
double f8[
1
0];
char bin[
1
0][40];
} v = {0};
v.ts = taosMemoryMalloc(sizeof(int64_t) *
900000 * 6
0);
v.ts = taosMemoryMalloc(sizeof(int64_t) *
1 * 1
0);
int *lb = taosMemoryMalloc(60 * sizeof(int));
int *lb = taosMemoryMalloc(10 * sizeof(int));
TAOS_BIND *tags = taosMemoryCalloc(1, sizeof(TAOS_BIND) * 9 * 1);
TAOS_BIND_v2 *params = taosMemoryCalloc(1, sizeof(TAOS_BIND_v2) * 1*10);
// int one_null = 1;
int one_not_null = 0;
TAOS_BIND_v2 *params = taosMemoryCalloc(1, sizeof(TAOS_BIND_v2) * 900000*10);
char* is_null = taosMemoryMalloc(sizeof(char) * 60);
char* no_null = taosMemoryMalloc(sizeof(char) * 60);
char* is_null = taosMemoryMalloc(sizeof(char) * 10);
char* no_null = taosMemoryMalloc(sizeof(char) * 10);
for (int i = 0; i <
6
0; ++i) {
for (int i = 0; i <
1
0; ++i) {
lb[i] = 40;
no_null[i] = 0;
is_null[i] = (i % 10 == 2) ? 1 : 0;
...
...
@@ -3461,308 +2521,220 @@ int stmt_funcb1(TAOS_STMT *stmt) {
memset(v.bin[i], '0'+i%10, 40);
}
for (int i = 0; i <
900000
0; i+=10) {
for (int i = 0; i <
1
0; i+=10) {
params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP;
params[i+0].buffer_length = sizeof(int64_t);
params[i+0].buffer = &v.ts[
6
0*i/10];
params[i+0].buffer = &v.ts[
1
0*i/10];
params[i+0].length = NULL;
params[i+0].is_null = no_null;
params[i+0].num =
6
0;
params[i+0].num =
1
0;
params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL;
params[i+1].buffer_length = sizeof(int8_t);
params[i+1].buffer = v.b;
params[i+1].length = NULL;
params[i+1].is_null = is_null;
params[i+1].num =
6
0;
params[i+1].num =
1
0;
params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT;
params[i+2].buffer_length = sizeof(int8_t);
params[i+2].buffer = v.v1;
params[i+2].length = NULL;
params[i+2].is_null = is_null;
params[i+2].num =
6
0;
params[i+2].num =
1
0;
params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT;
params[i+3].buffer_length = sizeof(int16_t);
params[i+3].buffer = v.v2;
params[i+3].length = NULL;
params[i+3].is_null = is_null;
params[i+3].num =
6
0;
params[i+3].num =
1
0;
params[i+4].buffer_type = TSDB_DATA_TYPE_INT;
params[i+4].buffer_length = sizeof(int32_t);
params[i+4].buffer = v.v4;
params[i+4].length = NULL;
params[i+4].is_null = is_null;
params[i+4].num =
6
0;
params[i+4].num =
1
0;
params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT;
params[i+5].buffer_length = sizeof(int64_t);
params[i+5].buffer = v.v8;
params[i+5].length = NULL;
params[i+5].is_null = is_null;
params[i+5].num =
6
0;
params[i+5].num =
1
0;
params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT;
params[i+6].buffer_length = sizeof(float);
params[i+6].buffer = v.f4;
params[i+6].length = NULL;
params[i+6].is_null = is_null;
params[i+6].num =
6
0;
params[i+6].num =
1
0;
params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE;
params[i+7].buffer_length = sizeof(double);
params[i+7].buffer = v.f8;
params[i+7].length = NULL;
params[i+7].is_null = is_null;
params[i+7].num =
6
0;
params[i+7].num =
1
0;
params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY;
params[i+8].buffer_length = 40;
params[i+8].buffer = v.bin;
params[i+8].length = lb;
params[i+8].is_null = is_null;
params[i+8].num =
6
0;
params[i+8].num =
1
0;
params[i+9].buffer_type = TSDB_DATA_TYPE_BINARY;
params[i+9].buffer_length = 40;
params[i+9].buffer = v.bin;
params[i+9].length = lb;
params[i+9].is_null = is_null;
params[i+9].num =
6
0;
params[i+9].num =
1
0;
}
int64_t tts = 1591060628000;
for (int i = 0; i <
5400000
0; ++i) {
for (int i = 0; i <
1
0; ++i) {
v.ts[i] = tts + i;
}
unsigned long long starttime = taosGetTimestampUs();
char *sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?)";
int code = taos_stmt_prepare(stmt, sql, 0);
if (code != 0){
printf("failed to execute taos_stmt_prepare. code:0x%x\n", code);
}
int id = 0;
for (int l = 0; l < 3000; l++) {
for (int zz = 0; zz < 300; zz++) {
char buf[32];
sprintf(buf, "m%d", zz);
code = taos_stmt_set_tbname(stmt, buf);
if (code != 0){
printf("failed to execute taos_stmt_set_tbname. code:0x%x\n", code);
}
taos_stmt_bind_param_batch(stmt, params + id * 10);
taos_stmt_add_batch(stmt);
}
if (taos_stmt_execute(stmt) != 0) {
printf("failed to execute insert statement.\n");
exit(1);
}
++id;
}
unsigned long long endtime = taosGetTimestampUs();
printf("insert total %d records, used %u seconds, avg:%u useconds\n", 3000*300*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*300*60));
taosMemoryFree(v.ts);
taosMemoryFree(lb);
taosMemoryFree(params);
taosMemoryFree(is_null);
taosMemoryFree(no_null);
return 0;
}
//1table 18000 reocrds
int stmt_funcb2(TAOS_STMT *stmt) {
struct {
int64_t *ts;
int8_t b[18000];
int8_t v1[18000];
int16_t v2[18000];
int32_t v4[18000];
int64_t v8[18000];
float f4[18000];
double f8[18000];
char bin[18000][40];
} v = {0};
v.ts = taosMemoryMalloc(sizeof(int64_t) * 900000 * 60);
int *lb = taosMemoryMalloc(18000 * sizeof(int));
TAOS_BIND_v2 *params = taosMemoryCalloc(1, sizeof(TAOS_BIND_v2) * 3000*10);
char* is_null = taosMemoryMalloc(sizeof(char) * 18000);
char* no_null = taosMemoryMalloc(sizeof(char) * 18000);
for (int i = 0; i < 18000; ++i) {
lb[i] = 40;
no_null[i] = 0;
is_null[i] = (i % 10 == 2) ? 1 : 0;
v.b[i] = (int8_t)(i % 2);
v.v1[i] = (int8_t)((i+1) % 2);
v.v2[i] = (int16_t)i;
v.v4[i] = (int32_t)(i+1);
v.v8[i] = (int64_t)(i+2);
v.f4[i] = (float)(i+3);
v.f8[i] = (double)(i+4);
memset(v.bin[i], '0'+i%10, 40);
}
for (int i = 0; i < 30000; i+=10) {
params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP;
params[i+0].buffer_length = sizeof(int64_t);
params[i+0].buffer = &v.ts[18000*i/10];
params[i+0].length = NULL;
params[i+0].is_null = no_null;
params[i+0].num = 18000;
params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL;
params[i+1].buffer_length = sizeof(int8_t);
params[i+1].buffer = v.b;
params[i+1].length = NULL;
params[i+1].is_null = is_null;
params[i+1].num = 18000;
params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT;
params[i+2].buffer_length = sizeof(int8_t);
params[i+2].buffer = v.v1;
params[i+2].length = NULL;
params[i+2].is_null = is_null;
params[i+2].num = 18000;
for (int i = 0; i < 1; ++i) {
tags[i+0].buffer_type = TSDB_DATA_TYPE_INT;
tags[i+0].buffer = v.v4;
tags[i+0].is_null = &one_not_null;
tags[i+0].length = NULL;
params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT;
params[i+3].buffer_length = sizeof(int16_t);
params[i+3].buffer = v.v2;
params[i+3].length = NULL;
params[i+3].is_null = is_null;
params[i+3].num = 18000;
tags[i+1].buffer_type = TSDB_DATA_TYPE_BOOL;
tags[i+1].buffer = v.b;
tags[i+1].is_null = &one_not_null;
tags[i+1].length = NULL;
params[i+4].buffer_type = TSDB_DATA_TYPE_INT;
params[i+4].buffer_length = sizeof(int32_t);
params[i+4].buffer = v.v4;
params[i+4].length = NULL;
params[i+4].is_null = is_null;
params[i+4].num = 18000;
tags[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT;
tags[i+2].buffer = v.v1;
tags[i+2].is_null = &one_not_null;
tags[i+2].length = NULL;
params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT;
params[i+5].buffer_length = sizeof(int64_t);
params[i+5].buffer = v.v8;
params[i+5].length = NULL;
params[i+5].is_null = is_null;
params[i+5].num = 18000;
tags[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT;
tags[i+3].buffer = v.v2;
tags[i+3].is_null = &one_not_null;
tags[i+3].length = NULL;
params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT;
params[i+6].buffer_length = sizeof(float);
params[i+6].buffer = v.f4;
params[i+6].length = NULL;
params[i+6].is_null = is_null;
params[i+6].num = 18000;
tags[i+4].buffer_type = TSDB_DATA_TYPE_BIGINT;
tags[i+4].buffer = v.v8;
tags[i+4].is_null = &one_not_null;
tags[i+4].length = NULL;
params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE;
params[i+7].buffer_length = sizeof(double);
params[i+7].buffer = v.f8;
params[i+7].length = NULL;
params[i+7].is_null = is_null;
params[i+7].num = 18000;
tags[i+5].buffer_type = TSDB_DATA_TYPE_FLOAT;
tags[i+5].buffer = v.f4;
tags[i+5].is_null = &one_not_null;
tags[i+5].length = NULL;
params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY;
params[i+8].buffer_length = 40;
params[i+8].buffer = v.bin;
params[i+8].length = lb;
params[i+8].is_null = is_null;
params[i+8].num = 18000;
tags[i+6].buffer_type = TSDB_DATA_TYPE_DOUBLE;
tags[i+6].buffer = v.f8;
tags[i+6].is_null = &one_not_null;
tags[i+6].length = NULL;
params[i+9].buffer_type = TSDB_DATA_TYPE_BINARY;
params[i+9].buffer_length = 40;
params[i+9].buffer = v.bin;
params[i+9].length = lb;
params[i+9].is_null = is_null;
params[i+9].num = 18000;
}
tags[i+7].buffer_type = TSDB_DATA_TYPE_BINARY;
tags[i+7].buffer = v.bin;
tags[i+7].is_null = &one_not_null;
tags[i+7].length = (uintptr_t *)lb;
int64_t tts = 1591060628000;
for (int i = 0; i < 54000000; ++i) {
v.ts[i] = tts + i;
tags[i+8].buffer_type = TSDB_DATA_TYPE_NCHAR;
tags[i+8].buffer = v.bin;
tags[i+8].is_null = &one_not_null;
tags[i+8].length = (uintptr_t *)lb;
}
unsigned long long starttime = taosGetTimestampUs();
char *sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?)";
char *sql = "insert into ?
using stb1 tags(?,?,?,?,?,?,?,?,?)
values(?,?,?,?,?,?,?,?,?,?)";
int code = taos_stmt_prepare(stmt, sql, 0);
if (code != 0){
printf("failed to execute taos_stmt_prepare. code:0x%x\n", code);
printf("failed to execute taos_stmt_prepare. code:%s\n", taos_stmt_errstr(stmt));
exit(1);
}
int id = 0;
for (int l = 0; l < 10; l++) {
for (int zz = 0; zz < 300; zz++) {
char buf[32];
sprintf(buf, "m%d", zz);
code = taos_stmt_set_tbname(stmt, buf);
if (code != 0){
printf("failed to execute taos_stmt_set_tbname. code:0x%x\n", code);
}
taos_stmt_bind_param_batch(stmt, params + id * 10);
taos_stmt_add_batch(stmt);
if (taos_stmt_execute(stmt) != 0) {
printf("failed to execute insert statement.\n");
exit(1);
}
++id;
for (int zz = 0; zz < 1; zz++) {
char buf[32];
sprintf(buf, "m%d", zz);
code = taos_stmt_set_tbname_tags(stmt, buf, tags);
if (code != 0){
printf("failed to execute taos_stmt_set_tbname_tags. error:%s\n", taos_stmt_errstr(stmt));
exit(1);
}
code = taos_stmt_bind_param_batch(stmt, params + id * 10);
if (code != 0) {
printf("failed to execute taos_stmt_bind_param_batch. error:%s\n", taos_stmt_errstr(stmt));
exit(1);
}
code = taos_stmt_bind_param_batch(stmt, params + id * 10);
if (code != 0) {
printf("failed to execute taos_stmt_bind_param_batch. error:%s\n", taos_stmt_errstr(stmt));
return -1;
}
taos_stmt_add_batch(stmt);
}
if (taos_stmt_execute(stmt) != 0) {
printf("failed to execute insert statement.\n");
exit(1);
}
++id;
unsigned long long endtime = taosGetTimestampUs();
printf("insert total %d records, used %u seconds, avg:%u useconds\n",
3000*300*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*300*6
0));
printf("insert total %d records, used %u seconds, avg:%u useconds\n",
10, (endtime-starttime)/1000000UL, (endtime-starttime)/(1
0));
taosMemoryFree(v.ts);
taosMemoryFree(lb);
taosMemoryFree(params);
taosMemoryFree(is_null);
taosMemoryFree(no_null);
taosMemoryFree(tags);
return 0;
}
//disorder
int stmt_funcb3(TAOS_STMT *stmt) {
//1 tables 10 records
int stmt_funcb_autoctb_e5(TAOS_STMT *stmt) {
struct {
int64_t *ts;
int8_t b[
6
0];
int8_t v1[
6
0];
int16_t v2[
6
0];
int32_t v4[
6
0];
int64_t v8[
6
0];
float f4[
6
0];
double f8[
6
0];
char bin[
6
0][40];
int8_t b[
1
0];
int8_t v1[
1
0];
int16_t v2[
1
0];
int32_t v4[
1
0];
int64_t v8[
1
0];
float f4[
1
0];
double f8[
1
0];
char bin[
1
0][40];
} v = {0};
v.ts = taosMemoryMalloc(sizeof(int64_t) *
900000 * 6
0);
v.ts = taosMemoryMalloc(sizeof(int64_t) *
1 * 1
0);
int *lb = taosMemoryMalloc(60 * sizeof(int));
int *lb = taosMemoryMalloc(10 * sizeof(int));
TAOS_BIND *tags = taosMemoryCalloc(1, sizeof(TAOS_BIND) * 9 * 1);
TAOS_BIND_v2 *params = taosMemoryCalloc(1, sizeof(TAOS_BIND_v2) * 1*10);
// int one_null = 1;
int one_not_null = 0;
TAOS_BIND_v2 *params = taosMemoryCalloc(1, sizeof(TAOS_BIND_v2) * 900000*10);
char* is_null = taosMemoryMalloc(sizeof(char) * 60);
char* no_null = taosMemoryMalloc(sizeof(char) * 60);
char* is_null = taosMemoryMalloc(sizeof(char) * 10);
char* no_null = taosMemoryMalloc(sizeof(char) * 10);
for (int i = 0; i <
6
0; ++i) {
for (int i = 0; i <
1
0; ++i) {
lb[i] = 40;
no_null[i] = 0;
is_null[i] = (i % 10 == 2) ? 1 : 0;
...
...
@@ -3776,135 +2748,187 @@ int stmt_funcb3(TAOS_STMT *stmt) {
memset(v.bin[i], '0'+i%10, 40);
}
for (int i = 0; i <
900000
0; i+=10) {
for (int i = 0; i <
1
0; i+=10) {
params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP;
params[i+0].buffer_length = sizeof(int64_t);
params[i+0].buffer = &v.ts[
6
0*i/10];
params[i+0].buffer = &v.ts[
1
0*i/10];
params[i+0].length = NULL;
params[i+0].is_null = no_null;
params[i+0].num =
6
0;
params[i+0].num =
1
0;
params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL;
params[i+1].buffer_length = sizeof(int8_t);
params[i+1].buffer = v.b;
params[i+1].length = NULL;
params[i+1].is_null = is_null;
params[i+1].num =
6
0;
params[i+1].num =
1
0;
params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT;
params[i+2].buffer_length = sizeof(int8_t);
params[i+2].buffer = v.v1;
params[i+2].length = NULL;
params[i+2].is_null = is_null;
params[i+2].num =
6
0;
params[i+2].num =
1
0;
params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT;
params[i+3].buffer_length = sizeof(int16_t);
params[i+3].buffer = v.v2;
params[i+3].length = NULL;
params[i+3].is_null = is_null;
params[i+3].num =
6
0;
params[i+3].num =
1
0;
params[i+4].buffer_type = TSDB_DATA_TYPE_INT;
params[i+4].buffer_length = sizeof(int32_t);
params[i+4].buffer = v.v4;
params[i+4].length = NULL;
params[i+4].is_null = is_null;
params[i+4].num =
6
0;
params[i+4].num =
1
0;
params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT;
params[i+5].buffer_length = sizeof(int64_t);
params[i+5].buffer = v.v8;
params[i+5].length = NULL;
params[i+5].is_null = is_null;
params[i+5].num =
6
0;
params[i+5].num =
1
0;
params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT;
params[i+6].buffer_length = sizeof(float);
params[i+6].buffer = v.f4;
params[i+6].length = NULL;
params[i+6].is_null = is_null;
params[i+6].num =
6
0;
params[i+6].num =
1
0;
params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE;
params[i+7].buffer_length = sizeof(double);
params[i+7].buffer = v.f8;
params[i+7].length = NULL;
params[i+7].is_null = is_null;
params[i+7].num =
6
0;
params[i+7].num =
1
0;
params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY;
params[i+8].buffer_length = 40;
params[i+8].buffer = v.bin;
params[i+8].length = lb;
params[i+8].is_null = is_null;
params[i+8].num =
6
0;
params[i+8].num =
1
0;
params[i+9].buffer_type = TSDB_DATA_TYPE_BINARY;
params[i+9].buffer_length = 40;
params[i+9].buffer = v.bin;
params[i+9].length = lb;
params[i+9].is_null = is_null;
params[i+9].num =
6
0;
params[i+9].num =
1
0;
}
int64_t tts = 1591060628000;
int64_t ttt = 0;
for (int i = 0; i < 54000000; ++i) {
for (int i = 0; i < 10; ++i) {
v.ts[i] = tts + i;
if (i > 0 && i%60 == 0) {
ttt = v.ts[i-1];
v.ts[i-1] = v.ts[i-60];
v.ts[i-60] = ttt;
}
}
for (int i = 0; i < 1; ++i) {
tags[i+0].buffer_type = TSDB_DATA_TYPE_INT;
tags[i+0].buffer = v.v4;
tags[i+0].is_null = &one_not_null;
tags[i+0].length = NULL;
tags[i+1].buffer_type = TSDB_DATA_TYPE_BOOL;
tags[i+1].buffer = v.b;
tags[i+1].is_null = &one_not_null;
tags[i+1].length = NULL;
tags[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT;
tags[i+2].buffer = v.v1;
tags[i+2].is_null = &one_not_null;
tags[i+2].length = NULL;
tags[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT;
tags[i+3].buffer = v.v2;
tags[i+3].is_null = &one_not_null;
tags[i+3].length = NULL;
tags[i+4].buffer_type = TSDB_DATA_TYPE_BIGINT;
tags[i+4].buffer = v.v8;
tags[i+4].is_null = &one_not_null;
tags[i+4].length = NULL;
tags[i+5].buffer_type = TSDB_DATA_TYPE_FLOAT;
tags[i+5].buffer = v.f4;
tags[i+5].is_null = &one_not_null;
tags[i+5].length = NULL;
tags[i+6].buffer_type = TSDB_DATA_TYPE_DOUBLE;
tags[i+6].buffer = v.f8;
tags[i+6].is_null = &one_not_null;
tags[i+6].length = NULL;
tags[i+7].buffer_type = TSDB_DATA_TYPE_BINARY;
tags[i+7].buffer = v.bin;
tags[i+7].is_null = &one_not_null;
tags[i+7].length = (uintptr_t *)lb;
tags[i+8].buffer_type = TSDB_DATA_TYPE_NCHAR;
tags[i+8].buffer = v.bin;
tags[i+8].is_null = &one_not_null;
tags[i+8].length = (uintptr_t *)lb;
}
unsigned long long starttime = taosGetTimestampUs();
char *sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?)";
int code = taos_stmt_prepare(
stmt
, sql, 0);
char *sql = "insert into ?
using stb1 tags(?,?,?,?,?,?,?,?,?)
values(?,?,?,?,?,?,?,?,?,?)";
int code = taos_stmt_prepare(
NULL
, sql, 0);
if (code != 0){
printf("failed to execute taos_stmt_prepare. code:0x%x\n", code);
printf("failed to execute taos_stmt_prepare. code:%s\n", taos_stmt_errstr(NULL));
return -1;
}
int id = 0;
for (int
l = 0; l < 3000; l
++) {
for (int zz = 0; zz < 300; zz++) {
char buf[32]
;
sprintf(buf, "m%d", zz
);
code = taos_stmt_set_tbname(stmt, buf);
if (code != 0){
printf("failed to execute taos_stmt_set_tbname. code:0x%x\n", code
);
}
for (int
zz = 0; zz < 1; zz
++) {
char buf[32];
sprintf(buf, "m%d", zz)
;
code = taos_stmt_set_tbname_tags(stmt, buf, tags
);
if (code != 0){
printf("failed to execute taos_stmt_set_tbname_tags. error:%s\n", taos_stmt_errstr(stmt));
exit(1
);
}
taos_stmt_bind_param_batch(stmt, params + id * 10);
taos_stmt_add_batch(stmt);
}
if (taos_stmt_execute(stmt) != 0) {
printf("failed to execute insert statement.\n");
code = taos_stmt_bind_param_batch(stmt, params + id * 10);
if (code != 0) {
printf("failed to execute taos_stmt_bind_param_batch. error:%s\n", taos_stmt_errstr(stmt));
exit(1);
}
code = taos_stmt_bind_param_batch(stmt, params + id * 10);
if (code != 0) {
printf("failed to execute taos_stmt_bind_param_batch. error:%s\n", taos_stmt_errstr(stmt));
return -1;
}
taos_stmt_add_batch(stmt);
}
++id;
if (taos_stmt_execute(stmt) != 0) {
printf("failed to execute insert statement.\n");
exit(1);
}
++id;
unsigned long long endtime = taosGetTimestampUs();
printf("insert total %d records, used %u seconds, avg:%u useconds\n",
3000*300*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*300*6
0));
printf("insert total %d records, used %u seconds, avg:%u useconds\n",
10, (endtime-starttime)/1000000UL, (endtime-starttime)/(1
0));
taosMemoryFree(v.ts);
taosMemoryFree(lb);
taosMemoryFree(params);
taosMemoryFree(is_null);
taosMemoryFree(no_null);
taosMemoryFree(tags);
return 0;
}
//samets
int stmt_funcb4(TAOS_STMT *stmt) {
struct {
...
...
@@ -4936,7 +3960,6 @@ int stmt_funcb_sc3(TAOS_STMT *stmt) {
}
#endif
void
prepareCheckResultImpl
(
TAOS
*
taos
,
char
*
tname
,
int
printr
,
int
expected
)
{
char
sql
[
255
]
=
"SELECT * FROM "
;
TAOS_RES
*
result
;
...
...
@@ -5323,6 +4346,9 @@ void* runcase(TAOS *taos) {
if
(
gCurCase
->
fullCol
)
{
gCurCase
->
bindColNum
=
gCurCase
->
colNum
;
}
gCurCase
->
bindNullNum
=
gTestNull
;
gCurCase
->
autoCreate
=
gTestAutoCreate
;
for
(
int32_t
n
=
0
;
n
<
gCurCase
->
runTimes
;
++
n
)
{
prepare
(
taos
,
gCurCase
->
colNum
,
gCurCase
->
colList
,
gCurCase
->
autoCreate
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录