Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
b49be4c7
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 搜索 >>
提交
b49be4c7
编写于
6月 01, 2020
作者:
A
alesapin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Better names
上级
254d55f2
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
31 addition
and
31 deletion
+31
-31
src/Databases/DatabaseOrdinary.cpp
src/Databases/DatabaseOrdinary.cpp
+1
-1
src/Storages/AlterCommands.cpp
src/Storages/AlterCommands.cpp
+11
-11
src/Storages/IStorage.cpp
src/Storages/IStorage.cpp
+4
-4
src/Storages/IStorage.h
src/Storages/IStorage.h
+2
-2
src/Storages/MergeTree/MergeTreeData.cpp
src/Storages/MergeTree/MergeTreeData.cpp
+4
-4
src/Storages/StorageInMemoryMetadata.cpp
src/Storages/StorageInMemoryMetadata.cpp
+4
-4
src/Storages/StorageInMemoryMetadata.h
src/Storages/StorageInMemoryMetadata.h
+2
-2
src/Storages/StorageReplicatedMergeTree.cpp
src/Storages/StorageReplicatedMergeTree.cpp
+3
-3
未找到文件。
src/Databases/DatabaseOrdinary.cpp
浏览文件 @
b49be4c7
...
...
@@ -246,7 +246,7 @@ void DatabaseOrdinary::alterTable(
auto
&
ast_create_query
=
ast
->
as
<
ASTCreateQuery
&>
();
ASTPtr
new_columns
=
InterpreterCreateQuery
::
formatColumns
(
metadata
.
columns
);
ASTPtr
new_indices
=
InterpreterCreateQuery
::
formatIndices
(
metadata
.
indices
);
ASTPtr
new_indices
=
InterpreterCreateQuery
::
formatIndices
(
metadata
.
secondary_
indices
);
ASTPtr
new_constraints
=
InterpreterCreateQuery
::
formatConstraints
(
metadata
.
constraints
);
ast_create_query
.
columns_list
->
replace
(
ast_create_query
.
columns_list
->
columns
,
new_columns
);
...
...
src/Storages/AlterCommands.cpp
浏览文件 @
b49be4c7
...
...
@@ -332,8 +332,8 @@ void AlterCommand::apply(StorageInMemoryMetadata & metadata, const Context & con
else
if
(
type
==
ADD_INDEX
)
{
if
(
std
::
any_of
(
metadata
.
indices
.
cbegin
(),
metadata
.
indices
.
cend
(),
metadata
.
secondary_
indices
.
cbegin
(),
metadata
.
secondary_
indices
.
cend
(),
[
this
](
const
auto
&
index
)
{
return
index
.
name
==
index_name
;
...
...
@@ -346,47 +346,47 @@ void AlterCommand::apply(StorageInMemoryMetadata & metadata, const Context & con
ErrorCodes
::
ILLEGAL_COLUMN
};
}
auto
insert_it
=
metadata
.
indices
.
end
();
auto
insert_it
=
metadata
.
secondary_
indices
.
end
();
if
(
!
after_index_name
.
empty
())
{
insert_it
=
std
::
find_if
(
metadata
.
indices
.
begin
(),
metadata
.
indices
.
end
(),
metadata
.
secondary_
indices
.
begin
(),
metadata
.
secondary_
indices
.
end
(),
[
this
](
const
auto
&
index
)
{
return
index
.
name
==
after_index_name
;
});
if
(
insert_it
==
metadata
.
indices
.
end
())
if
(
insert_it
==
metadata
.
secondary_
indices
.
end
())
throw
Exception
(
"Wrong index name. Cannot find index "
+
backQuote
(
after_index_name
)
+
" to insert after."
,
ErrorCodes
::
BAD_ARGUMENTS
);
++
insert_it
;
}
metadata
.
indices
.
emplace
(
insert_it
,
IndexDescription
::
getIndexFromAST
(
index_decl
,
metadata
.
columns
,
context
));
metadata
.
secondary_
indices
.
emplace
(
insert_it
,
IndexDescription
::
getIndexFromAST
(
index_decl
,
metadata
.
columns
,
context
));
}
else
if
(
type
==
DROP_INDEX
)
{
if
(
!
partition
&&
!
clear
)
{
auto
erase_it
=
std
::
find_if
(
metadata
.
indices
.
begin
(),
metadata
.
indices
.
end
(),
metadata
.
secondary_
indices
.
begin
(),
metadata
.
secondary_
indices
.
end
(),
[
this
](
const
auto
&
index
)
{
return
index
.
name
==
index_name
;
});
if
(
erase_it
==
metadata
.
indices
.
end
())
if
(
erase_it
==
metadata
.
secondary_
indices
.
end
())
{
if
(
if_exists
)
return
;
throw
Exception
(
"Wrong index name. Cannot find index "
+
backQuote
(
index_name
)
+
" to drop."
,
ErrorCodes
::
BAD_ARGUMENTS
);
}
metadata
.
indices
.
erase
(
erase_it
);
metadata
.
secondary_
indices
.
erase
(
erase_it
);
}
}
else
if
(
type
==
ADD_CONSTRAINT
)
...
...
src/Storages/IStorage.cpp
浏览文件 @
b49be4c7
...
...
@@ -39,13 +39,13 @@ const ColumnsDescription & IStorage::getColumns() const
const
IndicesDescription
&
IStorage
::
getSecondaryIndices
()
const
{
return
indices
;
return
secondary_
indices
;
}
bool
IStorage
::
hasSecondaryIndices
()
const
{
return
!
indices
.
empty
();
return
!
secondary_
indices
.
empty
();
}
const
ConstraintsDescription
&
IStorage
::
getConstraints
()
const
...
...
@@ -295,9 +295,9 @@ void IStorage::setColumns(ColumnsDescription columns_)
columns
=
std
::
move
(
columns_
);
}
void
IStorage
::
setSecondaryIndices
(
IndicesDescription
indices_
)
void
IStorage
::
setSecondaryIndices
(
IndicesDescription
secondary_
indices_
)
{
indices
=
std
::
move
(
indices_
);
secondary_indices
=
std
::
move
(
secondary_
indices_
);
}
void
IStorage
::
setConstraints
(
ConstraintsDescription
constraints_
)
...
...
src/Storages/IStorage.h
浏览文件 @
b49be4c7
...
...
@@ -144,7 +144,7 @@ public: /// thread-unsafe part. lockStructure must be acquired
const
ColumnsDescription
&
getColumns
()
const
;
/// returns combined set of columns
void
setColumns
(
ColumnsDescription
columns_
);
/// sets only real columns, possibly overwrites virtual ones.
void
setSecondaryIndices
(
IndicesDescription
indices_
);
void
setSecondaryIndices
(
IndicesDescription
secondary_
indices_
);
const
IndicesDescription
&
getSecondaryIndices
()
const
;
/// Has at least one non primary index
bool
hasSecondaryIndices
()
const
;
...
...
@@ -200,7 +200,7 @@ private:
mutable
std
::
mutex
id_mutex
;
ColumnsDescription
columns
;
IndicesDescription
indices
;
IndicesDescription
secondary_
indices
;
ConstraintsDescription
constraints
;
StorageMetadataKeyField
partition_key
;
...
...
src/Storages/MergeTree/MergeTreeData.cpp
浏览文件 @
b49be4c7
...
...
@@ -425,11 +425,11 @@ void MergeTreeData::setProperties(const StorageInMemoryMetadata & metadata, bool
ASTPtr
skip_indices_with_primary_key_expr_list
=
new_primary_key_expr_list
->
clone
();
ASTPtr
skip_indices_with_sorting_key_expr_list
=
new_sorting_key_expr_list
->
clone
();
if
(
!
metadata
.
indices
.
empty
())
if
(
!
metadata
.
secondary_
indices
.
empty
())
{
std
::
set
<
String
>
indices_names
;
for
(
const
auto
&
index
:
metadata
.
indices
)
for
(
const
auto
&
index
:
metadata
.
secondary_
indices
)
{
MergeTreeIndexFactory
::
instance
().
validate
(
index
,
attach
);
...
...
@@ -480,7 +480,7 @@ void MergeTreeData::setProperties(const StorageInMemoryMetadata & metadata, bool
new_primary_key
.
data_types
=
std
::
move
(
new_primary_key_data_types
);
setPrimaryKey
(
new_primary_key
);
setSecondaryIndices
(
metadata
.
indices
);
setSecondaryIndices
(
metadata
.
secondary_
indices
);
setConstraints
(
metadata
.
constraints
);
...
...
@@ -1357,7 +1357,7 @@ void MergeTreeData::checkAlterIsPossible(const AlterCommands & commands, const S
/// Check that needed transformations can be applied to the list of columns without considering type conversions.
StorageInMemoryMetadata
metadata
=
getInMemoryMetadata
();
commands
.
apply
(
metadata
,
global_context
);
if
(
getSecondaryIndices
().
empty
()
&&
!
metadata
.
indices
.
empty
()
&&
if
(
getSecondaryIndices
().
empty
()
&&
!
metadata
.
secondary_
indices
.
empty
()
&&
!
settings
.
allow_experimental_data_skipping_indices
)
throw
Exception
(
"You must set the setting `allow_experimental_data_skipping_indices` to 1 "
\
"before using data skipping indices."
,
ErrorCodes
::
BAD_ARGUMENTS
);
...
...
src/Storages/StorageInMemoryMetadata.cpp
浏览文件 @
b49be4c7
...
...
@@ -13,17 +13,17 @@ namespace DB
StorageInMemoryMetadata
::
StorageInMemoryMetadata
(
const
ColumnsDescription
&
columns_
,
const
IndicesDescription
&
indices_
,
const
IndicesDescription
&
secondary_
indices_
,
const
ConstraintsDescription
&
constraints_
)
:
columns
(
columns_
)
,
indices
(
indices_
)
,
secondary_indices
(
secondary_
indices_
)
,
constraints
(
constraints_
)
{
}
StorageInMemoryMetadata
::
StorageInMemoryMetadata
(
const
StorageInMemoryMetadata
&
other
)
:
columns
(
other
.
columns
)
,
indices
(
other
.
indices
)
,
secondary_indices
(
other
.
secondary_
indices
)
,
constraints
(
other
.
constraints
)
{
if
(
other
.
partition_by_ast
)
...
...
@@ -48,7 +48,7 @@ StorageInMemoryMetadata & StorageInMemoryMetadata::operator=(const StorageInMemo
return
*
this
;
columns
=
other
.
columns
;
indices
=
other
.
indices
;
secondary_indices
=
other
.
secondary_
indices
;
constraints
=
other
.
constraints
;
if
(
other
.
partition_by_ast
)
...
...
src/Storages/StorageInMemoryMetadata.h
浏览文件 @
b49be4c7
...
...
@@ -18,7 +18,7 @@ struct StorageInMemoryMetadata
/// defaults, comments, etc. All table engines have columns.
ColumnsDescription
columns
;
/// Table indices. Currently supported for MergeTree only.
IndicesDescription
indices
;
IndicesDescription
secondary_
indices
;
/// Table constraints. Currently supported for MergeTree only.
ConstraintsDescription
constraints
;
/// PARTITION BY expression. Currently supported for MergeTree only.
...
...
@@ -39,7 +39,7 @@ struct StorageInMemoryMetadata
StorageInMemoryMetadata
(
const
StorageInMemoryMetadata
&
other
);
StorageInMemoryMetadata
()
=
default
;
StorageInMemoryMetadata
(
const
ColumnsDescription
&
columns_
,
const
IndicesDescription
&
indices_
,
const
ConstraintsDescription
&
constraints_
);
StorageInMemoryMetadata
(
const
ColumnsDescription
&
columns_
,
const
IndicesDescription
&
secondary_
indices_
,
const
ConstraintsDescription
&
constraints_
);
StorageInMemoryMetadata
&
operator
=
(
const
StorageInMemoryMetadata
&
other
);
};
...
...
src/Storages/StorageReplicatedMergeTree.cpp
浏览文件 @
b49be4c7
...
...
@@ -501,7 +501,7 @@ void StorageReplicatedMergeTree::setTableStructure(ColumnsDescription new_column
}
if
(
metadata_diff
.
skip_indices_changed
)
metadata
.
indices
=
IndicesDescription
::
parse
(
metadata_diff
.
new_skip_indices
,
new_columns
,
global_context
);
metadata
.
secondary_
indices
=
IndicesDescription
::
parse
(
metadata_diff
.
new_skip_indices
,
new_columns
,
global_context
);
if
(
metadata_diff
.
constraints_changed
)
metadata
.
constraints
=
ConstraintsDescription
::
parse
(
metadata_diff
.
new_constraints
);
...
...
@@ -3319,8 +3319,8 @@ void StorageReplicatedMergeTree::alter(
if
(
ast_to_str
(
future_metadata
.
ttl_for_table_ast
)
!=
ast_to_str
(
current_metadata
.
ttl_for_table_ast
))
future_metadata_in_zk
.
ttl_table
=
serializeAST
(
*
future_metadata
.
ttl_for_table_ast
);
String
new_indices_str
=
future_metadata
.
indices
.
toString
();
if
(
new_indices_str
!=
current_metadata
.
indices
.
toString
())
String
new_indices_str
=
future_metadata
.
secondary_
indices
.
toString
();
if
(
new_indices_str
!=
current_metadata
.
secondary_
indices
.
toString
())
future_metadata_in_zk
.
skip_indices
=
new_indices_str
;
String
new_constraints_str
=
future_metadata
.
constraints
.
toString
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录