MCPcopy Create free account
hub / github.com/ByConity/ByConity / executeToDatabase

Method executeToDatabase

src/Interpreters/InterpreterAlterQuery.cpp:225–267  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

223}
224
225BlockIO 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
269AccessRightsElements InterpreterAlterQuery::getRequiredAccess() const
270{

Callers

nothing calls this directly

Calls 8

executeDDLQueryOnClusterFunction · 0.85
ExceptionClass · 0.70
parseFunction · 0.50
emptyMethod · 0.45
checkAccessMethod · 0.45
getDatabaseMethod · 0.45
emplace_backMethod · 0.45
applySettingsChangesMethod · 0.45

Tested by

no test coverage detected