Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
898c71fd
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
898c71fd
编写于
3月 23, 2022
作者:
M
Minglei Jin
提交者:
GitHub
3月 23, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #10876 from taosdata/fix/TS-1318-2.4
[TS-1318]<fix>: fixed unmatched tag columns in join queries
上级
ea009dc8
f75abdc1
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
113 addition
and
33 deletion
+113
-33
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+95
-1
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+1
-1
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+1
-1
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+1
-15
src/tsdb/src/tsdbReadImpl.c
src/tsdb/src/tsdbReadImpl.c
+12
-12
tests/script/general/parser/limit_stb.sim
tests/script/general/parser/limit_stb.sim
+3
-3
未找到文件。
src/client/src/tscSubquery.c
浏览文件 @
898c71fd
...
...
@@ -662,6 +662,7 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) {
}
else
{
filterVgroupTables
(
pQueryInfo
,
pTableMetaInfo
->
pVgroupTables
);
}
pQueryInfo
->
stableQuery
=
true
;
}
subquerySetState
(
pNew
,
&
pSql
->
subState
,
i
,
0
);
...
...
@@ -935,6 +936,96 @@ static void setTidTagType(SJoinSupporter* p, uint8_t type) {
}
}
static
int32_t
tidTagsMerge
(
SArray
*
arr
,
int32_t
start
,
int32_t
mid
,
int32_t
end
,
const
int32_t
tagSize
)
{
char
*
pTmp
,
*
pRes
=
NULL
;
char
*
result
=
NULL
;
STidTags
*
pi
,
*
pj
,
*
p
;
int32_t
k
=
0
;
int32_t
i
=
start
;
int32_t
j
=
mid
+
1
;
if
(
end
-
start
>
0
)
{
result
=
calloc
(
1
,
(
end
-
start
+
1
)
*
tagSize
);
if
(
result
==
NULL
)
{
tscError
(
"failed to allocate memory for tidTagsMerge"
);
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
}
pRes
=
result
;
while
(
i
<=
mid
&&
j
<=
end
)
{
pi
=
taosArrayGet
(
arr
,
i
);
pj
=
taosArrayGet
(
arr
,
j
);
if
(
pi
->
vgId
<=
pj
->
vgId
)
{
p
=
taosArrayGet
(
arr
,
i
++
);
memcpy
(
pRes
,
p
,
tagSize
);
}
else
{
p
=
taosArrayGet
(
arr
,
j
++
);
memcpy
(
pRes
,
p
,
tagSize
);
}
k
++
;
pRes
+=
tagSize
;
}
if
(
i
==
mid
+
1
)
{
while
(
j
<=
end
)
{
p
=
taosArrayGet
(
arr
,
j
++
);
memcpy
(
pRes
,
p
,
tagSize
);
k
++
;
pRes
+=
tagSize
;
}
}
if
(
j
==
end
+
1
)
{
while
(
i
<=
mid
)
{
p
=
taosArrayGet
(
arr
,
i
++
);
memcpy
(
pRes
,
p
,
tagSize
);
k
++
;
pRes
+=
tagSize
;
}
}
for
(
i
=
start
,
j
=
0
,
pTmp
=
result
;
j
<
k
;
i
++
,
j
++
,
pTmp
+=
tagSize
)
{
p
=
(
STidTags
*
)
taosArrayGet
(
arr
,
i
);
memcpy
(
p
,
pTmp
,
tagSize
);
}
if
(
result
)
{
tfree
(
result
);
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
tidTagsMergeSort
(
SArray
*
arr
,
int32_t
start
,
int32_t
end
,
const
int32_t
tagSize
)
{
int32_t
ret
;
int32_t
mid
;
if
(
start
>=
end
)
{
return
TSDB_CODE_SUCCESS
;
}
mid
=
(
start
+
end
)
/
2
;
ret
=
tidTagsMergeSort
(
arr
,
start
,
mid
,
tagSize
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
ret
;
}
ret
=
tidTagsMergeSort
(
arr
,
mid
+
1
,
end
,
tagSize
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
ret
;
}
return
tidTagsMerge
(
arr
,
start
,
mid
,
end
,
tagSize
);
}
static
int32_t
getIntersectionOfTableTuple
(
SQueryInfo
*
pQueryInfo
,
SSqlObj
*
pParentSql
,
SArray
*
resList
)
{
int16_t
joinNum
=
pParentSql
->
subState
.
numOfSub
;
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
...
...
@@ -1124,7 +1215,10 @@ static int32_t getIntersectionOfTableTuple(SQueryInfo* pQueryInfo, SSqlObj* pPar
// sort according to the tag value
size_t
num
=
taosArrayGetSize
(
ctxlist
[
i
].
res
);
qsort
((
ctxlist
[
i
].
res
)
->
pData
,
num
,
size
,
tidTagsCompar
);
int32_t
ret
=
tidTagsMergeSort
(
ctxlist
[
i
].
res
,
0
,
num
-
1
,
size
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
taosArrayPush
(
resList
,
&
ctxlist
[
i
].
res
);
...
...
src/client/src/tscUtil.c
浏览文件 @
898c71fd
...
...
@@ -394,7 +394,7 @@ bool tscIsPointInterpQuery(SQueryInfo* pQueryInfo) {
}
bool
tscNeedTableSeqScan
(
SQueryInfo
*
pQueryInfo
)
{
return
pQueryInfo
->
stableQuery
&&
(
tscQueryContainsFunction
(
pQueryInfo
,
TSDB_FUNC_TWA
)
||
tscQueryContainsFunction
(
pQueryInfo
,
TSDB_FUNC_ELAPSED
));
return
pQueryInfo
->
stableQuery
&&
(
tscQueryContainsFunction
(
pQueryInfo
,
TSDB_FUNC_TWA
)
||
tscQueryContainsFunction
(
pQueryInfo
,
TSDB_FUNC_ELAPSED
)
||
(
pQueryInfo
->
tsBuf
!=
NULL
)
);
}
bool
tscGetPointInterpQuery
(
SQueryInfo
*
pQueryInfo
)
{
...
...
src/query/src/qExecutor.c
浏览文件 @
898c71fd
...
...
@@ -4832,7 +4832,7 @@ static int32_t setupQueryHandle(void* tsdb, SQueryRuntimeEnv* pRuntimeEnv, int64
}
STsdbQueryCond
cond
=
createTsdbQueryCond
(
pQueryAttr
,
&
pQueryAttr
->
window
);
if
(
pQueryAttr
->
tsCompQuery
||
pQueryAttr
->
pointInterpQuery
)
{
if
(
pQueryAttr
->
tsCompQuery
||
pQueryAttr
->
pointInterpQuery
||
pQueryAttr
->
needTableSeqScan
)
{
cond
.
type
=
BLOCK_LOAD_TABLE_SEQ_ORDER
;
}
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
898c71fd
...
...
@@ -183,7 +183,6 @@ static void changeQueryHandleForInterpQuery(TsdbQueryHandleT pHandle);
static
void
doMergeTwoLevelData
(
STsdbQueryHandle
*
pQueryHandle
,
STableCheckInfo
*
pCheckInfo
,
SBlock
*
pBlock
);
static
int32_t
binarySearchForKey
(
char
*
pValue
,
int
num
,
TSKEY
key
,
int
order
);
static
int32_t
tsdbReadRowsFromCache
(
STableCheckInfo
*
pCheckInfo
,
TSKEY
maxKey
,
int
maxRowsToRead
,
STimeWindow
*
win
,
STsdbQueryHandle
*
pQueryHandle
);
static
int32_t
tsdbCheckInfoCompar
(
const
void
*
key1
,
const
void
*
key2
);
static
int32_t
doGetExternalRow
(
STsdbQueryHandle
*
pQueryHandle
,
int16_t
type
,
SMemRef
*
pMemRef
);
static
void
*
doFreeColumnInfoData
(
SArray
*
pColumnInfoData
);
static
void
*
destroyTableCheckInfo
(
SArray
*
pTableCheckInfo
);
...
...
@@ -333,8 +332,6 @@ static SArray* createCheckInfoFromTableGroup(STsdbQueryHandle* pQueryHandle, STa
}
}
taosArraySort
(
pTableCheckInfo
,
tsdbCheckInfoCompar
);
size_t
gsize
=
taosArrayGetSize
(
pTableCheckInfo
);
for
(
int32_t
i
=
0
;
i
<
gsize
;
++
i
)
{
...
...
@@ -3913,17 +3910,6 @@ static int32_t tableGroupComparFn(const void *p1, const void *p2, const void *pa
return
0
;
}
static
int
tsdbCheckInfoCompar
(
const
void
*
key1
,
const
void
*
key2
)
{
if
(((
STableCheckInfo
*
)
key1
)
->
tableId
.
tid
<
((
STableCheckInfo
*
)
key2
)
->
tableId
.
tid
)
{
return
-
1
;
}
else
if
(((
STableCheckInfo
*
)
key1
)
->
tableId
.
tid
>
((
STableCheckInfo
*
)
key2
)
->
tableId
.
tid
)
{
return
1
;
}
else
{
ASSERT
(
false
);
return
0
;
}
}
void
createTableGroupImpl
(
SArray
*
pGroups
,
SArray
*
pTableList
,
size_t
numOfTables
,
TSKEY
skey
,
STableGroupSupporter
*
pSupp
,
__ext_compar_fn_t
compareFn
)
{
STable
*
pTable
=
taosArrayGetP
(
pTableList
,
0
);
...
...
@@ -4662,4 +4648,4 @@ void tsdbAddScanCallback(TsdbQueryHandleT* queryHandle, readover_callback callba
pQueryHandle
->
readover_cb
=
callback
;
pQueryHandle
->
param
=
param
;
return
;
}
\ No newline at end of file
}
src/tsdb/src/tsdbReadImpl.c
浏览文件 @
898c71fd
...
...
@@ -172,28 +172,28 @@ int tsdbSetReadTable(SReadH *pReadh, STable *pTable) {
size_t
size
=
taosArrayGetSize
(
pReadh
->
aBlkIdx
);
if
(
size
>
0
)
{
while
(
true
)
{
if
(
pReadh
->
cidx
>=
size
)
{
pReadh
->
pBlkIdx
=
NULL
;
break
;
}
SBlockIdx
*
pBlkIdx
=
taosArrayGet
(
pReadh
->
aBlkIdx
,
pReadh
->
cidx
);
int64_t
left
=
0
,
right
=
size
-
1
;
while
(
left
<=
right
)
{
int64_t
mid
=
(
left
+
right
)
/
2
;
SBlockIdx
*
pBlkIdx
=
taosArrayGet
(
pReadh
->
aBlkIdx
,
(
size_t
)
mid
);
if
(
pBlkIdx
->
tid
==
TABLE_TID
(
pTable
))
{
if
(
pBlkIdx
->
uid
==
TABLE_UID
(
pTable
))
{
pReadh
->
pBlkIdx
=
pBlkIdx
;
}
else
{
pReadh
->
pBlkIdx
=
NULL
;
}
pReadh
->
cidx
++
;
break
;
}
else
if
(
pBlkIdx
->
tid
>
TABLE_TID
(
pTable
))
{
pReadh
->
pBlkIdx
=
NULL
;
break
;
}
else
if
(
pBlkIdx
->
tid
<
TABLE_TID
(
pTable
))
{
left
=
mid
+
1
;
}
else
{
pReadh
->
cidx
++
;
right
=
mid
-
1
;
}
}
if
(
left
>
right
)
{
pReadh
->
pBlkIdx
=
NULL
;
}
}
else
{
pReadh
->
pBlkIdx
=
NULL
;
}
...
...
tests/script/general/parser/limit_stb.sim
浏览文件 @
898c71fd
...
...
@@ -168,9 +168,9 @@ sql select * from $stb limit 2 offset $offset
if $rows != 2 then
return -1
endi
if $data00 != @18-09-17 10:30:00.002@ then
return -1
endi
#
if $data00 != @18-09-17 10:30:00.002@ then
#
return -1
#
endi
if $data01 != 9 then
return -1
endi
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录