Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
ed77e40d
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,发现更多精彩内容 >>
提交
ed77e40d
编写于
10月 01, 2018
作者:
C
CurtizJ
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix implicit macros
上级
d4de7634
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
22 addition
and
12 deletion
+22
-12
dbms/src/Common/Macros.cpp
dbms/src/Common/Macros.cpp
+12
-9
dbms/src/Common/Macros.h
dbms/src/Common/Macros.h
+4
-0
dbms/src/Storages/StorageReplicatedMergeTree.cpp
dbms/src/Storages/StorageReplicatedMergeTree.cpp
+2
-2
dbms/tests/integration/test_distributed_ddl/test.py
dbms/tests/integration/test_distributed_ddl/test.py
+4
-1
未找到文件。
dbms/src/Common/Macros.cpp
浏览文件 @
ed77e40d
...
...
@@ -56,19 +56,17 @@ String Macros::expand(const String & s, size_t level, const String & database_na
throw
Exception
(
"Unbalanced { and } in string with macros: '"
+
s
+
"'"
,
ErrorCodes
::
SYNTAX_ERROR
);
String
macro_name
=
s
.
substr
(
begin
,
end
-
begin
);
auto
it
=
macros
.
find
(
macro_name
);
if
(
macro_name
==
"database"
)
/// Prefer explicit macros over implicit.
if
(
it
!=
macros
.
end
())
res
+=
it
->
second
;
else
if
(
macro_name
==
"database"
&&
!
database_name
.
empty
())
res
+=
database_name
;
else
if
(
macro_name
==
"table"
)
else
if
(
macro_name
==
"table"
&&
!
table_name
.
empty
()
)
res
+=
table_name
;
else
{
auto
it
=
macros
.
find
(
macro_name
);
if
(
it
==
macros
.
end
())
throw
Exception
(
"No macro "
+
macro_name
+
" in config"
,
ErrorCodes
::
SYNTAX_ERROR
);
res
+=
it
->
second
;
}
throw
Exception
(
"No macro "
+
macro_name
+
" in config"
,
ErrorCodes
::
SYNTAX_ERROR
);
pos
=
end
+
1
;
}
...
...
@@ -76,6 +74,11 @@ String Macros::expand(const String & s, size_t level, const String & database_na
return
expand
(
res
,
level
+
1
,
database_name
,
table_name
);
}
String
Macros
::
expand
(
const
String
&
s
,
const
String
&
database_name
,
const
String
&
table_name
)
const
{
return
expand
(
s
,
0
,
database_name
,
table_name
);
}
Names
Macros
::
expand
(
const
Names
&
source_names
,
size_t
level
)
const
{
Names
result_names
;
...
...
dbms/src/Common/Macros.h
浏览文件 @
ed77e40d
...
...
@@ -28,10 +28,14 @@ public:
Macros
(
const
Poco
::
Util
::
AbstractConfiguration
&
config
,
const
String
&
key
);
/** Replace the substring of the form {macro_name} with the value for macro_name, obtained from the config file.
* If {database} and {table} macros aren`t defined explicitly, expand them as database_name and table_name respectively.
* level - the level of recursion.
*/
String
expand
(
const
String
&
s
,
size_t
level
=
0
,
const
String
&
database_name
=
""
,
const
String
&
table_name
=
""
)
const
;
String
expand
(
const
String
&
s
,
const
String
&
database_name
,
const
String
&
table_name
)
const
;
/** Apply expand for the list.
*/
Names
expand
(
const
Names
&
source_names
,
size_t
level
=
0
)
const
;
...
...
dbms/src/Storages/StorageReplicatedMergeTree.cpp
浏览文件 @
ed77e40d
...
...
@@ -207,8 +207,8 @@ StorageReplicatedMergeTree::StorageReplicatedMergeTree(
:
context
(
context_
),
database_name
(
database_name_
),
table_name
(
name_
),
full_path
(
path_
+
escapeForFileName
(
table_name
)
+
'/'
),
zookeeper_path
(
context
.
getMacros
()
->
expand
(
zookeeper_path_
,
0
,
database_name
,
table_name
)),
replica_name
(
context
.
getMacros
()
->
expand
(
replica_name_
)),
zookeeper_path
(
context
.
getMacros
()
->
expand
(
zookeeper_path_
,
database_name
,
table_name
)),
replica_name
(
context
.
getMacros
()
->
expand
(
replica_name_
,
database_name
,
table_name
)),
data
(
database_name
,
table_name
,
full_path
,
columns_
,
context_
,
primary_expr_ast_
,
secondary_sorting_expr_list_
,
date_column_name
,
partition_expr_ast_
,
...
...
dbms/tests/integration/test_distributed_ddl/test.py
浏览文件 @
ed77e40d
...
...
@@ -317,11 +317,14 @@ def test_macro(started_cluster):
ddl_check_query
(
instance
,
"DROP TABLE IF EXISTS distr ON CLUSTER '{cluster}'"
)
ddl_check_query
(
instance
,
"DROP TABLE IF EXISTS tab ON CLUSTER '{cluster}'"
)
def
test_implicit_macros
(
started_cluster
):
# Temporarily disable random ZK packet drops, they might broke creation if ReplicatedMergeTree replicas
firewall_drops_rules
=
cluster
.
pm_random_drops
.
pop_rules
()
instance
=
cluster
.
instances
[
'ch2'
]
ddl_check_query
(
instance
,
"DROP DATABASE IF EXISTS test_db ON CLUSTER '{cluster}'"
)
ddl_check_query
(
instance
,
"DROP TABLE IF EXISTS test_db.test_macro ON CLUSTER '{cluster}'"
)
ddl_check_query
(
instance
,
"CREATE DATABASE IF NOT EXISTS test_db ON CLUSTER '{cluster}'"
)
ddl_check_query
(
instance
,
"""
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录