Fixes in ALTER SUBSCRIPTION DROP PUBLICATION code
ALTER SUBSCRIPTION DROP PUBLICATION does not actually support copy_data option, so remove it from tab completion. Also, reword the error message that is thrown when all the publications from a subscription are specified to be dropped. Also, made few doc and cosmetic adjustments. Author: Vignesh C <vignesh21@gmail.com> Reviewed-by: Bharath Rupireddy <bharath.rupireddy@enterprisedb.com> Reviewed-by: Japin Li <japinli@hotmail.com> Discussion: https://www.postgresql.org/message-id/flat/CALDaNm21RwsDzs4xj14ApteAF7auyyomHNnp+NEL-sH8m-jMvQ@mail.gmail.com
This commit is contained in:
parent
63e6d05bf3
commit
e59d428f34
|
@ -22,9 +22,9 @@ PostgreSQL documentation
|
||||||
<refsynopsisdiv>
|
<refsynopsisdiv>
|
||||||
<synopsis>
|
<synopsis>
|
||||||
ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> CONNECTION '<replaceable>conninfo</replaceable>'
|
ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> CONNECTION '<replaceable>conninfo</replaceable>'
|
||||||
ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> SET PUBLICATION <replaceable class="parameter">publication_name</replaceable> [, ...] [ WITH ( <replaceable class="parameter">set_publication_option</replaceable> [= <replaceable class="parameter">value</replaceable>] [, ... ] ) ]
|
ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> SET PUBLICATION <replaceable class="parameter">publication_name</replaceable> [, ...] [ WITH ( <replaceable class="parameter">publication_option</replaceable> [= <replaceable class="parameter">value</replaceable>] [, ... ] ) ]
|
||||||
ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> ADD PUBLICATION <replaceable class="parameter">publication_name</replaceable> [, ...] [ WITH ( <replaceable class="parameter">set_publication_option</replaceable> [= <replaceable class="parameter">value</replaceable>] [, ... ] ) ]
|
ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> ADD PUBLICATION <replaceable class="parameter">publication_name</replaceable> [, ...] [ WITH ( <replaceable class="parameter">publication_option</replaceable> [= <replaceable class="parameter">value</replaceable>] [, ... ] ) ]
|
||||||
ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> DROP PUBLICATION <replaceable class="parameter">publication_name</replaceable> [, ...] [ WITH ( <replaceable class="parameter">set_publication_option</replaceable> [= <replaceable class="parameter">value</replaceable>] [, ... ] ) ]
|
ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> DROP PUBLICATION <replaceable class="parameter">publication_name</replaceable> [, ...] [ WITH ( <replaceable class="parameter">publication_option</replaceable> [= <replaceable class="parameter">value</replaceable>] [, ... ] ) ]
|
||||||
ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> REFRESH PUBLICATION [ WITH ( <replaceable class="parameter">refresh_option</replaceable> [= <replaceable class="parameter">value</replaceable>] [, ... ] ) ]
|
ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> REFRESH PUBLICATION [ WITH ( <replaceable class="parameter">refresh_option</replaceable> [= <replaceable class="parameter">value</replaceable>] [, ... ] ) ]
|
||||||
ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> ENABLE
|
ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> ENABLE
|
||||||
ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> DISABLE
|
ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> DISABLE
|
||||||
|
@ -102,17 +102,17 @@ ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> RENAME TO <
|
||||||
<para>
|
<para>
|
||||||
Changes the list of subscribed publications. <literal>SET</literal>
|
Changes the list of subscribed publications. <literal>SET</literal>
|
||||||
replaces the entire list of publications with a new list,
|
replaces the entire list of publications with a new list,
|
||||||
<literal>ADD</literal> adds additional publications,
|
<literal>ADD</literal> adds additional publications to the list of
|
||||||
<literal>DROP</literal> removes publications from the list of
|
publications, and <literal>DROP</literal> removes the publications from
|
||||||
publications. See <xref linkend="sql-createsubscription"/> for more
|
the list of publications. See <xref linkend="sql-createsubscription"/>
|
||||||
information. By default, this command will also act like
|
for more information. By default, this command will also act like
|
||||||
<literal>REFRESH PUBLICATION</literal>, except that in case of
|
<literal>REFRESH PUBLICATION</literal>, except that in case of
|
||||||
<literal>ADD</literal> or <literal>DROP</literal>, only the added or
|
<literal>ADD</literal> or <literal>DROP</literal>, only the added or
|
||||||
dropped publications are refreshed.
|
dropped publications are refreshed.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
<replaceable>set_publication_option</replaceable> specifies additional
|
<replaceable>publication_option</replaceable> specifies additional
|
||||||
options for this operation. The supported options are:
|
options for this operation. The supported options are:
|
||||||
|
|
||||||
<variablelist>
|
<variablelist>
|
||||||
|
@ -129,7 +129,8 @@ ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> RENAME TO <
|
||||||
</variablelist>
|
</variablelist>
|
||||||
|
|
||||||
Additionally, refresh options as described
|
Additionally, refresh options as described
|
||||||
under <literal>REFRESH PUBLICATION</literal> may be specified.
|
under <literal>REFRESH PUBLICATION</literal> may be specified,
|
||||||
|
except in the case of <literal>DROP PUBLICATION</literal>.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
|
@ -953,8 +953,6 @@ AlterSubscription(AlterSubscriptionStmt *stmt, bool isTopLevel)
|
||||||
bool refresh;
|
bool refresh;
|
||||||
List *publist;
|
List *publist;
|
||||||
|
|
||||||
publist = merge_publications(sub->publications, stmt->publication, isadd, stmt->subname);
|
|
||||||
|
|
||||||
parse_subscription_options(stmt->options,
|
parse_subscription_options(stmt->options,
|
||||||
NULL, /* no "connect" */
|
NULL, /* no "connect" */
|
||||||
NULL, NULL, /* no "enabled" */
|
NULL, NULL, /* no "enabled" */
|
||||||
|
@ -967,6 +965,8 @@ AlterSubscription(AlterSubscriptionStmt *stmt, bool isTopLevel)
|
||||||
NULL, NULL, /* no "binary" */
|
NULL, NULL, /* no "binary" */
|
||||||
NULL, NULL); /* no "streaming" */
|
NULL, NULL); /* no "streaming" */
|
||||||
|
|
||||||
|
publist = merge_publications(sub->publications, stmt->publication, isadd, stmt->subname);
|
||||||
|
|
||||||
values[Anum_pg_subscription_subpublications - 1] =
|
values[Anum_pg_subscription_subpublications - 1] =
|
||||||
publicationListToArray(publist);
|
publicationListToArray(publist);
|
||||||
replaces[Anum_pg_subscription_subpublications - 1] = true;
|
replaces[Anum_pg_subscription_subpublications - 1] = true;
|
||||||
|
@ -1676,7 +1676,7 @@ merge_publications(List *oldpublist, List *newpublist, bool addpub, const char *
|
||||||
if (!oldpublist)
|
if (!oldpublist)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
|
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
|
||||||
errmsg("subscription must contain at least one publication")));
|
errmsg("cannot drop all the publications from a subscription")));
|
||||||
|
|
||||||
return oldpublist;
|
return oldpublist;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1675,10 +1675,14 @@ psql_completion(const char *text, int start, int end)
|
||||||
else if (HeadMatches("ALTER", "SUBSCRIPTION", MatchAny) &&
|
else if (HeadMatches("ALTER", "SUBSCRIPTION", MatchAny) &&
|
||||||
TailMatches("ADD|DROP|SET", "PUBLICATION", MatchAny))
|
TailMatches("ADD|DROP|SET", "PUBLICATION", MatchAny))
|
||||||
COMPLETE_WITH("WITH (");
|
COMPLETE_WITH("WITH (");
|
||||||
/* ALTER SUBSCRIPTION <name> ADD|DROP|SET PUBLICATION <name> WITH ( */
|
/* ALTER SUBSCRIPTION <name> ADD|SET PUBLICATION <name> WITH ( */
|
||||||
else if (HeadMatches("ALTER", "SUBSCRIPTION", MatchAny) &&
|
else if (HeadMatches("ALTER", "SUBSCRIPTION", MatchAny) &&
|
||||||
TailMatches("ADD|DROP|SET", "PUBLICATION", MatchAny, "WITH", "("))
|
TailMatches("ADD|SET", "PUBLICATION", MatchAny, "WITH", "("))
|
||||||
COMPLETE_WITH("copy_data", "refresh");
|
COMPLETE_WITH("copy_data", "refresh");
|
||||||
|
/* ALTER SUBSCRIPTION <name> DROP PUBLICATION <name> WITH ( */
|
||||||
|
else if (HeadMatches("ALTER", "SUBSCRIPTION", MatchAny) &&
|
||||||
|
TailMatches("DROP", "PUBLICATION", MatchAny, "WITH", "("))
|
||||||
|
COMPLETE_WITH("refresh");
|
||||||
|
|
||||||
/* ALTER SCHEMA <name> */
|
/* ALTER SCHEMA <name> */
|
||||||
else if (Matches("ALTER", "SCHEMA", MatchAny))
|
else if (Matches("ALTER", "SCHEMA", MatchAny))
|
||||||
|
|
|
@ -223,7 +223,7 @@ ALTER SUBSCRIPTION regress_testsub DROP PUBLICATION testpub1, testpub1 WITH (ref
|
||||||
ERROR: publication name "testpub1" used more than once
|
ERROR: publication name "testpub1" used more than once
|
||||||
-- fail - all publications are deleted
|
-- fail - all publications are deleted
|
||||||
ALTER SUBSCRIPTION regress_testsub DROP PUBLICATION testpub, testpub1, testpub2 WITH (refresh = false);
|
ALTER SUBSCRIPTION regress_testsub DROP PUBLICATION testpub, testpub1, testpub2 WITH (refresh = false);
|
||||||
ERROR: subscription must contain at least one publication
|
ERROR: cannot drop all the publications from a subscription
|
||||||
-- fail - publication does not exist in subscription
|
-- fail - publication does not exist in subscription
|
||||||
ALTER SUBSCRIPTION regress_testsub DROP PUBLICATION testpub3 WITH (refresh = false);
|
ALTER SUBSCRIPTION regress_testsub DROP PUBLICATION testpub3 WITH (refresh = false);
|
||||||
ERROR: publication "testpub3" is not in subscription "regress_testsub"
|
ERROR: publication "testpub3" is not in subscription "regress_testsub"
|
||||||
|
|
Loading…
Reference in New Issue