mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-04 06:27:20 +02:00
Fix multiple minor infelicities in aclchk.c error reports.
pg_type_aclmask reported the wrong type's OID when complaining that it could not find a type's typelem. It also failed to provide a suitable errcode when the initially given OID doesn't exist (which is a user-facing error, since that OID can be user-specified). pg_foreign_data_wrapper_aclmask and pg_foreign_server_aclmask likewise lacked errcode specifications. Trivial cosmetic adjustments too. The wrong-type-OID problem was reported by Petru-Florin Mihancea in bug #14186; the other issues noted by me while reading the code. These errors all seem to be aboriginal in the respective routines, so back-patch as necessary. Report: <20160613163159.5798.52928@wrigleys.postgresql.org>
This commit is contained in:
parent
1ad83738d0
commit
e5bdaa127b
@ -4068,7 +4068,8 @@ pg_foreign_data_wrapper_aclmask(Oid fdw_oid, Oid roleid,
|
|||||||
tuple = SearchSysCache1(FOREIGNDATAWRAPPEROID, ObjectIdGetDatum(fdw_oid));
|
tuple = SearchSysCache1(FOREIGNDATAWRAPPEROID, ObjectIdGetDatum(fdw_oid));
|
||||||
if (!HeapTupleIsValid(tuple))
|
if (!HeapTupleIsValid(tuple))
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errmsg("foreign-data wrapper with OID %u does not exist",
|
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||||
|
errmsg("foreign-data wrapper with OID %u does not exist",
|
||||||
fdw_oid)));
|
fdw_oid)));
|
||||||
fdwForm = (Form_pg_foreign_data_wrapper) GETSTRUCT(tuple);
|
fdwForm = (Form_pg_foreign_data_wrapper) GETSTRUCT(tuple);
|
||||||
|
|
||||||
@ -4129,7 +4130,8 @@ pg_foreign_server_aclmask(Oid srv_oid, Oid roleid,
|
|||||||
tuple = SearchSysCache1(FOREIGNSERVEROID, ObjectIdGetDatum(srv_oid));
|
tuple = SearchSysCache1(FOREIGNSERVEROID, ObjectIdGetDatum(srv_oid));
|
||||||
if (!HeapTupleIsValid(tuple))
|
if (!HeapTupleIsValid(tuple))
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errmsg("foreign server with OID %u does not exist",
|
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||||
|
errmsg("foreign server with OID %u does not exist",
|
||||||
srv_oid)));
|
srv_oid)));
|
||||||
srvForm = (Form_pg_foreign_server) GETSTRUCT(tuple);
|
srvForm = (Form_pg_foreign_server) GETSTRUCT(tuple);
|
||||||
|
|
||||||
@ -4188,27 +4190,30 @@ pg_type_aclmask(Oid type_oid, Oid roleid, AclMode mask, AclMaskHow how)
|
|||||||
tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type_oid));
|
tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type_oid));
|
||||||
if (!HeapTupleIsValid(tuple))
|
if (!HeapTupleIsValid(tuple))
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errmsg("type with OID %u does not exist",
|
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||||
|
errmsg("type with OID %u does not exist",
|
||||||
type_oid)));
|
type_oid)));
|
||||||
typeForm = (Form_pg_type) GETSTRUCT(tuple);
|
typeForm = (Form_pg_type) GETSTRUCT(tuple);
|
||||||
|
|
||||||
/* "True" array types don't manage permissions of their own */
|
/*
|
||||||
if (typeForm->typelem != 0 && typeForm->typlen == -1)
|
* "True" array types don't manage permissions of their own; consult the
|
||||||
|
* element type instead.
|
||||||
|
*/
|
||||||
|
if (OidIsValid(typeForm->typelem) && typeForm->typlen == -1)
|
||||||
{
|
{
|
||||||
Oid elttype_oid = typeForm->typelem;
|
Oid elttype_oid = typeForm->typelem;
|
||||||
|
|
||||||
ReleaseSysCache(tuple);
|
ReleaseSysCache(tuple);
|
||||||
|
|
||||||
tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(elttype_oid));
|
tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(elttype_oid));
|
||||||
|
/* this case is not a user-facing error, so elog not ereport */
|
||||||
if (!HeapTupleIsValid(tuple))
|
if (!HeapTupleIsValid(tuple))
|
||||||
ereport(ERROR,
|
elog(ERROR, "cache lookup failed for type %u", elttype_oid);
|
||||||
(errmsg("type with OID %u does not exist",
|
|
||||||
type_oid)));
|
|
||||||
typeForm = (Form_pg_type) GETSTRUCT(tuple);
|
typeForm = (Form_pg_type) GETSTRUCT(tuple);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Normal case: get the type's ACL from pg_type
|
* Now get the type's owner and ACL from the tuple
|
||||||
*/
|
*/
|
||||||
ownerId = typeForm->typowner;
|
ownerId = typeForm->typowner;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user