Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
2779fe56
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看板
提交
2779fe56
编写于
11月 02, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: fix auto create table issue in stmt
上级
ecfcf705
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
42 addition
and
8 deletion
+42
-8
source/client/inc/clientStmt.h
source/client/inc/clientStmt.h
+13
-0
source/client/src/clientStmt.c
source/client/src/clientStmt.c
+29
-8
未找到文件。
source/client/inc/clientStmt.h
浏览文件 @
2779fe56
...
...
@@ -39,6 +39,7 @@ typedef enum {
STMT_BIND_COL
,
STMT_ADD_BATCH
,
STMT_EXECUTE
,
STMT_MAX
,
}
STMT_STATUS
;
typedef
struct
SStmtTableCache
{
...
...
@@ -94,12 +95,18 @@ typedef struct STscStmt {
STscObj
*
taos
;
SCatalog
*
pCatalog
;
int32_t
affectedRows
;
uint32_t
seqId
;
uint32_t
seqIds
[
STMT_MAX
];
SStmtSQLInfo
sql
;
SStmtExecInfo
exec
;
SStmtBindInfo
bInfo
;
}
STscStmt
;
extern
char
*
gStmtStatusStr
[];
#define STMT_LOG_SEQ(n) do { (pStmt)->seqId++; (pStmt)->seqIds[n]++; STMT_DLOG("the %dth:%d %s", (pStmt)->seqIds[n], (pStmt)->seqId, gStmtStatusStr[n]); } while (0)
#define STMT_STATUS_NE(S) (pStmt->sql.status != STMT_##S)
#define STMT_STATUS_EQ(S) (pStmt->sql.status == STMT_##S)
...
...
@@ -128,6 +135,12 @@ typedef struct STscStmt {
} \
} while (0)
#define STMT_ELOG(param, ...) qError("stmt:%p " param, pStmt, __VA_ARGS__)
#define STMT_DLOG(param, ...) qDebug("stmt:%p " param, pStmt, __VA_ARGS__)
#define STMT_ELOG_E(param) qError("stmt:%p " param, pStmt)
#define STMT_DLOG_E(param) qDebug("stmt:%p " param, pStmt)
TAOS_STMT
*
stmtInit
(
STscObj
*
taos
);
int
stmtClose
(
TAOS_STMT
*
stmt
);
int
stmtExec
(
TAOS_STMT
*
stmt
);
...
...
source/client/src/clientStmt.c
浏览文件 @
2779fe56
...
...
@@ -5,6 +5,8 @@
#include "clientStmt.h"
char
*
gStmtStatusStr
[]
=
{
"unknown"
,
"init"
,
"prepare"
,
"settbname"
,
"settags"
,
"fetchFields"
,
"bind"
,
"bindCol"
,
"addBatch"
,
"exec"
};
static
int32_t
stmtCreateRequest
(
STscStmt
*
pStmt
)
{
int32_t
code
=
0
;
...
...
@@ -21,6 +23,10 @@ static int32_t stmtCreateRequest(STscStmt* pStmt) {
int32_t
stmtSwitchStatus
(
STscStmt
*
pStmt
,
STMT_STATUS
newStatus
)
{
int32_t
code
=
0
;
if
(
newStatus
>=
STMT_INIT
&&
newStatus
<
STMT_MAX
)
{
STMT_LOG_SEQ
(
newStatus
);
}
switch
(
newStatus
)
{
case
STMT_PREPARE
:
break
;
...
...
@@ -528,13 +534,17 @@ TAOS_STMT* stmtInit(STscObj* taos) {
pStmt
->
bInfo
.
needParse
=
true
;
pStmt
->
sql
.
status
=
STMT_INIT
;
STMT_LOG_SEQ
(
STMT_INIT
);
tscDebug
(
"stmt:%p initialized"
,
pStmt
);
return
pStmt
;
}
int
stmtPrepare
(
TAOS_STMT
*
stmt
,
const
char
*
sql
,
unsigned
long
length
)
{
STscStmt
*
pStmt
=
(
STscStmt
*
)
stmt
;
tscDebug
(
"stmt
start to prepare"
);
STMT_DLOG_E
(
"
start to prepare"
);
if
(
pStmt
->
sql
.
status
>=
STMT_PREPARE
)
{
STMT_ERR_RET
(
stmtResetStmt
(
pStmt
));
...
...
@@ -555,7 +565,7 @@ int stmtPrepare(TAOS_STMT* stmt, const char* sql, unsigned long length) {
int
stmtSetTbName
(
TAOS_STMT
*
stmt
,
const
char
*
tbName
)
{
STscStmt
*
pStmt
=
(
STscStmt
*
)
stmt
;
tscDebug
(
"stmt
start to set tbName: %s"
,
tbName
);
STMT_DLOG
(
"
start to set tbName: %s"
,
tbName
);
STMT_ERR_RET
(
stmtSwitchStatus
(
pStmt
,
STMT_SETTBNAME
));
...
...
@@ -587,7 +597,7 @@ int stmtSetTbName(TAOS_STMT* stmt, const char* tbName) {
int
stmtSetTbTags
(
TAOS_STMT
*
stmt
,
TAOS_MULTI_BIND
*
tags
)
{
STscStmt
*
pStmt
=
(
STscStmt
*
)
stmt
;
tscDebug
(
"stmt
start to set tbTags"
);
STMT_DLOG_E
(
"
start to set tbTags"
);
STMT_ERR_RET
(
stmtSwitchStatus
(
pStmt
,
STMT_SETTAGS
));
...
...
@@ -649,7 +659,7 @@ int stmtFetchColFields(STscStmt* pStmt, int32_t* fieldNum, TAOS_FIELD_E** fields
int
stmtBindBatch
(
TAOS_STMT
*
stmt
,
TAOS_MULTI_BIND
*
bind
,
int32_t
colIdx
)
{
STscStmt
*
pStmt
=
(
STscStmt
*
)
stmt
;
tscDebug
(
"start to bind stmt data, colIdx: %d"
,
colIdx
);
STMT_DLOG
(
"start to bind stmt data, colIdx: %d"
,
colIdx
);
STMT_ERR_RET
(
stmtSwitchStatus
(
pStmt
,
STMT_BIND
));
...
...
@@ -743,7 +753,7 @@ int stmtBindBatch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind, int32_t colIdx) {
int
stmtAddBatch
(
TAOS_STMT
*
stmt
)
{
STscStmt
*
pStmt
=
(
STscStmt
*
)
stmt
;
tscDebug
(
"stmt
start to add batch"
);
STMT_DLOG_E
(
"
start to add batch"
);
STMT_ERR_RET
(
stmtSwitchStatus
(
pStmt
,
STMT_ADD_BATCH
));
...
...
@@ -756,8 +766,7 @@ int stmtUpdateTableUid(STscStmt* pStmt, SSubmitRsp* pRsp) {
tscDebug
(
"stmt start to update tbUid, blockNum: %d"
,
pRsp
->
nBlocks
);
if
(
pRsp
->
nBlocks
<=
0
)
{
tscError
(
"invalid submit resp block number %d"
,
pRsp
->
nBlocks
);
STMT_ERR_RET
(
TSDB_CODE_TSC_APP_ERROR
);
return
TSDB_CODE_SUCCESS
;
}
size_t
keyLen
=
0
;
...
...
@@ -810,7 +819,7 @@ int stmtExec(TAOS_STMT* stmt) {
SSubmitRsp
*
pRsp
=
NULL
;
bool
autoCreateTbl
=
pStmt
->
exec
.
autoCreateTbl
;
tscDebug
(
"stmt
start to exec"
);
STMT_DLOG_E
(
"
start to exec"
);
STMT_ERR_RET
(
stmtSwitchStatus
(
pStmt
,
STMT_EXECUTE
));
...
...
@@ -885,6 +894,8 @@ int stmtAffectedRowsOnce(TAOS_STMT* stmt) { return ((STscStmt*)stmt)->exec.affec
int
stmtIsInsert
(
TAOS_STMT
*
stmt
,
int
*
insert
)
{
STscStmt
*
pStmt
=
(
STscStmt
*
)
stmt
;
STMT_DLOG_E
(
"start is insert"
);
if
(
pStmt
->
sql
.
type
)
{
*
insert
=
(
STMT_TYPE_INSERT
==
pStmt
->
sql
.
type
||
STMT_TYPE_MULTI_INSERT
==
pStmt
->
sql
.
type
);
}
else
{
...
...
@@ -897,6 +908,8 @@ int stmtIsInsert(TAOS_STMT* stmt, int* insert) {
int
stmtGetTagFields
(
TAOS_STMT
*
stmt
,
int
*
nums
,
TAOS_FIELD_E
**
fields
)
{
STscStmt
*
pStmt
=
(
STscStmt
*
)
stmt
;
STMT_DLOG_E
(
"start to get tag fields"
);
if
(
STMT_TYPE_QUERY
==
pStmt
->
sql
.
type
)
{
STMT_RET
(
TSDB_CODE_TSC_STMT_API_ERROR
);
}
...
...
@@ -927,6 +940,8 @@ int stmtGetTagFields(TAOS_STMT* stmt, int* nums, TAOS_FIELD_E** fields) {
int
stmtGetColFields
(
TAOS_STMT
*
stmt
,
int
*
nums
,
TAOS_FIELD_E
**
fields
)
{
STscStmt
*
pStmt
=
(
STscStmt
*
)
stmt
;
STMT_DLOG_E
(
"start to get col fields"
);
if
(
STMT_TYPE_QUERY
==
pStmt
->
sql
.
type
)
{
STMT_RET
(
TSDB_CODE_TSC_STMT_API_ERROR
);
}
...
...
@@ -957,6 +972,8 @@ int stmtGetColFields(TAOS_STMT* stmt, int* nums, TAOS_FIELD_E** fields) {
int
stmtGetParamNum
(
TAOS_STMT
*
stmt
,
int
*
nums
)
{
STscStmt
*
pStmt
=
(
STscStmt
*
)
stmt
;
STMT_DLOG_E
(
"start to get param num"
);
STMT_ERR_RET
(
stmtSwitchStatus
(
pStmt
,
STMT_FETCH_FIELDS
));
if
(
pStmt
->
bInfo
.
needParse
&&
pStmt
->
sql
.
runTimes
&&
pStmt
->
sql
.
type
>
0
&&
...
...
@@ -986,6 +1003,8 @@ int stmtGetParamNum(TAOS_STMT* stmt, int* nums) {
int
stmtGetParam
(
TAOS_STMT
*
stmt
,
int
idx
,
int
*
type
,
int
*
bytes
)
{
STscStmt
*
pStmt
=
(
STscStmt
*
)
stmt
;
STMT_DLOG_E
(
"start to get param"
);
if
(
STMT_TYPE_QUERY
==
pStmt
->
sql
.
type
)
{
STMT_RET
(
TSDB_CODE_TSC_STMT_API_ERROR
);
}
...
...
@@ -1028,6 +1047,8 @@ int stmtGetParam(TAOS_STMT* stmt, int idx, int* type, int* bytes) {
TAOS_RES
*
stmtUseResult
(
TAOS_STMT
*
stmt
)
{
STscStmt
*
pStmt
=
(
STscStmt
*
)
stmt
;
STMT_DLOG_E
(
"start to use result"
);
if
(
STMT_TYPE_QUERY
!=
pStmt
->
sql
.
type
)
{
tscError
(
"useResult only for query statement"
);
return
NULL
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录