From 09f66bc083e463df2fdf37ae147498bcb6799255 Mon Sep 17 00:00:00 2001 From: Hou Zhijie Date: Mon, 11 Sep 2023 10:23:51 +0800 Subject: [PATCH 1/2] Ensure that the update on run_as_owner is reflected in the catalog. Previously, the update on run_as_owner was not properly applied. This patch makes the changes to the "run_as_owner" subscription option take effect as expected. --- src/backend/commands/subscriptioncmds.c | 7 +++++++ src/test/regress/expected/subscription.out | 4 +++- src/test/regress/sql/subscription.sql | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c index 34d881fd94..6fe111e98d 100644 --- a/src/backend/commands/subscriptioncmds.c +++ b/src/backend/commands/subscriptioncmds.c @@ -1204,6 +1204,13 @@ AlterSubscription(ParseState *pstate, AlterSubscriptionStmt *stmt, = true; } + if (IsSet(opts.specified_opts, SUBOPT_RUN_AS_OWNER)) + { + values[Anum_pg_subscription_subrunasowner - 1] = + BoolGetDatum(opts.runasowner); + replaces[Anum_pg_subscription_subrunasowner - 1] = true; + } + if (IsSet(opts.specified_opts, SUBOPT_ORIGIN)) { values[Anum_pg_subscription_suborigin - 1] = diff --git a/src/test/regress/expected/subscription.out b/src/test/regress/expected/subscription.out index 3c1a0869ec..b15eddbff3 100644 --- a/src/test/regress/expected/subscription.out +++ b/src/test/regress/expected/subscription.out @@ -155,14 +155,16 @@ ALTER SUBSCRIPTION regress_testsub SET PUBLICATION testpub2, testpub3 WITH (refr ALTER SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist2'; ALTER SUBSCRIPTION regress_testsub SET (slot_name = 'newname'); ALTER SUBSCRIPTION regress_testsub SET (password_required = false); +ALTER SUBSCRIPTION regress_testsub SET (run_as_owner = true); \dRs+ List of subscriptions Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Password required | Run as owner? | Synchronous commit | Conninfo | Skip LSN -----------------+---------------------------+---------+---------------------+--------+-----------+------------------+------------------+--------+-------------------+---------------+--------------------+------------------------------+---------- - regress_testsub | regress_subscription_user | f | {testpub2,testpub3} | f | off | d | f | any | f | f | off | dbname=regress_doesnotexist2 | 0/0 + regress_testsub | regress_subscription_user | f | {testpub2,testpub3} | f | off | d | f | any | f | t | off | dbname=regress_doesnotexist2 | 0/0 (1 row) ALTER SUBSCRIPTION regress_testsub SET (password_required = true); +ALTER SUBSCRIPTION regress_testsub SET (run_as_owner = false); -- fail ALTER SUBSCRIPTION regress_testsub SET (slot_name = ''); ERROR: replication slot name "" is too short diff --git a/src/test/regress/sql/subscription.sql b/src/test/regress/sql/subscription.sql index 55d7dbc9ab..444e563ff3 100644 --- a/src/test/regress/sql/subscription.sql +++ b/src/test/regress/sql/subscription.sql @@ -94,9 +94,11 @@ ALTER SUBSCRIPTION regress_testsub SET PUBLICATION testpub2, testpub3 WITH (refr ALTER SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist2'; ALTER SUBSCRIPTION regress_testsub SET (slot_name = 'newname'); ALTER SUBSCRIPTION regress_testsub SET (password_required = false); +ALTER SUBSCRIPTION regress_testsub SET (run_as_owner = true); \dRs+ ALTER SUBSCRIPTION regress_testsub SET (password_required = true); +ALTER SUBSCRIPTION regress_testsub SET (run_as_owner = false); -- fail ALTER SUBSCRIPTION regress_testsub SET (slot_name = ''); -- 2.30.0.windows.2