Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 373bda6

Browse files
committed
Improve error messages for incorrect types of logical replication targets
If trying to use something else than a plain table as logical replication target, a rather-generic error message gets used to report the problem. This can be confusing when it comes to foreign tables and partitioned tables, so use more dedicated messages in these cases. Author: Amit Langote Reviewed-by: Peter Eisentraut, Magnus Hagander, Michael Paquier Discussion: https://postgr.es/m/41799bee-40eb-7bb5-80b1-325ce17518bc@lab.ntt.co.jp
1 parent 1845ca2 commit 373bda6

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/backend/executor/execReplication.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,11 +609,29 @@ CheckSubscriptionRelkind(char relkind, const char *nspname,
609609
const char *relname)
610610
{
611611
/*
612-
* We currently only support writing to regular tables.
612+
* We currently only support writing to regular tables. However, give
613+
* a more specific error for partitioned and foreign tables.
613614
*/
615+
if (relkind == RELKIND_PARTITIONED_TABLE)
616+
ereport(ERROR,
617+
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
618+
errmsg("cannot use relation \"%s.%s\" as logical replication target",
619+
nspname, relname),
620+
errdetail("\"%s.%s\" is a partitioned table.",
621+
nspname, relname)));
622+
else if (relkind == RELKIND_FOREIGN_TABLE)
623+
ereport(ERROR,
624+
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
625+
errmsg("cannot use relation \"%s.%s\" as logical replication",
626+
nspname, relname),
627+
errdetail("\"%s.%s\" is a foreign table.",
628+
nspname, relname)));
629+
614630
if (relkind != RELKIND_RELATION)
615631
ereport(ERROR,
616632
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
617-
errmsg("logical replication target relation \"%s.%s\" is not a table",
633+
errmsg("cannot use relation \"%s.%s\" as logical replication target",
634+
nspname, relname),
635+
errdetail("\"%s.%s\" is not a table.",
618636
nspname, relname)));
619637
}

0 commit comments

Comments
 (0)