table function file - fix path validate [#add_table_function_file]

This commit is contained in:
decaseal 2018-04-02 18:38:43 +03:00
parent 58489628aa
commit fba2f32c53

View File

@ -46,11 +46,16 @@ namespace DB
std::string structure = static_cast<const ASTLiteral &>(*args[2]).value.safeGet<String>(); std::string structure = static_cast<const ASTLiteral &>(*args[2]).value.safeGet<String>();
/// Validate path /// Validate path
std::string clickhouse_path = Poco::Path(context.getPath()).makeAbsolute().toString(); Poco::Path clickhouse_data_poco_path = Poco::Path(context.getPath() + '/data').makeAbsolute();
std::string absolute_path = Poco::Path(path).absolute().toString(); std::string clickhouse_data_path = clickhouse_data_poco_path.toString();
if (!startsWith(absolute_path, clickhouse_path)) Poco::Path poco_path = Poco::Path(path);
throw Exception("Part path " + absolute_path + " is not inside " + clickhouse_path, ErrorCodes::LOGICAL_ERROR); if (poco_path.isRelative())
poco_path = Poco::Path(clickhouse_data_poco_path, poco_path);
std::string absolute_path = poco_path.absolute().toString();
if (!startsWith(absolute_path, clickhouse_data_path))
throw Exception("Part path " + absolute_path + " is not inside " + clickhouse_data_path, ErrorCodes::LOGICAL_ERROR);
// Create sample block // Create sample block
std::vector<std::string> structure_vals; std::vector<std::string> structure_vals;