Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ecb735de
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看板
提交
ecb735de
编写于
5月 10, 2021
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add api check
上级
2e08de2b
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
102 addition
and
10 deletion
+102
-10
src/client/src/tscPrepare.c
src/client/src/tscPrepare.c
+102
-10
未找到文件。
src/client/src/tscPrepare.c
浏览文件 @
ecb735de
...
...
@@ -53,10 +53,20 @@ typedef struct SMultiTbStmt {
SHashObj
*
pTableBlockHashList
;
// data block for each table
}
SMultiTbStmt
;
typedef
enum
{
STMT_INIT
=
1
,
STMT_PREPARE
,
STMT_SETTBNAME
,
STMT_BIND
,
STMT_BIND_COL
,
STMT_ADD_BATCH
,
STMT_EXECUTE
}
STMT_ST
;
typedef
struct
STscStmt
{
bool
isInsert
;
bool
multiTbInsert
;
int
64_t
prevTs
;
int
16_t
last
;
STscObj
*
taos
;
SSqlObj
*
pSql
;
SMultiTbStmt
mtb
;
...
...
@@ -1185,6 +1195,7 @@ TAOS_STMT* taos_stmt_init(TAOS* taos) {
pSql
->
maxRetry
=
TSDB_MAX_REPLICA
;
pSql
->
isBind
=
true
;
pStmt
->
pSql
=
pSql
;
pStmt
->
last
=
STMT_INIT
;
return
pStmt
;
}
...
...
@@ -1197,6 +1208,13 @@ int taos_stmt_prepare(TAOS_STMT* stmt, const char* sql, unsigned long length) {
return
TSDB_CODE_TSC_DISCONNECTED
;
}
if
(
pStmt
->
last
!=
STMT_INIT
)
{
tscError
(
"prepare status error, last:%d"
,
pStmt
->
last
);
return
TSDB_CODE_TSC_APP_ERROR
;
}
pStmt
->
last
=
STMT_PREPARE
;
SSqlObj
*
pSql
=
pStmt
->
pSql
;
size_t
sqlLen
=
strlen
(
sql
);
...
...
@@ -1302,6 +1320,13 @@ int taos_stmt_set_tbname(TAOS_STMT* stmt, const char* name) {
return
TSDB_CODE_TSC_APP_ERROR
;
}
if
(
pStmt
->
last
==
STMT_INIT
&&
pStmt
->
last
==
STMT_BIND
&&
pStmt
->
last
==
STMT_BIND_COL
)
{
tscError
(
"0x%"
PRIx64
" settbname status error, last:%d"
,
pSql
->
self
,
pStmt
->
last
);
return
TSDB_CODE_TSC_APP_ERROR
;
}
pStmt
->
last
=
STMT_SETTBNAME
;
uint64_t
*
uid
=
(
uint64_t
*
)
taosHashGet
(
pStmt
->
mtb
.
pTableHash
,
name
,
strlen
(
name
));
if
(
uid
!=
NULL
)
{
pStmt
->
mtb
.
currentUid
=
*
uid
;
...
...
@@ -1399,11 +1424,25 @@ int taos_stmt_close(TAOS_STMT* stmt) {
int
taos_stmt_bind_param
(
TAOS_STMT
*
stmt
,
TAOS_BIND
*
bind
)
{
STscStmt
*
pStmt
=
(
STscStmt
*
)
stmt
;
if
(
stmt
==
NULL
||
pStmt
->
pSql
==
NULL
||
pStmt
->
taos
==
NULL
)
{
terrno
=
TSDB_CODE_TSC_DISCONNECTED
;
return
TSDB_CODE_TSC_DISCONNECTED
;
}
if
(
pStmt
->
isInsert
)
{
if
(
pStmt
->
multiTbInsert
&&
pStmt
->
mtb
.
nameSet
==
false
)
{
tscError
(
"no table name set"
);
return
TSDB_CODE_TSC_APP_ERROR
;
if
(
pStmt
->
multiTbInsert
)
{
if
(
pStmt
->
last
!=
STMT_SETTBNAME
&&
pStmt
->
last
!=
STMT_ADD_BATCH
)
{
tscError
(
"0x%"
PRIx64
" bind param status error, last:%d"
,
pStmt
->
pSql
->
self
,
pStmt
->
last
);
return
TSDB_CODE_TSC_APP_ERROR
;
}
}
else
{
if
(
pStmt
->
last
!=
STMT_PREPARE
&&
pStmt
->
last
!=
STMT_ADD_BATCH
)
{
tscError
(
"0x%"
PRIx64
" bind param status error, last:%d"
,
pStmt
->
pSql
->
self
,
pStmt
->
last
);
return
TSDB_CODE_TSC_APP_ERROR
;
}
}
pStmt
->
last
=
STMT_BIND
;
return
insertStmtBindParam
(
pStmt
,
bind
);
}
else
{
...
...
@@ -1414,6 +1453,12 @@ int taos_stmt_bind_param(TAOS_STMT* stmt, TAOS_BIND* bind) {
int
taos_stmt_bind_param_batch
(
TAOS_STMT
*
stmt
,
TAOS_MULTI_BIND
*
bind
)
{
STscStmt
*
pStmt
=
(
STscStmt
*
)
stmt
;
if
(
stmt
==
NULL
||
pStmt
->
pSql
==
NULL
||
pStmt
->
taos
==
NULL
)
{
terrno
=
TSDB_CODE_TSC_DISCONNECTED
;
return
TSDB_CODE_TSC_DISCONNECTED
;
}
if
(
bind
==
NULL
||
bind
->
num
<=
0
)
{
tscError
(
"0x%"
PRIx64
" invalid parameter"
,
pStmt
->
pSql
->
self
);
return
TSDB_CODE_TSC_APP_ERROR
;
...
...
@@ -1424,16 +1469,30 @@ int taos_stmt_bind_param_batch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind) {
return
TSDB_CODE_TSC_APP_ERROR
;
}
if
(
pStmt
->
multiTbInsert
&&
!
pStmt
->
mtb
.
nameSet
)
{
tscError
(
"0x%"
PRIx64
" no table name set"
,
pStmt
->
pSql
->
self
);
return
TSDB_CODE_TSC_APP_ERROR
;
if
(
pStmt
->
multiTbInsert
)
{
if
(
pStmt
->
last
!=
STMT_SETTBNAME
&&
pStmt
->
last
!=
STMT_ADD_BATCH
)
{
tscError
(
"0x%"
PRIx64
" bind param status error, last:%d"
,
pStmt
->
pSql
->
self
,
pStmt
->
last
);
return
TSDB_CODE_TSC_APP_ERROR
;
}
}
else
{
if
(
pStmt
->
last
!=
STMT_PREPARE
&&
pStmt
->
last
!=
STMT_ADD_BATCH
)
{
tscError
(
"0x%"
PRIx64
" bind param status error, last:%d"
,
pStmt
->
pSql
->
self
,
pStmt
->
last
);
return
TSDB_CODE_TSC_APP_ERROR
;
}
}
pStmt
->
last
=
STMT_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
(
stmt
==
NULL
||
pStmt
->
pSql
==
NULL
||
pStmt
->
taos
==
NULL
)
{
terrno
=
TSDB_CODE_TSC_DISCONNECTED
;
return
TSDB_CODE_TSC_DISCONNECTED
;
}
if
(
bind
==
NULL
||
bind
->
num
<=
0
)
{
tscError
(
"0x%"
PRIx64
" invalid parameter"
,
pStmt
->
pSql
->
self
);
return
TSDB_CODE_TSC_APP_ERROR
;
...
...
@@ -1444,11 +1503,19 @@ int taos_stmt_bind_single_param_batch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind, in
return
TSDB_CODE_TSC_APP_ERROR
;
}
if
(
pStmt
->
multiTbInsert
&&
!
pStmt
->
mtb
.
nameSet
)
{
tscError
(
"0x%"
PRIx64
" no table name set"
,
pStmt
->
pSql
->
self
);
return
TSDB_CODE_TSC_APP_ERROR
;
if
(
pStmt
->
multiTbInsert
)
{
if
(
pStmt
->
last
!=
STMT_SETTBNAME
&&
pStmt
->
last
!=
STMT_ADD_BATCH
&&
pStmt
->
last
!=
STMT_BIND_COL
)
{
tscError
(
"0x%"
PRIx64
" bind param status error, last:%d"
,
pStmt
->
pSql
->
self
,
pStmt
->
last
);
return
TSDB_CODE_TSC_APP_ERROR
;
}
}
else
{
if
(
pStmt
->
last
!=
STMT_PREPARE
&&
pStmt
->
last
!=
STMT_ADD_BATCH
&&
pStmt
->
last
!=
STMT_BIND_COL
)
{
tscError
(
"0x%"
PRIx64
" bind param status error, last:%d"
,
pStmt
->
pSql
->
self
,
pStmt
->
last
);
return
TSDB_CODE_TSC_APP_ERROR
;
}
}
pStmt
->
last
=
STMT_BIND_COL
;
return
insertStmtBindParamBatch
(
pStmt
,
bind
,
colIdx
);
}
...
...
@@ -1457,9 +1524,22 @@ int taos_stmt_bind_single_param_batch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind, in
int
taos_stmt_add_batch
(
TAOS_STMT
*
stmt
)
{
STscStmt
*
pStmt
=
(
STscStmt
*
)
stmt
;
if
(
stmt
==
NULL
||
pStmt
->
pSql
==
NULL
||
pStmt
->
taos
==
NULL
)
{
terrno
=
TSDB_CODE_TSC_DISCONNECTED
;
return
TSDB_CODE_TSC_DISCONNECTED
;
}
if
(
pStmt
->
isInsert
)
{
if
(
pStmt
->
last
!=
STMT_BIND
&&
pStmt
->
last
!=
STMT_BIND_COL
)
{
tscError
(
"0x%"
PRIx64
" add batch status error, last:%d"
,
pStmt
->
pSql
->
self
,
pStmt
->
last
);
return
TSDB_CODE_TSC_APP_ERROR
;
}
pStmt
->
last
=
STMT_ADD_BATCH
;
return
insertStmtAddBatch
(
pStmt
);
}
return
TSDB_CODE_COM_OPS_NOT_SUPPORT
;
}
...
...
@@ -1474,7 +1554,19 @@ int taos_stmt_reset(TAOS_STMT* stmt) {
int
taos_stmt_execute
(
TAOS_STMT
*
stmt
)
{
int
ret
=
0
;
STscStmt
*
pStmt
=
(
STscStmt
*
)
stmt
;
if
(
stmt
==
NULL
||
pStmt
->
pSql
==
NULL
||
pStmt
->
taos
==
NULL
)
{
terrno
=
TSDB_CODE_TSC_DISCONNECTED
;
return
TSDB_CODE_TSC_DISCONNECTED
;
}
if
(
pStmt
->
isInsert
)
{
if
(
pStmt
->
last
!=
STMT_ADD_BATCH
)
{
tscError
(
"0x%"
PRIx64
" exec status error, last:%d"
,
pStmt
->
pSql
->
self
,
pStmt
->
last
);
return
TSDB_CODE_TSC_APP_ERROR
;
}
pStmt
->
last
=
STMT_EXECUTE
;
if
(
pStmt
->
multiTbInsert
)
{
ret
=
insertBatchStmtExecute
(
pStmt
);
}
else
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录