*
* 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(ParseState *pstate, List *stmt_options,
{
ListCell *lc;
+ /* Start out with cleared opts. */
+ memset(opts, 0, sizeof(SubOpts));
+
/* caller must expect some option */
Assert(supported_opts != 0);
{
/* 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),
"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),
"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),
* 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),
- /*- translator: both %s are strings of the form "option = value" */
- errmsg("%s and %s are mutually exclusive options",
- "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),
- /*- translator: both %s are strings of the form "option = value" */
- 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))
- 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->enabled)
+ {
+ if (IsSet(opts->specified_opts, SUBOPT_ENABLED))
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ /*- translator: both %s are strings of the form "option = value" */
+ errmsg("%s and %s are mutually exclusive options",
+ "slot_name = NONE", "enabled = true")));
+ else
+ 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))
- 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", "create_slot = false")));
+ if (opts->create_slot)
+ {
+ if (IsSet(opts->specified_opts, SUBOPT_CREATE_SLOT))
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ /*- translator: both %s are strings of the form "option = value" */
+ errmsg("%s and %s are mutually exclusive options",
+ "slot_name = NONE", "create_slot = true")));
+ else
+ 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", "create_slot = false")));
+ }
}
}