mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
Storage Log faminy support settings storage policy
This commit is contained in:
parent
496cacf25e
commit
a10f020b2d
@ -1104,7 +1104,7 @@ void registerStorageLog(StorageFactory & factory)
|
||||
throw Exception(ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH, "Engine {} doesn't support any arguments ({} given)",
|
||||
args.engine_name, args.engine_args.size());
|
||||
|
||||
String disk_name = getDiskName(*args.storage_def);
|
||||
String disk_name = getDiskName(*args.storage_def, args.getContext());
|
||||
DiskPtr disk = args.getContext()->getDisk(disk_name);
|
||||
|
||||
return std::make_shared<StorageLog>(
|
||||
|
@ -1,17 +1,27 @@
|
||||
#include "StorageLogSettings.h"
|
||||
#include <Disks/StoragePolicy.h>
|
||||
#include <Interpreters/Context.h>
|
||||
#include <Parsers/ASTCreateQuery.h>
|
||||
#include <Parsers/ASTSetQuery.h>
|
||||
|
||||
namespace DB
|
||||
{
|
||||
String getDiskName(ASTStorage & storage_def)
|
||||
String getDiskName(ASTStorage & storage_def, ContextPtr context)
|
||||
{
|
||||
if (storage_def.settings)
|
||||
{
|
||||
SettingsChanges changes = storage_def.settings->changes;
|
||||
for (const auto & change : changes)
|
||||
{
|
||||
/// How about both disk and storage_policy are specified?
|
||||
if (change.name == "disk")
|
||||
return change.value.safeGet<String>();
|
||||
if (change.name == "storage_policy")
|
||||
{
|
||||
auto policy = context->getStoragePolicy(change.value.safeGet<String>());
|
||||
return policy->getAnyDisk()->getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
return "default";
|
||||
}
|
||||
|
@ -5,6 +5,8 @@
|
||||
namespace DB
|
||||
{
|
||||
class ASTStorage;
|
||||
class Context;
|
||||
using ContextPtr = std::shared_ptr<const Context>;
|
||||
|
||||
String getDiskName(ASTStorage & storage_def);
|
||||
String getDiskName(ASTStorage & storage_def, ContextPtr context);
|
||||
}
|
||||
|
@ -678,7 +678,7 @@ void registerStorageStripeLog(StorageFactory & factory)
|
||||
throw Exception(ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH, "Engine {} doesn't support any arguments ({} given)",
|
||||
args.engine_name, args.engine_args.size());
|
||||
|
||||
String disk_name = getDiskName(*args.storage_def);
|
||||
String disk_name = getDiskName(*args.storage_def, args.getContext());
|
||||
DiskPtr disk = args.getContext()->getDisk(disk_name);
|
||||
|
||||
return std::make_shared<StorageStripeLog>(
|
||||
|
@ -0,0 +1,2 @@
|
||||
1
|
||||
1
|
@ -0,0 +1,15 @@
|
||||
DROP TABLE IF EXISTS test_2554_log;
|
||||
CREATE TABLE test_2554_log (n UInt32) ENGINE = Log SETTINGS storage_policy = 'default';
|
||||
|
||||
INSERT INTO test_2554_log SELECT 1;
|
||||
SELECT * FROM test_2554_log;
|
||||
|
||||
DROP TABLE test_2554_log;
|
||||
|
||||
DROP TABLE IF EXISTS test_2554_tinylog;
|
||||
CREATE TABLE test_2554_tinylog (n UInt32) ENGINE = Log SETTINGS storage_policy = 'default';
|
||||
|
||||
INSERT INTO test_2554_tinylog SELECT 1;
|
||||
SELECT * FROM test_2554_tinylog;
|
||||
|
||||
DROP TABLE test_2554_tinylog;
|
Loading…
Reference in New Issue
Block a user