summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Paquier2019-01-13 07:39:49 +0000
committerMichael Paquier2019-01-13 07:39:49 +0000
commit373bda61d2d620e704815553978726c9be9e1209 (patch)
tree7a0ae990ba184b88c84c417a219afe97b2ae567a
parent1845ca2cfd1f7fd6b536900cf129f6734a4ddded (diff)
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
-rw-r--r--src/backend/executor/execReplication.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/backend/executor/execReplication.c b/src/backend/executor/execReplication.c
index e9c1beb1b76..bb1ab575952 100644
--- a/src/backend/executor/execReplication.c
+++ b/src/backend/executor/execReplication.c
@@ -609,11 +609,29 @@ CheckSubscriptionRelkind(char relkind, const char *nspname,
const char *relname)
{
/*
- * We currently only support writing to regular tables.
+ * We currently only support writing to regular tables. However, give
+ * a more specific error for partitioned and foreign tables.
*/
+ if (relkind == RELKIND_PARTITIONED_TABLE)
+ ereport(ERROR,
+ (errcode(ERRCODE_WRONG_OBJECT_TYPE),
+ errmsg("cannot use relation \"%s.%s\" as logical replication target",
+ nspname, relname),
+ errdetail("\"%s.%s\" is a partitioned table.",
+ nspname, relname)));
+ else if (relkind == RELKIND_FOREIGN_TABLE)
+ ereport(ERROR,
+ (errcode(ERRCODE_WRONG_OBJECT_TYPE),
+ errmsg("cannot use relation \"%s.%s\" as logical replication",
+ nspname, relname),
+ errdetail("\"%s.%s\" is a foreign table.",
+ nspname, relname)));
+
if (relkind != RELKIND_RELATION)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
- errmsg("logical replication target relation \"%s.%s\" is not a table",
+ errmsg("cannot use relation \"%s.%s\" as logical replication target",
+ nspname, relname),
+ errdetail("\"%s.%s\" is not a table.",
nspname, relname)));
}