On 2018/12/05 10:28, Amit Langote wrote:
> On 2018/12/05 10:20, Michael Paquier wrote:
>> On Tue, Dec 04, 2018 at 09:25:09AM +0100, Magnus Hagander wrote:
>>> I think more people would directly understand the "is not a table" for a
>>> foreign table than a partitioned one (for example, it does now show up in
>>> \dt or under tables in pgadmin, but partitioned ones do). That said, if
>>> it's not too complicated, I think including foreign tables as well would
>>> definitely be useful, because it has table in the name. For the other
>>> types, I agree they don't need to be special-cased, they are fine the way
>>> they are.
>>
>> relkind is directly available in this code path, so it is not that hard
>> to add.  As you suggest, foreign tables make sense to add as those are
>> actually *tables*.  And it seems to me that we should also add toast
>> tables for clarity for the same reason.
> 
> Considering toast tables here seems like a stretch to me, because they're
> not user defined.  Chances of users adding a table to a publication whose
> name matches that of a toast table's on the subscription side seems thin
> too.  Partitioned tables and foreign tables are user-defined and something
> they'd expect to be handled appropriately.

Attached updated patch that adds the check for foreign tables.

Thanks,
Amit
diff --git a/src/backend/executor/execReplication.c 
b/src/backend/executor/execReplication.c
index 5bd3bbc35e..93c74986a9 100644
--- a/src/backend/executor/execReplication.c
+++ b/src/backend/executor/execReplication.c
@@ -608,6 +608,20 @@ void
 CheckSubscriptionRelkind(char relkind, const char *nspname,
                                                 const char *relname)
 {
+       /* Give more specific error for partitioned and foreign 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.")));
+       if (relkind == RELKIND_FOREIGN_TABLE)
+               ereport(ERROR,
+                               (errcode(ERRCODE_WRONG_OBJECT_TYPE),
+                                errmsg("\"%s.%s\" is a foreign table",
+                                               nspname, relname),
+                                errdetail("Foreign tables are not supported as 
logical replication targets.")));
+
        /*
         * We currently only support writing to regular tables.
         */

Reply via email to