Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
5b72cd23
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,体验更适合开发者的 AI 搜索 >>
未验证
提交
5b72cd23
编写于
2月 26, 2021
作者:
A
alesapin
提交者:
GitHub
2月 26, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #21183 from ClickHouse/fix_mutation_for_storages
Restrict mutations for engines which doesn't support them
上级
4bcaed98
653d962c
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
70 addition
and
0 deletion
+70
-0
src/Interpreters/InterpreterAlterQuery.cpp
src/Interpreters/InterpreterAlterQuery.cpp
+1
-0
src/Storages/IStorage.cpp
src/Storages/IStorage.cpp
+5
-0
src/Storages/IStorage.h
src/Storages/IStorage.h
+5
-0
src/Storages/MergeTree/MergeTreeData.cpp
src/Storages/MergeTree/MergeTreeData.cpp
+6
-0
src/Storages/MergeTree/MergeTreeData.h
src/Storages/MergeTree/MergeTreeData.h
+4
-0
src/Storages/StorageMaterializedView.cpp
src/Storages/StorageMaterializedView.cpp
+6
-0
src/Storages/StorageMaterializedView.h
src/Storages/StorageMaterializedView.h
+2
-0
src/Storages/StorageMemory.cpp
src/Storages/StorageMemory.cpp
+5
-0
src/Storages/StorageMemory.h
src/Storages/StorageMemory.h
+1
-0
src/Storages/StorageView.cpp
src/Storages/StorageView.cpp
+3
-0
tests/queries/0_stateless/01745_alter_delete_view.reference
tests/queries/0_stateless/01745_alter_delete_view.reference
+4
-0
tests/queries/0_stateless/01745_alter_delete_view.sql
tests/queries/0_stateless/01745_alter_delete_view.sql
+28
-0
未找到文件。
src/Interpreters/InterpreterAlterQuery.cpp
浏览文件 @
5b72cd23
...
...
@@ -104,6 +104,7 @@ BlockIO InterpreterAlterQuery::execute()
if
(
!
mutation_commands
.
empty
())
{
table
->
checkMutationIsPossible
(
mutation_commands
,
context
.
getSettingsRef
());
MutationsInterpreter
(
table
,
metadata_snapshot
,
mutation_commands
,
context
,
false
).
validate
();
table
->
mutate
(
mutation_commands
,
context
);
}
...
...
src/Storages/IStorage.cpp
浏览文件 @
5b72cd23
...
...
@@ -145,6 +145,11 @@ void IStorage::checkAlterIsPossible(const AlterCommands & commands, const Settin
}
}
void
IStorage
::
checkMutationIsPossible
(
const
MutationCommands
&
/*commands*/
,
const
Settings
&
/*settings*/
)
const
{
throw
Exception
(
"Table engine "
+
getName
()
+
" doesn't support mutations"
,
ErrorCodes
::
NOT_IMPLEMENTED
);
}
void
IStorage
::
checkAlterPartitionIsPossible
(
const
PartitionCommands
&
/*commands*/
,
const
StorageMetadataPtr
&
/*metadata_snapshot*/
,
const
Settings
&
/*settings*/
)
const
{
...
...
src/Storages/IStorage.h
浏览文件 @
5b72cd23
...
...
@@ -364,6 +364,11 @@ public:
*/
virtual
void
checkAlterIsPossible
(
const
AlterCommands
&
commands
,
const
Settings
&
settings
)
const
;
/**
* Checks that mutation commands can be applied to storage.
*/
virtual
void
checkMutationIsPossible
(
const
MutationCommands
&
commands
,
const
Settings
&
settings
)
const
;
/** ALTER tables with regard to its partitions.
* Should handle locks for each command on its own.
*/
...
...
src/Storages/MergeTree/MergeTreeData.cpp
浏览文件 @
5b72cd23
...
...
@@ -1670,6 +1670,12 @@ void MergeTreeData::checkAlterIsPossible(const AlterCommands & commands, const S
}
}
void
MergeTreeData
::
checkMutationIsPossible
(
const
MutationCommands
&
/*commands*/
,
const
Settings
&
/*settings*/
)
const
{
/// Some validation will be added
}
MergeTreeDataPartType
MergeTreeData
::
choosePartType
(
size_t
bytes_uncompressed
,
size_t
rows_count
)
const
{
const
auto
settings
=
getSettings
();
...
...
src/Storages/MergeTree/MergeTreeData.h
浏览文件 @
5b72cd23
...
...
@@ -519,6 +519,10 @@ public:
/// If something is wrong, throws an exception.
void
checkAlterIsPossible
(
const
AlterCommands
&
commands
,
const
Settings
&
settings
)
const
override
;
/// Checks if the Mutation can be performed.
/// (currently no additional checks: always ok)
void
checkMutationIsPossible
(
const
MutationCommands
&
commands
,
const
Settings
&
settings
)
const
override
;
/// Checks that partition name in all commands is valid
void
checkAlterPartitionIsPossible
(
const
PartitionCommands
&
commands
,
const
StorageMetadataPtr
&
metadata_snapshot
,
const
Settings
&
settings
)
const
override
;
...
...
src/Storages/StorageMaterializedView.cpp
浏览文件 @
5b72cd23
...
...
@@ -320,6 +320,12 @@ void StorageMaterializedView::checkAlterIsPossible(const AlterCommands & command
}
}
void
StorageMaterializedView
::
checkMutationIsPossible
(
const
MutationCommands
&
commands
,
const
Settings
&
settings
)
const
{
checkStatementCanBeForwarded
();
getTargetTable
()
->
checkMutationIsPossible
(
commands
,
settings
);
}
Pipe
StorageMaterializedView
::
alterPartition
(
const
StorageMetadataPtr
&
metadata_snapshot
,
const
PartitionCommands
&
commands
,
const
Context
&
context
)
{
...
...
src/Storages/StorageMaterializedView.h
浏览文件 @
5b72cd23
...
...
@@ -52,6 +52,8 @@ public:
void
alter
(
const
AlterCommands
&
params
,
const
Context
&
context
,
TableLockHolder
&
table_lock_holder
)
override
;
void
checkMutationIsPossible
(
const
MutationCommands
&
commands
,
const
Settings
&
settings
)
const
override
;
void
checkAlterIsPossible
(
const
AlterCommands
&
commands
,
const
Settings
&
settings
)
const
override
;
Pipe
alterPartition
(
const
StorageMetadataPtr
&
metadata_snapshot
,
const
PartitionCommands
&
commands
,
const
Context
&
context
)
override
;
...
...
src/Storages/StorageMemory.cpp
浏览文件 @
5b72cd23
...
...
@@ -253,6 +253,11 @@ static inline void updateBlockData(Block & old_block, const Block & new_block)
}
}
void
StorageMemory
::
checkMutationIsPossible
(
const
MutationCommands
&
/*commands*/
,
const
Settings
&
/*settings*/
)
const
{
/// Some validation will be added
}
void
StorageMemory
::
mutate
(
const
MutationCommands
&
commands
,
const
Context
&
context
)
{
std
::
lock_guard
lock
(
mutex
);
...
...
src/Storages/StorageMemory.h
浏览文件 @
5b72cd23
...
...
@@ -51,6 +51,7 @@ public:
void
drop
()
override
;
void
checkMutationIsPossible
(
const
MutationCommands
&
commands
,
const
Settings
&
settings
)
const
override
;
void
mutate
(
const
MutationCommands
&
commands
,
const
Context
&
context
)
override
;
void
truncate
(
const
ASTPtr
&
,
const
StorageMetadataPtr
&
,
const
Context
&
,
TableExclusiveLockHolder
&
)
override
;
...
...
src/Storages/StorageView.cpp
浏览文件 @
5b72cd23
...
...
@@ -105,6 +105,9 @@ void StorageView::read(
static
ASTTableExpression
*
getFirstTableExpression
(
ASTSelectQuery
&
select_query
)
{
if
(
!
select_query
.
tables
()
||
select_query
.
tables
()
->
children
.
empty
())
throw
Exception
(
"Logical error: no table expression in view select AST"
,
ErrorCodes
::
LOGICAL_ERROR
);
auto
*
select_element
=
select_query
.
tables
()
->
children
[
0
]
->
as
<
ASTTablesInSelectQueryElement
>
();
if
(
!
select_element
->
table_expression
)
...
...
tests/queries/0_stateless/01745_alter_delete_view.reference
0 → 100644
浏览文件 @
5b72cd23
1 1
2 1
1 1
2 1
tests/queries/0_stateless/01745_alter_delete_view.sql
0 → 100644
浏览文件 @
5b72cd23
DROP
VIEW
IF
EXISTS
test_view
;
DROP
TABLE
IF
EXISTS
test_table
;
CREATE
TABLE
test_table
(
f1
Int32
,
f2
Int32
,
pk
Int32
)
ENGINE
=
MergeTree
()
ORDER
BY
f1
PARTITION
BY
pk
;
CREATE
VIEW
test_view
AS
SELECT
f1
,
f2
FROM
test_table
WHERE
pk
=
2
;
INSERT
INTO
test_table
(
f1
,
f2
,
pk
)
VALUES
(
1
,
1
,
1
),
(
1
,
1
,
2
),
(
2
,
1
,
1
),
(
2
,
1
,
2
);
SELECT
*
FROM
test_view
ORDER
BY
f1
,
f2
;
ALTER
TABLE
test_view
DELETE
WHERE
pk
=
2
;
--{serverError 48}
SELECT
*
FROM
test_view
ORDER
BY
f1
,
f2
;
DROP
VIEW
IF
EXISTS
test_view
;
DROP
TABLE
IF
EXISTS
test_table
;
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录