Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
88de1b05
C
ClickHouse
项目概览
2dot5
/
ClickHouse
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
ClickHouse
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
88de1b05
编写于
11月 16, 2020
作者:
T
tavplubix
提交者:
GitHub
11月 16, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #16048 from ClickHouse/materialized-view-check-stack-size
Fix possible stack overflow in materialized views.
上级
11f56186
5c6191f7
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
39 addition
and
0 deletion
+39
-0
src/DataStreams/PushingToViewsBlockOutputStream.cpp
src/DataStreams/PushingToViewsBlockOutputStream.cpp
+3
-0
src/Storages/StorageMaterializedView.cpp
src/Storages/StorageMaterializedView.cpp
+8
-0
tests/queries/0_stateless/01527_materialized_view_stack_overflow.reference
...tateless/01527_materialized_view_stack_overflow.reference
+0
-0
tests/queries/0_stateless/01527_materialized_view_stack_overflow.sql
...es/0_stateless/01527_materialized_view_stack_overflow.sql
+28
-0
未找到文件。
src/DataStreams/PushingToViewsBlockOutputStream.cpp
浏览文件 @
88de1b05
...
...
@@ -10,6 +10,7 @@
#include <Common/CurrentThread.h>
#include <Common/setThreadName.h>
#include <Common/ThreadPool.h>
#include <Common/checkStackSize.h>
#include <Storages/MergeTree/ReplicatedMergeTreeBlockOutputStream.h>
#include <Storages/StorageValues.h>
#include <Storages/LiveView/StorageLiveView.h>
...
...
@@ -29,6 +30,8 @@ PushingToViewsBlockOutputStream::PushingToViewsBlockOutputStream(
,
context
(
context_
)
,
query_ptr
(
query_ptr_
)
{
checkStackSize
();
/** TODO This is a very important line. At any insertion into the table one of streams should own lock.
* Although now any insertion into the table is done via PushingToViewsBlockOutputStream,
* but it's clear that here is not the best place for this functionality.
...
...
src/Storages/StorageMaterializedView.cpp
浏览文件 @
88de1b05
...
...
@@ -21,6 +21,7 @@
#include <Storages/SelectQueryDescription.h>
#include <Common/typeid_cast.h>
#include <Common/checkStackSize.h>
#include <Processors/Sources/SourceFromInputStream.h>
#include <Processors/QueryPlan/SettingQuotaAndLimitsStep.h>
...
...
@@ -30,6 +31,7 @@ namespace DB
namespace
ErrorCodes
{
extern
const
int
BAD_ARGUMENTS
;
extern
const
int
NOT_IMPLEMENTED
;
extern
const
int
INCORRECT_QUERY
;
extern
const
int
QUERY_IS_NOT_SUPPORTED_IN_MATERIALIZED_VIEW
;
...
...
@@ -72,7 +74,11 @@ StorageMaterializedView::StorageMaterializedView(
setInMemoryMetadata
(
storage_metadata
);
if
(
!
has_inner_table
)
{
if
(
query
.
to_table_id
.
database_name
==
table_id_
.
database_name
&&
query
.
to_table_id
.
table_name
==
table_id_
.
table_name
)
throw
Exception
(
ErrorCodes
::
BAD_ARGUMENTS
,
"Materialized view {} cannot point to itself"
,
table_id_
.
getFullTableName
());
target_table_id
=
query
.
to_table_id
;
}
else
if
(
attach_
)
{
/// If there is an ATTACH request, then the internal table must already be created.
...
...
@@ -351,11 +357,13 @@ void StorageMaterializedView::shutdown()
StoragePtr
StorageMaterializedView
::
getTargetTable
()
const
{
checkStackSize
();
return
DatabaseCatalog
::
instance
().
getTable
(
target_table_id
,
global_context
);
}
StoragePtr
StorageMaterializedView
::
tryGetTargetTable
()
const
{
checkStackSize
();
return
DatabaseCatalog
::
instance
().
tryGetTable
(
target_table_id
,
global_context
);
}
...
...
tests/queries/0_stateless/01527_materialized_view_stack_overflow.reference
0 → 100644
浏览文件 @
88de1b05
tests/queries/0_stateless/01527_materialized_view_stack_overflow.sql
0 → 100644
浏览文件 @
88de1b05
DROP
TABLE
IF
EXISTS
t
;
DROP
TABLE
IF
EXISTS
v
;
CREATE
TABLE
t
(
c
String
)
ENGINE
=
Memory
;
CREATE
MATERIALIZED
VIEW
v
to
v
AS
SELECT
c
FROM
t
;
-- { serverError 36 }
CREATE
MATERIALIZED
VIEW
v
to
t
AS
SELECT
*
FROM
v
;
-- { serverError 60 }
DROP
TABLE
IF
EXISTS
t1
;
DROP
TABLE
IF
EXISTS
t2
;
DROP
TABLE
IF
EXISTS
v1
;
DROP
TABLE
IF
EXISTS
v2
;
CREATE
TABLE
t1
(
c
String
)
ENGINE
=
Memory
;
CREATE
TABLE
t2
(
c
String
)
ENGINE
=
Memory
;
CREATE
MATERIALIZED
VIEW
v1
to
t1
AS
SELECT
*
FROM
t2
;
CREATE
MATERIALIZED
VIEW
v2
to
t2
AS
SELECT
*
FROM
t1
;
INSERT
INTO
t1
VALUES
(
'Hello'
);
-- { serverError 306 }
INSERT
INTO
t2
VALUES
(
'World'
);
-- { serverError 306 }
DROP
TABLE
IF
EXISTS
t
;
DROP
TABLE
IF
EXISTS
v
;
DROP
TABLE
IF
EXISTS
t1
;
DROP
TABLE
IF
EXISTS
t2
;
DROP
TABLE
IF
EXISTS
v1
;
DROP
TABLE
IF
EXISTS
v2
;
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录