mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
Merge pull request #34949 from nikitamikhaylov/system_log_tables_and_settings
Recreate system.{*}_log table on settings changes
This commit is contained in:
commit
4b61e4795c
@ -23,6 +23,7 @@
|
||||
#include <Parsers/ASTIndexDeclaration.h>
|
||||
#include <Parsers/ASTInsertQuery.h>
|
||||
#include <Storages/IStorage.h>
|
||||
#include <Storages/MergeTree/MergeTreeSettings.h>
|
||||
#include <Common/setThreadName.h>
|
||||
#include <Common/MemoryTrackerBlockerInThread.h>
|
||||
#include <IO/WriteHelpers.h>
|
||||
@ -112,9 +113,7 @@ std::shared_ptr<TSystemLog> createSystemLog(
|
||||
}
|
||||
|
||||
|
||||
/// returns CREATE TABLE query, but with removed:
|
||||
/// - UUID
|
||||
/// - SETTINGS (for MergeTree)
|
||||
/// returns CREATE TABLE query, but with removed UUID
|
||||
/// That way it can be used to compare with the SystemLog::getCreateTableQuery()
|
||||
ASTPtr getCreateTableQueryClean(const StorageID & table_id, ContextPtr context)
|
||||
{
|
||||
@ -123,11 +122,6 @@ ASTPtr getCreateTableQueryClean(const StorageID & table_id, ContextPtr context)
|
||||
auto & old_create_query_ast = old_ast->as<ASTCreateQuery &>();
|
||||
/// Reset UUID
|
||||
old_create_query_ast.uuid = UUIDHelpers::Nil;
|
||||
/// Existing table has default settings (i.e. `index_granularity = 8192`), reset them.
|
||||
if (ASTStorage * storage = old_create_query_ast.storage)
|
||||
{
|
||||
storage->reset(storage->settings);
|
||||
}
|
||||
return old_ast;
|
||||
}
|
||||
|
||||
@ -476,6 +470,11 @@ ASTPtr SystemLog<LogElement>::getCreateTableQuery()
|
||||
"Storage to create table for " + LogElement::name(), 0, DBMS_DEFAULT_MAX_PARSER_DEPTH);
|
||||
create->set(create->storage, storage_ast);
|
||||
|
||||
/// Write additional (default) settings for MergeTree engine to make it make it possible to compare ASTs
|
||||
/// and recreate tables on settings changes.
|
||||
auto storage_settings = std::make_unique<MergeTreeSettings>(getContext()->getMergeTreeSettings());
|
||||
storage_settings->loadFromQuery(*create->storage);
|
||||
|
||||
return create;
|
||||
}
|
||||
|
||||
|
@ -12,9 +12,6 @@
|
||||
namespace DB
|
||||
{
|
||||
|
||||
class StorageFileBlockInputStream;
|
||||
class StorageFileBlockOutputStream;
|
||||
|
||||
class StorageFile final : public shared_ptr_helper<StorageFile>, public IStorage
|
||||
{
|
||||
friend struct shared_ptr_helper<StorageFile>;
|
||||
|
Loading…
Reference in New Issue
Block a user