Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
b6786bc6
T
TDengine
项目概览
慢慢CG
/
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看板
提交
b6786bc6
编写于
10月 14, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-1637]
上级
d838bacd
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
88 addition
and
65 deletion
+88
-65
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+9
-8
src/client/src/tscAsync.c
src/client/src/tscAsync.c
+1
-1
src/client/src/tscProfile.c
src/client/src/tscProfile.c
+6
-4
src/client/src/tscServer.c
src/client/src/tscServer.c
+0
-39
src/client/src/tscSql.c
src/client/src/tscSql.c
+55
-7
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+15
-3
src/kit/shell/inc/shell.h
src/kit/shell/inc/shell.h
+1
-0
src/kit/shell/src/shellEngine.c
src/kit/shell/src/shellEngine.c
+1
-3
未找到文件。
src/client/inc/tsclient.h
浏览文件 @
b6786bc6
...
...
@@ -80,6 +80,8 @@ enum {
DATA_FROM_DATA_FILE
=
2
,
};
typedef
void
(
*
__async_cb_func_t
)(
void
*
param
,
TAOS_RES
*
tres
,
int32_t
numOfRows
);
typedef
struct
STableComInfo
{
uint8_t
numOfTags
;
uint8_t
precision
;
...
...
@@ -226,7 +228,7 @@ typedef struct STableDataBlocks {
typedef
struct
SQueryInfo
{
int16_t
command
;
// the command may be different for each subclause, so keep it seperately.
uint32_t
type
;
// query/insert type
// TODO refactor
STimeWindow
window
;
// query time window
SInterval
interval
;
...
...
@@ -440,19 +442,20 @@ void tscPartiallyFreeSqlObj(SSqlObj *pSql);
* @param pObj
*/
void
tscFreeSqlObj
(
SSqlObj
*
pSql
);
void
tscFreeSqlObjInCache
(
void
*
pSql
);
void
tscFreeRegisteredSqlObj
(
void
*
pSql
);
void
tscCloseTscObj
(
STscObj
*
pObj
);
// todo move to taos? or create a new file: taos_internal.h
TAOS
*
taos_connect_a
(
char
*
ip
,
char
*
user
,
char
*
pass
,
char
*
db
,
uint16_t
port
,
void
(
*
fp
)(
void
*
,
TAOS_RES
*
,
int
),
void
*
param
,
void
**
taos
);
void
waitForQueryRsp
(
void
*
param
,
TAOS_RES
*
tres
,
int
code
)
;
TAOS_RES
*
taos_query_h
(
TAOS
*
taos
,
const
char
*
sqlstr
,
TAOS_RES
**
res
)
;
void
doAsyncQuery
(
STscObj
*
pObj
,
SSqlObj
*
pSql
,
void
(
*
fp
)(),
void
*
param
,
const
char
*
sqlstr
,
size_t
sqlLen
);
void
waitForQueryRsp
(
void
*
param
,
TAOS_RES
*
tres
,
int
code
);
void
doAsyncQuery
(
STscObj
*
pObj
,
SSqlObj
*
pSql
,
__async_cb_func_t
fp
,
void
*
param
,
const
char
*
sqlstr
,
size_t
sqlLen
);
void
tscProcessMultiVnodesImportFromFile
(
SSqlObj
*
pSql
);
void
tscKillSTableQuery
(
SSqlObj
*
pSql
);
void
tscInitResObjForLocalQuery
(
SSqlObj
*
pObj
,
int32_t
numOfRes
,
int32_t
rowLen
);
bool
tscIsUpdateQuery
(
SSqlObj
*
pSql
);
bool
tscHasReachLimitation
(
SQueryInfo
*
pQueryInfo
,
SSqlRes
*
pRes
);
...
...
@@ -517,8 +520,6 @@ extern SRpcCorEpSet tscMgmtEpSet;
extern
int
(
*
tscBuildMsg
[
TSDB_SQL_MAX
])(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
);
typedef
void
(
*
__async_cb_func_t
)(
void
*
param
,
TAOS_RES
*
tres
,
int
numOfRows
);
int32_t
tscCompareTidTags
(
const
void
*
p1
,
const
void
*
p2
);
void
tscBuildVgroupTableInfo
(
SSqlObj
*
pSql
,
STableMetaInfo
*
pTableMetaInfo
,
SArray
*
tables
);
...
...
src/client/src/tscAsync.c
浏览文件 @
b6786bc6
...
...
@@ -40,7 +40,7 @@ static void tscProcessAsyncRetrieveImpl(void *param, TAOS_RES *tres, int numOfRo
static
void
tscAsyncFetchRowsProxy
(
void
*
param
,
TAOS_RES
*
tres
,
int
numOfRows
);
static
void
tscAsyncFetchSingleRowProxy
(
void
*
param
,
TAOS_RES
*
tres
,
int
numOfRows
);
void
doAsyncQuery
(
STscObj
*
pObj
,
SSqlObj
*
pSql
,
void
(
*
fp
)()
,
void
*
param
,
const
char
*
sqlstr
,
size_t
sqlLen
)
{
void
doAsyncQuery
(
STscObj
*
pObj
,
SSqlObj
*
pSql
,
__async_cb_func_t
fp
,
void
*
param
,
const
char
*
sqlstr
,
size_t
sqlLen
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pSql
->
signature
=
pSql
;
...
...
src/client/src/tscProfile.c
浏览文件 @
b6786bc6
...
...
@@ -151,10 +151,12 @@ void tscKillQuery(STscObj *pObj, uint32_t killId) {
pthread_mutex_unlock
(
&
pObj
->
mutex
);
if
(
pSql
==
NULL
)
return
;
tscDebug
(
"%p query is killed, queryId:%d"
,
pSql
,
killId
);
taos_stop_query
(
pSql
);
if
(
pSql
==
NULL
)
{
tscError
(
"failed to kill query, id:%d, it may have completed/terminated"
,
killId
);
}
else
{
tscDebug
(
"%p query is killed, queryId:%d"
,
pSql
,
killId
);
taos_stop_query
(
pSql
);
}
}
void
tscAddIntoStreamList
(
SSqlStream
*
pStream
)
{
...
...
src/client/src/tscServer.c
浏览文件 @
b6786bc6
...
...
@@ -467,45 +467,6 @@ int tscProcessSql(SSqlObj *pSql) {
return
doProcessSql
(
pSql
);
}
void
tscKillSTableQuery
(
SSqlObj
*
pSql
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
if
(
!
tscIsTwoStageSTableQuery
(
pQueryInfo
,
0
))
{
return
;
}
// set the master sqlObj flag to cancel query
pSql
->
res
.
code
=
TSDB_CODE_TSC_QUERY_CANCELLED
;
for
(
int
i
=
0
;
i
<
pSql
->
subState
.
numOfSub
;
++
i
)
{
// NOTE: pSub may have been released already here
SSqlObj
*
pSub
=
pSql
->
pSubs
[
i
];
if
(
pSub
==
NULL
)
{
continue
;
}
void
**
p
=
taosCacheAcquireByKey
(
tscObjCache
,
&
pSub
,
sizeof
(
TSDB_CACHE_PTR_TYPE
));
if
(
p
==
NULL
)
{
continue
;
}
SSqlObj
*
pSubObj
=
(
SSqlObj
*
)
(
*
p
);
assert
(
pSubObj
->
self
==
(
SSqlObj
**
)
p
);
pSubObj
->
res
.
code
=
TSDB_CODE_TSC_QUERY_CANCELLED
;
if
(
pSubObj
->
pRpcCtx
!=
NULL
)
{
rpcCancelRequest
(
pSubObj
->
pRpcCtx
);
pSubObj
->
pRpcCtx
=
NULL
;
}
// tscQueueAsyncRes(pSubObj); // async res? not other functions?
taosCacheRelease
(
tscObjCache
,
(
void
**
)
&
p
,
false
);
}
tscDebug
(
"%p super table query cancelled"
,
pSql
);
}
int
tscBuildFetchMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
SRetrieveTableMsg
*
pRetrieveMsg
=
(
SRetrieveTableMsg
*
)
pSql
->
cmd
.
payload
;
pRetrieveMsg
->
qhandle
=
htobe64
(
pSql
->
res
.
qhandle
);
...
...
src/client/src/tscSql.c
浏览文件 @
b6786bc6
...
...
@@ -307,7 +307,7 @@ static void waitForRetrieveRsp(void *param, TAOS_RES *tres, int numOfRows) {
tsem_post
(
&
pSql
->
rspSem
);
}
TAOS_RES
*
taos_query_c
(
TAOS
*
taos
,
const
char
*
sqlstr
,
uint32_t
sqlLen
)
{
TAOS_RES
*
taos_query_c
(
TAOS
*
taos
,
const
char
*
sqlstr
,
uint32_t
sqlLen
,
TAOS_RES
**
res
)
{
STscObj
*
pObj
=
(
STscObj
*
)
taos
;
if
(
pObj
==
NULL
||
pObj
->
signature
!=
pObj
)
{
terrno
=
TSDB_CODE_TSC_DISCONNECTED
;
...
...
@@ -332,12 +332,20 @@ TAOS_RES* taos_query_c(TAOS *taos, const char *sqlstr, uint32_t sqlLen) {
tsem_init
(
&
pSql
->
rspSem
,
0
,
0
);
doAsyncQuery
(
pObj
,
pSql
,
waitForQueryRsp
,
taos
,
sqlstr
,
sqlLen
);
if
(
res
!=
NULL
)
{
*
res
=
pSql
;
}
tsem_wait
(
&
pSql
->
rspSem
);
return
pSql
;
}
TAOS_RES
*
taos_query
(
TAOS
*
taos
,
const
char
*
sqlstr
)
{
return
taos_query_c
(
taos
,
sqlstr
,
(
uint32_t
)
strlen
(
sqlstr
));
return
taos_query_c
(
taos
,
sqlstr
,
(
uint32_t
)
strlen
(
sqlstr
),
NULL
);
}
TAOS_RES
*
taos_query_h
(
TAOS
*
taos
,
const
char
*
sqlstr
,
TAOS_RES
**
res
)
{
return
taos_query_c
(
taos
,
sqlstr
,
(
uint32_t
)
strlen
(
sqlstr
),
res
);
}
int
taos_result_precision
(
TAOS_RES
*
res
)
{
...
...
@@ -689,6 +697,45 @@ int* taos_fetch_lengths(TAOS_RES *res) {
char
*
taos_get_client_info
()
{
return
version
;
}
static
void
tscKillSTableQuery
(
SSqlObj
*
pSql
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
if
(
!
tscIsTwoStageSTableQuery
(
pQueryInfo
,
0
))
{
return
;
}
// set the master sqlObj flag to cancel query
pSql
->
res
.
code
=
TSDB_CODE_TSC_QUERY_CANCELLED
;
for
(
int
i
=
0
;
i
<
pSql
->
subState
.
numOfSub
;
++
i
)
{
// NOTE: pSub may have been released already here
SSqlObj
*
pSub
=
pSql
->
pSubs
[
i
];
if
(
pSub
==
NULL
)
{
continue
;
}
void
**
p
=
taosCacheAcquireByKey
(
tscObjCache
,
&
pSub
,
sizeof
(
TSDB_CACHE_PTR_TYPE
));
if
(
p
==
NULL
)
{
continue
;
}
SSqlObj
*
pSubObj
=
(
SSqlObj
*
)
(
*
p
);
assert
(
pSubObj
->
self
==
(
SSqlObj
**
)
p
);
pSubObj
->
res
.
code
=
TSDB_CODE_TSC_QUERY_CANCELLED
;
if
(
pSubObj
->
pRpcCtx
!=
NULL
)
{
rpcCancelRequest
(
pSubObj
->
pRpcCtx
);
pSubObj
->
pRpcCtx
=
NULL
;
}
tscQueueAsyncRes
(
pSubObj
);
taosCacheRelease
(
tscObjCache
,
(
void
**
)
&
p
,
false
);
}
tscDebug
(
"%p super table query cancelled"
,
pSql
);
}
void
taos_stop_query
(
TAOS_RES
*
res
)
{
SSqlObj
*
pSql
=
(
SSqlObj
*
)
res
;
if
(
pSql
==
NULL
||
pSql
->
signature
!=
pSql
)
{
...
...
@@ -698,19 +745,20 @@ void taos_stop_query(TAOS_RES *res) {
tscDebug
(
"%p start to cancel query"
,
res
);
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
// TODO there are multi-thread problem.
// It may have been released by the other thread already.
// The ref count may fix this problem.
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
// set the error code for master pSqlObj firstly
pSql
->
res
.
code
=
TSDB_CODE_TSC_QUERY_CANCELLED
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
if
(
tscIsTwoStageSTableQuery
(
pQueryInfo
,
0
))
{
assert
(
pSql
->
pRpcCtx
==
NULL
);
tscKillSTableQuery
(
pSql
);
}
else
{
if
(
pSql
->
cmd
.
command
<
TSDB_SQL_LOCAL
)
{
/*
* There is multi-thread problem here, since pSql->pRpcCtx may have been
* reset and freed in the processMsgFromServer function, and causes the invalid
* write problem for rpcCancelRequest.
*/
if
(
pSql
->
pRpcCtx
!=
NULL
)
{
rpcCancelRequest
(
pSql
->
pRpcCtx
);
pSql
->
pRpcCtx
=
NULL
;
...
...
src/client/src/tscSubquery.c
浏览文件 @
b6786bc6
...
...
@@ -1563,6 +1563,11 @@ static int32_t tscReissueSubquery(SRetrieveSupport *trsupport, SSqlObj *pSql, in
}
void
tscHandleSubqueryError
(
SRetrieveSupport
*
trsupport
,
SSqlObj
*
pSql
,
int
numOfRows
)
{
// it has been freed already
if
(
pSql
->
param
!=
trsupport
||
pSql
->
param
==
NULL
)
{
return
;
}
SSqlObj
*
pParentSql
=
trsupport
->
pParentSql
;
int32_t
subqueryIndex
=
trsupport
->
subqueryIndex
;
...
...
@@ -1709,14 +1714,21 @@ static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* p
}
static
void
tscRetrieveFromDnodeCallBack
(
void
*
param
,
TAOS_RES
*
tres
,
int
numOfRows
)
{
SSqlObj
*
pSql
=
(
SSqlObj
*
)
tres
;
assert
(
pSql
!=
NULL
);
// this query has been freed already
SRetrieveSupport
*
trsupport
=
(
SRetrieveSupport
*
)
param
;
if
(
pSql
->
param
==
NULL
||
param
==
NULL
)
{
tscDebug
(
"%p already freed in dnodecallback"
,
pSql
);
assert
(
pSql
->
res
.
code
==
TSDB_CODE_TSC_QUERY_CANCELLED
);
return
;
}
tOrderDescriptor
*
pDesc
=
trsupport
->
pOrderDescriptor
;
int32_t
idx
=
trsupport
->
subqueryIndex
;
SSqlObj
*
pParentSql
=
trsupport
->
pParentSql
;
SSqlObj
*
pSql
=
(
SSqlObj
*
)
tres
;
assert
(
pSql
!=
NULL
&&
trsupport
==
pSql
->
param
);
SSubqueryState
*
pState
=
&
pParentSql
->
subState
;
assert
(
pState
->
numOfRemain
<=
pState
->
numOfSub
&&
pState
->
numOfRemain
>=
0
);
...
...
src/kit/shell/inc/shell.h
浏览文件 @
b6786bc6
...
...
@@ -20,6 +20,7 @@
#include "taos.h"
#include "taosdef.h"
#include "stdbool.h"
#include "tsclient.h"
#define MAX_USERNAME_SIZE 64
#define MAX_DBNAME_SIZE 64
...
...
src/kit/shell/src/shellEngine.c
浏览文件 @
b6786bc6
...
...
@@ -294,9 +294,7 @@ void shellRunCommandOnServer(TAOS *con, char command[]) {
st
=
taosGetTimestampUs
();
TAOS_RES
*
pSql
=
taos_query
(
con
,
command
);
atomic_store_ptr
(
&
result
,
pSql
);
// set the global TAOS_RES pointer
TAOS_RES
*
pSql
=
taos_query_h
(
con
,
command
,
&
result
);
if
(
taos_errno
(
pSql
))
{
taos_error
(
pSql
);
return
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录