Skip to content

Commit 4d5105a

Browse files
Improve error message for pg_create_subscription.
c3afe8c updated this error message, but it didn't use the new style established in de4d456. Reviewed-by: Tom Lane Discussion: https://postgr.es/m/20230512203721.GA2644063%40nathanxps13.home
1 parent 51b2c08 commit 4d5105a

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/backend/commands/subscriptioncmds.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,9 @@ CreateSubscription(ParseState *pstate, CreateSubscriptionStmt *stmt,
611611
if (!has_privs_of_role(owner, ROLE_PG_CREATE_SUBSCRIPTION))
612612
ereport(ERROR,
613613
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
614-
errmsg("must have privileges of pg_create_subscription to create subscriptions")));
614+
errmsg("permission denied to create subscription"),
615+
errdetail("Only roles with privileges of the \"%s\" role may create subscriptions.",
616+
"pg_create_subscription")));
615617

616618
/*
617619
* Since a subscription is a database object, we also check for CREATE

src/test/regress/expected/subscription.out

+2-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ ERROR: subscription "regress_testsub" already exists
7979
-- fail - must be superuser
8080
SET SESSION AUTHORIZATION 'regress_subscription_user2';
8181
CREATE SUBSCRIPTION regress_testsub2 CONNECTION 'dbname=regress_doesnotexist' PUBLICATION foo WITH (connect = false);
82-
ERROR: must have privileges of pg_create_subscription to create subscriptions
82+
ERROR: permission denied to create subscription
83+
DETAIL: Only roles with privileges of the "pg_create_subscription" role may create subscriptions.
8384
SET SESSION AUTHORIZATION 'regress_subscription_user';
8485
-- fail - invalid option combinations
8586
CREATE SUBSCRIPTION regress_testsub2 CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false, copy_data = true);

0 commit comments

Comments
 (0)