Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
90602b86
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,发现更多精彩内容 >>
提交
90602b86
编写于
7月 22, 2020
作者:
V
Vitaly Baranov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make SettingsChanges a class.
上级
d152e84a
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
85 addition
and
28 deletion
+85
-28
src/Access/EnabledSettings.cpp
src/Access/EnabledSettings.cpp
+1
-0
src/Access/EnabledSettings.h
src/Access/EnabledSettings.h
+0
-1
src/Access/SettingsConstraints.cpp
src/Access/SettingsConstraints.cpp
+1
-0
src/Access/SettingsConstraints.h
src/Access/SettingsConstraints.h
+2
-1
src/Access/SettingsProfileElement.cpp
src/Access/SettingsProfileElement.cpp
+1
-0
src/Access/SettingsProfileElement.h
src/Access/SettingsProfileElement.h
+1
-2
src/Access/SettingsProfilesCache.cpp
src/Access/SettingsProfilesCache.cpp
+1
-0
src/Common/SettingsChanges.cpp
src/Common/SettingsChanges.cpp
+50
-0
src/Common/SettingsChanges.h
src/Common/SettingsChanges.h
+13
-6
src/Common/ya.make
src/Common/ya.make
+1
-0
src/Core/SettingsCollection.h
src/Core/SettingsCollection.h
+1
-1
src/Parsers/QueryWithOutputSettingsPushDownVisitor.h
src/Parsers/QueryWithOutputSettingsPushDownVisitor.h
+1
-1
src/Storages/IStorage.h
src/Storages/IStorage.h
+0
-2
src/Storages/Kafka/StorageKafka.h
src/Storages/Kafka/StorageKafka.h
+1
-0
src/Storages/MergeTree/MergeTreeData.cpp
src/Storages/MergeTree/MergeTreeData.cpp
+11
-13
src/Storages/MergeTree/MergeTreeSettings.h
src/Storages/MergeTree/MergeTreeSettings.h
+0
-1
未找到文件。
src/Access/EnabledSettings.cpp
浏览文件 @
90602b86
#include <Access/EnabledSettings.h>
#include <Common/SettingsChanges.h>
namespace
DB
...
...
src/Access/EnabledSettings.h
浏览文件 @
90602b86
...
...
@@ -2,7 +2,6 @@
#include <Core/Types.h>
#include <Core/UUID.h>
#include <Common/SettingsChanges.h>
#include <Access/SettingsConstraints.h>
#include <Access/SettingsProfileElement.h>
#include <boost/container/flat_set.hpp>
...
...
src/Access/SettingsConstraints.cpp
浏览文件 @
90602b86
#include <Access/SettingsConstraints.h>
#include <Core/Settings.h>
#include <Common/FieldVisitors.h>
#include <Common/SettingsChanges.h>
#include <IO/WriteHelpers.h>
#include <Poco/Util/AbstractConfiguration.h>
...
...
src/Access/SettingsConstraints.h
浏览文件 @
90602b86
#pragma once
#include <Core/Field.h>
#include <Common/SettingsChanges.h>
#include <common/StringRef.h>
#include <unordered_map>
...
...
@@ -18,6 +17,8 @@ namespace Util
namespace
DB
{
struct
Settings
;
struct
SettingChange
;
class
SettingsChanges
;
/** Checks if specified changes of settings are allowed or not.
* If the changes are not allowed (i.e. violates some constraints) this class throws an exception.
...
...
src/Access/SettingsProfileElement.cpp
浏览文件 @
90602b86
...
...
@@ -4,6 +4,7 @@
#include <Access/SettingsProfile.h>
#include <Parsers/ASTSettingsProfileElement.h>
#include <Core/Settings.h>
#include <Common/SettingsChanges.h>
#include <IO/ReadHelpers.h>
#include <IO/WriteHelpers.h>
...
...
src/Access/SettingsProfileElement.h
浏览文件 @
90602b86
...
...
@@ -9,8 +9,7 @@
namespace
DB
{
struct
Settings
;
struct
SettingChange
;
using
SettingsChanges
=
std
::
vector
<
SettingChange
>
;
class
SettingsChanges
;
class
SettingsConstraints
;
class
ASTSettingsProfileElement
;
class
ASTSettingsProfileElements
;
...
...
src/Access/SettingsProfilesCache.cpp
浏览文件 @
90602b86
...
...
@@ -2,6 +2,7 @@
#include <Access/AccessControlManager.h>
#include <Access/SettingsProfile.h>
#include <Core/Settings.h>
#include <Common/SettingsChanges.h>
#include <Common/quoteString.h>
#include <boost/range/adaptor/map.hpp>
#include <boost/range/algorithm_ext/push_back.hpp>
...
...
src/Common/SettingsChanges.cpp
0 → 100644
浏览文件 @
90602b86
#include <Common/SettingsChanges.h>
namespace
DB
{
namespace
{
SettingChange
*
find
(
SettingsChanges
&
changes
,
const
std
::
string_view
&
name
)
{
auto
it
=
std
::
find_if
(
changes
.
begin
(),
changes
.
end
(),
[
&
name
](
const
SettingChange
&
change
)
{
return
change
.
name
==
name
;
});
if
(
it
==
changes
.
end
())
return
nullptr
;
return
&*
it
;
}
const
SettingChange
*
find
(
const
SettingsChanges
&
changes
,
const
std
::
string_view
&
name
)
{
auto
it
=
std
::
find_if
(
changes
.
begin
(),
changes
.
end
(),
[
&
name
](
const
SettingChange
&
change
)
{
return
change
.
name
==
name
;
});
if
(
it
==
changes
.
end
())
return
nullptr
;
return
&*
it
;
}
}
bool
SettingsChanges
::
tryGet
(
const
std
::
string_view
&
name
,
Field
&
out_value
)
const
{
const
auto
*
change
=
find
(
*
this
,
name
);
if
(
!
change
)
return
false
;
out_value
=
change
->
value
;
return
true
;
}
const
Field
*
SettingsChanges
::
tryGet
(
const
std
::
string_view
&
name
)
const
{
const
auto
*
change
=
find
(
*
this
,
name
);
if
(
!
change
)
return
nullptr
;
return
&
change
->
value
;
}
Field
*
SettingsChanges
::
tryGet
(
const
std
::
string_view
&
name
)
{
auto
*
change
=
find
(
*
this
,
name
);
if
(
!
change
)
return
nullptr
;
return
&
change
->
value
;
}
}
src/Common/SettingsChanges.h
浏览文件 @
90602b86
...
...
@@ -5,21 +5,28 @@
namespace
DB
{
struct
SettingChange
{
String
name
;
Field
value
;
SettingChange
()
{}
SettingChange
(
const
String
&
name_
,
const
Field
value_
)
:
name
(
name_
)
,
value
(
value_
)
{}
SettingChange
(
)
{}
SettingChange
(
const
std
::
string_view
&
name_
,
const
Field
&
value_
)
:
name
(
name_
),
value
(
value_
)
{}
SettingChange
(
const
std
::
string_view
&
name_
,
Field
&&
value_
)
:
name
(
name_
),
value
(
std
::
move
(
value_
)
)
{}
friend
bool
operator
==
(
const
SettingChange
&
lhs
,
const
SettingChange
&
rhs
)
{
return
(
lhs
.
name
==
rhs
.
name
)
&&
(
lhs
.
value
==
rhs
.
value
);
}
friend
bool
operator
!=
(
const
SettingChange
&
lhs
,
const
SettingChange
&
rhs
)
{
return
!
(
lhs
==
rhs
);
}
};
using
SettingsChanges
=
std
::
vector
<
SettingChange
>
;
class
SettingsChanges
:
public
std
::
vector
<
SettingChange
>
{
public:
using
std
::
vector
<
SettingChange
>::
vector
;
bool
tryGet
(
const
std
::
string_view
&
name
,
Field
&
out_value
)
const
;
const
Field
*
tryGet
(
const
std
::
string_view
&
name
)
const
;
Field
*
tryGet
(
const
std
::
string_view
&
name
);
};
}
src/Common/ya.make
浏览文件 @
90602b86
...
...
@@ -75,6 +75,7 @@ SRCS(
RWLock.cpp
SensitiveDataMasker.cpp
setThreadName.cpp
SettingsChanges.cpp
SharedLibrary.cpp
ShellCommand.cpp
StackTrace.cpp
...
...
src/Core/SettingsCollection.h
浏览文件 @
90602b86
...
...
@@ -14,7 +14,7 @@ namespace DB
class
Field
;
struct
SettingChange
;
using
SettingsChanges
=
std
::
vector
<
SettingChange
>
;
class
SettingsChanges
;
class
ReadBuffer
;
class
WriteBuffer
;
enum
class
SettingsBinaryFormat
;
...
...
src/Parsers/QueryWithOutputSettingsPushDownVisitor.h
浏览文件 @
90602b86
...
...
@@ -8,7 +8,7 @@ namespace DB
class
ASTSelectQuery
;
struct
SettingChange
;
using
SettingsChanges
=
std
::
vector
<
SettingChange
>
;
class
SettingsChanges
;
/// Pushdown SETTINGS clause that goes after FORMAT to the SELECT query:
/// (since settings after FORMAT parsed separatelly not in the ParserSelectQuery but in ParserQueryWithOutput)
...
...
src/Storages/IStorage.h
浏览文件 @
90602b86
...
...
@@ -37,8 +37,6 @@ using StorageActionBlockType = size_t;
class
ASTCreateQuery
;
struct
Settings
;
struct
SettingChange
;
using
SettingsChanges
=
std
::
vector
<
SettingChange
>
;
class
AlterCommands
;
class
MutationCommands
;
...
...
src/Storages/Kafka/StorageKafka.h
浏览文件 @
90602b86
...
...
@@ -5,6 +5,7 @@
#include <Storages/Kafka/Buffer_fwd.h>
#include <Storages/Kafka/KafkaSettings.h>
#include <Interpreters/Context.h>
#include <Common/SettingsChanges.h>
#include <Poco/Semaphore.h>
#include <ext/shared_ptr_helper.h>
...
...
src/Storages/MergeTree/MergeTreeData.cpp
浏览文件 @
90602b86
...
...
@@ -1472,24 +1472,22 @@ void MergeTreeData::checkAlterIsPossible(const AlterCommands & commands, const S
const
auto
&
new_changes
=
new_metadata
.
settings_changes
->
as
<
const
ASTSetQuery
&>
().
changes
;
for
(
const
auto
&
changed_setting
:
new_changes
)
{
if
(
MergeTreeSettings
::
findIndex
(
changed_setting
.
name
)
==
MergeTreeSettings
::
npos
)
throw
Exception
{
"Storage '"
+
getName
()
+
"' doesn't have setting '"
+
changed_setting
.
name
+
"'"
,
const
auto
&
setting_name
=
changed_setting
.
name
;
const
auto
&
new_value
=
changed_setting
.
value
;
if
(
MergeTreeSettings
::
findIndex
(
setting_name
)
==
MergeTreeSettings
::
npos
)
throw
Exception
{
"Storage '"
+
getName
()
+
"' doesn't have setting '"
+
setting_name
+
"'"
,
ErrorCodes
::
UNKNOWN_SETTING
};
auto
comparator
=
[
&
changed_setting
](
const
auto
&
change
)
{
return
change
.
name
==
changed_setting
.
name
;
}
;
const
Field
*
current_value
=
current_changes
.
tryGet
(
setting_name
)
;
auto
current_setting_it
=
std
::
find_if
(
current_changes
.
begin
(),
current_changes
.
end
(),
comparator
);
if
((
current_setting_it
==
current_changes
.
end
()
||
*
current_setting_it
!=
changed_setting
)
&&
MergeTreeSettings
::
isReadonlySetting
(
changed_setting
.
name
))
if
((
!
current_value
||
*
current_value
!=
new_value
)
&&
MergeTreeSettings
::
isReadonlySetting
(
setting_name
))
{
throw
Exception
{
"Setting '"
+
changed_setting
.
name
+
"' is readonly for storage '"
+
getName
()
+
"'"
,
throw
Exception
{
"Setting '"
+
setting_
name
+
"' is readonly for storage '"
+
getName
()
+
"'"
,
ErrorCodes
::
READONLY_SETTING
};
}
if
(
current_setting_it
==
current_changes
.
end
()
&&
MergeTreeSettings
::
isPartFormatSetting
(
changed_setting
.
name
))
if
(
!
current_value
&&
MergeTreeSettings
::
isPartFormatSetting
(
setting_name
))
{
MergeTreeSettings
copy
=
*
getSettings
();
copy
.
applyChange
(
changed_setting
);
...
...
@@ -1498,8 +1496,8 @@ void MergeTreeData::checkAlterIsPossible(const AlterCommands & commands, const S
throw
Exception
(
"Can't change settings. Reason: "
+
reason
,
ErrorCodes
::
NOT_IMPLEMENTED
);
}
if
(
changed_setting
.
name
==
"storage_policy"
)
checkStoragePolicy
(
global_context
.
getStoragePolicy
(
changed_setting
.
value
.
safeGet
<
String
>
()));
if
(
setting_
name
==
"storage_policy"
)
checkStoragePolicy
(
global_context
.
getStoragePolicy
(
new_
value
.
safeGet
<
String
>
()));
}
}
...
...
src/Storages/MergeTree/MergeTreeSettings.h
浏览文件 @
90602b86
...
...
@@ -2,7 +2,6 @@
#include <Core/Defines.h>
#include <Core/SettingsCollection.h>
#include <Common/SettingsChanges.h>
namespace
Poco
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录