pull/7219/head
Onur Tirtir 2023-09-25 10:44:38 +03:00
parent 4cea8c148f
commit f54f9166a5
2 changed files with 15 additions and 6 deletions

View File

@ -436,11 +436,6 @@ CreateDistributedTableConcurrently(Oid relationId, char *distributionColumnName,
char replicationModel = DecideDistTableReplicationModel(distributionMethod, char replicationModel = DecideDistTableReplicationModel(distributionMethod,
colocateWithTableName); colocateWithTableName);
if (replicationModel != REPLICATION_MODEL_STREAMING)
{
ereport(ERROR, (errmsg("cannot create a replicated distributed "
"table concurrently")));
}
/* /*
* we fail transaction before local table conversion if the table could not be colocated with * we fail transaction before local table conversion if the table could not be colocated with
@ -450,6 +445,19 @@ CreateDistributedTableConcurrently(Oid relationId, char *distributionColumnName,
if (!IsColocateWithDefault(colocateWithTableName) && !IsColocateWithNone( if (!IsColocateWithDefault(colocateWithTableName) && !IsColocateWithNone(
colocateWithTableName)) colocateWithTableName))
{ {
if (replicationModel != REPLICATION_MODEL_STREAMING)
{
ereport(ERROR, (errmsg("cannot create distributed table "
"concurrently because Citus allows "
"concurrent table distribution only when "
"citus.shard_replication_factor = 1"),
errhint("table %s is requested to be colocated "
"with %s which has "
"citus.shard_replication_factor > 1",
get_rel_name(relationId),
colocateWithTableName)));
}
EnsureColocateWithTableIsValid(relationId, distributionMethod, EnsureColocateWithTableIsValid(relationId, distributionMethod,
distributionColumnName, distributionColumnName,
colocateWithTableName); colocateWithTableName);

View File

@ -47,7 +47,8 @@ select create_distributed_table('dist_1', 'a');
set citus.shard_replication_factor to 1; set citus.shard_replication_factor to 1;
create table dist_2(a int); create table dist_2(a int);
select create_distributed_table_concurrently('dist_2', 'a', colocate_with=>'dist_1'); select create_distributed_table_concurrently('dist_2', 'a', colocate_with=>'dist_1');
ERROR: cannot create a replicated distributed table concurrently ERROR: cannot create distributed table concurrently because Citus allows concurrent table distribution only when citus.shard_replication_factor = 1
HINT: table dist_2 is requested to be colocated with dist_1 which has citus.shard_replication_factor > 1
begin; begin;
select create_distributed_table_concurrently('test','key'); select create_distributed_table_concurrently('test','key');
ERROR: create_distributed_table_concurrently cannot run inside a transaction block ERROR: create_distributed_table_concurrently cannot run inside a transaction block