Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite5bdaa1

Browse files
committed
Fix multiple minor infelicities in aclchk.c error reports.
pg_type_aclmask reported the wrong type's OID when complaining thatit could not find a type's typelem. It also failed to provide asuitable errcode when the initially given OID doesn't exist (whichis a user-facing error, since that OID can be user-specified).pg_foreign_data_wrapper_aclmask and pg_foreign_server_aclmask likewiselacked errcode specifications. Trivial cosmetic adjustments too.The wrong-type-OID problem was reported by Petru-Florin Mihancea inbug #14186; the other issues noted by me while reading the code.These errors all seem to be aboriginal in the respective routines, soback-patch as necessary.Report: <20160613163159.5798.52928@wrigleys.postgresql.org>
1 parent1ad8373 commite5bdaa1

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

‎src/backend/catalog/aclchk.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4068,7 +4068,8 @@ pg_foreign_data_wrapper_aclmask(Oid fdw_oid, Oid roleid,
40684068
tuple=SearchSysCache1(FOREIGNDATAWRAPPEROID,ObjectIdGetDatum(fdw_oid));
40694069
if (!HeapTupleIsValid(tuple))
40704070
ereport(ERROR,
4071-
(errmsg("foreign-data wrapper with OID %u does not exist",
4071+
(errcode(ERRCODE_UNDEFINED_OBJECT),
4072+
errmsg("foreign-data wrapper with OID %u does not exist",
40724073
fdw_oid)));
40734074
fdwForm= (Form_pg_foreign_data_wrapper)GETSTRUCT(tuple);
40744075

@@ -4129,7 +4130,8 @@ pg_foreign_server_aclmask(Oid srv_oid, Oid roleid,
41294130
tuple=SearchSysCache1(FOREIGNSERVEROID,ObjectIdGetDatum(srv_oid));
41304131
if (!HeapTupleIsValid(tuple))
41314132
ereport(ERROR,
4132-
(errmsg("foreign server with OID %u does not exist",
4133+
(errcode(ERRCODE_UNDEFINED_OBJECT),
4134+
errmsg("foreign server with OID %u does not exist",
41334135
srv_oid)));
41344136
srvForm= (Form_pg_foreign_server)GETSTRUCT(tuple);
41354137

@@ -4188,27 +4190,30 @@ pg_type_aclmask(Oid type_oid, Oid roleid, AclMode mask, AclMaskHow how)
41884190
tuple=SearchSysCache1(TYPEOID,ObjectIdGetDatum(type_oid));
41894191
if (!HeapTupleIsValid(tuple))
41904192
ereport(ERROR,
4191-
(errmsg("type with OID %u does not exist",
4193+
(errcode(ERRCODE_UNDEFINED_OBJECT),
4194+
errmsg("type with OID %u does not exist",
41924195
type_oid)));
41934196
typeForm= (Form_pg_type)GETSTRUCT(tuple);
41944197

4195-
/* "True" array types don't manage permissions of their own */
4196-
if (typeForm->typelem!=0&&typeForm->typlen==-1)
4198+
/*
4199+
* "True" array types don't manage permissions of their own; consult the
4200+
* element type instead.
4201+
*/
4202+
if (OidIsValid(typeForm->typelem)&&typeForm->typlen==-1)
41974203
{
41984204
Oidelttype_oid=typeForm->typelem;
41994205

42004206
ReleaseSysCache(tuple);
42014207

42024208
tuple=SearchSysCache1(TYPEOID,ObjectIdGetDatum(elttype_oid));
4209+
/* this case is not a user-facing error, so elog not ereport */
42034210
if (!HeapTupleIsValid(tuple))
4204-
ereport(ERROR,
4205-
(errmsg("type with OID %u does not exist",
4206-
type_oid)));
4211+
elog(ERROR,"cache lookup failed for type %u",elttype_oid);
42074212
typeForm= (Form_pg_type)GETSTRUCT(tuple);
42084213
}
42094214

42104215
/*
4211-
*Normal case:get the type's ACL frompg_type
4216+
*Nowget the type'sowner andACL fromthe tuple
42124217
*/
42134218
ownerId=typeForm->typowner;
42144219

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp