mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 01:51:59 +00:00
add column default_database
This commit is contained in:
parent
99929981ab
commit
66631ca680
@ -28,7 +28,7 @@ Structure of the `users` section:
|
||||
<profile>profile_name</profile>
|
||||
|
||||
<quota>default</quota>
|
||||
|
||||
<default_database>default<default_database>
|
||||
<databases>
|
||||
<database_name>
|
||||
<table_name>
|
||||
|
@ -15,6 +15,7 @@ CREATE USER [IF NOT EXISTS | OR REPLACE] name1 [ON CLUSTER cluster_name1]
|
||||
[NOT IDENTIFIED | IDENTIFIED {[WITH {no_password | plaintext_password | sha256_password | sha256_hash | double_sha1_password | double_sha1_hash}] BY {'password' | 'hash'}} | {WITH ldap SERVER 'server_name'} | {WITH kerberos [REALM 'realm']}]
|
||||
[HOST {LOCAL | NAME 'name' | REGEXP 'name_regexp' | IP 'address' | LIKE 'pattern'} [,...] | ANY | NONE]
|
||||
[DEFAULT ROLE role [,...]]
|
||||
[DEFAULT DATABASE database | NONE]
|
||||
[GRANTEES {user | role | ANY | NONE} [,...] [EXCEPT {user | role} [,...]]]
|
||||
[SETTINGS variable [= value] [MIN [=] min_value] [MAX [=] max_value] [READONLY | WRITABLE] | PROFILE 'profile_name'] [,...]
|
||||
```
|
||||
|
@ -50,6 +50,7 @@ NamesAndTypesList StorageSystemUsers::getNamesAndTypes()
|
||||
{"grantees_any", std::make_shared<DataTypeUInt8>()},
|
||||
{"grantees_list", std::make_shared<DataTypeArray>(std::make_shared<DataTypeString>())},
|
||||
{"grantees_except", std::make_shared<DataTypeArray>(std::make_shared<DataTypeString>())},
|
||||
{"default_database", std::make_shared<DataTypeString>()},
|
||||
};
|
||||
return names_and_types;
|
||||
}
|
||||
@ -85,6 +86,7 @@ void StorageSystemUsers::fillData(MutableColumns & res_columns, ContextPtr conte
|
||||
auto & column_grantees_list_offsets = assert_cast<ColumnArray &>(*res_columns[column_index++]).getOffsets();
|
||||
auto & column_grantees_except = assert_cast<ColumnString &>(assert_cast<ColumnArray &>(*res_columns[column_index]).getData());
|
||||
auto & column_grantees_except_offsets = assert_cast<ColumnArray &>(*res_columns[column_index++]).getOffsets();
|
||||
auto & column_default_database = assert_cast<ColumnString &>(*res_columns[column_index++]);
|
||||
|
||||
auto add_row = [&](const String & name,
|
||||
const UUID & id,
|
||||
@ -92,7 +94,8 @@ void StorageSystemUsers::fillData(MutableColumns & res_columns, ContextPtr conte
|
||||
const Authentication & authentication,
|
||||
const AllowedClientHosts & allowed_hosts,
|
||||
const RolesOrUsersSet & default_roles,
|
||||
const RolesOrUsersSet & grantees)
|
||||
const RolesOrUsersSet & grantees,
|
||||
const String default_database)
|
||||
{
|
||||
column_name.insertData(name.data(), name.length());
|
||||
column_id.push_back(id.toUnderType());
|
||||
@ -180,6 +183,8 @@ void StorageSystemUsers::fillData(MutableColumns & res_columns, ContextPtr conte
|
||||
for (const auto & except_name : grantees_ast->except_names)
|
||||
column_grantees_except.insertData(except_name.data(), except_name.length());
|
||||
column_grantees_except_offsets.push_back(column_grantees_except.size());
|
||||
|
||||
column_default_database.insertData(default_database.data(),default_database.length());
|
||||
};
|
||||
|
||||
for (const auto & id : ids)
|
||||
@ -192,7 +197,8 @@ void StorageSystemUsers::fillData(MutableColumns & res_columns, ContextPtr conte
|
||||
if (!storage)
|
||||
continue;
|
||||
|
||||
add_row(user->getName(), id, storage->getStorageName(), user->authentication, user->allowed_client_hosts, user->default_roles, user->grantees);
|
||||
add_row(user->getName(), id, storage->getStorageName(), user->authentication, user->allowed_client_hosts,
|
||||
user->default_roles, user->grantees, user->default_database);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1 @@
|
||||
system
|
@ -0,0 +1,3 @@
|
||||
create user if not exists u_02001 default database system;
|
||||
select default_database from system.users where name = 'u_02001';
|
||||
drop user if exists u_02001;
|
Loading…
Reference in New Issue
Block a user