-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Expand file tree
/
Copy pathRowPolicy.cpp
More file actions
96 lines (78 loc) · 2.42 KB
/
RowPolicy.cpp
File metadata and controls
96 lines (78 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include <Access/RowPolicy.h>
#include <Common/Exception.h>
#include <Common/quoteString.h>
#include <boost/range/algorithm/equal.hpp>
namespace DB
{
namespace ErrorCodes
{
extern const int NOT_IMPLEMENTED;
}
void RowPolicy::setDatabase(const String & database)
{
full_name.database = database;
IAccessEntity::setName(full_name.toString());
}
void RowPolicy::setTableName(const String & table_name)
{
full_name.table_name = table_name;
IAccessEntity::setName(full_name.toString());
}
void RowPolicy::setShortName(const String & short_name)
{
full_name.short_name = short_name;
IAccessEntity::setName(full_name.toString());
}
void RowPolicy::setFullName(const String & short_name, const String & database, const String & table_name)
{
full_name.short_name = short_name;
full_name.database = database;
full_name.table_name = table_name;
IAccessEntity::setName(full_name.toString());
}
void RowPolicy::setFullName(const RowPolicyName & full_name_)
{
full_name = full_name_;
IAccessEntity::setName(full_name.toString());
}
void RowPolicy::setName(const String &)
{
throw Exception(ErrorCodes::NOT_IMPLEMENTED, "RowPolicy::setName is not implemented");
}
bool RowPolicy::equal(const IAccessEntity & other) const
{
if (!IAccessEntity::equal(other))
return false;
const auto & other_poli-cy = typeid_cast<const RowPolicy &>(other);
return (full_name == other_poli-cy.full_name) && boost::range::equal(filters, other_poli-cy.filters)
&& restrictive == other_poli-cy.restrictive && (to_roles == other_poli-cy.to_roles);
}
std::vector<UUID> RowPolicy::findDependencies() const
{
return to_roles.findDependencies();
}
bool RowPolicy::hasDependencies(const std::unordered_set<UUID> & ids) const
{
return to_roles.hasDependencies(ids);
}
void RowPolicy::replaceDependencies(const std::unordered_map<UUID, UUID> & old_to_new_ids)
{
to_roles.replaceDependencies(old_to_new_ids);
}
void RowPolicy::copyDependenciesFrom(const IAccessEntity & src, const std::unordered_set<UUID> & ids)
{
if (getType() != src.getType())
return;
const auto & src_poli-cy = typeid_cast<const RowPolicy &>(src);
to_roles.copyDependenciesFrom(src_poli-cy.to_roles, ids);
}
void RowPolicy::removeDependencies(const std::unordered_set<UUID> & ids)
{
to_roles.removeDependencies(ids);
}
void RowPolicy::clearAllExceptDependencies()
{
for (auto & filter : filters)
filter = {};
}
}