Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c638f9d5
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看板
未验证
提交
c638f9d5
编写于
7月 14, 2022
作者:
H
Haojun Liao
提交者:
GitHub
7月 14, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #14889 from taosdata/feature/3_liaohj
fix(query):fix invalid write in sample query processing.
上级
0bd2c7f1
6fd4684a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
29 addition
and
13 deletion
+29
-13
source/common/src/tdatablock.c
source/common/src/tdatablock.c
+4
-1
source/libs/executor/src/tfill.c
source/libs/executor/src/tfill.c
+12
-8
source/libs/function/src/builtinsimpl.c
source/libs/function/src/builtinsimpl.c
+13
-4
未找到文件。
source/common/src/tdatablock.c
浏览文件 @
c638f9d5
...
...
@@ -542,8 +542,10 @@ int32_t blockDataToBuf(char* buf, const SSDataBlock* pBlock) {
}
int32_t
blockDataFromBuf
(
SSDataBlock
*
pBlock
,
const
char
*
buf
)
{
pBlock
->
info
.
rows
=
*
(
int32_t
*
)
buf
;
int32_t
numOfRows
=
*
(
int32_t
*
)
buf
;
blockDataEnsureCapacity
(
pBlock
,
numOfRows
);
pBlock
->
info
.
rows
=
numOfRows
;
size_t
numOfCols
=
taosArrayGetSize
(
pBlock
->
pDataBlock
);
const
char
*
pStart
=
buf
+
sizeof
(
uint32_t
);
...
...
@@ -589,6 +591,7 @@ int32_t blockDataFromBuf(SSDataBlock* pBlock, const char* buf) {
return
TSDB_CODE_SUCCESS
;
}
// todo remove this
int32_t
blockDataFromBuf1
(
SSDataBlock
*
pBlock
,
const
char
*
buf
,
size_t
capacity
)
{
pBlock
->
info
.
rows
=
*
(
int32_t
*
)
buf
;
pBlock
->
info
.
groupId
=
*
(
uint64_t
*
)(
buf
+
sizeof
(
int32_t
));
...
...
source/libs/executor/src/tfill.c
浏览文件 @
c638f9d5
...
...
@@ -53,8 +53,8 @@ static void setNullRow(SSDataBlock* pBlock, int64_t ts, int32_t rowIndex) {
// the first are always the timestamp column, so start from the second column.
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pBlock
->
pDataBlock
);
++
i
)
{
SColumnInfoData
*
p
=
taosArrayGet
(
pBlock
->
pDataBlock
,
i
);
if
(
p
->
info
.
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
colDataAppend
(
p
,
rowIndex
,
(
const
char
*
)
&
ts
,
false
);
if
(
p
->
info
.
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
// handle timestamp
colDataAppend
(
p
,
rowIndex
,
(
const
char
*
)
&
ts
,
false
);
}
else
{
colDataAppendNULL
(
p
,
rowIndex
);
}
...
...
@@ -83,15 +83,20 @@ static void doFillOneRow(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSDataBlock*
if
(
pFillInfo
->
type
==
TSDB_FILL_PREV
)
{
SArray
*
p
=
FILL_IS_ASC_FILL
(
pFillInfo
)
?
pFillInfo
->
prev
:
pFillInfo
->
next
;
for
(
int32_t
i
=
1
;
i
<
pFillInfo
->
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pFillInfo
->
numOfCols
;
++
i
)
{
SFillColInfo
*
pCol
=
&
pFillInfo
->
pFillCol
[
i
];
if
(
TSDB_COL_IS_TAG
(
pCol
->
flag
))
{
continue
;
}
SGroupKeys
*
pKey
=
taosArrayGet
(
p
,
i
);
SColumnInfoData
*
pDstColInfoData
=
taosArrayGet
(
pBlock
->
pDataBlock
,
GET_DEST_SLOT_ID
(
pCol
));
doSetVal
(
pDstColInfoData
,
index
,
pKey
);
if
(
pDstColInfoData
->
info
.
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
colDataAppend
(
pDstColInfoData
,
index
,
(
const
char
*
)
&
ts
,
false
);
}
else
{
SGroupKeys
*
pKey
=
taosArrayGet
(
p
,
i
);
doSetVal
(
pDstColInfoData
,
index
,
pKey
);
}
}
}
else
if
(
pFillInfo
->
type
==
TSDB_FILL_NEXT
)
{
SArray
*
p
=
FILL_IS_ASC_FILL
(
pFillInfo
)
?
pFillInfo
->
next
:
pFillInfo
->
prev
;
...
...
@@ -264,9 +269,8 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t
assert
(
pFillInfo
->
currentKey
==
ts
);
if
(
pFillInfo
->
type
==
TSDB_FILL_NEXT
&&
(
pFillInfo
->
index
+
1
)
<
pFillInfo
->
numOfRows
)
{
++
pFillInfo
->
index
;
copyCurrentRowIntoBuf
(
pFillInfo
,
pFillInfo
->
index
,
pFillInfo
->
next
);
--
pFillInfo
->
index
;
int32_t
nextRowIndex
=
pFillInfo
->
index
+
1
;
copyCurrentRowIntoBuf
(
pFillInfo
,
nextRowIndex
,
pFillInfo
->
next
);
}
// assign rows to dst buffer
...
...
source/libs/function/src/builtinsimpl.c
浏览文件 @
c638f9d5
...
...
@@ -3461,9 +3461,16 @@ void doAddIntoResult(SqlFunctionCtx* pCtx, void* pData, int32_t rowIndex, SSData
}
}
/*
* +------------------------------------+--------------+--------------+
* | null bitmap | | |
* |(n columns, one bit for each column)| src column #1| src column #2|
* +------------------------------------+--------------+--------------+
*/
void
saveTupleData
(
SqlFunctionCtx
*
pCtx
,
int32_t
rowIndex
,
const
SSDataBlock
*
pSrcBlock
,
STuplePos
*
pPos
)
{
SFilePage
*
pPage
=
NULL
;
// todo refactor: move away
int32_t
completeRowSize
=
pCtx
->
subsidiaries
.
num
*
sizeof
(
bool
);
for
(
int32_t
j
=
0
;
j
<
pCtx
->
subsidiaries
.
num
;
++
j
)
{
SqlFunctionCtx
*
pc
=
pCtx
->
subsidiaries
.
pCtx
[
j
];
...
...
@@ -3476,12 +3483,15 @@ void saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pS
}
else
{
pPage
=
getBufPage
(
pCtx
->
pBuf
,
pCtx
->
curBufPage
);
if
(
pPage
->
num
+
completeRowSize
>
getBufPageSize
(
pCtx
->
pBuf
))
{
// current page is all used, let's prepare a new buffer page
releaseBufPage
(
pCtx
->
pBuf
,
pPage
);
pPage
=
getNewBufPage
(
pCtx
->
pBuf
,
0
,
&
pCtx
->
curBufPage
);
pPage
->
num
=
sizeof
(
SFilePage
);
}
}
pPos
->
pageId
=
pCtx
->
curBufPage
;
pPos
->
offset
=
pPage
->
num
;
// keep the current row data, extract method
int32_t
offset
=
0
;
...
...
@@ -3509,7 +3519,6 @@ void saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pS
offset
+=
pCol
->
info
.
bytes
;
}
pPos
->
offset
=
pPage
->
num
;
pPage
->
num
+=
completeRowSize
;
setBufPageDirty
(
pPage
,
true
);
...
...
@@ -4839,7 +4848,7 @@ static void doReservoirSample(SqlFunctionCtx* pCtx, SSampleInfo* pInfo, char* da
if
(
pInfo
->
numSampled
<
pInfo
->
samples
)
{
sampleAssignResult
(
pInfo
,
data
,
pInfo
->
numSampled
);
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
saveTupleData
(
pCtx
,
index
,
pCtx
->
pSrcBlock
,
pInfo
->
tuplePos
+
pInfo
->
numSampled
*
sizeof
(
STuplePos
)
);
saveTupleData
(
pCtx
,
index
,
pCtx
->
pSrcBlock
,
&
pInfo
->
tuplePos
[
pInfo
->
numSampled
]
);
}
pInfo
->
numSampled
++
;
}
else
{
...
...
@@ -4847,7 +4856,7 @@ static void doReservoirSample(SqlFunctionCtx* pCtx, SSampleInfo* pInfo, char* da
if
(
j
<
pInfo
->
samples
)
{
sampleAssignResult
(
pInfo
,
data
,
j
);
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
copyTupleData
(
pCtx
,
index
,
pCtx
->
pSrcBlock
,
pInfo
->
tuplePos
+
j
*
sizeof
(
STuplePos
)
);
copyTupleData
(
pCtx
,
index
,
pCtx
->
pSrcBlock
,
&
pInfo
->
tuplePos
[
j
]
);
}
}
}
...
...
@@ -4885,7 +4894,7 @@ int32_t sampleFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
int32_t
currentRow
=
pBlock
->
info
.
rows
;
for
(
int32_t
i
=
0
;
i
<
pInfo
->
numSampled
;
++
i
)
{
colDataAppend
(
pCol
,
currentRow
+
i
,
pInfo
->
data
+
i
*
pInfo
->
colBytes
,
false
);
setSelectivityValue
(
pCtx
,
pBlock
,
pInfo
->
tuplePos
+
i
*
sizeof
(
STuplePos
)
,
currentRow
+
i
);
setSelectivityValue
(
pCtx
,
pBlock
,
&
pInfo
->
tuplePos
[
i
]
,
currentRow
+
i
);
}
return
pInfo
->
numSampled
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录