mirror of
https://github.com/postgres/postgres.git
synced 2025-06-25 01:02:05 +03:00
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>
This commit is contained in:
@ -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);
|
||||
|
Reference in New Issue
Block a user