From 5f3f9f06952fbc35af93d880a297b733bcb64055 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Fri, 7 Oct 2022 13:01:37 +1100 Subject: [PATCH v1] create subscription warning message. A small improvement to an existing CREATE SUBSCRIPTION warning message. Before: WARNING: tables were not subscribed, you will have to run ALTER SUBSCRIPTION ... REFRESH PUBLICATION to subscribe the tables After: WARNING: tables were not subscribed HINT: You will have to run ALTER SUBSCRIPTION ... REFRESH PUBLICATION to subscribe the tables. --- src/backend/commands/subscriptioncmds.c | 3 ++- src/test/regress/expected/object_address.out | 3 ++- src/test/regress/expected/subscription.out | 27 ++++++++++++++++++--------- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c index f3bfcca..f58ef11 100644 --- a/src/backend/commands/subscriptioncmds.c +++ b/src/backend/commands/subscriptioncmds.c @@ -760,8 +760,9 @@ CreateSubscription(ParseState *pstate, CreateSubscriptionStmt *stmt, } else ereport(WARNING, + (errmsg("tables were not subscribed"), /* translator: %s is an SQL ALTER statement */ - (errmsg("tables were not subscribed, you will have to run %s to subscribe the tables", + errhint("You will have to run %s to subscribe the tables.", "ALTER SUBSCRIPTION ... REFRESH PUBLICATION"))); table_close(rel, RowExclusiveLock); diff --git a/src/test/regress/expected/object_address.out b/src/test/regress/expected/object_address.out index 3549b63..802c633 100644 --- a/src/test/regress/expected/object_address.out +++ b/src/test/regress/expected/object_address.out @@ -48,7 +48,8 @@ CREATE PUBLICATION addr_pub FOR TABLE addr_nsp.gentable; CREATE PUBLICATION addr_pub_schema FOR TABLES IN SCHEMA addr_nsp; RESET client_min_messages; CREATE SUBSCRIPTION regress_addr_sub CONNECTION '' PUBLICATION bar WITH (connect = false, slot_name = NONE); -WARNING: tables were not subscribed, you will have to run ALTER SUBSCRIPTION ... REFRESH PUBLICATION to subscribe the tables +WARNING: tables were not subscribed +HINT: You will have to run ALTER SUBSCRIPTION ... REFRESH PUBLICATION to subscribe the tables. CREATE STATISTICS addr_nsp.gentable_stat ON a, b FROM addr_nsp.gentable; -- test some error cases SELECT pg_get_object_address('stone', '{}', '{}'); diff --git a/src/test/regress/expected/subscription.out b/src/test/regress/expected/subscription.out index ef0ebf9..97d5500 100644 --- a/src/test/regress/expected/subscription.out +++ b/src/test/regress/expected/subscription.out @@ -29,7 +29,8 @@ CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUB ERROR: publication name "foo" used more than once -- ok CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false); -WARNING: tables were not subscribed, you will have to run ALTER SUBSCRIPTION ... REFRESH PUBLICATION to subscribe the tables +WARNING: tables were not subscribed +HINT: You will have to run ALTER SUBSCRIPTION ... REFRESH PUBLICATION to subscribe the tables. COMMENT ON SUBSCRIPTION regress_testsub IS 'test subscription'; SELECT obj_description(s.oid, 'pg_subscription') FROM pg_subscription s; obj_description @@ -64,7 +65,8 @@ CREATE SUBSCRIPTION regress_testsub2 CONNECTION 'dbname=regress_doesnotexist' PU ERROR: subscription with slot_name = NONE must also set enabled = false -- ok - with slot_name = NONE CREATE SUBSCRIPTION regress_testsub3 CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (slot_name = NONE, connect = false); -WARNING: tables were not subscribed, you will have to run ALTER SUBSCRIPTION ... REFRESH PUBLICATION to subscribe the tables +WARNING: tables were not subscribed +HINT: You will have to run ALTER SUBSCRIPTION ... REFRESH PUBLICATION to subscribe the tables. -- fail ALTER SUBSCRIPTION regress_testsub3 ENABLE; ERROR: cannot enable subscription that does not have a slot name @@ -75,7 +77,8 @@ CREATE SUBSCRIPTION regress_testsub4 CONNECTION 'dbname=regress_doesnotexist' PU ERROR: unrecognized origin value: "foo" -- now it works CREATE SUBSCRIPTION regress_testsub4 CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (slot_name = NONE, connect = false, origin = none); -WARNING: tables were not subscribed, you will have to run ALTER SUBSCRIPTION ... REFRESH PUBLICATION to subscribe the tables +WARNING: tables were not subscribed +HINT: You will have to run ALTER SUBSCRIPTION ... REFRESH PUBLICATION to subscribe the tables. \dRs+ regress_testsub4 List of subscriptions Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Synchronous commit | Conninfo | Skip LSN @@ -199,7 +202,8 @@ CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUB ERROR: binary requires a Boolean value -- now it works CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false, binary = true); -WARNING: tables were not subscribed, you will have to run ALTER SUBSCRIPTION ... REFRESH PUBLICATION to subscribe the tables +WARNING: tables were not subscribed +HINT: You will have to run ALTER SUBSCRIPTION ... REFRESH PUBLICATION to subscribe the tables. \dRs+ List of subscriptions Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Synchronous commit | Conninfo | Skip LSN @@ -222,7 +226,8 @@ CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUB ERROR: streaming requires a Boolean value -- now it works CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false, streaming = true); -WARNING: tables were not subscribed, you will have to run ALTER SUBSCRIPTION ... REFRESH PUBLICATION to subscribe the tables +WARNING: tables were not subscribed +HINT: You will have to run ALTER SUBSCRIPTION ... REFRESH PUBLICATION to subscribe the tables. \dRs+ List of subscriptions Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Synchronous commit | Conninfo | Skip LSN @@ -278,7 +283,8 @@ ALTER SUBSCRIPTION regress_testsub DROP PUBLICATION testpub1, testpub2 WITH (ref DROP SUBSCRIPTION regress_testsub; CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION mypub WITH (connect = false, create_slot = false, copy_data = false); -WARNING: tables were not subscribed, you will have to run ALTER SUBSCRIPTION ... REFRESH PUBLICATION to subscribe the tables +WARNING: tables were not subscribed +HINT: You will have to run ALTER SUBSCRIPTION ... REFRESH PUBLICATION to subscribe the tables. ALTER SUBSCRIPTION regress_testsub ENABLE; -- fail - ALTER SUBSCRIPTION with refresh is not allowed in a transaction -- block or function @@ -304,7 +310,8 @@ CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUB ERROR: two_phase requires a Boolean value -- now it works CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false, two_phase = true); -WARNING: tables were not subscribed, you will have to run ALTER SUBSCRIPTION ... REFRESH PUBLICATION to subscribe the tables +WARNING: tables were not subscribed +HINT: You will have to run ALTER SUBSCRIPTION ... REFRESH PUBLICATION to subscribe the tables. \dRs+ List of subscriptions Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Synchronous commit | Conninfo | Skip LSN @@ -328,7 +335,8 @@ ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE); DROP SUBSCRIPTION regress_testsub; -- two_phase and streaming are compatible. CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false, streaming = true, two_phase = true); -WARNING: tables were not subscribed, you will have to run ALTER SUBSCRIPTION ... REFRESH PUBLICATION to subscribe the tables +WARNING: tables were not subscribed +HINT: You will have to run ALTER SUBSCRIPTION ... REFRESH PUBLICATION to subscribe the tables. \dRs+ List of subscriptions Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Synchronous commit | Conninfo | Skip LSN @@ -343,7 +351,8 @@ CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUB ERROR: disable_on_error requires a Boolean value -- now it works CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false, disable_on_error = false); -WARNING: tables were not subscribed, you will have to run ALTER SUBSCRIPTION ... REFRESH PUBLICATION to subscribe the tables +WARNING: tables were not subscribed +HINT: You will have to run ALTER SUBSCRIPTION ... REFRESH PUBLICATION to subscribe the tables. \dRs+ List of subscriptions Name | Owner | Enabled | Publication | Binary | Streaming | Two-phase commit | Disable on error | Origin | Synchronous commit | Conninfo | Skip LSN -- 1.8.3.1