-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow avnadmin creating database using sql [DDB-1557] #2
base: v24.3.5.46-lts-aiven
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good to me, but I added some non-critical nits.
@@ -469,6 +475,54 @@ BlockIO InterpreterGrantQuery::execute() | |||
if (need_check_grantees_are_allowed) | |||
current_user_access->checkGranteesAreAllowed(grantees); | |||
|
|||
if (query.default_replicated_db_privileges) { | |||
auto context = getContext(); | |||
auto username = context->getUserName(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This variable is unused
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rely on linters which I did not setup there too much(
"TRUNCATE " | ||
"ON " + escapeString(db_name) + ".* TO " + escapeString(grantee) + " WITH GRANT OPTION"; | ||
|
||
auto exec_result = executeQuery(default_grant_query, getContext(), QueryFlags{ .internal = true }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you have context
variable above. Maybe it'd be better to use it instead of getContext()
here?
|
||
void InterpreterCreateQuery::checkDatabaseNameAllowed() { | ||
auto & create = query_ptr->as<ASTCreateQuery &>(); | ||
if (!create.database || internal) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check for !create.database
is superfluous here, since this function is called only when is_create_database
is true
which means create.database
is always true
at this point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, probably unnecessary safety measure...
create_interpreter->setIsRestoreFromBackup(flags.distributed_backup_restore); | ||
// create_interpreter->setInternal(flags.internal); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A leftover?
There are 2 main changes: 1. Allow `avnadmin` calling `CREATE DATABASE`, which overrides during execution phase, ensuring correct parameters are passed and running it with `aiven` privileges. 2. Introduce `GRANT DEFAULT REPLICATED DATABASE PRIVILEGES` statement, which will give a user a default set of privileges for a database. This is necessary to maintain a common source of truth while creating databases from different environments.
8dec864
to
0390b75
Compare
There are 2 main changes:
avnadmin
callingCREATE DATABASE
, which overrides during execution phase, ensuring correct parameters are passed and running it withaiven
privileges.GRANT DEFAULT REPLICATED DATABASE PRIVILEGES
statement, which will give a user a default set of privileges for a database. This is necessary to maintain a common source of truth while creating databases from different environments.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
...
Documentation entry for user-facing changes
CI Settings (Only check the boxes if you know what you are doing):