Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
61b39d7e
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看板
提交
61b39d7e
编写于
6月 04, 2021
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support error msg
上级
ecbc6108
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
284 addition
and
38 deletion
+284
-38
src/client/src/tscPrepare.c
src/client/src/tscPrepare.c
+49
-36
tests/script/api/batchprepare.c
tests/script/api/batchprepare.c
+235
-2
未找到文件。
src/client/src/tscPrepare.c
浏览文件 @
61b39d7e
...
...
@@ -163,8 +163,8 @@ static int normalStmtBindParam(STscStmt* stmt, TAOS_BIND* bind) {
break
;
default:
tsc
Debug
(
"0x%"
PRIx64
" bind column%d: type mismatch or invalid"
,
stmt
->
pSql
->
self
,
i
);
return
TSDB_CODE_TSC_INVALID_VALUE
;
tsc
Error
(
"0x%"
PRIx64
" bind column%d: type mismatch or invalid"
,
stmt
->
pSql
->
self
,
i
);
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
&
stmt
->
pSql
->
cmd
),
"bind type mismatch or invalid"
)
;
}
}
...
...
@@ -727,6 +727,7 @@ static int doBindParam(STableDataBlocks* pBlock, char* data, SParamInfo* param,
#endif
if
(
bind
->
buffer_type
!=
param
->
type
)
{
tscError
(
"column type mismatch"
);
return
TSDB_CODE_TSC_INVALID_VALUE
;
}
...
...
@@ -754,6 +755,7 @@ static int doBindParam(STableDataBlocks* pBlock, char* data, SParamInfo* param,
case
TSDB_DATA_TYPE_BINARY
:
if
((
*
bind
->
length
)
>
(
uintptr_t
)
param
->
bytes
)
{
tscError
(
"column length is too big"
);
return
TSDB_CODE_TSC_INVALID_VALUE
;
}
size
=
(
short
)
*
bind
->
length
;
...
...
@@ -763,6 +765,7 @@ static int doBindParam(STableDataBlocks* pBlock, char* data, SParamInfo* param,
case
TSDB_DATA_TYPE_NCHAR
:
{
int32_t
output
=
0
;
if
(
!
taosMbsToUcs4
(
bind
->
buffer
,
*
bind
->
length
,
varDataVal
(
data
+
param
->
offset
),
param
->
bytes
-
VARSTR_HEADER_SIZE
,
&
output
))
{
tscError
(
"convert nchar failed"
);
return
TSDB_CODE_TSC_INVALID_VALUE
;
}
varDataSetLen
(
data
+
param
->
offset
,
output
);
...
...
@@ -787,6 +790,7 @@ static int doBindParam(STableDataBlocks* pBlock, char* data, SParamInfo* param,
static
int
doBindBatchParam
(
STableDataBlocks
*
pBlock
,
SParamInfo
*
param
,
TAOS_MULTI_BIND
*
bind
,
int32_t
rowNum
)
{
if
(
bind
->
buffer_type
!=
param
->
type
||
!
isValidDataType
(
param
->
type
))
{
tscError
(
"column mismatch or invalid"
);
return
TSDB_CODE_TSC_INVALID_VALUE
;
}
...
...
@@ -892,8 +896,8 @@ static int insertStmtBindParam(STscStmt* stmt, TAOS_BIND* bind) {
int
code
=
doBindParam
(
pBlock
,
data
,
param
,
&
bind
[
param
->
idx
],
1
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tscDebug
(
"0x%"
PRIx64
" bind column %d: type mismatch or invalid"
,
pStmt
->
pSql
->
self
,
param
->
idx
);
return
code
;
tscDebug
(
"0x%"
PRIx64
" bind column %d: type mismatch or invalid"
,
pStmt
->
pSql
->
self
,
param
->
idx
);
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
&
stmt
->
pSql
->
cmd
),
"bind column type mismatch or invalid"
)
;
}
}
...
...
@@ -957,13 +961,13 @@ static int insertStmtBindParamBatch(STscStmt* stmt, TAOS_MULTI_BIND* bind, int c
SParamInfo
*
param
=
&
pBlock
->
params
[
j
];
if
(
bind
[
param
->
idx
].
num
!=
rowNum
)
{
tscError
(
"0x%"
PRIx64
" param %d: num[%d:%d] not match"
,
pStmt
->
pSql
->
self
,
param
->
idx
,
rowNum
,
bind
[
param
->
idx
].
num
);
return
TSDB_CODE_TSC_INVALID_VALUE
;
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
&
stmt
->
pSql
->
cmd
),
"bind row num mismatch"
)
;
}
int
code
=
doBindBatchParam
(
pBlock
,
param
,
&
bind
[
param
->
idx
],
pCmd
->
batchSize
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tscError
(
"0x%"
PRIx64
" bind column %d: type mismatch or invalid"
,
pStmt
->
pSql
->
self
,
param
->
idx
);
return
code
;
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
&
stmt
->
pSql
->
cmd
),
"bind column type mismatch or invalid"
)
;
}
}
...
...
@@ -974,7 +978,7 @@ static int insertStmtBindParamBatch(STscStmt* stmt, TAOS_MULTI_BIND* bind, int c
int
code
=
doBindBatchParam
(
pBlock
,
param
,
bind
,
pCmd
->
batchSize
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tscError
(
"0x%"
PRIx64
" bind column %d: type mismatch or invalid"
,
pStmt
->
pSql
->
self
,
param
->
idx
);
return
code
;
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
&
stmt
->
pSql
->
cmd
),
"bind column type mismatch or invalid"
)
;
}
if
(
colIdx
==
(
pBlock
->
numOfParams
-
1
))
{
...
...
@@ -993,7 +997,7 @@ static int insertStmtUpdateBatch(STscStmt* stmt) {
if
(
pCmd
->
batchSize
>
INT16_MAX
)
{
tscError
(
"too many record:%d"
,
pCmd
->
batchSize
);
return
TSDB_CODE_TSC_APP_ERROR
;
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
&
stmt
->
pSql
->
cmd
),
"too many records"
)
;
}
if
(
taosHashGetSize
(
pCmd
->
insertParam
.
pTableBlockHashList
)
==
0
)
{
...
...
@@ -1057,7 +1061,8 @@ static int insertStmtReset(STscStmt* pStmt) {
static
int
insertStmtExecute
(
STscStmt
*
stmt
)
{
SSqlCmd
*
pCmd
=
&
stmt
->
pSql
->
cmd
;
if
(
pCmd
->
batchSize
==
0
)
{
return
TSDB_CODE_TSC_INVALID_VALUE
;
tscError
(
"no records bind"
);
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
&
stmt
->
pSql
->
cmd
),
"no records bind"
);
}
if
(
taosHashGetSize
(
pCmd
->
insertParam
.
pTableBlockHashList
)
==
0
)
{
...
...
@@ -1174,7 +1179,7 @@ static int insertBatchStmtExecute(STscStmt* pStmt) {
if
(
pStmt
->
mtb
.
nameSet
==
false
)
{
tscError
(
"0x%"
PRIx64
" no table name set"
,
pStmt
->
pSql
->
self
);
return
TSDB_CODE_TSC_APP_ERROR
;
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
&
pStmt
->
pSql
->
cmd
),
"no table name set"
)
;
}
pStmt
->
pSql
->
retry
=
pStmt
->
pSql
->
maxRetry
+
1
;
//no retry
...
...
@@ -1215,7 +1220,8 @@ int stmtParseInsertTbTags(SSqlObj* pSql, STscStmt* pStmt) {
int32_t
index
=
0
;
SStrToken
sToken
=
tStrGetToken
(
pCmd
->
insertParam
.
sql
,
&
index
,
false
);
if
(
sToken
.
n
==
0
)
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
tscError
(
"table is is expected, sql:%s"
,
pCmd
->
insertParam
.
sql
);
return
tscSQLSyntaxErrMsg
(
pCmd
->
payload
,
"table name is expected"
,
pCmd
->
insertParam
.
sql
);
}
if
(
sToken
.
n
==
1
&&
sToken
.
type
==
TK_QUESTION
)
{
...
...
@@ -1237,24 +1243,28 @@ int stmtParseInsertTbTags(SSqlObj* pSql, STscStmt* pStmt) {
return
TSDB_CODE_SUCCESS
;
}
if
(
sToken
.
n
<=
0
||
sToken
.
type
!=
TK_USING
)
{
return
tscSQLSyntaxErrMsg
(
pCmd
->
payload
,
"keywords USING is expected"
,
sToken
.
z
);
if
(
sToken
.
n
<=
0
||
sToken
.
type
!=
TK_USING
)
{
tscError
(
"keywords USING is expected, sql:%s"
,
pCmd
->
insertParam
.
sql
);
return
tscSQLSyntaxErrMsg
(
pCmd
->
payload
,
"keywords USING is expected"
,
sToken
.
z
?
sToken
.
z
:
pCmd
->
insertParam
.
sql
);
}
sToken
=
tStrGetToken
(
pCmd
->
insertParam
.
sql
,
&
index
,
false
);
if
(
sToken
.
n
<=
0
||
((
sToken
.
type
!=
TK_ID
)
&&
(
sToken
.
type
!=
TK_STRING
)))
{
return
tscSQLSyntaxErrMsg
(
pCmd
->
payload
,
"invalid token"
,
sToken
.
z
);
tscError
(
"invalid token, sql:%s"
,
pCmd
->
insertParam
.
sql
);
return
tscSQLSyntaxErrMsg
(
pCmd
->
payload
,
"invalid token"
,
sToken
.
z
?
sToken
.
z
:
pCmd
->
insertParam
.
sql
);
}
pStmt
->
mtb
.
stbname
=
sToken
;
sToken
=
tStrGetToken
(
pCmd
->
insertParam
.
sql
,
&
index
,
false
);
if
(
sToken
.
n
<=
0
||
sToken
.
type
!=
TK_TAGS
)
{
return
tscSQLSyntaxErrMsg
(
pCmd
->
payload
,
"keyword TAGS expected"
,
sToken
.
z
);
tscError
(
"keyword TAGS expected, sql:%s"
,
pCmd
->
insertParam
.
sql
);
return
tscSQLSyntaxErrMsg
(
pCmd
->
payload
,
"keyword TAGS expected"
,
sToken
.
z
?
sToken
.
z
:
pCmd
->
insertParam
.
sql
);
}
sToken
=
tStrGetToken
(
pCmd
->
insertParam
.
sql
,
&
index
,
false
);
if
(
sToken
.
n
<=
0
||
sToken
.
type
!=
TK_LP
)
{
return
tscSQLSyntaxErrMsg
(
pCmd
->
payload
,
") expected"
,
sToken
.
z
);
tscError
(
"( expected, sql:%s"
,
pCmd
->
insertParam
.
sql
);
return
tscSQLSyntaxErrMsg
(
pCmd
->
payload
,
"( expected"
,
sToken
.
z
?
sToken
.
z
:
pCmd
->
insertParam
.
sql
);
}
pStmt
->
mtb
.
tags
=
taosArrayInit
(
4
,
sizeof
(
SStrToken
));
...
...
@@ -1264,7 +1274,8 @@ int stmtParseInsertTbTags(SSqlObj* pSql, STscStmt* pStmt) {
while
(
loopCont
)
{
sToken
=
tStrGetToken
(
pCmd
->
insertParam
.
sql
,
&
index
,
false
);
if
(
sToken
.
n
<=
0
)
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
tscError
(
"unexpected sql end, sql:%s"
,
pCmd
->
insertParam
.
sql
);
return
tscSQLSyntaxErrMsg
(
pCmd
->
payload
,
"unexpected sql end"
,
pCmd
->
insertParam
.
sql
);
}
switch
(
sToken
.
type
)
{
...
...
@@ -1272,7 +1283,8 @@ int stmtParseInsertTbTags(SSqlObj* pSql, STscStmt* pStmt) {
loopCont
=
0
;
break
;
case
TK_VALUES
:
return
TSDB_CODE_TSC_INVALID_OPERATION
;
tscError
(
"unexpected token values, sql:%s"
,
pCmd
->
insertParam
.
sql
);
return
tscSQLSyntaxErrMsg
(
pCmd
->
payload
,
"unexpected token"
,
sToken
.
z
);
case
TK_QUESTION
:
pStmt
->
mtb
.
tagSet
=
false
;
//continue
default:
...
...
@@ -1282,12 +1294,14 @@ int stmtParseInsertTbTags(SSqlObj* pSql, STscStmt* pStmt) {
}
if
(
taosArrayGetSize
(
pStmt
->
mtb
.
tags
)
<=
0
)
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
tscError
(
"no tags, sql:%s"
,
pCmd
->
insertParam
.
sql
);
return
tscSQLSyntaxErrMsg
(
pCmd
->
payload
,
"no tags"
,
pCmd
->
insertParam
.
sql
);
}
sToken
=
tStrGetToken
(
pCmd
->
insertParam
.
sql
,
&
index
,
false
);
if
(
sToken
.
n
<=
0
||
(
sToken
.
type
!=
TK_VALUES
&&
sToken
.
type
!=
TK_LP
))
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
tscError
(
"sql error, sql:%s"
,
pCmd
->
insertParam
.
sql
);
return
tscSQLSyntaxErrMsg
(
pCmd
->
payload
,
"sql error"
,
sToken
.
z
?
sToken
.
z
:
pCmd
->
insertParam
.
sql
);
}
pStmt
->
mtb
.
values
=
sToken
;
...
...
@@ -1329,8 +1343,8 @@ int stmtGenInsertStatement(SSqlObj* pSql, STscStmt* pStmt, const char* name, TAO
}
else
{
if
(
tags
[
j
].
buffer
==
NULL
)
{
free
(
str
);
tscError
(
"empty"
);
return
TSDB_CODE_TSC_APP_ERROR
;
tscError
(
"empty
tag value in params
"
);
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
&
pStmt
->
pSql
->
cmd
),
"empty tag value in params"
)
;
}
ret
=
converToStr
(
str
+
len
,
tags
[
j
].
buffer_type
,
tags
[
j
].
buffer
,
tags
[
j
].
length
?
(
int32_t
)
*
tags
[
j
].
length
:
-
1
,
&
l
);
...
...
@@ -1410,6 +1424,11 @@ TAOS_STMT* taos_stmt_init(TAOS* taos) {
return
NULL
;
}
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
&
pSql
->
cmd
,
TSDB_DEFAULT_PAYLOAD_SIZE
))
{
tscError
(
"%p failed to malloc payload buffer"
,
pSql
);
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
tsem_init
(
&
pSql
->
rspSem
,
0
,
0
);
pSql
->
signature
=
pSql
;
pSql
->
pTscObj
=
pObj
;
...
...
@@ -1431,7 +1450,7 @@ int taos_stmt_prepare(TAOS_STMT* stmt, const char* sql, unsigned long length) {
if
(
pStmt
->
last
!=
STMT_INIT
)
{
tscError
(
"prepare status error, last:%d"
,
pStmt
->
last
);
return
TSDB_CODE_TSC_APP_ERROR
;
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
"prepare status error"
)
;
}
pStmt
->
last
=
STMT_PREPARE
;
...
...
@@ -1447,11 +1466,6 @@ int taos_stmt_prepare(TAOS_STMT* stmt, const char* sql, unsigned long length) {
pCmd
->
insertParam
.
insertType
=
TSDB_QUERY_TYPE_STMT_INSERT
;
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
TSDB_DEFAULT_PAYLOAD_SIZE
))
{
tscError
(
"%p failed to malloc payload buffer"
,
pSql
);
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
pSql
->
sqlstr
=
realloc
(
pSql
->
sqlstr
,
sqlLen
+
1
);
if
(
pSql
->
sqlstr
==
NULL
)
{
...
...
@@ -1489,6 +1503,7 @@ int taos_stmt_prepare(TAOS_STMT* stmt, const char* sql, unsigned long length) {
if
(
code
==
TSDB_CODE_TSC_ACTION_IN_PROGRESS
)
{
// wait for the callback function to post the semaphore
tsem_wait
(
&
pSql
->
rspSem
);
pSql
->
res
.
code
=
code
;
return
pSql
->
res
.
code
;
}
...
...
@@ -1510,20 +1525,18 @@ int taos_stmt_set_tbname_tags(TAOS_STMT* stmt, const char* name, TAOS_BIND* tags
}
if
(
name
==
NULL
)
{
terrno
=
TSDB_CODE_TSC_APP_ERROR
;
tscError
(
"0x%"
PRIx64
" name is NULL"
,
pSql
->
self
);
return
TSDB_CODE_TSC_APP_ERROR
;
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
&
pStmt
->
pSql
->
cmd
),
"name is NULL"
)
;
}
if
(
pStmt
->
multiTbInsert
==
false
||
!
tscIsInsertData
(
pSql
->
sqlstr
))
{
terrno
=
TSDB_CODE_TSC_APP_ERROR
;
tscError
(
"0x%"
PRIx64
" not multi table insert"
,
pSql
->
self
);
return
TSDB_CODE_TSC_APP_ERROR
;
tscError
(
"0x%"
PRIx64
" not multiple table insert"
,
pSql
->
self
);
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
&
pStmt
->
pSql
->
cmd
),
"not multiple table insert"
);
}
if
(
pStmt
->
last
==
STMT_INIT
||
pStmt
->
last
==
STMT_BIND
||
pStmt
->
last
==
STMT_BIND_COL
)
{
tscError
(
"0x%"
PRIx64
" set
tbname
status error, last:%d"
,
pSql
->
self
,
pStmt
->
last
);
return
TSDB_CODE_TSC_APP_ERROR
;
tscError
(
"0x%"
PRIx64
" set
_tbname_tags
status error, last:%d"
,
pSql
->
self
,
pStmt
->
last
);
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
&
pStmt
->
pSql
->
cmd
),
"set_tbname_tags status error"
)
;
}
pStmt
->
last
=
STMT_SETTBNAME
;
...
...
@@ -1552,7 +1565,7 @@ int taos_stmt_set_tbname_tags(TAOS_STMT* stmt, const char* name, TAOS_BIND* tags
}
else
{
if
(
tags
==
NULL
)
{
tscError
(
"No tags set"
);
return
TSDB_CODE_TSC_APP_ERROR
;
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
&
pStmt
->
pSql
->
cmd
),
"no tags set"
)
;
}
int32_t
ret
=
stmtGenInsertStatement
(
pSql
,
pStmt
,
name
,
tags
);
...
...
tests/script/api/batchprepare.c
浏览文件 @
61b39d7e
...
...
@@ -1860,6 +1860,224 @@ int stmt_funcb_autoctb_e2(TAOS_STMT *stmt) {
//1 tables 10 records
int
stmt_funcb_autoctb_e3
(
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
=
malloc
(
sizeof
(
int64_t
)
*
1
*
10
);
int
*
lb
=
malloc
(
10
*
sizeof
(
int
));
TAOS_BIND
*
tags
=
calloc
(
1
,
sizeof
(
TAOS_BIND
)
*
9
*
1
);
TAOS_MULTI_BIND
*
params
=
calloc
(
1
,
sizeof
(
TAOS_MULTI_BIND
)
*
1
*
10
);
// int one_null = 1;
int
one_not_null
=
0
;
char
*
is_null
=
malloc
(
sizeof
(
char
)
*
10
);
char
*
no_null
=
malloc
(
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
;
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
=
getCurrentTime
();
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:0x%x
\n
"
,
code
);
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
);
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
);
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
=
getCurrentTime
();
printf
(
"insert total %d records, used %u seconds, avg:%u useconds
\n
"
,
10
,
(
endtime
-
starttime
)
/
1000000UL
,
(
endtime
-
starttime
)
/
(
10
));
free
(
v
.
ts
);
free
(
lb
);
free
(
params
);
free
(
is_null
);
free
(
no_null
);
free
(
tags
);
return
0
;
}
//300 tables 60 records
int
stmt_funcb1
(
TAOS_STMT
*
stmt
)
{
struct
{
...
...
@@ -3835,7 +4053,7 @@ void* runcase(void *par) {
#endif
#if 1
#if 1
prepare
(
taos
,
1
,
1
);
stmt
=
taos_stmt_init
(
taos
);
...
...
@@ -3900,7 +4118,7 @@ void* runcase(void *par) {
#endif
#if 1
#if 1
prepare
(
taos
,
1
,
0
);
stmt
=
taos_stmt_init
(
taos
);
...
...
@@ -3930,6 +4148,21 @@ void* runcase(void *par) {
#endif
#if 1
prepare
(
taos
,
1
,
0
);
stmt
=
taos_stmt_init
(
taos
);
printf
(
"1t+10r+bm+autoctb+e3 start
\n
"
);
stmt_funcb_autoctb_e3
(
stmt
);
printf
(
"1t+10r+bm+autoctb+e3 end
\n
"
);
printf
(
"check result start
\n
"
);
//check_result(taos, "m0", 1, 0);
printf
(
"check result end
\n
"
);
taos_stmt_close
(
stmt
);
#endif
#if 1
prepare
(
taos
,
1
,
1
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录