v11-0001-PS-Fix-v11.patch
application/octet-stream
Filename: v11-0001-PS-Fix-v11.patch
Type: application/octet-stream
Part: 0
Patch
Format: format-patch
Series: patch v11-0001
Subject: PS Fix v11.
| File | + | − |
|---|---|---|
| src/backend/commands/subscriptioncmds.c | 5 | 14 |
From eee6f50f071f00794aeb6a668c781af41e70178e Mon Sep 17 00:00:00 2001
From: Peter Smith <peter.b.smith@fujitsu.com>
Date: Wed, 7 Jul 2021 09:15:10 +1000
Subject: [PATCH v11] PS Fix v11.
Make the parse_subscription_options function reposonsilbe for zapping the SubOpts param up-front, instead of hoping the caller will do it.
Remove redundant condition checks for "supported_opts" where we already know the option must be supported.
---
src/backend/commands/subscriptioncmds.c | 19 +++++--------------
1 file changed, 5 insertions(+), 14 deletions(-)
diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c
index eb88d87..1193771 100644
--- a/src/backend/commands/subscriptioncmds.c
+++ b/src/backend/commands/subscriptioncmds.c
@@ -92,14 +92,15 @@ static void ReportSlotConnectionError(List *rstates, Oid subid, char *slotname,
*
* Since not all options can be specified in both commands, this function
* will report an error if mutually exclusive options are specified.
- *
- * Caller is expected to have cleared 'opts'.
*/
static void
parse_subscription_options(List *stmt_options, bits32 supported_opts, SubOpts *opts)
{
ListCell *lc;
+ /* Start out with cleared opts. */
+ memset(opts, 0, sizeof(SubOpts));
+
/* caller must expect some option */
Assert(supported_opts != 0);
@@ -251,7 +252,6 @@ parse_subscription_options(List *stmt_options, bits32 supported_opts, SubOpts *o
{
/* Check for incompatible options from the user. */
if (opts->enabled &&
- IsSet(supported_opts, SUBOPT_ENABLED) &&
IsSet(opts->specified_opts, SUBOPT_ENABLED))
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
@@ -260,7 +260,6 @@ parse_subscription_options(List *stmt_options, bits32 supported_opts, SubOpts *o
"connect = false", "enabled = true")));
if (opts->create_slot &&
- IsSet(supported_opts, SUBOPT_CREATE_SLOT) &&
IsSet(opts->specified_opts, SUBOPT_CREATE_SLOT))
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
@@ -268,7 +267,6 @@ parse_subscription_options(List *stmt_options, bits32 supported_opts, SubOpts *o
"connect = false", "create_slot = true")));
if (opts->copy_data &&
- IsSet(supported_opts, SUBOPT_COPY_DATA) &&
IsSet(opts->specified_opts, SUBOPT_COPY_DATA))
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
@@ -286,11 +284,9 @@ parse_subscription_options(List *stmt_options, bits32 supported_opts, SubOpts *o
* was used.
*/
if (!opts->slot_name &&
- IsSet(supported_opts, SUBOPT_SLOT_NAME) &&
IsSet(opts->specified_opts, SUBOPT_SLOT_NAME))
{
if (opts->enabled &&
- IsSet(supported_opts, SUBOPT_ENABLED) &&
IsSet(opts->specified_opts, SUBOPT_ENABLED))
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
@@ -299,7 +295,6 @@ parse_subscription_options(List *stmt_options, bits32 supported_opts, SubOpts *o
"slot_name = NONE", "enabled = true")));
if (opts->create_slot &&
- IsSet(supported_opts, SUBOPT_CREATE_SLOT) &&
IsSet(opts->specified_opts, SUBOPT_CREATE_SLOT))
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
@@ -307,18 +302,14 @@ parse_subscription_options(List *stmt_options, bits32 supported_opts, SubOpts *o
errmsg("%s and %s are mutually exclusive options",
"slot_name = NONE", "create_slot = true")));
- if (opts->enabled &&
- IsSet(supported_opts, SUBOPT_ENABLED) &&
- !IsSet(opts->specified_opts, SUBOPT_ENABLED))
+ if (opts->enabled)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
/*- translator: both %s are strings of the form "option = value" */
errmsg("subscription with %s must also set %s",
"slot_name = NONE", "enabled = false")));
- if (opts->create_slot &&
- IsSet(supported_opts, SUBOPT_CREATE_SLOT) &&
- !IsSet(opts->specified_opts, SUBOPT_CREATE_SLOT))
+ if (opts->create_slot)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
/*- translator: both %s are strings of the form "option = value" */
--
1.8.3.1