2019-11-17 11:57:02 +00:00
|
|
|
#include <Access/RowPolicy.h>
|
|
|
|
#include <Common/quoteString.h>
|
|
|
|
#include <boost/range/algorithm/equal.hpp>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2020-05-02 16:05:01 +00:00
|
|
|
namespace ErrorCodes
|
|
|
|
{
|
2020-05-02 22:30:28 +00:00
|
|
|
extern const int NOT_IMPLEMENTED;
|
2020-05-02 16:05:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-05-02 22:30:28 +00:00
|
|
|
void RowPolicy::setDatabase(const String & database)
|
2019-11-17 11:57:02 +00:00
|
|
|
{
|
2021-11-18 07:45:52 +00:00
|
|
|
full_name.database = database;
|
|
|
|
IAccessEntity::setName(full_name.toString());
|
2019-11-17 11:57:02 +00:00
|
|
|
}
|
|
|
|
|
2020-05-02 22:30:28 +00:00
|
|
|
void RowPolicy::setTableName(const String & table_name)
|
2019-11-17 11:57:02 +00:00
|
|
|
{
|
2021-11-18 07:45:52 +00:00
|
|
|
full_name.table_name = table_name;
|
|
|
|
IAccessEntity::setName(full_name.toString());
|
2019-11-17 11:57:02 +00:00
|
|
|
}
|
|
|
|
|
2020-05-02 22:30:28 +00:00
|
|
|
void RowPolicy::setShortName(const String & short_name)
|
2019-11-17 11:57:02 +00:00
|
|
|
{
|
2021-11-18 07:45:52 +00:00
|
|
|
full_name.short_name = short_name;
|
|
|
|
IAccessEntity::setName(full_name.toString());
|
2019-11-17 11:57:02 +00:00
|
|
|
}
|
|
|
|
|
2021-11-18 07:45:52 +00:00
|
|
|
void RowPolicy::setFullName(const String & short_name, const String & database, const String & table_name)
|
2019-11-17 11:57:02 +00:00
|
|
|
{
|
2021-11-18 07:45:52 +00:00
|
|
|
full_name.short_name = short_name;
|
|
|
|
full_name.database = database;
|
|
|
|
full_name.table_name = table_name;
|
|
|
|
IAccessEntity::setName(full_name.toString());
|
2019-11-17 11:57:02 +00:00
|
|
|
}
|
|
|
|
|
2021-11-18 07:45:52 +00:00
|
|
|
void RowPolicy::setFullName(const RowPolicyName & full_name_)
|
2019-11-17 11:57:02 +00:00
|
|
|
{
|
2021-11-18 07:45:52 +00:00
|
|
|
full_name = full_name_;
|
|
|
|
IAccessEntity::setName(full_name.toString());
|
2019-11-17 11:57:02 +00:00
|
|
|
}
|
|
|
|
|
2020-05-02 22:30:28 +00:00
|
|
|
void RowPolicy::setName(const String &)
|
2019-11-17 11:57:02 +00:00
|
|
|
{
|
2023-01-23 21:13:58 +00:00
|
|
|
throw Exception(ErrorCodes::NOT_IMPLEMENTED, "RowPolicy::setName() is not implemented");
|
2019-11-17 11:57:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool RowPolicy::equal(const IAccessEntity & other) const
|
|
|
|
{
|
|
|
|
if (!IAccessEntity::equal(other))
|
|
|
|
return false;
|
|
|
|
const auto & other_policy = typeid_cast<const RowPolicy &>(other);
|
2021-11-18 13:04:42 +00:00
|
|
|
return (full_name == other_policy.full_name) && boost::range::equal(filters, other_policy.filters)
|
2022-03-21 05:41:33 +00:00
|
|
|
&& restrictive == other_policy.restrictive && (to_roles == other_policy.to_roles);
|
2019-11-17 11:57:02 +00:00
|
|
|
}
|
|
|
|
|
2022-06-15 18:25:13 +00:00
|
|
|
std::vector<UUID> RowPolicy::findDependencies() const
|
|
|
|
{
|
|
|
|
return to_roles.findDependencies();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RowPolicy::replaceDependencies(const std::unordered_map<UUID, UUID> & old_to_new_ids)
|
|
|
|
{
|
|
|
|
to_roles.replaceDependencies(old_to_new_ids);
|
|
|
|
}
|
|
|
|
|
2019-11-17 11:57:02 +00:00
|
|
|
}
|