mirror of
https://github.com/postgres/postgres.git
synced 2025-07-08 11:42:09 +03:00
Error message wording improvements
This commit is contained in:
@ -323,25 +323,25 @@ CreateRole(ParseState *pstate, CreateRoleStmt *stmt)
|
|||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
||||||
errmsg("permission denied to create role"),
|
errmsg("permission denied to create role"),
|
||||||
errdetail("Only roles with the %s attribute may create roles with %s.",
|
errdetail("Only roles with the %s attribute may create roles with the %s attribute.",
|
||||||
"SUPERUSER", "SUPERUSER")));
|
"SUPERUSER", "SUPERUSER")));
|
||||||
if (createdb && !have_createdb_privilege())
|
if (createdb && !have_createdb_privilege())
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
||||||
errmsg("permission denied to create role"),
|
errmsg("permission denied to create role"),
|
||||||
errdetail("Only roles with the %s attribute may create roles with %s.",
|
errdetail("Only roles with the %s attribute may create roles with the %s attribute.",
|
||||||
"CREATEDB", "CREATEDB")));
|
"CREATEDB", "CREATEDB")));
|
||||||
if (isreplication && !has_rolreplication(currentUserId))
|
if (isreplication && !has_rolreplication(currentUserId))
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
||||||
errmsg("permission denied to create role"),
|
errmsg("permission denied to create role"),
|
||||||
errdetail("Only roles with the %s attribute may create roles with %s.",
|
errdetail("Only roles with the %s attribute may create roles with the %s attribute.",
|
||||||
"REPLICATION", "REPLICATION")));
|
"REPLICATION", "REPLICATION")));
|
||||||
if (bypassrls && !has_bypassrls_privilege(currentUserId))
|
if (bypassrls && !has_bypassrls_privilege(currentUserId))
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
||||||
errmsg("permission denied to create role"),
|
errmsg("permission denied to create role"),
|
||||||
errdetail("Only roles with the %s attribute may create roles with %s.",
|
errdetail("Only roles with the %s attribute may create roles with the %s attribute.",
|
||||||
"BYPASSRLS", "BYPASSRLS")));
|
"BYPASSRLS", "BYPASSRLS")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -758,7 +758,7 @@ AlterRole(ParseState *pstate, AlterRoleStmt *stmt)
|
|||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
||||||
errmsg("permission denied to alter role"),
|
errmsg("permission denied to alter role"),
|
||||||
errdetail("Only roles with the %s attribute may alter roles with %s.",
|
errdetail("Only roles with the %s attribute may alter roles with the %s attribute.",
|
||||||
"SUPERUSER", "SUPERUSER")));
|
"SUPERUSER", "SUPERUSER")));
|
||||||
if (!superuser() && dissuper)
|
if (!superuser() && dissuper)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
@ -1031,7 +1031,7 @@ AlterRoleSet(AlterRoleSetStmt *stmt)
|
|||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
||||||
errmsg("permission denied to alter role"),
|
errmsg("permission denied to alter role"),
|
||||||
errdetail("Only roles with the %s attribute may alter roles with %s.",
|
errdetail("Only roles with the %s attribute may alter roles with the %s attribute.",
|
||||||
"SUPERUSER", "SUPERUSER")));
|
"SUPERUSER", "SUPERUSER")));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1171,7 +1171,7 @@ DropRole(DropRoleStmt *stmt)
|
|||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
||||||
errmsg("permission denied to drop role"),
|
errmsg("permission denied to drop role"),
|
||||||
errdetail("Only roles with the %s attribute may drop roles with %s.",
|
errdetail("Only roles with the %s attribute may drop roles with the %s attribute.",
|
||||||
"SUPERUSER", "SUPERUSER")));
|
"SUPERUSER", "SUPERUSER")));
|
||||||
if (!is_admin_of_role(GetUserId(), roleid))
|
if (!is_admin_of_role(GetUserId(), roleid))
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
@ -1426,7 +1426,7 @@ RenameRole(const char *oldname, const char *newname)
|
|||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
||||||
errmsg("permission denied to rename role"),
|
errmsg("permission denied to rename role"),
|
||||||
errdetail("Only roles with the %s attribute may rename roles with %s.",
|
errdetail("Only roles with the %s attribute may rename roles with the %s attribute.",
|
||||||
"SUPERUSER", "SUPERUSER")));
|
"SUPERUSER", "SUPERUSER")));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2141,14 +2141,14 @@ check_role_membership_authorization(Oid currentUserId, Oid roleid,
|
|||||||
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
||||||
errmsg("permission denied to grant role \"%s\"",
|
errmsg("permission denied to grant role \"%s\"",
|
||||||
GetUserNameFromId(roleid, false)),
|
GetUserNameFromId(roleid, false)),
|
||||||
errdetail("Only roles with the %s attribute may grant roles with %s.",
|
errdetail("Only roles with the %s attribute may grant roles with the %s attribute.",
|
||||||
"SUPERUSER", "SUPERUSER")));
|
"SUPERUSER", "SUPERUSER")));
|
||||||
else
|
else
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
||||||
errmsg("permission denied to revoke role \"%s\"",
|
errmsg("permission denied to revoke role \"%s\"",
|
||||||
GetUserNameFromId(roleid, false)),
|
GetUserNameFromId(roleid, false)),
|
||||||
errdetail("Only roles with the %s attribute may revoke roles with %s.",
|
errdetail("Only roles with the %s attribute may revoke roles with the %s attribute.",
|
||||||
"SUPERUSER", "SUPERUSER")));
|
"SUPERUSER", "SUPERUSER")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ pg_cancel_backend(PG_FUNCTION_ARGS)
|
|||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
||||||
errmsg("permission denied to cancel query"),
|
errmsg("permission denied to cancel query"),
|
||||||
errdetail("Only roles with the %s attribute may cancel queries of roles with %s.",
|
errdetail("Only roles with the %s attribute may cancel queries of roles with the %s attribute.",
|
||||||
"SUPERUSER", "SUPERUSER")));
|
"SUPERUSER", "SUPERUSER")));
|
||||||
|
|
||||||
if (r == SIGNAL_BACKEND_NOPERMISSION)
|
if (r == SIGNAL_BACKEND_NOPERMISSION)
|
||||||
@ -228,7 +228,7 @@ pg_terminate_backend(PG_FUNCTION_ARGS)
|
|||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
||||||
errmsg("permission denied to terminate process"),
|
errmsg("permission denied to terminate process"),
|
||||||
errdetail("Only roles with the %s attribute may terminate processes of roles with %s.",
|
errdetail("Only roles with the %s attribute may terminate processes of roles with the %s attribute.",
|
||||||
"SUPERUSER", "SUPERUSER")));
|
"SUPERUSER", "SUPERUSER")));
|
||||||
|
|
||||||
if (r == SIGNAL_BACKEND_NOPERMISSION)
|
if (r == SIGNAL_BACKEND_NOPERMISSION)
|
||||||
|
@ -946,7 +946,7 @@ InitPostgres(const char *in_dbname, Oid dboid,
|
|||||||
if (nfree < SuperuserReservedConnections)
|
if (nfree < SuperuserReservedConnections)
|
||||||
ereport(FATAL,
|
ereport(FATAL,
|
||||||
(errcode(ERRCODE_TOO_MANY_CONNECTIONS),
|
(errcode(ERRCODE_TOO_MANY_CONNECTIONS),
|
||||||
errmsg("remaining connection slots are reserved for roles with %s",
|
errmsg("remaining connection slots are reserved for roles with the %s attribute",
|
||||||
"SUPERUSER")));
|
"SUPERUSER")));
|
||||||
|
|
||||||
if (!has_privs_of_role(GetUserId(), ROLE_PG_USE_RESERVED_CONNECTIONS))
|
if (!has_privs_of_role(GetUserId(), ROLE_PG_USE_RESERVED_CONNECTIONS))
|
||||||
|
@ -8,19 +8,19 @@ CREATE ROLE regress_role_normal;
|
|||||||
SET SESSION AUTHORIZATION regress_role_limited_admin;
|
SET SESSION AUTHORIZATION regress_role_limited_admin;
|
||||||
CREATE ROLE regress_nosuch_superuser SUPERUSER;
|
CREATE ROLE regress_nosuch_superuser SUPERUSER;
|
||||||
ERROR: permission denied to create role
|
ERROR: permission denied to create role
|
||||||
DETAIL: Only roles with the SUPERUSER attribute may create roles with SUPERUSER.
|
DETAIL: Only roles with the SUPERUSER attribute may create roles with the SUPERUSER attribute.
|
||||||
CREATE ROLE regress_nosuch_replication_bypassrls REPLICATION BYPASSRLS;
|
CREATE ROLE regress_nosuch_replication_bypassrls REPLICATION BYPASSRLS;
|
||||||
ERROR: permission denied to create role
|
ERROR: permission denied to create role
|
||||||
DETAIL: Only roles with the REPLICATION attribute may create roles with REPLICATION.
|
DETAIL: Only roles with the REPLICATION attribute may create roles with the REPLICATION attribute.
|
||||||
CREATE ROLE regress_nosuch_replication REPLICATION;
|
CREATE ROLE regress_nosuch_replication REPLICATION;
|
||||||
ERROR: permission denied to create role
|
ERROR: permission denied to create role
|
||||||
DETAIL: Only roles with the REPLICATION attribute may create roles with REPLICATION.
|
DETAIL: Only roles with the REPLICATION attribute may create roles with the REPLICATION attribute.
|
||||||
CREATE ROLE regress_nosuch_bypassrls BYPASSRLS;
|
CREATE ROLE regress_nosuch_bypassrls BYPASSRLS;
|
||||||
ERROR: permission denied to create role
|
ERROR: permission denied to create role
|
||||||
DETAIL: Only roles with the BYPASSRLS attribute may create roles with BYPASSRLS.
|
DETAIL: Only roles with the BYPASSRLS attribute may create roles with the BYPASSRLS attribute.
|
||||||
CREATE ROLE regress_nosuch_createdb CREATEDB;
|
CREATE ROLE regress_nosuch_createdb CREATEDB;
|
||||||
ERROR: permission denied to create role
|
ERROR: permission denied to create role
|
||||||
DETAIL: Only roles with the CREATEDB attribute may create roles with CREATEDB.
|
DETAIL: Only roles with the CREATEDB attribute may create roles with the CREATEDB attribute.
|
||||||
-- ok, can create a role without any special attributes
|
-- ok, can create a role without any special attributes
|
||||||
CREATE ROLE regress_role_limited;
|
CREATE ROLE regress_role_limited;
|
||||||
-- fail, can't give it in any of the restricted attributes
|
-- fail, can't give it in any of the restricted attributes
|
||||||
@ -71,7 +71,7 @@ NOTICE: SYSID can no longer be specified
|
|||||||
-- fail, cannot grant membership in superuser role
|
-- fail, cannot grant membership in superuser role
|
||||||
CREATE ROLE regress_nosuch_super IN ROLE regress_role_super;
|
CREATE ROLE regress_nosuch_super IN ROLE regress_role_super;
|
||||||
ERROR: permission denied to grant role "regress_role_super"
|
ERROR: permission denied to grant role "regress_role_super"
|
||||||
DETAIL: Only roles with the SUPERUSER attribute may grant roles with SUPERUSER.
|
DETAIL: Only roles with the SUPERUSER attribute may grant roles with the SUPERUSER attribute.
|
||||||
-- fail, database owner cannot have members
|
-- fail, database owner cannot have members
|
||||||
CREATE ROLE regress_nosuch_dbowner IN ROLE pg_database_owner;
|
CREATE ROLE regress_nosuch_dbowner IN ROLE pg_database_owner;
|
||||||
ERROR: role "pg_database_owner" cannot have explicit members
|
ERROR: role "pg_database_owner" cannot have explicit members
|
||||||
@ -238,7 +238,7 @@ DROP ROLE regress_adminroles;
|
|||||||
-- fail, cannot drop ourself, nor superusers or roles we lack ADMIN for
|
-- fail, cannot drop ourself, nor superusers or roles we lack ADMIN for
|
||||||
DROP ROLE regress_role_super;
|
DROP ROLE regress_role_super;
|
||||||
ERROR: permission denied to drop role
|
ERROR: permission denied to drop role
|
||||||
DETAIL: Only roles with the SUPERUSER attribute may drop roles with SUPERUSER.
|
DETAIL: Only roles with the SUPERUSER attribute may drop roles with the SUPERUSER attribute.
|
||||||
DROP ROLE regress_role_admin;
|
DROP ROLE regress_role_admin;
|
||||||
ERROR: current user cannot be dropped
|
ERROR: current user cannot be dropped
|
||||||
DROP ROLE regress_rolecreator;
|
DROP ROLE regress_rolecreator;
|
||||||
|
Reference in New Issue
Block a user