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

Method executeToTables

src/Interpreters/InterpreterRenameQuery.cpp:99–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97}
98
99BlockIO InterpreterRenameQuery::executeToTables(const ASTRenameQuery & rename, const RenameDescriptions & descriptions, TableGuards & ddl_guards)
100{
101 auto & database_catalog = DatabaseCatalog::instance();
102
103 for (const auto & elem : descriptions)
104 {
105 if (!rename.exchange)
106 database_catalog.assertTableDoesntExist(StorageID(elem.to_database_name, elem.to_table_name), getContext());
107
108 DatabasePtr database = database_catalog.getDatabase(elem.from_database_name, getContext());
109 if (typeid_cast<DatabaseReplicated *>(database.get())
110 && !getContext()->getClientInfo().is_replicated_database_internal)
111 {
112 if (1 < descriptions.size())
113 throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Database {} is Replicated, "
114 "it does not support renaming of multiple tables in single query.", elem.from_database_name);
115
116 UniqueTableName from(elem.from_database_name, elem.from_table_name);
117 UniqueTableName to(elem.to_database_name, elem.to_table_name);
118 ddl_guards[from]->releaseTableLock();
119 ddl_guards[to]->releaseTableLock();
120 return typeid_cast<DatabaseReplicated *>(database.get())->tryEnqueueReplicatedDDL(query_ptr, getContext());
121 }
122 else
123 {
124 database->renameTable(
125 getContext(),
126 elem.from_table_name,
127 *database_catalog.getDatabase(elem.to_database_name, getContext()),
128 elem.to_table_name,
129 rename.exchange,
130 rename.dictionary);
131 }
132 }
133 if (auto txn = getContext()->getCurrentTransaction())
134 txn->commitV1();
135
136 return {};
137}
138
139BlockIO InterpreterRenameQuery::executeToDatabase(const ASTRenameQuery &, const RenameDescriptions & descriptions)
140{

Callers

nothing calls this directly

Calls 11

releaseTableLockMethod · 0.80
getCurrentTransactionMethod · 0.80
StorageIDClass · 0.70
ExceptionClass · 0.70
getDatabaseMethod · 0.45
getMethod · 0.45
sizeMethod · 0.45
renameTableMethod · 0.45
commitV1Method · 0.45

Tested by

no test coverage detected