Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
4972daea
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,发现更多精彩内容 >>
提交
4972daea
编写于
3月 11, 2020
作者:
A
Alexander Tokmakov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixes
上级
8b3a245a
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
40 addition
and
28 deletion
+40
-28
dbms/src/Interpreters/Context.cpp
dbms/src/Interpreters/Context.cpp
+28
-14
dbms/src/Interpreters/DatabaseCatalog.cpp
dbms/src/Interpreters/DatabaseCatalog.cpp
+0
-1
dbms/src/Interpreters/DatabaseCatalog.h
dbms/src/Interpreters/DatabaseCatalog.h
+1
-1
dbms/src/Interpreters/GlobalSubqueriesVisitor.h
dbms/src/Interpreters/GlobalSubqueriesVisitor.h
+4
-1
dbms/src/Interpreters/InterpreterDropQuery.cpp
dbms/src/Interpreters/InterpreterDropQuery.cpp
+0
-1
dbms/src/Interpreters/InterpreterSystemQuery.cpp
dbms/src/Interpreters/InterpreterSystemQuery.cpp
+0
-2
dbms/src/Storages/StorageID.cpp
dbms/src/Storages/StorageID.cpp
+6
-1
dbms/src/Storages/StorageID.h
dbms/src/Storages/StorageID.h
+1
-7
未找到文件。
dbms/src/Interpreters/Context.cpp
浏览文件 @
4972daea
...
...
@@ -86,7 +86,6 @@ namespace ErrorCodes
extern
const
int
UNKNOWN_DATABASE
;
extern
const
int
UNKNOWN_TABLE
;
extern
const
int
TABLE_ALREADY_EXISTS
;
extern
const
int
DATABASE_ALREADY_EXISTS
;
extern
const
int
THERE_IS_NO_SESSION
;
extern
const
int
THERE_IS_NO_QUERY
;
extern
const
int
NO_ELEMENTS_IN_CONFIG
;
...
...
@@ -818,6 +817,7 @@ void Context::setProfile(const String & profile)
bool
Context
::
isExternalTableExist
(
const
String
&
table_name
)
const
{
assert
(
global_context
!=
this
);
auto
lock
=
getLock
();
return
external_tables_mapping
.
count
(
table_name
);
}
...
...
@@ -861,6 +861,7 @@ Tables Context::getExternalTables() const
void
Context
::
addExternalTable
(
const
String
&
table_name
,
TemporaryTableHolder
&&
temporary_table
)
{
assert
(
global_context
!=
this
);
auto
lock
=
getLock
();
if
(
external_tables_mapping
.
end
()
!=
external_tables_mapping
.
find
(
table_name
))
throw
Exception
(
"Temporary table "
+
backQuoteIfNeed
(
table_name
)
+
" already exists."
,
ErrorCodes
::
TABLE_ALREADY_EXISTS
);
...
...
@@ -870,9 +871,9 @@ void Context::addExternalTable(const String & table_name, TemporaryTableHolder &
bool
Context
::
removeExternalTable
(
const
String
&
table_name
)
{
assert
(
global_context
!=
this
);
std
::
shared_ptr
<
TemporaryTableHolder
>
holder
;
{
auto
lock
=
getLock
();
auto
iter
=
external_tables_mapping
.
find
(
table_name
);
if
(
iter
==
external_tables_mapping
.
end
())
return
false
;
...
...
@@ -885,12 +886,14 @@ bool Context::removeExternalTable(const String & table_name)
void
Context
::
addScalar
(
const
String
&
name
,
const
Block
&
block
)
{
assert
(
global_context
!=
this
);
scalars
[
name
]
=
block
;
}
bool
Context
::
hasScalar
(
const
String
&
name
)
const
{
assert
(
global_context
!=
this
);
return
scalars
.
count
(
name
);
}
...
...
@@ -2087,19 +2090,30 @@ StorageID Context::resolveStorageIDImpl(StorageID storage_id, StorageNamespace w
/// Global context should not contain temporary tables
assert
(
global_context
!=
this
);
/// Firstly look for temporary table in current context
auto
it
=
external_tables_mapping
.
find
(
storage_id
.
getTableName
());
if
(
it
!=
external_tables_mapping
.
end
())
return
it
->
second
->
getGlobalTableID
();
/// If not found and current context was created from some session context, look for temporay table in session context
if
(
session_context
&&
session_context
!=
this
)
auto
resolved_id
=
StorageID
::
createEmpty
();
auto
try_resolve
=
[
&
](
const
Context
&
context
)
->
bool
{
const
auto
&
external_tables
=
session_context
->
external_tables_mapping
;
it
=
external_tables
.
find
(
storage_id
.
getTableName
());
if
(
it
!=
external_tables
.
end
())
return
it
->
second
->
getGlobalTableID
();
}
const
auto
&
tables
=
context
.
external_tables_mapping
;
auto
it
=
tables
.
find
(
storage_id
.
getTableName
());
if
(
it
==
tables
.
end
())
return
false
;
resolved_id
=
it
->
second
->
getGlobalTableID
();
return
true
;
};
/// Firstly look for temporary table in current context
if
(
try_resolve
(
*
this
))
return
resolved_id
;
/// If not found and current context was created from some query context, look for temporary table in query context
bool
is_local_context
=
query_context
&&
query_context
!=
this
;
if
(
is_local_context
&&
try_resolve
(
*
query_context
))
return
resolved_id
;
/// If not found and current context was created from some session context, look for temporary table in session context
bool
is_local_or_query_context
=
session_context
&&
session_context
!=
this
;
if
(
is_local_or_query_context
&&
try_resolve
(
*
session_context
))
return
resolved_id
;
}
if
(
in_current_database
)
...
...
dbms/src/Interpreters/DatabaseCatalog.cpp
浏览文件 @
4972daea
...
...
@@ -17,7 +17,6 @@ namespace ErrorCodes
extern
const
int
UNKNOWN_TABLE
;
extern
const
int
TABLE_ALREADY_EXISTS
;
extern
const
int
DATABASE_ALREADY_EXISTS
;
extern
const
int
DDL_GUARD_IS_ACTIVE
;
extern
const
int
DATABASE_NOT_EMPTY
;
extern
const
int
DATABASE_ACCESS_DENIED
;
}
...
...
dbms/src/Interpreters/DatabaseCatalog.h
浏览文件 @
4972daea
...
...
@@ -138,7 +138,7 @@ public:
Dependencies
getDependencies
(
const
StorageID
&
from
)
const
;
/// For Materialized and Live View
void
updateDependency
(
const
StorageID
&
old_from
,
const
StorageID
&
old_where
,
const
StorageID
&
new_from
,
const
StorageID
&
new_where
);
void
updateDependency
(
const
StorageID
&
old_from
,
const
StorageID
&
old_where
,
const
StorageID
&
new_from
,
const
StorageID
&
new_where
);
private:
DatabaseCatalog
(
const
Context
*
global_context_
);
...
...
dbms/src/Interpreters/GlobalSubqueriesVisitor.h
浏览文件 @
4972daea
...
...
@@ -78,7 +78,10 @@ public:
if
(
is_table
)
{
/// If this is already an external table, you do not need to add anything. Just remember its presence.
if
(
external_tables
.
end
()
!=
external_tables
.
find
(
getIdentifierName
(
subquery_or_table_name
)))
auto
temporary_table_name
=
getIdentifierName
(
subquery_or_table_name
);
bool
exists_in_local_map
=
external_tables
.
end
()
!=
external_tables
.
find
(
temporary_table_name
);
bool
exists_in_context
=
!
context
.
tryResolveStorageID
(
StorageID
(
""
,
temporary_table_name
),
Context
::
ResolveExternal
).
empty
();
if
(
exists_in_local_map
||
exists_in_context
)
return
;
}
...
...
dbms/src/Interpreters/InterpreterDropQuery.cpp
浏览文件 @
4972daea
...
...
@@ -18,7 +18,6 @@ namespace DB
namespace
ErrorCodes
{
extern
const
int
DATABASE_NOT_EMPTY
;
extern
const
int
LOGICAL_ERROR
;
extern
const
int
SYNTAX_ERROR
;
extern
const
int
UNKNOWN_TABLE
;
...
...
dbms/src/Interpreters/InterpreterSystemQuery.cpp
浏览文件 @
4972daea
...
...
@@ -154,8 +154,6 @@ void InterpreterSystemQuery::startStopAction(StorageActionBlockType action_type,
}
InterpreterSystemQuery
::
InterpreterSystemQuery
(
const
ASTPtr
&
query_ptr_
,
Context
&
context_
)
:
query_ptr
(
query_ptr_
->
clone
()),
context
(
context_
),
log
(
&
Poco
::
Logger
::
get
(
"InterpreterSystemQuery"
))
{
...
...
dbms/src/Storages/StorageID.cpp
浏览文件 @
4972daea
...
...
@@ -4,11 +4,16 @@
#include <IO/WriteHelpers.h>
#include <Interpreters/Context.h>
#include <Interpreters/DatabaseAndTableWithAlias.h>
#include <Common/quoteString.h>
namespace
DB
{
namespace
ErrorCodes
{
extern
const
int
LOGICAL_ERROR
;
extern
const
int
UNKNOWN_DATABASE
;
}
StorageID
::
StorageID
(
const
ASTQueryWithTableAndOutput
&
query
,
const
Context
&
local_context
)
{
database_name
=
local_context
.
resolveDatabase
(
query
.
database
);
...
...
dbms/src/Storages/StorageID.h
浏览文件 @
4972daea
...
...
@@ -8,12 +8,6 @@
namespace
DB
{
namespace
ErrorCodes
{
extern
const
int
LOGICAL_ERROR
;
extern
const
int
UNKNOWN_DATABASE
;
}
static
constexpr
char
const
*
TABLE_WITH_UUID_NAME_PLACEHOLDER
=
"_"
;
class
ASTQueryWithTableAndOutput
;
...
...
@@ -70,7 +64,7 @@ struct StorageID
/// Avoid implicit construction of empty StorageID. However, it's needed for deferred initialization.
static
StorageID
createEmpty
()
{
return
{};
}
QualifiedTableName
getQualifiedName
()
const
{
return
{
getDatabaseName
()
,
getTableName
()};
}
QualifiedTableName
getQualifiedName
()
const
{
return
{
database_name
,
getTableName
()};
}
private:
StorageID
()
=
default
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录