Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
695572cc
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看板
提交
695572cc
编写于
1月 15, 2021
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix bug
上级
e29a53ef
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
22 addition
and
15 deletion
+22
-15
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+22
-15
未找到文件。
src/client/src/tscSubquery.c
浏览文件 @
695572cc
...
...
@@ -68,25 +68,28 @@ static void subquerySetState(SSqlObj *pSql, SSubqueryState *subState, int idx, i
pthread_mutex_unlock
(
&
subState
->
mutex
);
}
static
bool
allSubqueryDone
(
SS
ubqueryState
*
subState
)
{
static
bool
allSubqueryDone
(
SS
qlObj
*
pParentSql
)
{
bool
done
=
true
;
SSubqueryState
*
subState
=
&
pParentSql
->
subState
;
//lock in caller
for
(
int
i
=
0
;
i
<
subState
->
numOfSub
;
i
++
)
{
if
(
0
==
subState
->
states
[
i
])
{
tscDebug
(
"subquery:%
d is NOT finished, total:%d"
,
i
,
subState
->
numOfSub
);
tscDebug
(
"subquery:%
p,%d is NOT finished, total:%d"
,
pParentSql
->
pSubs
[
i
]
,
i
,
subState
->
numOfSub
);
done
=
false
;
break
;
}
else
{
tscDebug
(
"subquery:%
d is finished, total:%d"
,
i
,
subState
->
numOfSub
);
tscDebug
(
"subquery:%
p,%d is finished, total:%d"
,
pParentSql
->
pSubs
[
i
]
,
i
,
subState
->
numOfSub
);
}
}
return
done
;
}
static
bool
subAndCheckDone
(
SSqlObj
*
pSql
,
SSubqueryState
*
subState
,
int
idx
)
{
static
bool
subAndCheckDone
(
SSqlObj
*
pSql
,
SSqlObj
*
pParentSql
,
int
idx
)
{
SSubqueryState
*
subState
=
&
pParentSql
->
subState
;
assert
(
idx
<
subState
->
numOfSub
);
pthread_mutex_lock
(
&
subState
->
mutex
);
...
...
@@ -95,7 +98,7 @@ static bool subAndCheckDone(SSqlObj *pSql, SSubqueryState *subState, int idx) {
subState
->
states
[
idx
]
=
1
;
bool
done
=
allSubqueryDone
(
subState
);
bool
done
=
allSubqueryDone
(
pParentSql
);
pthread_mutex_unlock
(
&
subState
->
mutex
);
...
...
@@ -580,7 +583,7 @@ void freeJoinSubqueryObj(SSqlObj* pSql) {
}
static
void
quitAllSubquery
(
SSqlObj
*
pSqlSub
,
SSqlObj
*
pSqlObj
,
SJoinSupporter
*
pSupporter
)
{
if
(
subAndCheckDone
(
pSqlSub
,
&
pSqlObj
->
subState
,
pSupporter
->
subqueryIndex
))
{
if
(
subAndCheckDone
(
pSqlSub
,
pSqlObj
,
pSupporter
->
subqueryIndex
))
{
tscError
(
"%p all subquery return and query failed, global code:%s"
,
pSqlObj
,
tstrerror
(
pSqlObj
->
res
.
code
));
freeJoinSubqueryObj
(
pSqlObj
);
return
;
...
...
@@ -897,7 +900,7 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
// no data exists in next vnode, mark the <tid, tags> query completed
// only when there is no subquery exits any more, proceeds to get the intersect of the <tid, tags> tuple sets.
if
(
!
subAndCheckDone
(
pSql
,
&
pParentSql
->
subState
,
pSupporter
->
subqueryIndex
))
{
if
(
!
subAndCheckDone
(
pSql
,
pParentSql
,
pSupporter
->
subqueryIndex
))
{
tscDebug
(
"%p tagRetrieve:%p,%d completed, total:%d"
,
pParentSql
,
tres
,
pSupporter
->
subqueryIndex
,
pParentSql
->
subState
.
numOfSub
);
return
;
}
...
...
@@ -945,8 +948,10 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
((
SJoinSupporter
*
)
psub2
->
param
)
->
pVgroupTables
=
tscVgroupTableInfoClone
(
pTableMetaInfo2
->
pVgroupTables
);
pParentSql
->
subState
.
numOfSub
=
2
;
memset
(
pParentSql
->
subState
.
states
,
0
,
sizeof
(
pParentSql
->
subState
.
states
[
0
])
*
pParentSql
->
subState
.
numOfSub
);
tscDebug
(
"%p reset all sub states to 0"
,
pParentSql
);
for
(
int32_t
m
=
0
;
m
<
pParentSql
->
subState
.
numOfSub
;
++
m
)
{
SSqlObj
*
sub
=
pParentSql
->
pSubs
[
m
];
issueTSCompQuery
(
sub
,
sub
->
param
,
pParentSql
);
...
...
@@ -1063,7 +1068,7 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
return
;
}
if
(
!
subAndCheckDone
(
pSql
,
&
pParentSql
->
subState
,
pSupporter
->
subqueryIndex
))
{
if
(
!
subAndCheckDone
(
pSql
,
pParentSql
,
pSupporter
->
subqueryIndex
))
{
return
;
}
...
...
@@ -1142,7 +1147,7 @@ static void joinRetrieveFinalResCallback(void* param, TAOS_RES* tres, int numOfR
}
}
if
(
!
subAndCheckDone
(
pSql
,
p
State
,
pSupporter
->
subqueryIndex
))
{
if
(
!
subAndCheckDone
(
pSql
,
p
ParentSql
,
pSupporter
->
subqueryIndex
))
{
tscDebug
(
"%p sub:%p,%d completed, total:%d"
,
pParentSql
,
tres
,
pSupporter
->
subqueryIndex
,
pState
->
numOfSub
);
return
;
}
...
...
@@ -1263,7 +1268,7 @@ void tscFetchDatablockForSubquery(SSqlObj* pSql) {
for
(
int32_t
i
=
0
;
i
<
pSql
->
subState
.
numOfSub
;
++
i
)
{
SSqlObj
*
pSub
=
pSql
->
pSubs
[
i
];
if
(
pSub
!=
NULL
&&
pSub
->
res
.
row
>=
pSub
->
res
.
numOfRows
&&
pSub
->
res
.
completed
)
{
pSql
->
subState
.
states
[
i
]
=
0
;
subquerySetState
(
pSub
,
&
pSql
->
subState
,
i
,
0
)
;
}
}
}
...
...
@@ -1476,7 +1481,7 @@ void tscJoinQueryCallback(void* param, TAOS_RES* tres, int code) {
// In case of consequence query from other vnode, do not wait for other query response here.
if
(
!
(
pTableMetaInfo
->
vgroupIndex
>
0
&&
tscNonOrderedProjectionQueryOnSTable
(
pQueryInfo
,
0
)))
{
if
(
!
subAndCheckDone
(
pSql
,
&
pParentSql
->
subState
,
pSupporter
->
subqueryIndex
))
{
if
(
!
subAndCheckDone
(
pSql
,
pParentSql
,
pSupporter
->
subqueryIndex
))
{
return
;
}
}
...
...
@@ -1830,6 +1835,7 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
}
memset
(
pState
->
states
,
0
,
sizeof
(
*
pState
->
states
)
*
pState
->
numOfSub
);
tscDebug
(
"%p reset all sub states to 0"
,
pSql
);
pRes
->
code
=
TSDB_CODE_SUCCESS
;
...
...
@@ -2009,7 +2015,7 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO
}
}
if
(
!
subAndCheckDone
(
pSql
,
p
State
,
subqueryIndex
))
{
if
(
!
subAndCheckDone
(
pSql
,
p
ParentSql
,
subqueryIndex
))
{
tscDebug
(
"%p sub:%p,%d freed, not finished, total:%d"
,
pParentSql
,
pSql
,
trsupport
->
subqueryIndex
,
pState
->
numOfSub
);
tscFreeRetrieveSup
(
pSql
);
...
...
@@ -2079,7 +2085,7 @@ static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* p
return
;
}
if
(
!
subAndCheckDone
(
pSql
,
&
pParentSql
->
subState
,
idx
))
{
if
(
!
subAndCheckDone
(
pSql
,
pParentSql
,
idx
))
{
tscDebug
(
"%p sub:%p orderOfSub:%d freed, not finished"
,
pParentSql
,
pSql
,
trsupport
->
subqueryIndex
);
tscFreeRetrieveSup
(
pSql
);
...
...
@@ -2350,7 +2356,7 @@ static void multiVnodeInsertFinalize(void* param, TAOS_RES* tres, int numOfRows)
}
}
if
(
!
subAndCheckDone
(
tres
,
&
pParentObj
->
subState
,
pSupporter
->
index
))
{
if
(
!
subAndCheckDone
(
tres
,
pParentObj
,
pSupporter
->
index
))
{
tscDebug
(
"%p insert:%p,%d completed, total:%d"
,
pParentObj
,
tres
,
pSupporter
->
index
,
pParentObj
->
subState
.
numOfSub
);
return
;
}
...
...
@@ -2487,6 +2493,7 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) {
}
memset
(
pSql
->
subState
.
states
,
0
,
sizeof
(
*
pSql
->
subState
.
states
)
*
pSql
->
subState
.
numOfSub
);
tscDebug
(
"%p reset all sub states to 0"
,
pSql
);
pSql
->
pSubs
=
calloc
(
pSql
->
subState
.
numOfSub
,
POINTER_BYTES
);
if
(
pSql
->
pSubs
==
NULL
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录