mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 16:42:05 +00:00
Rename sql command "CREATE POLICY" -> "CREATE ROW POLICY", "CREATE POLICY" is now an alias.
This commit is contained in:
parent
c2f5e3c4ad
commit
e5d8f05251
@ -90,9 +90,9 @@ enum class AccessType
|
|||||||
M(ALTER_ROLE, "", GLOBAL, ALL) \
|
M(ALTER_ROLE, "", GLOBAL, ALL) \
|
||||||
M(DROP_ROLE, "", GLOBAL, ALL) \
|
M(DROP_ROLE, "", GLOBAL, ALL) \
|
||||||
M(ROLE_ADMIN, "", GLOBAL, ALL) /* allows to grant and revoke the roles which are not granted to the current user with admin option */\
|
M(ROLE_ADMIN, "", GLOBAL, ALL) /* allows to grant and revoke the roles which are not granted to the current user with admin option */\
|
||||||
M(CREATE_POLICY, "CREATE ROW POLICY", GLOBAL, ALL) \
|
M(CREATE_ROW_POLICY, "CREATE POLICY", GLOBAL, ALL) \
|
||||||
M(ALTER_POLICY, "ALTER ROW POLICY", GLOBAL, ALL) \
|
M(ALTER_ROW_POLICY, "ALTER POLICY", GLOBAL, ALL) \
|
||||||
M(DROP_POLICY, "DROP ROW POLICY", GLOBAL, ALL) \
|
M(DROP_ROW_POLICY, "DROP POLICY", GLOBAL, ALL) \
|
||||||
M(CREATE_QUOTA, "", GLOBAL, ALL) \
|
M(CREATE_QUOTA, "", GLOBAL, ALL) \
|
||||||
M(ALTER_QUOTA, "", GLOBAL, ALL) \
|
M(ALTER_QUOTA, "", GLOBAL, ALL) \
|
||||||
M(DROP_QUOTA, "", GLOBAL, ALL) \
|
M(DROP_QUOTA, "", GLOBAL, ALL) \
|
||||||
|
@ -411,7 +411,7 @@ boost::shared_ptr<const AccessRights> ContextAccess::calculateResultAccess(bool
|
|||||||
|
|
||||||
static const AccessFlags all_dcl = AccessType::CREATE_USER | AccessType::ALTER_USER | AccessType::DROP_USER
|
static const AccessFlags all_dcl = AccessType::CREATE_USER | AccessType::ALTER_USER | AccessType::DROP_USER
|
||||||
| AccessType::CREATE_ROLE | AccessType::ALTER_ROLE | AccessType::DROP_ROLE | AccessType::ROLE_ADMIN
|
| AccessType::CREATE_ROLE | AccessType::ALTER_ROLE | AccessType::DROP_ROLE | AccessType::ROLE_ADMIN
|
||||||
| AccessType::CREATE_POLICY | AccessType::ALTER_POLICY | AccessType::DROP_POLICY
|
| AccessType::CREATE_ROW_POLICY | AccessType::ALTER_ROW_POLICY | AccessType::DROP_ROW_POLICY
|
||||||
| AccessType::CREATE_SETTINGS_PROFILE | AccessType::ALTER_SETTINGS_PROFILE | AccessType::DROP_SETTINGS_PROFILE
|
| AccessType::CREATE_SETTINGS_PROFILE | AccessType::ALTER_SETTINGS_PROFILE | AccessType::DROP_SETTINGS_PROFILE
|
||||||
| AccessType::CREATE_QUOTA | AccessType::ALTER_QUOTA | AccessType::DROP_QUOTA;
|
| AccessType::CREATE_QUOTA | AccessType::ALTER_QUOTA | AccessType::DROP_QUOTA;
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ BlockIO InterpreterCreateRowPolicyQuery::execute()
|
|||||||
{
|
{
|
||||||
const auto & query = query_ptr->as<const ASTCreateRowPolicyQuery &>();
|
const auto & query = query_ptr->as<const ASTCreateRowPolicyQuery &>();
|
||||||
auto & access_control = context.getAccessControlManager();
|
auto & access_control = context.getAccessControlManager();
|
||||||
context.checkAccess(query.alter ? AccessType::ALTER_POLICY : AccessType::CREATE_POLICY);
|
context.checkAccess(query.alter ? AccessType::ALTER_ROW_POLICY : AccessType::CREATE_ROW_POLICY);
|
||||||
|
|
||||||
std::optional<ExtendedRoleSet> roles_from_query;
|
std::optional<ExtendedRoleSet> roles_from_query;
|
||||||
if (query.roles)
|
if (query.roles)
|
||||||
|
@ -37,7 +37,7 @@ namespace
|
|||||||
case Kind::USER: return AccessType::DROP_USER;
|
case Kind::USER: return AccessType::DROP_USER;
|
||||||
case Kind::ROLE: return AccessType::DROP_ROLE;
|
case Kind::ROLE: return AccessType::DROP_ROLE;
|
||||||
case Kind::QUOTA: return AccessType::DROP_QUOTA;
|
case Kind::QUOTA: return AccessType::DROP_QUOTA;
|
||||||
case Kind::ROW_POLICY: return AccessType::DROP_POLICY;
|
case Kind::ROW_POLICY: return AccessType::DROP_ROW_POLICY;
|
||||||
case Kind::SETTINGS_PROFILE: return AccessType::DROP_SETTINGS_PROFILE;
|
case Kind::SETTINGS_PROFILE: return AccessType::DROP_SETTINGS_PROFILE;
|
||||||
}
|
}
|
||||||
__builtin_unreachable();
|
__builtin_unreachable();
|
||||||
|
@ -122,7 +122,7 @@ namespace
|
|||||||
|
|
||||||
String ASTCreateRowPolicyQuery::getID(char) const
|
String ASTCreateRowPolicyQuery::getID(char) const
|
||||||
{
|
{
|
||||||
return "CREATE POLICY or ALTER POLICY query";
|
return "CREATE ROW POLICY or ALTER ROW POLICY query";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -136,11 +136,11 @@ void ASTCreateRowPolicyQuery::formatImpl(const FormatSettings & settings, Format
|
|||||||
{
|
{
|
||||||
if (attach)
|
if (attach)
|
||||||
{
|
{
|
||||||
settings.ostr << (settings.hilite ? hilite_keyword : "") << "ATTACH POLICY";
|
settings.ostr << (settings.hilite ? hilite_keyword : "") << "ATTACH ROW POLICY";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
settings.ostr << (settings.hilite ? hilite_keyword : "") << (alter ? "ALTER POLICY" : "CREATE POLICY")
|
settings.ostr << (settings.hilite ? hilite_keyword : "") << (alter ? "ALTER ROW POLICY" : "CREATE ROW POLICY")
|
||||||
<< (settings.hilite ? hilite_none : "");
|
<< (settings.hilite ? hilite_none : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ def test_create():
|
|||||||
def check():
|
def check():
|
||||||
assert instance.query("SHOW CREATE USER u1") == "CREATE USER u1 SETTINGS PROFILE s1\n"
|
assert instance.query("SHOW CREATE USER u1") == "CREATE USER u1 SETTINGS PROFILE s1\n"
|
||||||
assert instance.query("SHOW CREATE USER u2") == "CREATE USER u2 HOST LOCAL DEFAULT ROLE rx\n"
|
assert instance.query("SHOW CREATE USER u2") == "CREATE USER u2 HOST LOCAL DEFAULT ROLE rx\n"
|
||||||
assert instance.query("SHOW CREATE ROW POLICY p ON mydb.mytable") == "CREATE POLICY p ON mydb.mytable FOR SELECT USING a < 1000 TO u1, u2\n"
|
assert instance.query("SHOW CREATE ROW POLICY p ON mydb.mytable") == "CREATE ROW POLICY p ON mydb.mytable FOR SELECT USING a < 1000 TO u1, u2\n"
|
||||||
assert instance.query("SHOW CREATE QUOTA q") == "CREATE QUOTA q KEYED BY \\'none\\' FOR INTERVAL 1 HOUR MAX QUERIES = 100 TO ALL EXCEPT rx\n"
|
assert instance.query("SHOW CREATE QUOTA q") == "CREATE QUOTA q KEYED BY \\'none\\' FOR INTERVAL 1 HOUR MAX QUERIES = 100 TO ALL EXCEPT rx\n"
|
||||||
assert instance.query("SHOW GRANTS FOR u1") == ""
|
assert instance.query("SHOW GRANTS FOR u1") == ""
|
||||||
assert instance.query("SHOW GRANTS FOR u2") == "GRANT rx TO u2\n"
|
assert instance.query("SHOW GRANTS FOR u2") == "GRANT rx TO u2\n"
|
||||||
|
@ -228,22 +228,22 @@ def test_dcl_introspection():
|
|||||||
assert instance.query("SHOW POLICIES") == "another ON mydb.filtered_table1\nanother ON mydb.filtered_table2\nanother ON mydb.filtered_table3\nanother ON mydb.local\ndefault ON mydb.filtered_table1\ndefault ON mydb.filtered_table2\ndefault ON mydb.filtered_table3\ndefault ON mydb.local\n"
|
assert instance.query("SHOW POLICIES") == "another ON mydb.filtered_table1\nanother ON mydb.filtered_table2\nanother ON mydb.filtered_table3\nanother ON mydb.local\ndefault ON mydb.filtered_table1\ndefault ON mydb.filtered_table2\ndefault ON mydb.filtered_table3\ndefault ON mydb.local\n"
|
||||||
assert instance.query("SHOW POLICIES CURRENT") == "default ON mydb.filtered_table1\ndefault ON mydb.filtered_table2\ndefault ON mydb.filtered_table3\ndefault ON mydb.local\n"
|
assert instance.query("SHOW POLICIES CURRENT") == "default ON mydb.filtered_table1\ndefault ON mydb.filtered_table2\ndefault ON mydb.filtered_table3\ndefault ON mydb.local\n"
|
||||||
|
|
||||||
assert instance.query("SHOW CREATE POLICY default ON mydb.filtered_table1") == "CREATE POLICY default ON mydb.filtered_table1 FOR SELECT USING a = 1 TO default\n"
|
assert instance.query("SHOW CREATE POLICY default ON mydb.filtered_table1") == "CREATE ROW POLICY default ON mydb.filtered_table1 FOR SELECT USING a = 1 TO default\n"
|
||||||
assert instance.query("SHOW CREATE POLICY default ON mydb.filtered_table2") == "CREATE POLICY default ON mydb.filtered_table2 FOR SELECT USING ((a + b) < 1) OR ((c - d) > 5) TO default\n"
|
assert instance.query("SHOW CREATE POLICY default ON mydb.filtered_table2") == "CREATE ROW POLICY default ON mydb.filtered_table2 FOR SELECT USING ((a + b) < 1) OR ((c - d) > 5) TO default\n"
|
||||||
assert instance.query("SHOW CREATE POLICY default ON mydb.filtered_table3") == "CREATE POLICY default ON mydb.filtered_table3 FOR SELECT USING c = 1 TO default\n"
|
assert instance.query("SHOW CREATE POLICY default ON mydb.filtered_table3") == "CREATE ROW POLICY default ON mydb.filtered_table3 FOR SELECT USING c = 1 TO default\n"
|
||||||
assert instance.query("SHOW CREATE POLICY default ON mydb.local") == "CREATE POLICY default ON mydb.local FOR SELECT USING 1 TO default\n"
|
assert instance.query("SHOW CREATE POLICY default ON mydb.local") == "CREATE ROW POLICY default ON mydb.local FOR SELECT USING 1 TO default\n"
|
||||||
|
|
||||||
copy_policy_xml('all_rows.xml')
|
copy_policy_xml('all_rows.xml')
|
||||||
assert instance.query("SHOW POLICIES CURRENT") == "default ON mydb.filtered_table1\ndefault ON mydb.filtered_table2\ndefault ON mydb.filtered_table3\n"
|
assert instance.query("SHOW POLICIES CURRENT") == "default ON mydb.filtered_table1\ndefault ON mydb.filtered_table2\ndefault ON mydb.filtered_table3\n"
|
||||||
assert instance.query("SHOW CREATE POLICY default ON mydb.filtered_table1") == "CREATE POLICY default ON mydb.filtered_table1 FOR SELECT USING 1 TO default\n"
|
assert instance.query("SHOW CREATE POLICY default ON mydb.filtered_table1") == "CREATE ROW POLICY default ON mydb.filtered_table1 FOR SELECT USING 1 TO default\n"
|
||||||
assert instance.query("SHOW CREATE POLICY default ON mydb.filtered_table2") == "CREATE POLICY default ON mydb.filtered_table2 FOR SELECT USING 1 TO default\n"
|
assert instance.query("SHOW CREATE POLICY default ON mydb.filtered_table2") == "CREATE ROW POLICY default ON mydb.filtered_table2 FOR SELECT USING 1 TO default\n"
|
||||||
assert instance.query("SHOW CREATE POLICY default ON mydb.filtered_table3") == "CREATE POLICY default ON mydb.filtered_table3 FOR SELECT USING 1 TO default\n"
|
assert instance.query("SHOW CREATE POLICY default ON mydb.filtered_table3") == "CREATE ROW POLICY default ON mydb.filtered_table3 FOR SELECT USING 1 TO default\n"
|
||||||
|
|
||||||
copy_policy_xml('no_rows.xml')
|
copy_policy_xml('no_rows.xml')
|
||||||
assert instance.query("SHOW POLICIES CURRENT") == "default ON mydb.filtered_table1\ndefault ON mydb.filtered_table2\ndefault ON mydb.filtered_table3\n"
|
assert instance.query("SHOW POLICIES CURRENT") == "default ON mydb.filtered_table1\ndefault ON mydb.filtered_table2\ndefault ON mydb.filtered_table3\n"
|
||||||
assert instance.query("SHOW CREATE POLICY default ON mydb.filtered_table1") == "CREATE POLICY default ON mydb.filtered_table1 FOR SELECT USING NULL TO default\n"
|
assert instance.query("SHOW CREATE POLICY default ON mydb.filtered_table1") == "CREATE ROW POLICY default ON mydb.filtered_table1 FOR SELECT USING NULL TO default\n"
|
||||||
assert instance.query("SHOW CREATE POLICY default ON mydb.filtered_table2") == "CREATE POLICY default ON mydb.filtered_table2 FOR SELECT USING NULL TO default\n"
|
assert instance.query("SHOW CREATE POLICY default ON mydb.filtered_table2") == "CREATE ROW POLICY default ON mydb.filtered_table2 FOR SELECT USING NULL TO default\n"
|
||||||
assert instance.query("SHOW CREATE POLICY default ON mydb.filtered_table3") == "CREATE POLICY default ON mydb.filtered_table3 FOR SELECT USING NULL TO default\n"
|
assert instance.query("SHOW CREATE POLICY default ON mydb.filtered_table3") == "CREATE ROW POLICY default ON mydb.filtered_table3 FOR SELECT USING NULL TO default\n"
|
||||||
|
|
||||||
copy_policy_xml('no_filters.xml')
|
copy_policy_xml('no_filters.xml')
|
||||||
assert instance.query("SHOW POLICIES") == ""
|
assert instance.query("SHOW POLICIES") == ""
|
||||||
@ -268,7 +268,7 @@ def test_dcl_management():
|
|||||||
instance.query("ALTER POLICY pA ON mydb.filtered_table1 RENAME TO pB")
|
instance.query("ALTER POLICY pA ON mydb.filtered_table1 RENAME TO pB")
|
||||||
assert instance.query("SELECT * FROM mydb.filtered_table1") == "1\t0\n"
|
assert instance.query("SELECT * FROM mydb.filtered_table1") == "1\t0\n"
|
||||||
assert instance.query("SHOW POLICIES CURRENT ON mydb.filtered_table1") == "pB\n"
|
assert instance.query("SHOW POLICIES CURRENT ON mydb.filtered_table1") == "pB\n"
|
||||||
assert instance.query("SHOW CREATE POLICY pB ON mydb.filtered_table1") == "CREATE POLICY pB ON mydb.filtered_table1 FOR SELECT USING a > b TO default\n"
|
assert instance.query("SHOW CREATE POLICY pB ON mydb.filtered_table1") == "CREATE ROW POLICY pB ON mydb.filtered_table1 FOR SELECT USING a > b TO default\n"
|
||||||
|
|
||||||
instance.query("DROP POLICY pB ON mydb.filtered_table1")
|
instance.query("DROP POLICY pB ON mydb.filtered_table1")
|
||||||
assert instance.query("SELECT * FROM mydb.filtered_table1") == "0\t0\n0\t1\n1\t0\n1\t1\n"
|
assert instance.query("SELECT * FROM mydb.filtered_table1") == "0\t0\n0\t1\n1\t0\n1\t1\n"
|
||||||
|
Loading…
Reference in New Issue
Block a user