mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-19 16:20:50 +00:00
Disallow creating refreshable MV on Linux < 3.15
This commit is contained in:
parent
8534aa07fc
commit
5539faa54e
@ -57,11 +57,15 @@ namespace ErrorCodes
|
||||
namespace DB
|
||||
{
|
||||
|
||||
static bool supportsAtomicRenameImpl()
|
||||
static bool supportsAtomicRenameImpl(std::string * out_message)
|
||||
{
|
||||
VersionNumber renameat2_minimal_version(3, 15, 0);
|
||||
VersionNumber linux_version(Poco::Environment::osVersion());
|
||||
return linux_version >= renameat2_minimal_version;
|
||||
if (linux_version >= renameat2_minimal_version)
|
||||
return true;
|
||||
if (out_message)
|
||||
*out_message = fmt::format("Linux kernel 3.15+ is required, got {}", linux_version.toString());
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool renameat2(const std::string & old_path, const std::string & new_path, int flags)
|
||||
@ -97,9 +101,9 @@ static bool renameat2(const std::string & old_path, const std::string & new_path
|
||||
ErrnoException::throwFromPath(ErrorCodes::SYSTEM_ERROR, new_path, "Cannot rename {} to {}", old_path, new_path);
|
||||
}
|
||||
|
||||
bool supportsAtomicRename()
|
||||
bool supportsAtomicRename(std::string * out_message)
|
||||
{
|
||||
static bool supports = supportsAtomicRenameImpl();
|
||||
static bool supports = supportsAtomicRenameImpl(out_message);
|
||||
return supports;
|
||||
}
|
||||
|
||||
@ -152,15 +156,19 @@ static bool renameat2(const std::string & old_path, const std::string & new_path
|
||||
}
|
||||
|
||||
|
||||
static bool supportsAtomicRenameImpl()
|
||||
static bool supportsAtomicRenameImpl(std::string * out_message)
|
||||
{
|
||||
auto fun = dlsym(RTLD_DEFAULT, "renamex_np");
|
||||
return fun != nullptr;
|
||||
if (fun != nullptr)
|
||||
return true;
|
||||
if (out_message)
|
||||
*out_message = "macOS 10.12 or later is required";
|
||||
return false;
|
||||
}
|
||||
|
||||
bool supportsAtomicRename()
|
||||
bool supportsAtomicRename(std::string * out_message)
|
||||
{
|
||||
static bool supports = supportsAtomicRenameImpl();
|
||||
static bool supports = supportsAtomicRenameImpl(out_message);
|
||||
return supports;
|
||||
}
|
||||
|
||||
@ -179,8 +187,10 @@ static bool renameat2(const std::string &, const std::string &, int)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool supportsAtomicRename()
|
||||
bool supportsAtomicRename(std::string * out_message)
|
||||
{
|
||||
if (out_message)
|
||||
*out_message = "only Linux and macOS are supported";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ namespace DB
|
||||
{
|
||||
|
||||
/// Returns true, if the following functions supported by the system
|
||||
bool supportsAtomicRename();
|
||||
bool supportsAtomicRename(std::string * out_message = nullptr);
|
||||
|
||||
/// Atomically rename old_path to new_path. If new_path exists, do not overwrite it and throw exception
|
||||
void renameNoReplace(const std::string & old_path, const std::string & new_path);
|
||||
|
@ -197,8 +197,9 @@ void DatabaseAtomic::renameTable(ContextPtr local_context, const String & table_
|
||||
throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Moving tables between databases of different engines is not supported");
|
||||
}
|
||||
|
||||
if (exchange && !supportsAtomicRename())
|
||||
throw Exception(ErrorCodes::NOT_IMPLEMENTED, "RENAME EXCHANGE is not supported");
|
||||
std::string message;
|
||||
if (exchange && !supportsAtomicRename(&message))
|
||||
throw Exception(ErrorCodes::NOT_IMPLEMENTED, "RENAME EXCHANGE is not supported because exchanging files is not supported by the OS ({})", message);
|
||||
|
||||
waitDatabaseStarted();
|
||||
|
||||
|
@ -968,6 +968,11 @@ void InterpreterCreateQuery::validateMaterializedViewColumnsAndEngine(const ASTC
|
||||
if (database && database->getEngineName() != "Atomic")
|
||||
throw Exception(ErrorCodes::INCORRECT_QUERY,
|
||||
"Refreshable materialized views (except with APPEND) only support Atomic database engine, but database {} has engine {}", create.getDatabase(), database->getEngineName());
|
||||
|
||||
std::string message;
|
||||
if (!supportsAtomicRename(&message))
|
||||
throw Exception(ErrorCodes::NOT_IMPLEMENTED,
|
||||
"Can't create refreshable materialized view because exchanging files is not supported by the OS ({})", message);
|
||||
}
|
||||
|
||||
Block input_block;
|
||||
|
Loading…
Reference in New Issue
Block a user