mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-03 21:12:28 +00:00
fix
This commit is contained in:
parent
e790013a48
commit
e179500c54
@ -273,15 +273,6 @@ int Server::main(const std::vector<std::string> & /*args*/)
|
||||
|
||||
global_context->setPath(path);
|
||||
|
||||
/// Check that we have read and write access to all data paths
|
||||
auto disk_selector = global_context->getDiskSelector();
|
||||
for (const auto & [name, disk] : disk_selector.getDisksMap())
|
||||
{
|
||||
Poco::File disk_path(disk->getPath());
|
||||
if (!disk_path.canRead() || !disk_path.canWrite())
|
||||
throw Exception("There is no RW access to disk " + name + " (" + disk->getPath() + ")", ErrorCodes::PATH_ACCESS_DENIED);
|
||||
}
|
||||
|
||||
StatusFile status{path + "status"};
|
||||
|
||||
SCOPE_EXIT({
|
||||
|
@ -27,14 +27,18 @@ String DatabaseAtomic::getTableDataPath(const String & table_name) const
|
||||
auto it = table_name_to_path.find(table_name);
|
||||
if (it == table_name_to_path.end())
|
||||
throw Exception("Table " + table_name + " not found in database " + getDatabaseName(), ErrorCodes::UNKNOWN_TABLE);
|
||||
return data_path + it->second;
|
||||
assert(it->second != data_path && !it->second.empty());
|
||||
return it->second;
|
||||
}
|
||||
|
||||
String DatabaseAtomic::getTableDataPath(const ASTCreateQuery & query) const
|
||||
{
|
||||
//stringToUUID(query.uuid); /// Check UUID is valid
|
||||
const size_t uuid_prefix_len = 3;
|
||||
return data_path + toString(query.uuid).substr(0, uuid_prefix_len) + '/' + toString(query.uuid) + '/';
|
||||
auto tmp = data_path + toString(query.uuid).substr(0, uuid_prefix_len) + '/' + toString(query.uuid) + '/';
|
||||
assert(tmp != data_path && !tmp.empty());
|
||||
return tmp;
|
||||
|
||||
}
|
||||
|
||||
void DatabaseAtomic::drop(const Context &)
|
||||
@ -44,6 +48,7 @@ void DatabaseAtomic::drop(const Context &)
|
||||
|
||||
void DatabaseAtomic::attachTable(const String & name, const StoragePtr & table, const String & relative_table_path)
|
||||
{
|
||||
assert(relative_table_path != data_path && !relative_table_path.empty());
|
||||
DatabaseWithDictionaries::attachTable(name, table, relative_table_path);
|
||||
std::lock_guard lock(mutex);
|
||||
table_name_to_path.emplace(std::make_pair(name, relative_table_path));
|
||||
|
@ -62,7 +62,7 @@ namespace
|
||||
StoragePtr table;
|
||||
std::tie(table_name, table)
|
||||
= createTableFromAST(query, database_name, database.getTableDataPath(query), context, has_force_restore_data_flag);
|
||||
database.attachTable(table_name, table);
|
||||
database.attachTable(table_name, table, database.getTableDataPath(query));
|
||||
}
|
||||
catch (Exception & e)
|
||||
{
|
||||
|
@ -100,7 +100,7 @@ void DatabaseWithDictionaries::createDictionary(const Context & context, const S
|
||||
out.sync();
|
||||
out.close();
|
||||
}
|
||||
|
||||
|
||||
bool succeeded = false;
|
||||
SCOPE_EXIT({
|
||||
if (!succeeded)
|
||||
|
@ -745,7 +745,9 @@ void Context::addDependencyUnsafe(const StorageID & from, const StorageID & wher
|
||||
{
|
||||
checkDatabaseAccessRightsImpl(from.database_name);
|
||||
checkDatabaseAccessRightsImpl(where.database_name);
|
||||
shared->view_dependencies[from].insert(where);
|
||||
// FIXME when loading metadata storage may not know UUIDs of it's dependencies, because they are not loaded yet,
|
||||
// so UUID of `from` is not used here.
|
||||
shared->view_dependencies[{from.database_name, from.table_name}].insert(where);
|
||||
|
||||
// Notify table of dependencies change
|
||||
auto table = tryGetTable(from);
|
||||
@ -763,7 +765,7 @@ void Context::removeDependencyUnsafe(const StorageID & from, const StorageID & w
|
||||
{
|
||||
checkDatabaseAccessRightsImpl(from.database_name);
|
||||
checkDatabaseAccessRightsImpl(where.database_name);
|
||||
shared->view_dependencies[from].erase(where);
|
||||
shared->view_dependencies[{from.database_name, from.table_name}].erase(where);
|
||||
|
||||
// Notify table of dependencies change
|
||||
auto table = tryGetTable(from);
|
||||
@ -792,7 +794,7 @@ Dependencies Context::getDependencies(const StorageID & from) const
|
||||
checkDatabaseAccessRightsImpl(db);
|
||||
}
|
||||
|
||||
ViewDependencies::const_iterator iter = shared->view_dependencies.find(StorageID(db, from.table_name, from.uuid));
|
||||
ViewDependencies::const_iterator iter = shared->view_dependencies.find(StorageID(db, from.table_name));
|
||||
if (iter == shared->view_dependencies.end())
|
||||
return {};
|
||||
|
||||
|
@ -69,6 +69,10 @@ BlockInputStreamPtr InterpreterShowCreateQuery::executeImpl()
|
||||
if (!create_query && show_query && show_query->temporary)
|
||||
throw Exception("Unable to show the create query of " + show_query->table + ". Maybe it was created by the system.", ErrorCodes::THERE_IS_NO_QUERY);
|
||||
|
||||
//FIXME temporary print create query without UUID for tests (remove it)
|
||||
auto & create = create_query->as<ASTCreateQuery &>();
|
||||
create.uuid = UUID{UInt128{0, 0}};
|
||||
|
||||
std::stringstream stream;
|
||||
formatAST(*create_query, stream, false, true);
|
||||
String res = stream.str();
|
||||
|
@ -1334,7 +1334,7 @@ void MergeTreeData::rename(
|
||||
for (const auto & disk : disks)
|
||||
{
|
||||
auto new_table_path_parent = Poco::Path(new_table_path).makeParent().toString();
|
||||
disk->createDirectory(new_table_path_parent);
|
||||
disk->createDirectories(new_table_path_parent);
|
||||
disk->moveDirectory(relative_data_path, new_table_path);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user