Merge pull request #34860 from zhangjmruc/master

Support non-table DDLs on cross replicated cluster
This commit is contained in:
tavplubix 2022-03-04 19:37:51 +01:00 committed by GitHub
commit e49521163f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 5 deletions

View File

@ -259,15 +259,19 @@ bool DDLTask::tryFindHostInCluster()
* */
is_circular_replicated = true;
auto * query_with_table = dynamic_cast<ASTQueryWithTableAndOutput *>(query.get());
if (!query_with_table || !query_with_table->database)
/// For other DDLs like CREATE USER, there is no database name and should be executed successfully.
if (query_with_table)
{
if (!query_with_table->database)
throw Exception(ErrorCodes::INCONSISTENT_CLUSTER_DEFINITION,
"For a distributed DDL on circular replicated cluster its table name must be qualified by database name.");
}
if (default_database == query_with_table->getDatabase())
return true;
}
}
}
found_exact_match = true;
host_shard_num = shard_num;
host_replica_num = replica_num;

View File

@ -104,3 +104,11 @@ def test_atomic_database(started_cluster):
node1.query("INSERT INTO replica_1.rmt VALUES (1, 'test')")
node2.query("SYSTEM SYNC REPLICA replica_2.rmt", timeout=5)
assert_eq_with_retry(node2, "SELECT * FROM replica_2.rmt", '1\ttest')
def test_non_query_with_table_ddl(started_cluster):
node1.query("CREATE USER A ON CLUSTER cross_3shards_2replicas")
assert node1.query("SELECT 1", user='A') == "1\n"
assert node2.query("SELECT 1", user='A') == "1\n"
node2.query("DROP USER A ON CLUSTER cross_3shards_2replicas")