Improve error message for pg_create_subscription.
authorNathan Bossart <[email protected]>
Fri, 12 May 2023 20:50:46 +0000 (13:50 -0700)
committerNathan Bossart <[email protected]>
Fri, 12 May 2023 21:16:56 +0000 (14:16 -0700)
c3afe8cf5a updated this error message, but it didn't use the new
style established in de4d456b40.

Reviewed-by: Tom Lane
Discussion: https://postgr.es/m/20230512203721.GA2644063%40nathanxps13.home

src/backend/commands/subscriptioncmds.c
src/test/regress/expected/subscription.out

index 8b3de032eee50e9d44591c5e22ab18da4859da35..e8b288d01cbdb13f40bcd8ede6a11b3b14f6fb9f 100644 (file)
@@ -611,7 +611,9 @@ CreateSubscription(ParseState *pstate, CreateSubscriptionStmt *stmt,
        if (!has_privs_of_role(owner, ROLE_PG_CREATE_SUBSCRIPTION))
                ereport(ERROR,
                                (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
-                                errmsg("must have privileges of pg_create_subscription to create subscriptions")));
+                                errmsg("permission denied to create subscription"),
+                                errdetail("Only roles with privileges of the \"%s\" role may create subscriptions.",
+                                                  "pg_create_subscription")));
 
        /*
         * Since a subscription is a database object, we also check for CREATE
index d73624625948f0303eb176d9dffcf61603a4dbee..8b5f657897ead48f6fd2c471428c3e585d00354f 100644 (file)
@@ -79,7 +79,8 @@ ERROR:  subscription "regress_testsub" already exists
 -- fail - must be superuser
 SET SESSION AUTHORIZATION 'regress_subscription_user2';
 CREATE SUBSCRIPTION regress_testsub2 CONNECTION 'dbname=regress_doesnotexist' PUBLICATION foo WITH (connect = false);
-ERROR:  must have privileges of pg_create_subscription to create subscriptions
+ERROR:  permission denied to create subscription
+DETAIL:  Only roles with privileges of the "pg_create_subscription" role may create subscriptions.
 SET SESSION AUTHORIZATION 'regress_subscription_user';
 -- fail - invalid option combinations
 CREATE SUBSCRIPTION regress_testsub2 CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false, copy_data = true);