Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
738080c7
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,发现更多精彩内容 >>
提交
738080c7
编写于
1月 16, 2019
作者:
C
chertus
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
minor improvements
上级
8bb35ac9
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
25 addition
and
27 deletion
+25
-27
dbms/src/Interpreters/DatabaseAndTableWithAlias.cpp
dbms/src/Interpreters/DatabaseAndTableWithAlias.cpp
+16
-0
dbms/src/Interpreters/DatabaseAndTableWithAlias.h
dbms/src/Interpreters/DatabaseAndTableWithAlias.h
+3
-0
dbms/src/Interpreters/TranslateQualifiedNamesVisitor.cpp
dbms/src/Interpreters/TranslateQualifiedNamesVisitor.cpp
+6
-27
未找到文件。
dbms/src/Interpreters/DatabaseAndTableWithAlias.cpp
浏览文件 @
738080c7
...
...
@@ -118,6 +118,22 @@ DatabaseAndTableWithAlias::DatabaseAndTableWithAlias(const ASTTableExpression &
throw
Exception
(
"Logical error: no known elements in ASTTableExpression"
,
ErrorCodes
::
LOGICAL_ERROR
);
}
bool
DatabaseAndTableWithAlias
::
satisfies
(
const
DatabaseAndTableWithAlias
&
db_table
,
bool
table_may_be_an_alias
)
{
/// table.*, alias.* or database.table.*
if
(
database
.
empty
())
{
if
(
!
db_table
.
table
.
empty
()
&&
table
==
db_table
.
table
)
return
true
;
if
(
!
db_table
.
alias
.
empty
())
return
(
alias
==
db_table
.
alias
)
||
(
table_may_be_an_alias
&&
table
==
db_table
.
alias
);
}
return
database
==
db_table
.
database
&&
table
==
db_table
.
table
;
}
String
DatabaseAndTableWithAlias
::
getQualifiedNamePrefix
()
const
{
if
(
alias
.
empty
()
&&
table
.
empty
())
...
...
dbms/src/Interpreters/DatabaseAndTableWithAlias.h
浏览文件 @
738080c7
...
...
@@ -33,6 +33,9 @@ struct DatabaseAndTableWithAlias
/// If ast is ASTIdentifier, prepend getQualifiedNamePrefix() to it's name.
void
makeQualifiedName
(
const
ASTPtr
&
ast
)
const
;
/// Check if it satisfies another db_table name. @note opterion is not symmetric.
bool
satisfies
(
const
DatabaseAndTableWithAlias
&
table
,
bool
table_may_be_an_alias
);
};
void
stripIdentifier
(
DB
::
ASTPtr
&
ast
,
size_t
num_qualifiers_to_strip
);
...
...
dbms/src/Interpreters/TranslateQualifiedNamesVisitor.cpp
浏览文件 @
738080c7
...
...
@@ -89,38 +89,17 @@ std::vector<ASTPtr *> TranslateQualifiedNamesMatcher::visit(const ASTIdentifier
std
::
vector
<
ASTPtr
*>
TranslateQualifiedNamesMatcher
::
visit
(
const
ASTQualifiedAsterisk
&
,
const
ASTPtr
&
ast
,
Data
&
data
)
{
const
std
::
vector
<
DatabaseAndTableWithAlias
>
&
tables
=
data
.
tables
;
if
(
ast
->
children
.
size
()
!=
1
)
throw
Exception
(
"Logical error: qualified asterisk must have exactly one child"
,
ErrorCodes
::
LOGICAL_ERROR
);
ASTIdentifier
*
ident
=
typeid_cast
<
ASTIdentifier
*>
(
ast
->
children
[
0
].
get
());
if
(
!
ident
)
throw
Exception
(
"Logical error: qualified asterisk must have identifier as its child"
,
ErrorCodes
::
LOGICAL_ERROR
);
size_t
num_components
=
ident
->
children
.
size
();
if
(
num_components
>
2
)
throw
Exception
(
"Qualified asterisk cannot have more than two qualifiers"
,
ErrorCodes
::
UNKNOWN_ELEMENT_IN_AST
);
auto
&
ident
=
ast
->
children
[
0
];
DatabaseAndTableWithAlias
db_and_table
(
*
ident
);
/// @note it could contain table alias as table name.
DatabaseAndTableWithAlias
db_and_table
(
ident
);
for
(
const
auto
&
table_names
:
tables
)
{
/// database.table.*, table.* or alias.*
if
(
num_components
==
2
)
{
if
(
!
table_names
.
database
.
empty
()
&&
db_and_table
.
database
==
table_names
.
database
&&
db_and_table
.
table
==
table_names
.
table
)
return
{};
}
else
if
(
num_components
==
0
)
{
if
((
!
table_names
.
table
.
empty
()
&&
db_and_table
.
table
==
table_names
.
table
)
||
(
!
table_names
.
alias
.
empty
()
&&
db_and_table
.
table
==
table_names
.
alias
))
return
{};
}
}
for
(
const
auto
&
known_table
:
data
.
tables
)
if
(
db_and_table
.
satisfies
(
known_table
,
true
))
return
{};
throw
Exception
(
"Unknown qualified identifier: "
+
ident
->
getAliasOrColumnName
(),
ErrorCodes
::
UNKNOWN_IDENTIFIER
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录