On 2018/12/03 17:51, Magnus Hagander wrote:
> On Mon, Dec 3, 2018 at 7:39 AM Tatsuo Ishii <[email protected]> wrote:
>>> Could we improve the error message that's output when the subscription
>>> target relation is a partitioned table? Currently, we get:
>>>
>>> ERROR: logical replication target relation "public.foo" is not a table
>>>
>>> I think it'd be more helpful to get:
>>>
>>> ERROR: "public.foo" is a partitioned table
>>> DETAIL: Partitioned tables are not supported as logical replication
>> targets
>>>
>>> Thoughts?
>>
>> +1
>
> +1 as well. That is definitely confusing -- to most people, that is still a
> table...
Okay, here is a patch. I didn't find any tests in subscription.sql
related to unsupported relkinds, so didn't bother adding one for this case
either.
Thanks,
Amit
diff --git a/src/backend/executor/execReplication.c
b/src/backend/executor/execReplication.c
index 5bd3bbc35e..095f3be54d 100644
--- a/src/backend/executor/execReplication.c
+++ b/src/backend/executor/execReplication.c
@@ -608,6 +608,14 @@ void
CheckSubscriptionRelkind(char relkind, const char *nspname,
const char *relname)
{
+ /* Give more specific error for partitioned tables */
+ if (relkind == RELKIND_PARTITIONED_TABLE)
+ ereport(ERROR,
+ (errcode(ERRCODE_WRONG_OBJECT_TYPE),
+ errmsg("\"%s.%s\" is a partitioned table",
+ nspname, relname),
+ errdetail("Partitioned tables are not
supported as logical replication targets")));
+
/*
* We currently only support writing to regular tables.
*/