Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Rattenking
TDengine
提交
562e62e9
T
TDengine
项目概览
Rattenking
/
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,发现更多精彩内容 >>
提交
562e62e9
编写于
8月 07, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-225] add check after killing query.
上级
24aa1a35
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
39 addition
and
35 deletion
+39
-35
src/client/inc/tscUtil.h
src/client/inc/tscUtil.h
+3
-0
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+1
-0
src/client/src/tscSql.c
src/client/src/tscSql.c
+17
-35
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+18
-0
未找到文件。
src/client/inc/tscUtil.h
浏览文件 @
562e62e9
...
...
@@ -270,6 +270,9 @@ void tscAsyncQuerySingleRowForNextVnode(void *param, TAOS_RES *tres, int numOfRo
void
tscTryQueryNextClause
(
SSqlObj
*
pSql
,
__async_cb_func_t
fp
);
int
tscSetMgmtEpSetFromCfg
(
const
char
*
first
,
const
char
*
second
);
bool
tscSetSqlOwner
(
SSqlObj
*
pSql
);
void
tscClearSqlOwner
(
SSqlObj
*
pSql
);
void
*
malloc_throw
(
size_t
size
);
void
*
calloc_throw
(
size_t
nmemb
,
size_t
size
);
char
*
strdup_throw
(
const
char
*
str
);
...
...
src/client/inc/tsclient.h
浏览文件 @
562e62e9
...
...
@@ -302,6 +302,7 @@ typedef struct STscObj {
typedef
struct
SSqlObj
{
void
*
signature
;
pthread_t
owner
;
// owner of sql object, by which it is executed
STscObj
*
pTscObj
;
void
*
pRpcCtx
;
void
(
*
fp
)();
...
...
src/client/src/tscSql.c
浏览文件 @
562e62e9
...
...
@@ -233,48 +233,21 @@ static void waitForRetrieveRsp(void *param, TAOS_RES *tres, int numOfRows) {
sem_post
(
&
pSql
->
rspSem
);
}
TAOS_RES
*
taos_query
(
TAOS
*
taos
,
const
char
*
sqlstr
)
{
TAOS_RES
*
taos_query
_c
(
TAOS
*
taos
,
const
char
*
sqlstr
,
uint32_t
sqlLen
)
{
STscObj
*
pObj
=
(
STscObj
*
)
taos
;
if
(
pObj
==
NULL
||
pObj
->
signature
!=
pObj
)
{
terrno
=
TSDB_CODE_TSC_DISCONNECTED
;
return
NULL
;
}
int32_t
sqlLen
=
strlen
(
sqlstr
);
if
(
sqlLen
>
tsMaxSQLStringLen
)
{
tscError
(
"sql string exceeds max length:%d"
,
tsMaxSQLStringLen
);
terrno
=
TSDB_CODE_TSC_INVALID_SQL
;
return
NULL
;
}
taosNotePrintTsc
(
sqlstr
);
SSqlObj
*
pSql
=
calloc
(
1
,
sizeof
(
SSqlObj
));
if
(
pSql
==
NULL
)
{
tscError
(
"failed to malloc sqlObj"
);
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
return
NULL
;
}
doAsyncQuery
(
pObj
,
pSql
,
waitForQueryRsp
,
taos
,
sqlstr
,
sqlLen
);
// wait for the callback function to post the semaphore
tsem_wait
(
&
pSql
->
rspSem
);
return
pSql
;
}
TAOS_RES
*
taos_query_c
(
TAOS
*
taos
,
const
char
*
sqlstr
,
uint32_t
sqlLen
)
{
STscObj
*
pObj
=
(
STscObj
*
)
taos
;
if
(
pObj
==
NULL
||
pObj
->
signature
!=
pObj
)
{
terrno
=
TSDB_CODE_TSC_DISCONNECTED
;
return
NULL
;
}
if
(
sqlLen
>
tsMaxSQLStringLen
)
{
tscError
(
"sql string exceeds max length:%d"
,
tsMaxSQLStringLen
);
terrno
=
TSDB_CODE_TSC_INVALID_SQL
;
return
NULL
;
}
SSqlObj
*
pSql
=
calloc
(
1
,
sizeof
(
SSqlObj
));
if
(
pSql
==
NULL
)
{
tscError
(
"failed to malloc sqlObj"
);
...
...
@@ -287,6 +260,11 @@ TAOS_RES* taos_query_c(TAOS *taos, const char *sqlstr, uint32_t sqlLen) {
tsem_wait
(
&
pSql
->
rspSem
);
return
pSql
;
}
TAOS_RES
*
taos_query
(
TAOS
*
taos
,
const
char
*
sqlstr
)
{
return
taos_query_c
(
taos
,
sqlstr
,
strlen
(
sqlstr
));
}
int
taos_result_precision
(
TAOS_RES
*
res
)
{
SSqlObj
*
pSql
=
(
SSqlObj
*
)
res
;
if
(
pSql
==
NULL
||
pSql
->
signature
!=
pSql
)
return
0
;
...
...
@@ -422,7 +400,10 @@ TAOS_ROW taos_fetch_row(TAOS_RES *res) {
pCmd
->
command
==
TSDB_SQL_INSERT
)
{
return
NULL
;
}
// set the sql object owner
tscSetSqlOwner
(
pSql
);
// current data set are exhausted, fetch more data from node
if
(
pRes
->
row
>=
pRes
->
numOfRows
&&
(
pRes
->
completed
!=
true
||
hasMoreVnodesToTry
(
pSql
)
||
hasMoreClauseToTry
(
pSql
))
&&
(
pCmd
->
command
==
TSDB_SQL_RETRIEVE
||
...
...
@@ -441,7 +422,10 @@ TAOS_ROW taos_fetch_row(TAOS_RES *res) {
sem_wait
(
&
pSql
->
rspSem
);
}
return
doSetResultRowData
(
pSql
,
true
);
void
*
data
=
doSetResultRowData
(
pSql
,
true
);
tscClearSqlOwner
(
pSql
);
return
data
;
}
int
taos_fetch_block
(
TAOS_RES
*
res
,
TAOS_ROW
*
rows
)
{
...
...
@@ -509,7 +493,7 @@ int taos_select_db(TAOS *taos, const char *db) {
}
// send free message to vnode to free qhandle and corresponding resources in vnode
static
bool
tsc
FreeQhandle
InVnode
(
SSqlObj
*
pSql
)
{
static
bool
tsc
KillQuery
InVnode
(
SSqlObj
*
pSql
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlRes
*
pRes
=
&
pSql
->
res
;
...
...
@@ -557,16 +541,14 @@ void taos_free_result(TAOS_RES *res) {
}
pQueryInfo
->
type
=
TSDB_QUERY_TYPE_FREE_RESOURCE
;
if
(
!
tsc
FreeQhandle
InVnode
(
pSql
))
{
if
(
!
tsc
KillQuery
InVnode
(
pSql
))
{
tscFreeSqlObj
(
pSql
);
tscDebug
(
"%p sqlObj is freed by app"
,
pSql
);
}
}
// todo should not be used in async query
int
taos_errno
(
TAOS_RES
*
tres
)
{
SSqlObj
*
pSql
=
(
SSqlObj
*
)
tres
;
if
(
pSql
==
NULL
||
pSql
->
signature
!=
pSql
)
{
return
terrno
;
}
...
...
src/client/src/tscUtil.c
浏览文件 @
562e62e9
...
...
@@ -2223,3 +2223,21 @@ int tscSetMgmtEpSetFromCfg(const char *first, const char *second) {
return
0
;
}
bool
tscSetSqlOwner
(
SSqlObj
*
pSql
)
{
SSqlRes
*
pRes
=
&
pSql
->
res
;
// set the sql object owner
uint64_t
threadId
=
taosGetPthreadId
();
if
(
atomic_val_compare_exchange_64
(
&
pSql
->
owner
,
0
,
threadId
)
!=
0
)
{
pRes
->
code
=
TSDB_CODE_QRY_IN_EXEC
;
return
false
;
}
return
true
;
}
void
tscClearSqlOwner
(
SSqlObj
*
pSql
)
{
assert
(
pSql
->
owner
!=
0
);
atomic_store_64
(
&
pSql
->
owner
,
0
);
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录