Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
2f13fcb4
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,发现更多精彩内容 >>
提交
2f13fcb4
编写于
10月 14, 2020
作者:
V
Vitaly Baranov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix ambiguity in parsing of settings profiles.
上级
6a58bb5c
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
48 addition
and
11 deletion
+48
-11
src/Parsers/ParserSettingsProfileElement.cpp
src/Parsers/ParserSettingsProfileElement.cpp
+26
-11
tests/queries/0_stateless/01294_create_settings_profile.reference
...eries/0_stateless/01294_create_settings_profile.reference
+7
-0
tests/queries/0_stateless/01294_create_settings_profile.sql
tests/queries/0_stateless/01294_create_settings_profile.sql
+15
-0
未找到文件。
src/Parsers/ParserSettingsProfileElement.cpp
浏览文件 @
2f13fcb4
...
...
@@ -6,6 +6,7 @@
#include <Parsers/ASTLiteral.h>
#include <Parsers/ASTIdentifier.h>
#include <Parsers/parseIdentifierOrStringLiteral.h>
#include <boost/algorithm/string/predicate.hpp>
namespace
DB
...
...
@@ -14,8 +15,16 @@ namespace
{
bool
parseProfileKeyword
(
IParserBase
::
Pos
&
pos
,
Expected
&
expected
,
bool
use_inherit_keyword
)
{
return
ParserKeyword
{
"PROFILE"
}.
ignore
(
pos
,
expected
)
||
(
use_inherit_keyword
&&
ParserKeyword
{
"INHERIT"
}.
ignore
(
pos
,
expected
));
if
(
ParserKeyword
{
"PROFILE"
}.
ignore
(
pos
,
expected
))
return
true
;
if
(
use_inherit_keyword
&&
ParserKeyword
{
"INHERIT"
}.
ignore
(
pos
,
expected
))
{
ParserKeyword
{
"PROFILE"
}.
ignore
(
pos
,
expected
);
return
true
;
}
return
false
;
}
...
...
@@ -137,6 +146,15 @@ namespace
if
(
!
has_value_or_constraint
)
return
false
;
if
(
boost
::
iequals
(
res_setting_name
,
"PROFILE"
)
&&
res_value
.
isNull
()
&&
res_min_value
.
isNull
()
&&
res_max_value
.
isNull
()
&&
res_readonly
)
{
/// Ambiguity: "profile readonly" can be treated either as a profile named "readonly" or
/// as a setting named 'profile' with the readonly constraint.
/// So we've decided to treat it as a profile named "readonly".
return
false
;
}
setting_name
=
std
::
move
(
res_setting_name
);
value
=
std
::
move
(
res_value
);
min_value
=
std
::
move
(
res_min_value
);
...
...
@@ -163,15 +181,12 @@ namespace
Field
max_value
;
std
::
optional
<
bool
>
readonly
;
if
(
parseSettingNameWithValueOrConstraints
(
pos
,
expected
,
setting_name
,
value
,
min_value
,
max_value
,
readonly
))
{
}
else
if
(
parseProfileKeyword
(
pos
,
expected
,
use_inherit_keyword
)
||
previous_element_was_parent_profile
)
{
if
(
!
parseProfileNameOrID
(
pos
,
expected
,
id_mode
,
parent_profile
))
return
false
;
}
else
bool
ok
=
parseSettingNameWithValueOrConstraints
(
pos
,
expected
,
setting_name
,
value
,
min_value
,
max_value
,
readonly
);
if
(
!
ok
&&
(
parseProfileKeyword
(
pos
,
expected
,
use_inherit_keyword
)
||
previous_element_was_parent_profile
))
ok
=
parseProfileNameOrID
(
pos
,
expected
,
id_mode
,
parent_profile
);
if
(
!
ok
)
return
false
;
result
=
std
::
make_shared
<
ASTSettingsProfileElement
>
();
...
...
tests/queries/0_stateless/01294_create_settings_profile.reference
浏览文件 @
2f13fcb4
...
...
@@ -41,6 +41,13 @@ CREATE SETTINGS PROFILE s1_01294 SETTINGS max_memory_usage = 6000000
CREATE SETTINGS PROFILE s2_01294 SETTINGS max_memory_usage = 6000000 TO r1_01294
CREATE SETTINGS PROFILE s3_01294 SETTINGS max_memory_usage = 6000000 TO r1_01294
CREATE SETTINGS PROFILE s4_01294 TO r1_01294
-- readonly ambiguity
CREATE SETTINGS PROFILE s1_01294 SETTINGS readonly = 1
CREATE SETTINGS PROFILE s2_01294 SETTINGS readonly READONLY
CREATE SETTINGS PROFILE s3_01294 SETTINGS INHERIT readonly
CREATE SETTINGS PROFILE s4_01294 SETTINGS INHERIT readonly, INHERIT readonly
CREATE SETTINGS PROFILE s5_01294 SETTINGS INHERIT readonly, readonly = 1
CREATE SETTINGS PROFILE s6_01294 SETTINGS INHERIT readonly, readonly READONLY
-- system.settings_profiles
s1_01294 local directory 0 0 [] []
s2_01294 local directory 1 0 ['r1_01294'] []
...
...
tests/queries/0_stateless/01294_create_settings_profile.sql
浏览文件 @
2f13fcb4
...
...
@@ -87,6 +87,21 @@ ALTER PROFILE s2_01294, s3_01294, s4_01294 TO r1_01294;
SHOW
CREATE
PROFILE
s1_01294
,
s2_01294
,
s3_01294
,
s4_01294
;
DROP
PROFILE
s1_01294
,
s2_01294
,
s3_01294
,
s4_01294
;
SELECT
'-- readonly ambiguity'
;
CREATE
PROFILE
s1_01294
SETTINGS
readonly
=
1
;
CREATE
PROFILE
s2_01294
SETTINGS
readonly
readonly
;
CREATE
PROFILE
s3_01294
SETTINGS
profile
readonly
;
CREATE
PROFILE
s4_01294
SETTINGS
profile
readonly
,
readonly
;
CREATE
PROFILE
s5_01294
SETTINGS
profile
readonly
,
readonly
=
1
;
CREATE
PROFILE
s6_01294
SETTINGS
profile
readonly
,
readonly
readonly
;
SHOW
CREATE
PROFILE
s1_01294
;
SHOW
CREATE
PROFILE
s2_01294
;
SHOW
CREATE
PROFILE
s3_01294
;
SHOW
CREATE
PROFILE
s4_01294
;
SHOW
CREATE
PROFILE
s5_01294
;
SHOW
CREATE
PROFILE
s6_01294
;
DROP
PROFILE
s1_01294
,
s2_01294
,
s3_01294
,
s4_01294
,
s5_01294
,
s6_01294
;
SELECT
'-- system.settings_profiles'
;
CREATE
PROFILE
s1_01294
;
CREATE
PROFILE
s2_01294
SETTINGS
readonly
=
0
TO
r1_01294
;;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录