Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
3fff8aba
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看板
提交
3fff8aba
编写于
10月 23, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-1373]
上级
a89368e6
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
76 addition
and
10 deletion
+76
-10
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+68
-10
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+8
-0
未找到文件。
src/client/src/tscSubquery.c
浏览文件 @
3fff8aba
...
...
@@ -465,6 +465,8 @@ static void quitAllSubquery(SSqlObj* pSqlObj, SJoinSupporter* pSupporter) {
static
void
updateQueryTimeRange
(
SQueryInfo
*
pQueryInfo
,
STimeWindow
*
win
)
{
assert
(
pQueryInfo
->
window
.
skey
<=
win
->
skey
&&
pQueryInfo
->
window
.
ekey
>=
win
->
ekey
);
pQueryInfo
->
window
=
*
win
;
}
int32_t
tscCompareTidTags
(
const
void
*
p1
,
const
void
*
p2
)
{
...
...
@@ -963,19 +965,18 @@ static void joinRetrieveFinalResCallback(void* param, TAOS_RES* tres, int numOfR
static
SJoinSupporter
*
tscUpdateSubqueryStatus
(
SSqlObj
*
pSql
,
int32_t
numOfFetch
)
{
int32_t
notInvolved
=
0
;
SJoinSupporter
*
pSupporter
=
NULL
;
SSubqueryState
*
pState
=
&
pSql
->
subState
;
for
(
int32_t
i
=
0
;
i
<
pSql
->
subState
.
numOfSub
;
++
i
)
{
if
(
pSql
->
pSubs
[
i
]
==
NULL
)
{
notInvolved
++
;
}
else
{
pSupporter
=
(
SJoinSupporter
*
)
pSql
->
pSubs
[
i
]
->
param
;
//
} else {
//
(SJoinSupporter*)pSql->pSubs[i]->param;
}
}
pState
->
numOfRemain
=
numOfFetch
;
return
pSupporter
;
return
NULL
;
}
void
tscFetchDatablockFromSubquery
(
SSqlObj
*
pSql
)
{
...
...
@@ -983,14 +984,16 @@ void tscFetchDatablockFromSubquery(SSqlObj* pSql) {
int32_t
numOfFetch
=
0
;
bool
hasData
=
true
;
// if the subquery is NULL, it does not involved in the final result generation
for
(
int32_t
i
=
0
;
i
<
pSql
->
subState
.
numOfSub
;
++
i
)
{
// if the subquery is NULL, it does not involved in the final result generation
SSqlObj
*
pSub
=
pSql
->
pSubs
[
i
];
if
(
pSub
==
NULL
)
{
continue
;
}
SSqlRes
*
pRes
=
&
pSub
->
res
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSub
->
cmd
,
0
);
if
(
!
tscHasReachLimitation
(
pQueryInfo
,
pRes
))
{
...
...
@@ -1014,8 +1017,61 @@ void tscFetchDatablockFromSubquery(SSqlObj* pSql) {
tscBuildResFromSubqueries
(
pSql
);
return
;
}
else
if
(
numOfFetch
<=
0
)
{
pSql
->
res
.
completed
=
true
;
freeJoinSubqueryObj
(
pSql
);
bool
tryNextVnode
=
false
;
SSqlObj
*
pp
=
pSql
->
pSubs
[
0
];
SQueryInfo
*
pi
=
tscGetQueryInfoDetail
(
&
pp
->
cmd
,
0
);
if
(
tscNonOrderedProjectionQueryOnSTable
(
pi
,
0
))
{
for
(
int32_t
i
=
0
;
i
<
pSql
->
subState
.
numOfSub
;
++
i
)
{
if
(
pSql
->
pSubs
[
i
]
!=
NULL
)
{
pSql
->
subState
.
numOfRemain
++
;
}
}
}
for
(
int32_t
i
=
0
;
i
<
pSql
->
subState
.
numOfSub
;
++
i
)
{
SSqlObj
*
pSub
=
pSql
->
pSubs
[
i
];
if
(
pSub
==
NULL
)
{
continue
;
}
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSub
->
cmd
,
0
);
if
(
tscNonOrderedProjectionQueryOnSTable
(
pQueryInfo
,
0
))
{
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
assert
(
pQueryInfo
->
numOfTables
==
1
);
// for projection query, need to try next vnode if current vnode is exhausted
int32_t
numOfVgroups
=
0
;
// TODO refactor
if
(
pTableMetaInfo
->
pVgroupTables
!=
NULL
)
{
numOfVgroups
=
taosArrayGetSize
(
pTableMetaInfo
->
pVgroupTables
);
}
else
{
numOfVgroups
=
pTableMetaInfo
->
vgroupList
->
numOfVgroups
;
}
if
((
++
pTableMetaInfo
->
vgroupIndex
)
<
numOfVgroups
)
{
tscDebug
(
"%p no result in current vnode anymore, try next vnode, vgIndex:%d"
,
pSub
,
pTableMetaInfo
->
vgroupIndex
);
pSub
->
cmd
.
command
=
TSDB_SQL_SELECT
;
pSub
->
fp
=
tscJoinQueryCallback
;
tscProcessSql
(
pSub
);
tryNextVnode
=
true
;
}
else
{
tscDebug
(
"%p no result in current subquery anymore"
,
pSub
);
}
}
}
if
(
tryNextVnode
)
{
return
;
}
else
{
pSql
->
res
.
completed
=
true
;
freeJoinSubqueryObj
(
pSql
);
}
if
(
pSql
->
res
.
code
==
TSDB_CODE_SUCCESS
)
{
(
*
pSql
->
fp
)(
pSql
->
param
,
pSql
,
0
);
...
...
@@ -1027,15 +1083,17 @@ void tscFetchDatablockFromSubquery(SSqlObj* pSql) {
}
// TODO multi-vnode retrieve for projection query with limitation has bugs, since the global limiation is not handled
// retrieve data from current vnode.
tscDebug
(
"%p retrieve data from %d subqueries"
,
pSql
,
numOfFetch
);
SJoinSupporter
*
pSupporter
=
tscUpdateSubqueryStatus
(
pSql
,
numOfFetch
);
SJoinSupporter
*
pSupporter
=
NULL
;
tscUpdateSubqueryStatus
(
pSql
,
numOfFetch
);
for
(
int32_t
i
=
0
;
i
<
pSql
->
subState
.
numOfSub
;
++
i
)
{
SSqlObj
*
pSql1
=
pSql
->
pSubs
[
i
];
if
(
pSql1
==
NULL
)
{
continue
;
}
SSqlRes
*
pRes1
=
&
pSql1
->
res
;
SSqlCmd
*
pCmd1
=
&
pSql1
->
cmd
;
...
...
src/query/src/qExecutor.c
浏览文件 @
3fff8aba
...
...
@@ -4775,6 +4775,14 @@ static bool multiTableMultioutputHelper(SQInfo *pQInfo, int32_t index) {
return
false
;
}
}
else
{
STSElem
elem
=
tsBufGetElem
(
pRuntimeEnv
->
pTSBuf
);
if
(
tVariantCompare
(
&
elem
.
tag
,
&
pRuntimeEnv
->
pCtx
[
0
].
tag
)
!=
0
)
{
STSElem
elem1
=
tsBufGetElemStartPos
(
pRuntimeEnv
->
pTSBuf
,
pQInfo
->
vgId
,
&
pRuntimeEnv
->
pCtx
[
0
].
tag
);
if
(
elem1
.
vnode
<
0
)
{
return
false
;
}
}
tsBufSetCursor
(
pRuntimeEnv
->
pTSBuf
,
&
pRuntimeEnv
->
cur
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录