| 223 | } |
| 224 | |
| 225 | BlockIO InterpreterAlterQuery::executeToDatabase(const ASTAlterQuery & alter) |
| 226 | { |
| 227 | BlockIO res; |
| 228 | |
| 229 | if (!alter.cluster.empty()) |
| 230 | return executeDDLQueryOnCluster(query_ptr, getContext(), getRequiredAccess()); |
| 231 | |
| 232 | getContext()->checkAccess(getRequiredAccess()); |
| 233 | DatabasePtr database = DatabaseCatalog::instance().getDatabase(alter.database, getContext()); |
| 234 | AlterCommands alter_commands; |
| 235 | |
| 236 | for (const auto & child : alter.command_list->children) |
| 237 | { |
| 238 | auto * command_ast = child->as<ASTAlterCommand>(); |
| 239 | if (auto alter_command = AlterCommand::parse(command_ast, getContext())) |
| 240 | alter_commands.emplace_back(std::move(*alter_command)); |
| 241 | else |
| 242 | throw Exception("Wrong parameter type in ALTER DATABASE query", ErrorCodes::LOGICAL_ERROR); |
| 243 | } |
| 244 | |
| 245 | if (!alter_commands.empty()) |
| 246 | { |
| 247 | /// Only ALTER SETTING is supported. |
| 248 | for (const auto & command : alter_commands) |
| 249 | { |
| 250 | if (command.type != AlterCommand::MODIFY_DATABASE_SETTING) |
| 251 | throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Unsupported alter type for database engines"); |
| 252 | } |
| 253 | |
| 254 | for (const auto & command : alter_commands) |
| 255 | { |
| 256 | if (!command.ignore) |
| 257 | { |
| 258 | if (command.type == AlterCommand::MODIFY_DATABASE_SETTING) |
| 259 | database->applySettingsChanges(command.settings_changes, getContext()); |
| 260 | else |
| 261 | throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Unsupported alter command"); |
| 262 | } |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | return res; |
| 267 | } |
| 268 | |
| 269 | AccessRightsElements InterpreterAlterQuery::getRequiredAccess() const |
| 270 | { |
nothing calls this directly
no test coverage detected