From ece40ad7ef853488d323f59a09d0614ff242fa09 Mon Sep 17 00:00:00 2001 From: "houzj.fnst" Date: Thu, 2 Sep 2021 19:16:03 +0800 Subject: [PATCH] diff for 0002 --- src/backend/commands/subscriptioncmds.c | 49 ++++++++------------------------- src/backend/parser/gram.y | 6 ++-- src/include/nodes/parsenodes.h | 6 ++-- 3 files changed, 19 insertions(+), 42 deletions(-) diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c index a58b864..b3ae2c5 100644 --- a/src/backend/commands/subscriptioncmds.c +++ b/src/backend/commands/subscriptioncmds.c @@ -210,6 +210,8 @@ parse_subscription_options(ParseState *pstate, List *stmt_options, PGC_BACKEND, PGC_S_TEST, GUC_ACTION_SET, false, 0, false); } + else + opts->synchronous_commit = "off"; } else if (IsSet(supported_opts, SUBOPT_REFRESH) && strcmp(defel->defname, "refresh") == 0) @@ -881,14 +883,19 @@ AlterSubscription(ParseState *pstate, AlterSubscriptionStmt *stmt, switch (stmt->kind) { - case ALTER_SUBSCRIPTION_SET_OPTIONS: + case ALTER_SUBSCRIPTION_OPTIONS: { - supported_opts = (SUBOPT_SLOT_NAME | - SUBOPT_SYNCHRONOUS_COMMIT | SUBOPT_BINARY | - SUBOPT_STREAMING); + if (stmt->isReset) + supported_opts = (SUBOPT_SYNCHRONOUS_COMMIT | SUBOPT_BINARY | + SUBOPT_STREAMING); + else + supported_opts = (SUBOPT_SLOT_NAME | + SUBOPT_SYNCHRONOUS_COMMIT | SUBOPT_BINARY | + SUBOPT_STREAMING); parse_subscription_options(pstate, stmt->options, - supported_opts, &opts, false); + supported_opts, &opts, + stmt->isReset); if (IsSet(opts.specified_opts, SUBOPT_SLOT_NAME)) { @@ -938,38 +945,6 @@ AlterSubscription(ParseState *pstate, AlterSubscriptionStmt *stmt, break; } - case ALTER_SUBSCRIPTION_RESET_OPTIONS: - { - supported_opts = (SUBOPT_SYNCHRONOUS_COMMIT | SUBOPT_BINARY | - SUBOPT_STREAMING); - - parse_subscription_options(pstate, stmt->options, - supported_opts, &opts, true); - - if (IsSet(opts.specified_opts, SUBOPT_SYNCHRONOUS_COMMIT)) - { - values[Anum_pg_subscription_subsynccommit - 1] = - CStringGetTextDatum("off"); - replaces[Anum_pg_subscription_subsynccommit - 1] = true; - } - - if (IsSet(opts.specified_opts, SUBOPT_BINARY)) - { - values[Anum_pg_subscription_subbinary - 1] = - BoolGetDatum(false); - replaces[Anum_pg_subscription_subbinary - 1] = true; - } - - if (IsSet(opts.specified_opts, SUBOPT_STREAMING)) - { - values[Anum_pg_subscription_substream - 1] = - BoolGetDatum(false); - replaces[Anum_pg_subscription_substream - 1] = true; - } - - update_tuple = true; - break; - } case ALTER_SUBSCRIPTION_ENABLED: { parse_subscription_options(pstate, stmt->options, diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index bcf85e8..9cbc065 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -9707,18 +9707,20 @@ AlterSubscriptionStmt: { AlterSubscriptionStmt *n = makeNode(AlterSubscriptionStmt); - n->kind = ALTER_SUBSCRIPTION_SET_OPTIONS; + n->kind = ALTER_SUBSCRIPTION_OPTIONS; n->subname = $3; n->options = $5; + n->isReset = false; $$ = (Node *)n; } | ALTER SUBSCRIPTION name RESET definition { AlterSubscriptionStmt *n = makeNode(AlterSubscriptionStmt); - n->kind = ALTER_SUBSCRIPTION_RESET_OPTIONS; + n->kind = ALTER_SUBSCRIPTION_OPTIONS; n->subname = $3; n->options = $5; + n->isReset = true; $$ = (Node *)n; } | ALTER SUBSCRIPTION name CONNECTION Sconst diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h index 3f55d63..346887f 100644 --- a/src/include/nodes/parsenodes.h +++ b/src/include/nodes/parsenodes.h @@ -3659,8 +3659,7 @@ typedef struct CreateSubscriptionStmt typedef enum AlterSubscriptionType { - ALTER_SUBSCRIPTION_SET_OPTIONS, - ALTER_SUBSCRIPTION_RESET_OPTIONS, + ALTER_SUBSCRIPTION_OPTIONS, ALTER_SUBSCRIPTION_CONNECTION, ALTER_SUBSCRIPTION_SET_PUBLICATION, ALTER_SUBSCRIPTION_ADD_PUBLICATION, @@ -3672,11 +3671,12 @@ typedef enum AlterSubscriptionType typedef struct AlterSubscriptionStmt { NodeTag type; - AlterSubscriptionType kind; /* ALTER_SUBSCRIPTION_SET_OPTIONS, etc */ + AlterSubscriptionType kind; /* ALTER_SUBSCRIPTION_OPTIONS, etc */ char *subname; /* Name of the subscription */ char *conninfo; /* Connection string to publisher */ List *publication; /* One or more publication to subscribe to */ List *options; /* List of DefElem nodes */ + bool isReset; /* true if RESET option */ } AlterSubscriptionStmt; typedef struct DropSubscriptionStmt -- 2.7.2.windows.1