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

Method executeDropQuery

src/Interpreters/InterpreterDropQuery.cpp:496–524  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

494}
495
496void InterpreterDropQuery::executeDropQuery(ASTDropQuery::Kind kind, ContextPtr global_context, ContextPtr current_context, const StorageID & target_table_id, bool no_delay)
497{
498 if (DatabaseCatalog::instance().tryGetTable(target_table_id, current_context))
499 {
500 /// We create and execute `drop` query for internal table.
501 auto drop_query = std::make_shared<ASTDropQuery>();
502 drop_query->database = target_table_id.database_name;
503 drop_query->table = target_table_id.table_name;
504 drop_query->kind = kind;
505 drop_query->no_delay = no_delay;
506 drop_query->if_exists = true;
507 ASTPtr ast_drop_query = drop_query;
508 /// FIXME We have to use global context to execute DROP query for inner table
509 /// to avoid "Not enough privileges" error if current user has only DROP VIEW ON mat_view_name privilege
510 /// and not allowed to drop inner table explicitly. Allowing to drop inner table without explicit grant
511 /// looks like expected behaviour and we have tests for it.
512 auto drop_context = Context::createCopy(global_context);
513 drop_context->getClientInfo().query_kind = ClientInfo::QueryKind::SECONDARY_QUERY;
514 if (auto txn = current_context->getZooKeeperMetadataTransaction())
515 {
516 /// For Replicated database
517 drop_context->getClientInfo().is_replicated_database_internal = true;
518 drop_context->setQueryContext(std::const_pointer_cast<Context>(current_context));
519 drop_context->initZooKeeperMetadataTransaction(txn, true);
520 }
521 InterpreterDropQuery drop_interpreter(ast_drop_query, drop_context);
522 drop_interpreter.execute();
523 }
524}
525
526}

Callers

nothing calls this directly

Calls 5

setQueryContextMethod · 0.80
tryGetTableMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected