mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 01:22:04 +00:00
storage file - fix check creation is allowed [#add_table_function_file]
This commit is contained in:
parent
22870e1e24
commit
139b40f976
@ -42,15 +42,14 @@ static std::string getTablePath(const std::string & db_dir_path, const std::stri
|
||||
return db_dir_path + escapeForFileName(table_name) + "/data." + escapeForFileName(format_name);
|
||||
}
|
||||
|
||||
static void checkCreationIsAllowed(Context & context_global, const std::string & table_path, const std::string & db_dir_path)
|
||||
static void checkCreationIsAllowed(Context & context_global, const std::string & db_dir_path, const std::string & table_path, const int & table_fd)
|
||||
{
|
||||
if (context_global.getApplicationType() != Context::ApplicationType::SERVER)
|
||||
return;
|
||||
|
||||
if (table_path.empty())
|
||||
if (table_fd >= 0)
|
||||
throw Exception("Using file descriptor as source of storage isn't allowed for server daemons", ErrorCodes::DATABASE_ACCESS_DENIED);
|
||||
|
||||
if (!startsWith(table_path, db_dir_path))
|
||||
else if (!startsWith(table_path, db_dir_path))
|
||||
throw Exception("Part path " + table_path + " is not inside " + db_dir_path, ErrorCodes::DATABASE_ACCESS_DENIED);
|
||||
}
|
||||
|
||||
@ -77,7 +76,7 @@ StorageFile::StorageFile(
|
||||
poco_path = Poco::Path(db_dir_path, poco_path);
|
||||
|
||||
path = poco_path.absolute().toString();
|
||||
checkCreationIsAllowed(context_global, path, db_dir_path);
|
||||
checkCreationIsAllowed(context_global, db_dir_path, path, table_fd);
|
||||
is_db_table = false;
|
||||
}
|
||||
else /// Is DB's file
|
||||
@ -92,7 +91,7 @@ StorageFile::StorageFile(
|
||||
}
|
||||
else /// Will use FD
|
||||
{
|
||||
checkCreationIsAllowed(context_global, "", db_dir_path);
|
||||
checkCreationIsAllowed(context_global, db_dir_path, path, table_fd);
|
||||
|
||||
is_db_table = false;
|
||||
use_table_fd = true;
|
||||
|
Loading…
Reference in New Issue
Block a user