Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Mz丶苗
TDengine
提交
9cc8a36c
T
TDengine
项目概览
Mz丶苗
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9cc8a36c
编写于
5月 08, 2021
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support bind single column
上级
003562bc
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
49 addition
and
14 deletion
+49
-14
src/client/src/tscPrepare.c
src/client/src/tscPrepare.c
+48
-14
src/inc/taos.h
src/inc/taos.h
+1
-0
未找到文件。
src/client/src/tscPrepare.c
浏览文件 @
9cc8a36c
...
...
@@ -762,7 +762,7 @@ static int doBindBatchParam(STableDataBlocks* pBlock, SParamInfo* param, TAOS_MU
if
(
bind
->
is_null
!=
NULL
&&
bind
->
is_null
[
i
])
{
setNull
(
data
+
param
->
offset
,
param
->
type
,
param
->
bytes
);
return
TSDB_CODE_SUCCESS
;
continue
;
}
if
(
size
>
0
)
{
...
...
@@ -776,13 +776,15 @@ static int doBindBatchParam(STableDataBlocks* pBlock, SParamInfo* param, TAOS_MU
}
}
else
if
(
param
->
type
==
TSDB_DATA_TYPE_BINARY
)
{
if
(
bind
->
length
[
i
]
>
(
uintptr_t
)
param
->
bytes
)
{
tscError
(
"invalid binary length"
);
return
TSDB_CODE_TSC_INVALID_VALUE
;
}
size
=
(
short
)
bind
->
length
[
i
];
STR_WITH_SIZE_TO_VARSTR
(
data
+
param
->
offset
,
bind
->
buffer
+
bind
->
buffer_length
*
i
,
size
);
int16_t
b
size
=
(
short
)
bind
->
length
[
i
];
STR_WITH_SIZE_TO_VARSTR
(
data
+
param
->
offset
,
bind
->
buffer
+
bind
->
buffer_length
*
i
,
b
size
);
}
else
if
(
param
->
type
==
TSDB_DATA_TYPE_NCHAR
)
{
int32_t
output
=
0
;
if
(
!
taosMbsToUcs4
(
bind
->
buffer
+
bind
->
buffer_length
*
i
,
bind
->
length
[
i
],
varDataVal
(
data
+
param
->
offset
),
param
->
bytes
-
VARSTR_HEADER_SIZE
,
&
output
))
{
tscError
(
"convert failed"
);
return
TSDB_CODE_TSC_INVALID_VALUE
;
}
varDataSetLen
(
data
+
param
->
offset
,
output
);
...
...
@@ -857,7 +859,7 @@ static int insertStmtBindParam(STscStmt* stmt, TAOS_BIND* bind) {
}
static
int
insertStmtBindParamBatch
(
STscStmt
*
stmt
,
TAOS_MULTI_BIND
*
bind
)
{
static
int
insertStmtBindParamBatch
(
STscStmt
*
stmt
,
TAOS_MULTI_BIND
*
bind
,
int
colIdx
)
{
SSqlCmd
*
pCmd
=
&
stmt
->
pSql
->
cmd
;
STscStmt
*
pStmt
=
(
STscStmt
*
)
stmt
;
int
rowNum
=
bind
->
num
;
...
...
@@ -877,6 +879,8 @@ static int insertStmtBindParamBatch(STscStmt* stmt, TAOS_MULTI_BIND* bind) {
pBlock
=
*
t1
;
assert
(
colIdx
==
-
1
||
(
colIdx
>=
0
&&
colIdx
<
pBlock
->
numOfParams
));
uint32_t
totalDataSize
=
sizeof
(
SSubmitBlk
)
+
(
pCmd
->
batchSize
+
rowNum
)
*
pBlock
->
rowSize
;
if
(
totalDataSize
>
pBlock
->
nAllocSize
)
{
const
double
factor
=
1
.
5
;
...
...
@@ -890,21 +894,35 @@ static int insertStmtBindParamBatch(STscStmt* stmt, TAOS_MULTI_BIND* bind) {
pBlock
->
nAllocSize
=
(
uint32_t
)(
totalDataSize
*
factor
);
}
for
(
uint32_t
j
=
0
;
j
<
pBlock
->
numOfParams
;
++
j
)
{
SParamInfo
*
param
=
&
pBlock
->
params
[
j
];
if
(
bind
[
param
->
idx
].
num
!=
rowNum
)
{
tscError
(
"param %d: num[%d:%d] not match"
,
param
->
idx
,
rowNum
,
bind
[
param
->
idx
].
num
);
return
TSDB_CODE_TSC_INVALID_VALUE
;
if
(
colIdx
==
-
1
)
{
for
(
uint32_t
j
=
0
;
j
<
pBlock
->
numOfParams
;
++
j
)
{
SParamInfo
*
param
=
&
pBlock
->
params
[
j
];
if
(
bind
[
param
->
idx
].
num
!=
rowNum
)
{
tscError
(
"param %d: num[%d:%d] not match"
,
param
->
idx
,
rowNum
,
bind
[
param
->
idx
].
num
);
return
TSDB_CODE_TSC_INVALID_VALUE
;
}
int
code
=
doBindBatchParam
(
pBlock
,
param
,
&
bind
[
param
->
idx
],
pCmd
->
batchSize
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tscError
(
"param %d: type mismatch or invalid"
,
param
->
idx
);
return
code
;
}
}
int
code
=
doBindBatchParam
(
pBlock
,
param
,
&
bind
[
param
->
idx
],
pCmd
->
batchSize
);
pCmd
->
batchSize
+=
rowNum
-
1
;
}
else
{
SParamInfo
*
param
=
&
pBlock
->
params
[
colIdx
];
int
code
=
doBindBatchParam
(
pBlock
,
param
,
bind
,
pCmd
->
batchSize
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tscError
(
"param %d: type mismatch or invalid"
,
param
->
idx
);
return
code
;
}
}
pCmd
->
batchSize
+=
rowNum
-
1
;
if
(
colIdx
==
(
pBlock
->
numOfParams
-
1
))
{
pCmd
->
batchSize
+=
rowNum
-
1
;
}
}
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -1386,10 +1404,26 @@ int taos_stmt_bind_param_batch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind) {
return
TSDB_CODE_TSC_APP_ERROR
;
}
return
insertStmtBindParamBatch
(
pStmt
,
bind
);
return
insertStmtBindParamBatch
(
pStmt
,
bind
,
-
1
);
}
int
taos_stmt_bind_single_param_batch
(
TAOS_STMT
*
stmt
,
TAOS_MULTI_BIND
*
bind
,
int
colIdx
)
{
STscStmt
*
pStmt
=
(
STscStmt
*
)
stmt
;
if
(
bind
==
NULL
||
bind
->
num
<=
0
)
{
tscError
(
"invalid parameter"
);
return
TSDB_CODE_TSC_APP_ERROR
;
}
if
(
!
pStmt
->
isInsert
||
!
pStmt
->
multiTbInsert
||
!
pStmt
->
mtb
.
nameSet
)
{
tscError
(
"not or invalid batch insert"
);
return
TSDB_CODE_TSC_APP_ERROR
;
}
return
insertStmtBindParamBatch
(
pStmt
,
bind
,
colIdx
);
}
int
taos_stmt_add_batch
(
TAOS_STMT
*
stmt
)
{
STscStmt
*
pStmt
=
(
STscStmt
*
)
stmt
;
if
(
pStmt
->
isInsert
)
{
...
...
src/inc/taos.h
浏览文件 @
9cc8a36c
...
...
@@ -119,6 +119,7 @@ int taos_stmt_num_params(TAOS_STMT *stmt, int *nums);
int
taos_stmt_get_param
(
TAOS_STMT
*
stmt
,
int
idx
,
int
*
type
,
int
*
bytes
);
int
taos_stmt_bind_param
(
TAOS_STMT
*
stmt
,
TAOS_BIND
*
bind
);
int
taos_stmt_bind_param_batch
(
TAOS_STMT
*
stmt
,
TAOS_MULTI_BIND
*
bind
);
int
taos_stmt_bind_single_param_batch
(
TAOS_STMT
*
stmt
,
TAOS_MULTI_BIND
*
bind
,
int
colIdx
);
int
taos_stmt_add_batch
(
TAOS_STMT
*
stmt
);
int
taos_stmt_execute
(
TAOS_STMT
*
stmt
);
TAOS_RES
*
taos_stmt_use_result
(
TAOS_STMT
*
stmt
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录