Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
adminstrot
TDengine
提交
c2432e6b
TDengine
项目概览
adminstrot
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
c2432e6b
编写于
6月 23, 2020
作者:
S
Shengliang Guan
提交者:
GitHub
6月 23, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2416 from taosdata/feature/query
[td-225] fix bugs found in regression test.
上级
597291e0
acd899bb
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
70 addition
and
16 deletion
+70
-16
src/inc/tsdb.h
src/inc/tsdb.h
+17
-0
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+15
-16
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+38
-0
未找到文件。
src/inc/tsdb.h
浏览文件 @
c2432e6b
...
...
@@ -208,6 +208,14 @@ TsdbQueryHandleT tsdbQueryLastRow(TSDB_REPO_T *tsdb, STsdbQueryCond *pCond, STab
*/
SArray
*
tsdbGetQueriedTableList
(
TsdbQueryHandleT
*
pHandle
);
/**
* get the group list according to table id from client
* @param tsdb
* @param pCond
* @param groupList
* @param qinfo
* @return
*/
TsdbQueryHandleT
tsdbQueryRowsInExternalWindow
(
TSDB_REPO_T
*
tsdb
,
STsdbQueryCond
*
pCond
,
STableGroupInfo
*
groupList
,
void
*
qinfo
);
...
...
@@ -276,6 +284,15 @@ void tsdbDestoryTableGroup(STableGroupInfo *pGroupList);
*/
int32_t
tsdbGetOneTableGroup
(
TSDB_REPO_T
*
tsdb
,
uint64_t
uid
,
STableGroupInfo
*
pGroupInfo
);
/**
*
* @param tsdb
* @param pTableIdList
* @param pGroupInfo
* @return
*/
int32_t
tsdbGetTableGroupFromIdList
(
TSDB_REPO_T
*
tsdb
,
SArray
*
pTableIdList
,
STableGroupInfo
*
pGroupInfo
);
/**
* clean up the query handle
* @param queryHandle
...
...
src/query/src/qExecutor.c
浏览文件 @
c2432e6b
...
...
@@ -5495,7 +5495,7 @@ static int compareTableIdInfo(const void* a, const void* b) {
}
static
SQInfo
*
createQInfoImpl
(
SQueryTableMsg
*
pQueryMsg
,
SArray
*
pTableIdList
,
SSqlGroupbyExpr
*
pGroupbyExpr
,
SExprInfo
*
pExprs
,
STableGroupInfo
*
tableqinfo
GroupInfo
,
SColumnInfo
*
pTagCols
)
{
STableGroupInfo
*
pTable
GroupInfo
,
SColumnInfo
*
pTagCols
)
{
SQInfo
*
pQInfo
=
(
SQInfo
*
)
calloc
(
1
,
sizeof
(
SQInfo
));
if
(
pQInfo
==
NULL
)
{
return
NULL
;
...
...
@@ -5581,18 +5581,18 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SArray* pTableIdList,
// to make sure third party won't overwrite this structure
pQInfo
->
signature
=
pQInfo
;
pQInfo
->
tableGroupInfo
=
*
tableqinfo
GroupInfo
;
size_t
numOfGroups
=
taosArrayGetSize
(
tableqinfo
GroupInfo
->
pGroupList
);
pQInfo
->
tableGroupInfo
=
*
pTable
GroupInfo
;
size_t
numOfGroups
=
taosArrayGetSize
(
pTable
GroupInfo
->
pGroupList
);
pQInfo
->
tableqinfoGroupInfo
.
pGroupList
=
taosArrayInit
(
numOfGroups
,
POINTER_BYTES
);
pQInfo
->
tableqinfoGroupInfo
.
numOfTables
=
tableqinfo
GroupInfo
->
numOfTables
;
pQInfo
->
tableqinfoGroupInfo
.
numOfTables
=
pTable
GroupInfo
->
numOfTables
;
int
tableIndex
=
0
;
STimeWindow
window
=
pQueryMsg
->
window
;
taosArraySort
(
pTableIdList
,
compareTableIdInfo
);
for
(
int32_t
i
=
0
;
i
<
numOfGroups
;
++
i
)
{
SArray
*
pa
=
taosArrayGetP
(
tableqinfo
GroupInfo
->
pGroupList
,
i
);
SArray
*
pa
=
taosArrayGetP
(
pTable
GroupInfo
->
pGroupList
,
i
);
size_t
s
=
taosArrayGetSize
(
pa
);
SArray
*
p1
=
taosArrayInit
(
s
,
POINTER_BYTES
);
...
...
@@ -5898,13 +5898,13 @@ int32_t qCreateQueryInfo(void *tsdb, int32_t vgId, SQueryTableMsg *pQueryMsg, qi
}
bool
isSTableQuery
=
false
;
STableGroupInfo
table
qinfo
GroupInfo
=
{
0
};
STableGroupInfo
tableGroupInfo
=
{
0
};
if
(
TSDB_QUERY_HAS_TYPE
(
pQueryMsg
->
queryType
,
TSDB_QUERY_TYPE_TABLE_QUERY
))
{
STableIdInfo
*
id
=
taosArrayGet
(
pTableIdList
,
0
);
qTrace
(
"qmsg:%p query normal table, uid:%"
PRId64
", tid:%d"
,
pQueryMsg
,
id
->
uid
,
id
->
tid
);
if
((
code
=
tsdbGetOneTableGroup
(
tsdb
,
id
->
uid
,
&
table
qinfo
GroupInfo
))
!=
TSDB_CODE_SUCCESS
)
{
if
((
code
=
tsdbGetOneTableGroup
(
tsdb
,
id
->
uid
,
&
tableGroupInfo
))
!=
TSDB_CODE_SUCCESS
)
{
goto
_over
;
}
}
else
if
(
TSDB_QUERY_HAS_TYPE
(
pQueryMsg
->
queryType
,
TSDB_QUERY_TYPE_MULTITABLE_QUERY
|
TSDB_QUERY_TYPE_STABLE_QUERY
))
{
...
...
@@ -5921,25 +5921,24 @@ int32_t qCreateQueryInfo(void *tsdb, int32_t vgId, SQueryTableMsg *pQueryMsg, qi
numOfGroupByCols
=
0
;
}
code
=
tsdbQuerySTableByTagCond
(
tsdb
,
id
->
uid
,
tagCond
,
pQueryMsg
->
tagCondLen
,
pQueryMsg
->
tagNameRelType
,
tbnameCond
,
&
table
qinfo
GroupInfo
,
pGroupColIndex
,
code
=
tsdbQuerySTableByTagCond
(
tsdb
,
id
->
uid
,
tagCond
,
pQueryMsg
->
tagCondLen
,
pQueryMsg
->
tagNameRelType
,
tbnameCond
,
&
tableGroupInfo
,
pGroupColIndex
,
numOfGroupByCols
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_over
;
}
}
else
{
tableqinfoGroupInfo
.
pGroupList
=
taosArrayInit
(
1
,
POINTER_BYTES
);
tableqinfoGroupInfo
.
numOfTables
=
taosArrayGetSize
(
pTableIdList
);
SArray
*
p
=
taosArrayClone
(
pTableIdList
);
taosArrayPush
(
tableqinfoGroupInfo
.
pGroupList
,
&
p
);
code
=
tsdbGetTableGroupFromIdList
(
tsdb
,
pTableIdList
,
&
tableGroupInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_over
;
}
qTrace
(
"qmsg:%p query on %zu tables in one group from client"
,
pQueryMsg
,
table
qinfo
GroupInfo
.
numOfTables
);
qTrace
(
"qmsg:%p query on %zu tables in one group from client"
,
pQueryMsg
,
tableGroupInfo
.
numOfTables
);
}
}
else
{
assert
(
0
);
}
(
*
pQInfo
)
=
createQInfoImpl
(
pQueryMsg
,
pTableIdList
,
pGroupbyExpr
,
pExprs
,
&
table
qinfo
GroupInfo
,
pTagColumnInfo
);
(
*
pQInfo
)
=
createQInfoImpl
(
pQueryMsg
,
pTableIdList
,
pGroupbyExpr
,
pExprs
,
&
tableGroupInfo
,
pTagColumnInfo
);
if
((
*
pQInfo
)
==
NULL
)
{
code
=
TSDB_CODE_QRY_OUT_OF_MEMORY
;
goto
_over
;
...
...
@@ -6162,7 +6161,7 @@ static void buildTagQueryResult(SQInfo* pQInfo) {
while
(
pQInfo
->
tableIndex
<
num
&&
count
<
pQuery
->
rec
.
capacity
)
{
int32_t
i
=
pQInfo
->
tableIndex
++
;
STableQueryInfo
*
item
=
taosArrayGet
(
pa
,
i
);
STableQueryInfo
*
item
=
taosArrayGet
P
(
pa
,
i
);
char
*
output
=
pQuery
->
sdata
[
0
]
->
data
+
i
*
rsize
;
varDataSetLen
(
output
,
rsize
-
VARSTR_HEADER_SIZE
);
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
c2432e6b
...
...
@@ -2254,6 +2254,44 @@ int32_t tsdbGetOneTableGroup(TSDB_REPO_T* tsdb, uint64_t uid, STableGroupInfo* p
return
terrno
;
}
int32_t
tsdbGetTableGroupFromIdList
(
TSDB_REPO_T
*
tsdb
,
SArray
*
pTableIdList
,
STableGroupInfo
*
pGroupInfo
)
{
if
(
tsdbRLockRepoMeta
(
tsdb
)
<
0
)
goto
_error
;
assert
(
pTableIdList
!=
NULL
);
size_t
size
=
taosArrayGetSize
(
pTableIdList
);
pGroupInfo
->
pGroupList
=
taosArrayInit
(
1
,
POINTER_BYTES
);
SArray
*
group
=
taosArrayInit
(
1
,
POINTER_BYTES
);
int32_t
i
=
0
;
for
(;
i
<
size
;
++
i
)
{
STableIdInfo
*
id
=
taosArrayGet
(
pTableIdList
,
i
);
STable
*
pTable
=
tsdbGetTableByUid
(
tsdbGetMeta
(
tsdb
),
id
->
uid
);
if
(
pTable
==
NULL
)
{
tsdbWarn
(
"table uid:%"
PRIu64
", tid:%d has been drop already"
,
id
->
uid
,
id
->
tid
);
continue
;
}
if
(
pTable
->
type
==
TSDB_SUPER_TABLE
)
{
tsdbError
(
"direct query on super tale is not allowed, table uid:%"
PRIu64
", tid:%d"
,
id
->
uid
,
id
->
tid
);
terrno
=
TSDB_CODE_QRY_INVALID_MSG
;
}
tsdbRefTable
(
pTable
);
taosArrayPush
(
group
,
&
pTable
);
}
if
(
tsdbUnlockRepoMeta
(
tsdb
)
<
0
)
goto
_error
;
pGroupInfo
->
numOfTables
=
i
;
taosArrayPush
(
pGroupInfo
->
pGroupList
,
&
group
);
return
TSDB_CODE_SUCCESS
;
_error:
return
terrno
;
}
void
tsdbCleanupQueryHandle
(
TsdbQueryHandleT
queryHandle
)
{
STsdbQueryHandle
*
pQueryHandle
=
(
STsdbQueryHandle
*
)
queryHandle
;
if
(
pQueryHandle
==
NULL
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录