mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 10:02:01 +00:00
SQLUserDefinedFunctionsLoader allow symlinks in user_defined directory
This commit is contained in:
parent
53f5f355d9
commit
965b706350
@ -86,29 +86,34 @@ void UserDefinedSQLObjectsLoader::loadObjects(ContextPtr context)
|
||||
if (unlikely(!enable_persistence))
|
||||
return;
|
||||
|
||||
LOG_DEBUG(log, "loading user defined objects");
|
||||
LOG_DEBUG(log, "Loading user defined objects");
|
||||
|
||||
String dir_path = context->getUserDefinedPath();
|
||||
Poco::DirectoryIterator dir_end;
|
||||
for (Poco::DirectoryIterator it(dir_path); it != dir_end; ++it)
|
||||
{
|
||||
if (it->isLink())
|
||||
if (it->isDirectory())
|
||||
continue;
|
||||
|
||||
const auto & file_name = it.name();
|
||||
const std::string & file_name = it.name();
|
||||
|
||||
/// For '.svn', '.gitignore' directory and similar.
|
||||
if (file_name.at(0) == '.')
|
||||
continue;
|
||||
|
||||
if (!it->isDirectory() && endsWith(file_name, ".sql"))
|
||||
{
|
||||
if (!startsWith(file_name, "function_") || !endsWith(file_name, ".sql"))
|
||||
continue;
|
||||
|
||||
std::string_view object_name = file_name;
|
||||
object_name.remove_suffix(strlen(".sql"));
|
||||
|
||||
object_name.remove_prefix(strlen("function_"));
|
||||
object_name.remove_suffix(strlen(".sql"));
|
||||
|
||||
if (object_name.empty())
|
||||
continue;
|
||||
|
||||
loadUserDefinedObject(context, UserDefinedSQLObjectType::Function, object_name, dir_path + it.name());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UserDefinedSQLObjectsLoader::storeObject(ContextPtr context, UserDefinedSQLObjectType object_type, const String & object_name, const IAST & ast, bool replace)
|
||||
|
Loading…
Reference in New Issue
Block a user