aboutsummaryrefslogtreecommitdiff
path: root/src/backend/replication/logical/worker.c
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2017-05-17 20:47:37 -0400
committerPeter Eisentraut <peter_e@gmx.net>2017-05-17 20:47:37 -0400
commit62345698513cbcb3c48a6dae414abf0f24fd163a (patch)
treedce30a85bf9960d030111553ee651ada8b508240 /src/backend/replication/logical/worker.c
parentce554810329b9b8e862eade08b598148931eb456 (diff)
downloadpostgresql-62345698513cbcb3c48a6dae414abf0f24fd163a.tar.gz
postgresql-62345698513cbcb3c48a6dae414abf0f24fd163a.zip
Improve CREATE SUBSCRIPTION option parsing
When creating a subscription with slot_name = NONE, we failed to check that also create_slot = false and enabled = false were set. This created an invalid subscription and could later lead to a crash if a NULL slot name was accessed. Add more checks around that for robustness. Reported-by: tushar <tushar.ahuja@enterprisedb.com>
Diffstat (limited to 'src/backend/replication/logical/worker.c')
-rw-r--r--src/backend/replication/logical/worker.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index 9d1eab9e1e6..7d1787db5cb 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -1552,6 +1552,15 @@ ApplyWorkerMain(Datum main_arg)
myslotname = MySubscription->slotname;
+ /*
+ * This shouldn't happen if the subscription is enabled, but guard
+ * against DDL bugs or manual catalog changes. (libpqwalreceiver
+ * will crash if slot is NULL.
+ */
+ if (!myslotname)
+ ereport(ERROR,
+ (errmsg("subscription has no replication slot set")));
+
/* Setup replication origin tracking. */
StartTransactionCommand();
snprintf(originname, sizeof(originname), "pg_%u", MySubscription->oid);