aboutsummaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorAmit Kapila <akapila@postgresql.org>2021-08-24 08:38:11 +0530
committerAmit Kapila <akapila@postgresql.org>2021-08-24 08:38:11 +0530
commit5cfcd46e9d297eac627bf3183272713112ac5f60 (patch)
treee6a43e82be8662600701917d0790e2fd1f19606f /src/backend
parent779557bd22895420b48eba409d2286f1dea08c06 (diff)
downloadpostgresql-5cfcd46e9d297eac627bf3183272713112ac5f60.tar.gz
postgresql-5cfcd46e9d297eac627bf3183272713112ac5f60.zip
Fix Alter Subscription's Add/Drop Publication behavior.
The current refresh behavior tries to just refresh added/dropped publications but that leads to removing wrong tables from subscription. We can't refresh just the dropped publication because it is quite possible that some of the tables are removed from publication by that time and now those will remain as part of the subscription. Also, there is a chance that the tables that were part of the publication being dropped are also part of another publication, so we can't remove those. So, we decided that by default, add/drop commands will also act like REFRESH PUBLICATION which means they will refresh all the publications. We can keep the old behavior for "add publication" but it is better to be consistent with "drop publication". Author: Hou Zhijie Reviewed-by: Masahiko Sawada, Amit Kapila Backpatch-through: 14, where it was introduced Discussion: https://postgr.es/m/OS0PR01MB5716935D4C2CC85A6143073F94EF9@OS0PR01MB5716.jpnprd01.prod.outlook.com
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/commands/subscriptioncmds.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c
index e096d5fd2d5..1719f045171 100644
--- a/src/backend/commands/subscriptioncmds.c
+++ b/src/backend/commands/subscriptioncmds.c
@@ -960,8 +960,7 @@ AlterSubscription(AlterSubscriptionStmt *stmt, bool isTopLevel)
NULL, NULL, /* no "enabled" */
NULL, /* no "create_slot" */
NULL, NULL, /* no "slot_name" */
- isadd ? &copy_data : NULL, /* for drop, no
- * "copy_data" */
+ &copy_data,
NULL, /* no "synchronous_commit" */
&refresh,
NULL, NULL, /* no "binary" */
@@ -986,8 +985,8 @@ AlterSubscription(AlterSubscriptionStmt *stmt, bool isTopLevel)
PreventInTransactionBlock(isTopLevel, "ALTER SUBSCRIPTION with refresh");
- /* Only refresh the added/dropped list of publications. */
- sub->publications = stmt->publication;
+ /* Refresh the new list of publications. */
+ sub->publications = publist;
AlterSubscription_refresh(sub, copy_data);
}