Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f79eeb30
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看板
提交
f79eeb30
编写于
4月 04, 2023
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: add stmt error handling
上级
d0a7e02a
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
75 addition
and
4 deletion
+75
-4
source/client/inc/clientLog.h
source/client/inc/clientLog.h
+1
-0
source/client/inc/clientStmt.h
source/client/inc/clientStmt.h
+4
-0
source/client/src/clientEnv.c
source/client/src/clientEnv.c
+1
-0
source/client/src/clientStmt.c
source/client/src/clientStmt.c
+19
-3
tests/script/api/batchprepare.c
tests/script/api/batchprepare.c
+50
-1
未找到文件。
source/client/inc/clientLog.h
浏览文件 @
f79eeb30
...
@@ -26,6 +26,7 @@ extern "C" {
...
@@ -26,6 +26,7 @@ extern "C" {
#define tscFatal(...) do { if (cDebugFlag & DEBUG_FATAL) { taosPrintLog("TSC FATAL ", DEBUG_FATAL, cDebugFlag, __VA_ARGS__); }} while(0)
#define tscFatal(...) do { if (cDebugFlag & DEBUG_FATAL) { taosPrintLog("TSC FATAL ", DEBUG_FATAL, cDebugFlag, __VA_ARGS__); }} while(0)
#define tscError(...) do { if (cDebugFlag & DEBUG_ERROR) { taosPrintLog("TSC ERROR ", DEBUG_ERROR, cDebugFlag, __VA_ARGS__); }} while(0)
#define tscError(...) do { if (cDebugFlag & DEBUG_ERROR) { taosPrintLog("TSC ERROR ", DEBUG_ERROR, cDebugFlag, __VA_ARGS__); }} while(0)
#define tscWarn(...) do { if (cDebugFlag & DEBUG_WARN) { taosPrintLog("TSC WARN ", DEBUG_WARN, cDebugFlag, __VA_ARGS__); }} while(0)
#define tscWarn(...) do { if (cDebugFlag & DEBUG_WARN) { taosPrintLog("TSC WARN ", DEBUG_WARN, cDebugFlag, __VA_ARGS__); }} while(0)
#define tscWarnL(...) do { if (cDebugFlag & DEBUG_WARN) { taosPrintLongString("TSC WARN ", DEBUG_WARN, cDebugFlag, __VA_ARGS__); }} while(0)
#define tscInfo(...) do { if (cDebugFlag & DEBUG_INFO) { taosPrintLog("TSC ", DEBUG_INFO, cDebugFlag, __VA_ARGS__); }} while(0)
#define tscInfo(...) do { if (cDebugFlag & DEBUG_INFO) { taosPrintLog("TSC ", DEBUG_INFO, cDebugFlag, __VA_ARGS__); }} while(0)
#define tscDebug(...) do { if (cDebugFlag & DEBUG_DEBUG) { taosPrintLog("TSC ", DEBUG_DEBUG, cDebugFlag, __VA_ARGS__); }} while(0)
#define tscDebug(...) do { if (cDebugFlag & DEBUG_DEBUG) { taosPrintLog("TSC ", DEBUG_DEBUG, cDebugFlag, __VA_ARGS__); }} while(0)
#define tscTrace(...) do { if (cDebugFlag & DEBUG_TRACE) { taosPrintLog("TSC ", DEBUG_TRACE, cDebugFlag, __VA_ARGS__); }} while(0)
#define tscTrace(...) do { if (cDebugFlag & DEBUG_TRACE) { taosPrintLog("TSC ", DEBUG_TRACE, cDebugFlag, __VA_ARGS__); }} while(0)
...
...
source/client/inc/clientStmt.h
浏览文件 @
f79eeb30
...
@@ -102,6 +102,7 @@ typedef struct STscStmt {
...
@@ -102,6 +102,7 @@ typedef struct STscStmt {
SStmtBindInfo
bInfo
;
SStmtBindInfo
bInfo
;
int64_t
reqid
;
int64_t
reqid
;
int32_t
errCode
;
}
STscStmt
;
}
STscStmt
;
extern
char
*
gStmtStatusStr
[];
extern
char
*
gStmtStatusStr
[];
...
@@ -121,6 +122,7 @@ extern char *gStmtStatusStr[];
...
@@ -121,6 +122,7 @@ extern char *gStmtStatusStr[];
int32_t _code = c; \
int32_t _code = c; \
if (_code != TSDB_CODE_SUCCESS) { \
if (_code != TSDB_CODE_SUCCESS) { \
terrno = _code; \
terrno = _code; \
pStmt->errCode = _code; \
return _code; \
return _code; \
} \
} \
} while (0)
} while (0)
...
@@ -129,6 +131,7 @@ extern char *gStmtStatusStr[];
...
@@ -129,6 +131,7 @@ extern char *gStmtStatusStr[];
int32_t _code = c; \
int32_t _code = c; \
if (_code != TSDB_CODE_SUCCESS) { \
if (_code != TSDB_CODE_SUCCESS) { \
terrno = _code; \
terrno = _code; \
pStmt->errCode = _code; \
} \
} \
return _code; \
return _code; \
} while (0)
} while (0)
...
@@ -137,6 +140,7 @@ extern char *gStmtStatusStr[];
...
@@ -137,6 +140,7 @@ extern char *gStmtStatusStr[];
code = c; \
code = c; \
if (code != TSDB_CODE_SUCCESS) { \
if (code != TSDB_CODE_SUCCESS) { \
terrno = code; \
terrno = code; \
pStmt->errCode = code; \
goto _return; \
goto _return; \
} \
} \
} while (0)
} while (0)
...
...
source/client/src/clientEnv.c
浏览文件 @
f79eeb30
...
@@ -103,6 +103,7 @@ static void deregisterRequest(SRequestObj *pRequest) {
...
@@ -103,6 +103,7 @@ static void deregisterRequest(SRequestObj *pRequest) {
if
(
duration
>=
SLOW_QUERY_INTERVAL
)
{
if
(
duration
>=
SLOW_QUERY_INTERVAL
)
{
atomic_add_fetch_64
((
int64_t
*
)
&
pActivity
->
numOfSlowQueries
,
1
);
atomic_add_fetch_64
((
int64_t
*
)
&
pActivity
->
numOfSlowQueries
,
1
);
tscWarnL
(
"slow query: %s, duration:%"
PRId64
,
pRequest
->
sqlstr
,
duration
);
}
}
releaseTscObj
(
pTscObj
->
id
);
releaseTscObj
(
pTscObj
->
id
);
...
...
source/client/src/clientStmt.c
浏览文件 @
f79eeb30
...
@@ -32,8 +32,14 @@ int32_t stmtSwitchStatus(STscStmt* pStmt, STMT_STATUS newStatus) {
...
@@ -32,8 +32,14 @@ int32_t stmtSwitchStatus(STscStmt* pStmt, STMT_STATUS newStatus) {
STMT_LOG_SEQ
(
newStatus
);
STMT_LOG_SEQ
(
newStatus
);
}
}
if
(
pStmt
->
errCode
&&
newStatus
!=
STMT_PREPARE
)
{
STMT_DLOG
(
"stmt already failed with err: %s"
,
tstrerror
(
pStmt
->
errCode
));
return
pStmt
->
errCode
;
}
switch
(
newStatus
)
{
switch
(
newStatus
)
{
case
STMT_PREPARE
:
case
STMT_PREPARE
:
pStmt
->
errCode
=
0
;
break
;
break
;
case
STMT_SETTBNAME
:
case
STMT_SETTBNAME
:
if
(
STMT_STATUS_EQ
(
INIT
)
||
STMT_STATUS_EQ
(
BIND
)
||
STMT_STATUS_EQ
(
BIND_COL
))
{
if
(
STMT_STATUS_EQ
(
INIT
)
||
STMT_STATUS_EQ
(
BIND
)
||
STMT_STATUS_EQ
(
BIND_COL
))
{
...
@@ -197,7 +203,10 @@ int32_t stmtGetExecInfo(TAOS_STMT* stmt, SHashObj** pVgHash, SHashObj** pBlockHa
...
@@ -197,7 +203,10 @@ int32_t stmtGetExecInfo(TAOS_STMT* stmt, SHashObj** pVgHash, SHashObj** pBlockHa
STscStmt
*
pStmt
=
(
STscStmt
*
)
stmt
;
STscStmt
*
pStmt
=
(
STscStmt
*
)
stmt
;
*
pVgHash
=
pStmt
->
sql
.
pVgHash
;
*
pVgHash
=
pStmt
->
sql
.
pVgHash
;
pStmt
->
sql
.
pVgHash
=
NULL
;
*
pBlockHash
=
pStmt
->
exec
.
pBlockHash
;
*
pBlockHash
=
pStmt
->
exec
.
pBlockHash
;
pStmt
->
exec
.
pBlockHash
=
NULL
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -325,6 +334,8 @@ int32_t stmtCleanExecInfo(STscStmt* pStmt, bool keepTable, bool deepClean) {
...
@@ -325,6 +334,8 @@ int32_t stmtCleanExecInfo(STscStmt* pStmt, bool keepTable, bool deepClean) {
}
}
int32_t
stmtCleanSQLInfo
(
STscStmt
*
pStmt
)
{
int32_t
stmtCleanSQLInfo
(
STscStmt
*
pStmt
)
{
STMT_DLOG_E
(
"start to free SQL info"
);
taosMemoryFree
(
pStmt
->
sql
.
queryRes
.
fields
);
taosMemoryFree
(
pStmt
->
sql
.
queryRes
.
fields
);
taosMemoryFree
(
pStmt
->
sql
.
queryRes
.
userFields
);
taosMemoryFree
(
pStmt
->
sql
.
queryRes
.
userFields
);
taosMemoryFree
(
pStmt
->
sql
.
sqlStr
);
taosMemoryFree
(
pStmt
->
sql
.
sqlStr
);
...
@@ -351,6 +362,8 @@ int32_t stmtCleanSQLInfo(STscStmt* pStmt) {
...
@@ -351,6 +362,8 @@ int32_t stmtCleanSQLInfo(STscStmt* pStmt) {
memset
(
&
pStmt
->
sql
,
0
,
sizeof
(
pStmt
->
sql
));
memset
(
&
pStmt
->
sql
,
0
,
sizeof
(
pStmt
->
sql
));
STMT_DLOG_E
(
"end to free SQL info"
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -441,11 +454,10 @@ int32_t stmtGetFromCache(STscStmt* pStmt) {
...
@@ -441,11 +454,10 @@ int32_t stmtGetFromCache(STscStmt* pStmt) {
.
mgmtEps
=
getEpSet_s
(
&
pStmt
->
taos
->
pAppInfo
->
mgmtEp
)};
.
mgmtEps
=
getEpSet_s
(
&
pStmt
->
taos
->
pAppInfo
->
mgmtEp
)};
int32_t
code
=
catalogGetTableMeta
(
pStmt
->
pCatalog
,
&
conn
,
&
pStmt
->
bInfo
.
sname
,
&
pTableMeta
);
int32_t
code
=
catalogGetTableMeta
(
pStmt
->
pCatalog
,
&
conn
,
&
pStmt
->
bInfo
.
sname
,
&
pTableMeta
);
if
(
TSDB_CODE_PAR_TABLE_NOT_EXIST
==
code
)
{
if
(
TSDB_CODE_PAR_TABLE_NOT_EXIST
==
code
)
{
STMT_ERR_RET
(
stmtCleanBindInfo
(
pStmt
));
tscDebug
(
"tb %s not exist"
,
pStmt
->
bInfo
.
tbFName
);
tscDebug
(
"tb %s not exist"
,
pStmt
->
bInfo
.
tbFName
);
stmtCleanBindInfo
(
pStmt
);
return
TSDB_CODE_SUCCESS
;
STMT_ERR_RET
(
code
)
;
}
}
STMT_ERR_RET
(
code
);
STMT_ERR_RET
(
code
);
...
@@ -922,9 +934,13 @@ _return:
...
@@ -922,9 +934,13 @@ _return:
int
stmtClose
(
TAOS_STMT
*
stmt
)
{
int
stmtClose
(
TAOS_STMT
*
stmt
)
{
STscStmt
*
pStmt
=
(
STscStmt
*
)
stmt
;
STscStmt
*
pStmt
=
(
STscStmt
*
)
stmt
;
STMT_DLOG_E
(
"start to free stmt"
);
stmtCleanSQLInfo
(
pStmt
);
stmtCleanSQLInfo
(
pStmt
);
taosMemoryFree
(
stmt
);
taosMemoryFree
(
stmt
);
STMT_DLOG_E
(
"stmt freed"
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
...
tests/script/api/batchprepare.c
浏览文件 @
f79eeb30
...
@@ -122,9 +122,11 @@ int insertAUTOTest2(TAOS_STMT *stmt, TAOS *taos);
...
@@ -122,9 +122,11 @@ int insertAUTOTest2(TAOS_STMT *stmt, TAOS *taos);
int
insertAUTOTest3
(
TAOS_STMT
*
stmt
,
TAOS
*
taos
);
int
insertAUTOTest3
(
TAOS_STMT
*
stmt
,
TAOS
*
taos
);
int
queryColumnTest
(
TAOS_STMT
*
stmt
,
TAOS
*
taos
);
int
queryColumnTest
(
TAOS_STMT
*
stmt
,
TAOS
*
taos
);
int
queryMiscTest
(
TAOS_STMT
*
stmt
,
TAOS
*
taos
);
int
queryMiscTest
(
TAOS_STMT
*
stmt
,
TAOS
*
taos
);
int
insertNonExistsTb
(
TAOS_STMT
*
stmt
,
TAOS
*
taos
);
enum
{
enum
{
TTYPE_INSERT
=
1
,
TTYPE_INSERT
=
1
,
TTYPE_INSERT_NG
,
TTYPE_QUERY
,
TTYPE_QUERY
,
};
};
...
@@ -187,6 +189,8 @@ CaseCfg gCase[] = {
...
@@ -187,6 +189,8 @@ CaseCfg gCase[] = {
{
"query:SUBT-COLUMN"
,
tListLen
(
fullColList
),
fullColList
,
TTYPE_QUERY
,
0
,
false
,
false
,
queryColumnTest
,
10
,
10
,
1
,
3
,
0
,
0
,
1
,
2
},
{
"query:SUBT-COLUMN"
,
tListLen
(
fullColList
),
fullColList
,
TTYPE_QUERY
,
0
,
false
,
false
,
queryColumnTest
,
10
,
10
,
1
,
3
,
0
,
0
,
1
,
2
},
{
"query:SUBT-MISC"
,
tListLen
(
fullColList
),
fullColList
,
TTYPE_QUERY
,
0
,
false
,
false
,
queryMiscTest
,
10
,
10
,
1
,
3
,
0
,
0
,
1
,
2
},
{
"query:SUBT-MISC"
,
tListLen
(
fullColList
),
fullColList
,
TTYPE_QUERY
,
0
,
false
,
false
,
queryMiscTest
,
10
,
10
,
1
,
3
,
0
,
0
,
1
,
2
},
{
"query:NG-TBNEXISTS"
,
tListLen
(
fullColList
),
fullColList
,
TTYPE_INSERT_NG
,
0
,
false
,
false
,
insertNonExistsTb
,
10
,
10
,
1
,
3
,
0
,
0
,
1
,
-
1
},
// {"query:SUBT-COLUMN", tListLen(fullColList), fullColList, TTYPE_QUERY, 0, false, false, queryColumnTest, 1, 10, 1, 1, 0, 0, 1, 2},
// {"query:SUBT-COLUMN", tListLen(fullColList), fullColList, TTYPE_QUERY, 0, false, false, queryColumnTest, 1, 10, 1, 1, 0, 0, 1, 2},
// {"query:SUBT-MISC", tListLen(fullColList), fullColList, TTYPE_QUERY, 0, false, false, queryMiscTest, 2, 10, 1, 1, 0, 0, 1, 2},
// {"query:SUBT-MISC", tListLen(fullColList), fullColList, TTYPE_QUERY, 0, false, false, queryMiscTest, 2, 10, 1, 1, 0, 0, 1, 2},
...
@@ -250,7 +254,7 @@ CaseCtrl gCaseCtrl = {
...
@@ -250,7 +254,7 @@ CaseCtrl gCaseCtrl = {
.funcIdxList = NULL,
.funcIdxList = NULL,
.checkParamNum = false,
.checkParamNum = false,
.runTimes = 0,
.runTimes = 0,
.caseIdx = 2
4
,
.caseIdx = 2
6
,
.caseNum = 1,
.caseNum = 1,
.caseRunIdx = -1,
.caseRunIdx = -1,
.caseRunNum = -1,
.caseRunNum = -1,
...
@@ -2191,6 +2195,47 @@ int queryMiscTest(TAOS_STMT *stmt, TAOS *taos) {
...
@@ -2191,6 +2195,47 @@ int queryMiscTest(TAOS_STMT *stmt, TAOS *taos) {
}
}
int
insertNonExistsTb
(
TAOS_STMT
*
stmt
,
TAOS
*
taos
)
{
BindData
data
=
{
0
};
prepareInsertData
(
&
data
);
int
code
=
taos_stmt_prepare
(
stmt
,
data
.
sql
,
0
);
if
(
code
!=
0
){
printf
(
"!!!failed to execute taos_stmt_prepare. error:%s
\n
"
,
taos_stmt_errstr
(
stmt
));
exit
(
1
);
}
bpCheckIsInsert
(
stmt
,
1
);
char
*
buf
=
"tbnexist"
;
code
=
bpSetTableNameTags
(
&
data
,
0
,
buf
,
stmt
);
if
(
code
==
0
){
printf
(
"!!!taos_stmt_set_tbname expected error not occurred
\n
"
);
exit
(
1
);
}
if
(
0
==
taos_stmt_bind_param_batch
(
stmt
,
data
.
pBind
))
{
printf
(
"!!!taos_stmt_bind_param_batch expected error not occurred
\n
"
);
exit
(
1
);
}
if
(
0
==
taos_stmt_add_batch
(
stmt
))
{
printf
(
"!!!taos_stmt_add_batch expected error not occurred
\n
"
);
exit
(
1
);
}
if
(
0
==
taos_stmt_execute
(
stmt
))
{
printf
(
"!!!taos_stmt_execute expected error not occurred
\n
"
);
exit
(
1
);
}
destroyData
(
&
data
);
return
0
;
}
int
errorSQLTest1
(
TAOS_STMT
*
stmt
,
TAOS
*
taos
)
{
int
errorSQLTest1
(
TAOS_STMT
*
stmt
,
TAOS
*
taos
)
{
BindData
data
=
{
0
};
BindData
data
=
{
0
};
...
@@ -2213,6 +2258,10 @@ int errorSQLTest1(TAOS_STMT *stmt, TAOS *taos) {
...
@@ -2213,6 +2258,10 @@ int errorSQLTest1(TAOS_STMT *stmt, TAOS *taos) {
}
}
void
prepareCheckResultImpl
(
TAOS
*
taos
,
char
*
tname
,
bool
printr
,
int
expected
,
bool
silent
)
{
void
prepareCheckResultImpl
(
TAOS
*
taos
,
char
*
tname
,
bool
printr
,
int
expected
,
bool
silent
)
{
if
(
TTYPE_INSERT_NG
==
gCurCase
->
testType
)
{
return
;
}
char
sql
[
255
]
=
"SELECT * FROM "
;
char
sql
[
255
]
=
"SELECT * FROM "
;
int32_t
rows
=
0
;
int32_t
rows
=
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录