diff --git a/src/backend/distributed/commands/function.c b/src/backend/distributed/commands/function.c index a02fd2e5d..2ffe30ec2 100644 --- a/src/backend/distributed/commands/function.c +++ b/src/backend/distributed/commands/function.c @@ -342,6 +342,8 @@ GetFunctionColocationId(Oid functionOid, char *colocateWithTableName, if (pg_strncasecmp(colocateWithTableName, "default", NAMEDATALEN) == 0) { + Oid colocatedTableId = InvalidOid; + /* check for default colocation group */ colocationId = ColocationId(ShardCount, ShardReplicationFactor, distributionArgumentOid); @@ -356,6 +358,22 @@ GetFunctionColocationId(Oid functionOid, char *colocateWithTableName, errhint("Provide a distributed table via \"colocate_with\" " "option to create_distributed_function()"))); } + + colocatedTableId = ColocatedTableId(colocationId); + if (colocatedTableId != InvalidOid) + { + EnsureFunctionCanBeColocatedWithTable(functionOid, distributionArgumentOid, + colocatedTableId); + } + else if (ReplicationModel == REPLICATION_MODEL_COORDINATOR) + { + /* streaming replication model is required for metadata syncing */ + ereport(ERROR, (errmsg("cannot create a function with a distribution " + "argument when citus.replication_model is " + "'statement'"), + errhint("Set citus.replication_model to 'streaming' " + "before creating distributed tables"))); + } } else { @@ -412,7 +430,7 @@ EnsureFunctionCanBeColocatedWithTable(Oid functionOid, Oid distributionColumnTyp "with distributed tables that are created using " "streaming replication model."), errhint("When distributing tables make sure that " - "\"citus.replication_model\" is set to \"streaming\""))); + "citus.replication_model = 'streaming'"))); } /*