Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
42296cc8
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,发现更多精彩内容 >>
提交
42296cc8
编写于
12月 10, 2019
作者:
A
Alexander Tokmakov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove separate getTableName() and getDatabaseName()
上级
ef129b4b
变更
17
隐藏空白更改
内联
并排
Showing
17 changed file
with
65 addition
and
68 deletion
+65
-68
dbms/src/Core/iostream_debug_helpers.cpp
dbms/src/Core/iostream_debug_helpers.cpp
+2
-1
dbms/src/DataStreams/PushingToViewsBlockOutputStream.cpp
dbms/src/DataStreams/PushingToViewsBlockOutputStream.cpp
+3
-2
dbms/src/Databases/DatabaseMySQL.cpp
dbms/src/Databases/DatabaseMySQL.cpp
+4
-4
dbms/src/Interpreters/InterpreterDropQuery.cpp
dbms/src/Interpreters/InterpreterDropQuery.cpp
+4
-3
dbms/src/Interpreters/InterpreterSelectQuery.cpp
dbms/src/Interpreters/InterpreterSelectQuery.cpp
+4
-3
dbms/src/Interpreters/PartLog.cpp
dbms/src/Interpreters/PartLog.cpp
+4
-3
dbms/src/Storages/Distributed/DistributedBlockOutputStream.cpp
...src/Storages/Distributed/DistributedBlockOutputStream.cpp
+2
-2
dbms/src/Storages/IStorage.cpp
dbms/src/Storages/IStorage.cpp
+6
-7
dbms/src/Storages/IStorage.h
dbms/src/Storages/IStorage.h
+0
-12
dbms/src/Storages/LiveView/ProxyStorage.h
dbms/src/Storages/LiveView/ProxyStorage.h
+1
-1
dbms/src/Storages/MergeTree/StorageFromMergeTreeDataPart.h
dbms/src/Storages/MergeTree/StorageFromMergeTreeDataPart.h
+7
-5
dbms/src/Storages/StorageBuffer.cpp
dbms/src/Storages/StorageBuffer.cpp
+2
-3
dbms/src/Storages/StorageDistributed.cpp
dbms/src/Storages/StorageDistributed.cpp
+2
-3
dbms/src/Storages/StorageMerge.cpp
dbms/src/Storages/StorageMerge.cpp
+10
-5
dbms/src/Storages/StorageMergeTree.cpp
dbms/src/Storages/StorageMergeTree.cpp
+3
-4
dbms/src/Storages/StorageReplicatedMergeTree.cpp
dbms/src/Storages/StorageReplicatedMergeTree.cpp
+5
-6
dbms/src/Storages/System/StorageSystemGraphite.cpp
dbms/src/Storages/System/StorageSystemGraphite.cpp
+6
-4
未找到文件。
dbms/src/Core/iostream_debug_helpers.cpp
浏览文件 @
42296cc8
...
...
@@ -47,7 +47,8 @@ std::ostream & operator<<(std::ostream & stream, const IDataType & what)
std
::
ostream
&
operator
<<
(
std
::
ostream
&
stream
,
const
IStorage
&
what
)
{
stream
<<
"IStorage(name = "
<<
what
.
getName
()
<<
", tableName = "
<<
what
.
getTableName
()
<<
") {"
auto
table_id
=
what
.
getStorageID
();
stream
<<
"IStorage(name = "
<<
what
.
getName
()
<<
", tableName = "
<<
table_id
.
table_name
<<
") {"
<<
what
.
getColumns
().
getAllPhysical
().
toString
()
<<
"}"
;
return
stream
;
}
...
...
dbms/src/DataStreams/PushingToViewsBlockOutputStream.cpp
浏览文件 @
42296cc8
...
...
@@ -54,10 +54,11 @@ PushingToViewsBlockOutputStream::PushingToViewsBlockOutputStream(
if
(
auto
*
materialized_view
=
dynamic_cast
<
const
StorageMaterializedView
*>
(
dependent_table
.
get
()))
{
StoragePtr
inner_table
=
materialized_view
->
getTargetTable
();
auto
inner_table_id
=
inner_table
->
getStorageID
();
query
=
materialized_view
->
getInnerQuery
();
std
::
unique_ptr
<
ASTInsertQuery
>
insert
=
std
::
make_unique
<
ASTInsertQuery
>
();
insert
->
database
=
inner_table
->
getDatabaseName
()
;
insert
->
table
=
inner_table
->
getTableName
();
insert
->
database
=
inner_table
_id
.
database_name
;
insert
->
table
=
inner_table
_id
.
table_name
;
//FIXME add uuid
ASTPtr
insert_query_ptr
(
insert
.
release
());
InterpreterInsertQuery
interpreter
(
insert_query_ptr
,
*
views_context
);
BlockIO
io
=
interpreter
.
execute
();
...
...
dbms/src/Databases/DatabaseMySQL.cpp
浏览文件 @
42296cc8
...
...
@@ -132,9 +132,9 @@ static ASTPtr getCreateQueryFromStorage(const StoragePtr & storage, const ASTPtr
{
/// init create query.
create_table_query
->
table
=
storage
->
getTableName
()
;
create_table_query
->
database
=
storage
->
getDatabaseName
()
;
auto
table_id
=
storage
->
getStorageID
();
create_table_query
->
table
=
table_id
.
table_name
;
create_table_query
->
database
=
table_id
.
database_name
;
for
(
const
auto
&
column_type_and_name
:
storage
->
getColumns
().
getOrdinary
())
{
...
...
@@ -144,7 +144,7 @@ static ASTPtr getCreateQueryFromStorage(const StoragePtr & storage, const ASTPtr
columns_expression_list
->
children
.
emplace_back
(
column_declaration
);
}
auto
mysql_table_name
=
std
::
make_shared
<
ASTLiteral
>
(
storage
->
getTableName
()
);
auto
mysql_table_name
=
std
::
make_shared
<
ASTLiteral
>
(
table_id
.
table_name
);
auto
storage_engine_arguments
=
table_storage_define
->
as
<
ASTStorage
>
()
->
engine
->
arguments
;
storage_engine_arguments
->
children
.
insert
(
storage_engine_arguments
->
children
.
begin
()
+
2
,
mysql_table_name
);
}
...
...
dbms/src/Interpreters/InterpreterDropQuery.cpp
浏览文件 @
42296cc8
...
...
@@ -79,13 +79,14 @@ BlockIO InterpreterDropQuery::executeToTable(
if
(
database_and_table
.
first
&&
database_and_table
.
second
)
{
auto
table_id
=
database_and_table
.
second
->
getStorageID
();
if
(
kind
==
ASTDropQuery
::
Kind
::
Detach
)
{
database_and_table
.
second
->
shutdown
();
/// If table was already dropped by anyone, an exception will be thrown
auto
table_lock
=
database_and_table
.
second
->
lockExclusively
(
context
.
getCurrentQueryId
());
/// Drop table from memory, don't touch data and metadata
database_and_table
.
first
->
detachTable
(
database_and_table
.
second
->
getTableName
()
);
database_and_table
.
first
->
detachTable
(
table_id
.
table_name
);
}
else
if
(
kind
==
ASTDropQuery
::
Kind
::
Truncate
)
{
...
...
@@ -107,7 +108,7 @@ BlockIO InterpreterDropQuery::executeToTable(
const
std
::
string
metadata_file_without_extension
=
database_and_table
.
first
->
getMetadataPath
()
+
escapeForFileName
(
database_and_table
.
second
->
getTableName
()
);
+
escapeForFileName
(
table_id
.
table_name
);
const
auto
prev_metadata_name
=
metadata_file_without_extension
+
".sql"
;
const
auto
drop_metadata_name
=
metadata_file_without_extension
+
".sql.tmp_drop"
;
...
...
@@ -131,7 +132,7 @@ BlockIO InterpreterDropQuery::executeToTable(
String
table_data_path_relative
=
database_and_table
.
first
->
getTableDataPath
(
table_name
);
/// Delete table metadata and table itself from memory
database_and_table
.
first
->
removeTable
(
context
,
database_and_table
.
second
->
getTableName
()
);
database_and_table
.
first
->
removeTable
(
context
,
table_id
.
table_name
);
database_and_table
.
second
->
is_dropped
=
true
;
/// If it is not virtual database like Dictionary then drop remaining data dir
...
...
dbms/src/Interpreters/InterpreterSelectQuery.cpp
浏览文件 @
42296cc8
...
...
@@ -295,7 +295,8 @@ InterpreterSelectQuery::InterpreterSelectQuery(
if
(
auto
view_source
=
context
->
getViewSource
())
{
auto
&
storage_values
=
static_cast
<
const
StorageValues
&>
(
*
view_source
);
if
(
storage_values
.
getDatabaseName
()
==
database_name
&&
storage_values
.
getTableName
()
==
table_name
)
auto
tmp_table_id
=
storage_values
.
getStorageID
();
if
(
tmp_table_id
.
database_name
==
database_name
&&
tmp_table_id
.
table_name
==
table_name
)
{
/// Read from view source.
storage
=
context
->
getViewSource
();
...
...
@@ -419,9 +420,9 @@ InterpreterSelectQuery::InterpreterSelectQuery(
sanitizeBlock
(
result_header
);
/// Remove limits for some tables in the `system` database.
if
(
storage
&&
(
storage
->
getDatabaseName
()
==
"system"
))
if
(
storage
&&
(
table_id
->
database_name
==
"system"
))
{
String
table_name
=
storage
->
getTableName
()
;
String
table_name
=
table_id
->
table_name
;
if
((
table_name
==
"quotas"
)
||
(
table_name
==
"quota_usage"
)
||
(
table_name
==
"one"
))
{
options
.
ignore_quota
=
true
;
...
...
dbms/src/Interpreters/PartLog.cpp
浏览文件 @
42296cc8
...
...
@@ -110,7 +110,8 @@ bool PartLog::addNewParts(Context & current_context, const PartLog::MutableDataP
try
{
part_log
=
current_context
.
getPartLog
(
parts
.
front
()
->
storage
.
getDatabaseName
());
// assume parts belong to the same table
auto
table_id
=
parts
.
front
()
->
storage
.
getStorageID
();
part_log
=
current_context
.
getPartLog
(
table_id
.
database_name
);
// assume parts belong to the same table
if
(
!
part_log
)
return
false
;
...
...
@@ -122,8 +123,8 @@ bool PartLog::addNewParts(Context & current_context, const PartLog::MutableDataP
elem
.
event_time
=
time
(
nullptr
);
elem
.
duration_ms
=
elapsed_ns
/
1000000
;
elem
.
database_name
=
part
->
storage
.
getDatabaseName
()
;
elem
.
table_name
=
part
->
storage
.
getTableName
()
;
elem
.
database_name
=
table_id
.
database_name
;
elem
.
table_name
=
table_id
.
table_name
;
elem
.
partition_id
=
part
->
info
.
partition_id
;
elem
.
part_name
=
part
->
name
;
elem
.
path_on_disk
=
part
->
getFullPath
();
...
...
dbms/src/Storages/Distributed/DistributedBlockOutputStream.cpp
浏览文件 @
42296cc8
...
...
@@ -90,7 +90,7 @@ void DistributedBlockOutputStream::write(const Block & block)
if
(
ordinary_block
.
has
(
col
.
name
))
{
ordinary_block
.
erase
(
col
.
name
);
LOG_DEBUG
(
log
,
storage
.
get
TableName
()
LOG_DEBUG
(
log
,
storage
.
get
StorageID
().
getNameForLogs
()
<<
": column "
+
col
.
name
+
" will be removed, "
<<
"because it is MATERIALIZED"
);
}
...
...
@@ -515,7 +515,7 @@ void DistributedBlockOutputStream::writeAsyncImpl(const Block & block, const siz
else
{
if
(
shard_info
.
dir_name_for_internal_replication
.
empty
())
throw
Exception
(
"Directory name for async inserts is empty, table "
+
storage
.
get
TableName
(),
ErrorCodes
::
LOGICAL_ERROR
);
throw
Exception
(
"Directory name for async inserts is empty, table "
+
storage
.
get
StorageID
().
getNameForLogs
(),
ErrorCodes
::
LOGICAL_ERROR
);
writeToShard
(
block
,
{
shard_info
.
dir_name_for_internal_replication
});
}
...
...
dbms/src/Storages/IStorage.cpp
浏览文件 @
42296cc8
...
...
@@ -176,7 +176,7 @@ void IStorage::check(const Names & column_names, bool include_virtuals) const
{
if
(
columns_map
.
end
()
==
columns_map
.
find
(
name
))
throw
Exception
(
"There is no column with name "
+
backQuote
(
name
)
+
" in table "
+
get
TableName
()
+
". There are columns: "
+
list_of_columns
,
"There is no column with name "
+
backQuote
(
name
)
+
" in table "
+
get
StorageID
().
getNameForLogs
()
+
". There are columns: "
+
list_of_columns
,
ErrorCodes
::
NO_SUCH_COLUMN_IN_TABLE
);
if
(
unique_names
.
end
()
!=
unique_names
.
find
(
name
))
...
...
@@ -344,7 +344,7 @@ TableStructureWriteLockHolder IStorage::lockAlterIntention(const String & query_
void
IStorage
::
lockNewDataStructureExclusively
(
TableStructureWriteLockHolder
&
lock_holder
,
const
String
&
query_id
)
{
if
(
!
lock_holder
.
alter_intention_lock
)
throw
Exception
(
"Alter intention lock for table "
+
get
TableName
()
+
" was not taken. This is a bug."
,
ErrorCodes
::
LOGICAL_ERROR
);
throw
Exception
(
"Alter intention lock for table "
+
get
StorageID
().
getNameForLogs
()
+
" was not taken. This is a bug."
,
ErrorCodes
::
LOGICAL_ERROR
);
lock_holder
.
new_data_structure_lock
=
new_data_structure_lock
->
getLock
(
RWLockImpl
::
Write
,
query_id
);
}
...
...
@@ -352,7 +352,7 @@ void IStorage::lockNewDataStructureExclusively(TableStructureWriteLockHolder & l
void
IStorage
::
lockStructureExclusively
(
TableStructureWriteLockHolder
&
lock_holder
,
const
String
&
query_id
)
{
if
(
!
lock_holder
.
alter_intention_lock
)
throw
Exception
(
"Alter intention lock for table "
+
get
TableName
()
+
" was not taken. This is a bug."
,
ErrorCodes
::
LOGICAL_ERROR
);
throw
Exception
(
"Alter intention lock for table "
+
get
StorageID
().
getNameForLogs
()
+
" was not taken. This is a bug."
,
ErrorCodes
::
LOGICAL_ERROR
);
if
(
!
lock_holder
.
new_data_structure_lock
)
lock_holder
.
new_data_structure_lock
=
new_data_structure_lock
->
getLock
(
RWLockImpl
::
Write
,
query_id
);
...
...
@@ -405,15 +405,14 @@ void IStorage::alter(
if
(
params
.
isModifyingData
())
throw
Exception
(
"Method alter supports only change comment of column for storage "
+
getName
(),
ErrorCodes
::
NOT_IMPLEMENTED
);
const
String
database_name
=
getDatabaseName
();
const
String
table_name
=
getTableName
();
auto
table_id
=
getStorageID
();
if
(
params
.
isSettingsAlter
())
{
SettingsChanges
new_changes
;
params
.
applyForSettingsOnly
(
new_changes
);
IDatabase
::
ASTModifier
settings_modifier
=
getSettingsModifier
(
new_changes
);
context
.
getDatabase
(
database_name
)
->
alterTable
(
context
,
table_name
,
getColumns
(),
getIndices
(),
getConstraints
(),
settings_modifier
);
context
.
getDatabase
(
table_id
.
database_name
)
->
alterTable
(
context
,
table_id
.
table_name
,
getColumns
(),
getIndices
(),
getConstraints
(),
settings_modifier
);
//FIXME
}
else
{
...
...
@@ -422,7 +421,7 @@ void IStorage::alter(
auto
new_indices
=
getIndices
();
auto
new_constraints
=
getConstraints
();
params
.
applyForColumnsOnly
(
new_columns
);
context
.
getDatabase
(
database_name
)
->
alterTable
(
context
,
table_name
,
new_columns
,
new_indices
,
new_constraints
,
{});
context
.
getDatabase
(
table_id
.
database_name
)
->
alterTable
(
context
,
table_id
.
table_name
,
new_columns
,
new_indices
,
new_constraints
,
{});
//FIXME
setColumns
(
std
::
move
(
new_columns
));
}
}
...
...
dbms/src/Storages/IStorage.h
浏览文件 @
42296cc8
...
...
@@ -90,18 +90,6 @@ public:
/// The name of the table.
StorageID
getStorageID
(
std
::
unique_lock
<
std
::
mutex
>
*
lock
=
nullptr
)
const
;
// FIXME remove those methods
std
::
string
getTableName
()
const
{
std
::
lock_guard
lock
(
id_mutex
);
return
id
.
table_name
;
}
std
::
string
getDatabaseName
()
const
{
std
::
lock_guard
lock
(
id_mutex
);
return
id
.
database_name
;
}
/// Returns true if the storage receives data from a remote server or servers.
virtual
bool
isRemote
()
const
{
return
false
;
}
...
...
dbms/src/Storages/LiveView/ProxyStorage.h
浏览文件 @
42296cc8
...
...
@@ -9,7 +9,7 @@ class ProxyStorage : public IStorage
{
public:
ProxyStorage
(
StoragePtr
storage_
,
BlockInputStreams
streams_
,
QueryProcessingStage
::
Enum
to_stage_
)
:
IStorage
({
""
,
storage_
->
get
TableName
()
}),
storage
(
std
::
move
(
storage_
)),
streams
(
std
::
move
(
streams_
)),
to_stage
(
to_stage_
)
{}
:
IStorage
({
""
,
storage_
->
get
StorageID
().
table_name
}),
storage
(
std
::
move
(
storage_
)),
streams
(
std
::
move
(
streams_
)),
to_stage
(
to_stage_
)
{}
public:
std
::
string
getName
()
const
override
{
return
"ProxyStorage("
+
storage
->
getName
()
+
")"
;
}
...
...
dbms/src/Storages/MergeTree/StorageFromMergeTreeDataPart.h
浏览文件 @
42296cc8
...
...
@@ -49,11 +49,7 @@ public:
protected:
StorageFromMergeTreeDataPart
(
const
MergeTreeData
::
DataPartPtr
&
part_
)
:
IStorage
({
part_
->
storage
.
getDatabaseName
(),
part_
->
storage
.
getTableName
()
+
" (part "
+
part_
->
name
+
")"
}
,
part_
->
storage
.
getVirtuals
())
:
IStorage
(
getIDFromPart
(
part_
),
part_
->
storage
.
getVirtuals
())
,
part
(
part_
)
{
setColumns
(
part_
->
storage
.
getColumns
());
...
...
@@ -62,6 +58,12 @@ protected:
private:
MergeTreeData
::
DataPartPtr
part
;
static
StorageID
getIDFromPart
(
const
MergeTreeData
::
DataPartPtr
&
part_
)
{
auto
table_id
=
part_
->
storage
.
getStorageID
();
return
StorageID
(
table_id
.
database_name
,
table_id
.
table_name
+
" (part "
+
part_
->
name
+
")"
);
}
};
}
dbms/src/Storages/StorageBuffer.cpp
浏览文件 @
42296cc8
...
...
@@ -713,8 +713,7 @@ void StorageBuffer::alter(const AlterCommands & params, const Context & context,
{
lockStructureExclusively
(
table_lock_holder
,
context
.
getCurrentQueryId
());
const
String
database_name_
=
getDatabaseName
();
const
String
table_name_
=
getTableName
();
auto
table_id
=
getStorageID
();
/// So that no blocks of the old structure remain.
optimize
({}
/*query*/
,
{}
/*partition_id*/
,
false
/*final*/
,
false
/*deduplicate*/
,
context
);
...
...
@@ -723,7 +722,7 @@ void StorageBuffer::alter(const AlterCommands & params, const Context & context,
auto
new_indices
=
getIndices
();
auto
new_constraints
=
getConstraints
();
params
.
applyForColumnsOnly
(
new_columns
);
context
.
getDatabase
(
database_name_
)
->
alterTable
(
context
,
table_name_
,
new_columns
,
new_indices
,
new_constraints
,
{});
context
.
getDatabase
(
table_id
.
database_name
)
->
alterTable
(
context
,
table_id
.
table_name
,
new_columns
,
new_indices
,
new_constraints
,
{});
//FIXME
setColumns
(
std
::
move
(
new_columns
));
}
...
...
dbms/src/Storages/StorageDistributed.cpp
浏览文件 @
42296cc8
...
...
@@ -402,14 +402,13 @@ void StorageDistributed::alter(
{
lockStructureExclusively
(
table_lock_holder
,
context
.
getCurrentQueryId
());
const
String
current_database_name
=
getDatabaseName
();
const
String
current_table_name
=
getTableName
();
auto
table_id
=
getStorageID
();
auto
new_columns
=
getColumns
();
auto
new_indices
=
getIndices
();
auto
new_constraints
=
getConstraints
();
params
.
applyForColumnsOnly
(
new_columns
);
context
.
getDatabase
(
current_database_name
)
->
alterTable
(
context
,
current_
table_name
,
new_columns
,
new_indices
,
new_constraints
,
{});
context
.
getDatabase
(
table_id
.
database_name
)
->
alterTable
(
context
,
table_id
.
table_name
,
new_columns
,
new_indices
,
new_constraints
,
{});
setColumns
(
std
::
move
(
new_columns
));
}
...
...
dbms/src/Storages/StorageMerge.cpp
浏览文件 @
42296cc8
...
...
@@ -281,7 +281,10 @@ BlockInputStreams StorageMerge::createSourceStreams(const SelectQueryInfo & quer
SelectQueryInfo
modified_query_info
=
query_info
;
modified_query_info
.
query
=
query_info
.
query
->
clone
();
VirtualColumnUtils
::
rewriteEntityInAst
(
modified_query_info
.
query
,
"_table"
,
storage
?
storage
->
getTableName
()
:
""
);
StorageID
table_id
;
if
(
storage
)
table_id
=
storage
->
getStorageID
();
VirtualColumnUtils
::
rewriteEntityInAst
(
modified_query_info
.
query
,
"_table"
,
table_id
.
table_name
);
if
(
!
storage
)
return
BlockInputStreams
{
...
...
@@ -301,7 +304,7 @@ BlockInputStreams StorageMerge::createSourceStreams(const SelectQueryInfo & quer
}
else
if
(
processed_stage
>
storage
->
getQueryProcessingStage
(
modified_context
))
{
modified_query_info
.
query
->
as
<
ASTSelectQuery
>
()
->
replaceDatabaseAndTable
(
source_database
,
storage
->
getTableName
()
);
modified_query_info
.
query
->
as
<
ASTSelectQuery
>
()
->
replaceDatabaseAndTable
(
source_database
,
table_id
.
table_name
);
/// Maximum permissible parallelism is streams_num
modified_context
.
getSettingsRef
().
max_threads
=
UInt64
(
streams_num
);
...
...
@@ -332,7 +335,7 @@ BlockInputStreams StorageMerge::createSourceStreams(const SelectQueryInfo & quer
{
if
(
has_table_virtual_column
)
source_stream
=
std
::
make_shared
<
AddingConstColumnBlockInputStream
<
String
>>
(
source_stream
,
std
::
make_shared
<
DataTypeString
>
(),
storage
->
getTableName
()
,
"_table"
);
source_stream
,
std
::
make_shared
<
DataTypeString
>
(),
table_id
.
table_name
,
"_table"
);
/// Subordinary tables could have different but convertible types, like numeric types of different width.
/// We must return streams with structure equals to structure of Merge table.
...
...
@@ -381,7 +384,8 @@ StorageMerge::StorageListWithLocks StorageMerge::getSelectedTables(const ASTPtr
if
(
storage
.
get
()
!=
this
)
{
selected_tables
.
emplace_back
(
storage
,
get_lock
?
storage
->
lockStructureForShare
(
false
,
query_id
)
:
TableStructureReadLockHolder
{});
virtual_column
->
insert
(
storage
->
getTableName
());
auto
table_id
=
storage
->
getStorageID
();
virtual_column
->
insert
(
table_id
.
table_name
);
}
iterator
->
next
();
...
...
@@ -394,7 +398,8 @@ StorageMerge::StorageListWithLocks StorageMerge::getSelectedTables(const ASTPtr
auto
values
=
VirtualColumnUtils
::
extractSingleValueFromBlock
<
String
>
(
virtual_columns_block
,
"_table"
);
/// Remove unused tables from the list
selected_tables
.
remove_if
([
&
]
(
const
auto
&
elem
)
{
return
values
.
find
(
elem
.
first
->
getTableName
())
==
values
.
end
();
});
//FIXME table name can be changed, use StorageID
selected_tables
.
remove_if
([
&
]
(
const
auto
&
elem
)
{
return
values
.
find
(
elem
.
first
->
getStorageID
().
table_name
)
==
values
.
end
();
});
}
return
selected_tables
;
...
...
dbms/src/Storages/StorageMergeTree.cpp
浏览文件 @
42296cc8
...
...
@@ -260,8 +260,7 @@ void StorageMergeTree::alter(
const
Context
&
context
,
TableStructureWriteLockHolder
&
table_lock_holder
)
{
const
String
current_database_name
=
getDatabaseName
();
const
String
current_table_name
=
getTableName
();
auto
table_id
=
getStorageID
();
lockNewDataStructureExclusively
(
table_lock_holder
,
context
.
getCurrentQueryId
());
...
...
@@ -313,7 +312,7 @@ void StorageMergeTree::alter(
{
lockStructureExclusively
(
table_lock_holder
,
context
.
getCurrentQueryId
());
context
.
getDatabase
(
current_database_name
)
->
alterTable
(
context
,
current_
table_name
,
new_columns
,
new_indices
,
new_constraints
,
storage_modifier
);
context
.
getDatabase
(
table_id
.
database_name
)
->
alterTable
(
context
,
table_id
.
table_name
,
new_columns
,
new_indices
,
new_constraints
,
storage_modifier
);
update_metadata
();
}
...
...
@@ -330,7 +329,7 @@ void StorageMergeTree::alter(
lockStructureExclusively
(
table_lock_holder
,
context
.
getCurrentQueryId
());
context
.
getDatabase
(
current_database_name
)
->
alterTable
(
context
,
current_
table_name
,
new_columns
,
new_indices
,
new_constraints
,
storage_modifier
);
context
.
getDatabase
(
table_id
.
database_name
)
->
alterTable
(
context
,
table_id
.
table_name
,
new_columns
,
new_indices
,
new_constraints
,
storage_modifier
);
update_metadata
();
...
...
dbms/src/Storages/StorageReplicatedMergeTree.cpp
浏览文件 @
42296cc8
...
...
@@ -3249,8 +3249,7 @@ void StorageReplicatedMergeTree::alter(
LOG_DEBUG
(
log
,
"Doing ALTER"
);
const
String
current_database_name
=
getDatabaseName
();
const
String
current_table_name
=
getTableName
();
auto
table_id
=
getStorageID
();
/// We cannot check this alter commands with method isModifyingData()
/// because ReplicatedMergeTree stores both columns and metadata for
...
...
@@ -3267,8 +3266,8 @@ void StorageReplicatedMergeTree::alter(
changeSettings
(
new_changes
,
table_lock_holder
);
IDatabase
::
ASTModifier
settings_modifier
=
getSettingsModifier
(
new_changes
);
global_context
.
getDatabase
(
current_
database_name
)
->
alterTable
(
query_context
,
current_
table_name
,
getColumns
(),
getIndices
(),
getConstraints
(),
settings_modifier
);
global_context
.
getDatabase
(
table_id
.
database_name
)
->
alterTable
(
query_context
,
table_id
.
table_name
,
getColumns
(),
getIndices
(),
getConstraints
(),
settings_modifier
);
return
;
}
...
...
@@ -3349,8 +3348,8 @@ void StorageReplicatedMergeTree::alter(
changeSettings
(
new_changes
,
table_lock_holder
);
global_context
.
getDatabase
(
current_
database_name
)
->
alterTable
(
query_context
,
current_
table_name
,
getColumns
(),
getIndices
(),
getConstraints
(),
settings_modifier
);
global_context
.
getDatabase
(
table_id
.
database_name
)
->
alterTable
(
query_context
,
table_id
.
table_name
,
getColumns
(),
getIndices
(),
getConstraints
(),
settings_modifier
);
}
...
...
dbms/src/Storages/System/StorageSystemGraphite.cpp
浏览文件 @
42296cc8
...
...
@@ -48,20 +48,22 @@ StorageSystemGraphite::Configs StorageSystemGraphite::getConfigs(const Context &
{
const
String
&
config_name
=
table_data
->
merging_params
.
graphite_params
.
config_name
;
auto
table_id
=
table_data
->
getStorageID
();
if
(
!
graphite_configs
.
count
(
config_name
))
{
//TODO add uuid
Config
new_config
=
{
table_data
->
merging_params
.
graphite_params
,
{
table_
data
->
getDatabaseName
()
},
{
table_
data
->
getTableName
()
},
{
table_
id
.
database_name
},
{
table_
id
.
database_name
},
};
graphite_configs
.
emplace
(
config_name
,
new_config
);
}
else
{
graphite_configs
[
config_name
].
databases
.
emplace_back
(
table_
data
->
getDatabaseName
()
);
graphite_configs
[
config_name
].
tables
.
emplace_back
(
table_
data
->
getTableName
()
);
graphite_configs
[
config_name
].
databases
.
emplace_back
(
table_
id
.
database_name
);
graphite_configs
[
config_name
].
tables
.
emplace_back
(
table_
id
.
database_name
);
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录