MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / commitAlterTable

Method commitAlterTable

src/Databases/DatabaseReplicated.cpp:2351–2375  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2349}
2350
2351void DatabaseReplicated::commitAlterTable(const StorageID & table_id,
2352 const String & table_metadata_tmp_path, const String & table_metadata_path,
2353 const String & statement, ContextPtr query_context)
2354{
2355 auto txn = query_context->getZooKeeperMetadataTransaction();
2356 chassert(!ddl_worker || !ddl_worker->isCurrentlyActive() || txn);
2357 if (txn && txn->isInitialQuery())
2358 {
2359 String metadata_zk_path = zookeeper_path + "/metadata/" + escapeForFileName(table_id.table_name);
2360 txn->addOp(zkutil::makeSetRequest(metadata_zk_path, statement, -1));
2361 }
2362
2363 std::lock_guard lock{metadata_mutex};
2364 UInt64 new_digest = tables_metadata_digest;
2365 new_digest -= getMetadataHash(table_id.table_name);
2366 new_digest += DB::getMetadataHash(table_id.table_name, statement);
2367 if (txn && !is_recovering)
2368 txn->addOp(zkutil::makeSetRequest(replica_path + "/digest", toString(new_digest), -1));
2369
2370 DatabaseAtomic::commitAlterTable(table_id, table_metadata_tmp_path, table_metadata_path, statement, query_context);
2371 tables_metadata_digest = new_digest;
2372
2373 /// commitCreateTable() commits the txn, so no need to try to attach it to txn
2374 assertDigest(query_context);
2375}
2376
2377
2378bool DatabaseReplicated::canExecuteReplicatedMetadataAlter() const

Callers

nothing calls this directly

Calls 9

escapeForFileNameFunction · 0.85
makeSetRequestFunction · 0.85
getMetadataHashFunction · 0.85
assertDigestFunction · 0.85
isCurrentlyActiveMethod · 0.80
isInitialQueryMethod · 0.80
toStringFunction · 0.50
addOpMethod · 0.45

Tested by

no test coverage detected