Skip to content

Commit de9037d

Browse files
committed
Downgrade errors in object_ownercheck() to internal
The "does not exist" errors in object_ownership() were written as ereport(), suggesting that they are user-facing. But no code path except one can reach this function without first checking that the object exists. If this were actually a user-facing error message, then there would be some problems: get_object_class_descr() is meant to be for internal errors only and does not support translation. The one case that can reach this without first checking the object existence is from be_lo_unlink(). (This makes some sense since large objects are referred to by their OID directly.) In this one case, we can add a line of code to check the object existence explicitly, consistent with other LO code. For the rest, downgrade the error messages to elog()s. The new message wordings are the same as in DropObjectById(). Reviewed-by: Alvaro Herrera <alvherre@alvh.no-ip.org> Discussion: https://www.postgresql.org/message-id/flat/da2f8942-be6d-48d0-ac1c-a053370a6b1f@eisentraut.org
1 parent 6fdd5d9 commit de9037d

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/backend/catalog/aclchk.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4082,9 +4082,8 @@ object_ownercheck(Oid classid, Oid objectid, Oid roleid)
40824082

40834083
tuple = SearchSysCache1(cacheid, ObjectIdGetDatum(objectid));
40844084
if (!HeapTupleIsValid(tuple))
4085-
ereport(ERROR,
4086-
(errcode(ERRCODE_UNDEFINED_OBJECT),
4087-
errmsg("%s with OID %u does not exist", get_object_class_descr(classid), objectid)));
4085+
elog(ERROR, "cache lookup failed for %s %u",
4086+
get_object_class_descr(classid), objectid);
40884087

40894088
ownerId = DatumGetObjectId(SysCacheGetAttrNotNull(cacheid,
40904089
tuple,
@@ -4113,9 +4112,8 @@ object_ownercheck(Oid classid, Oid objectid, Oid roleid)
41134112

41144113
tuple = systable_getnext(scan);
41154114
if (!HeapTupleIsValid(tuple))
4116-
ereport(ERROR,
4117-
(errcode(ERRCODE_UNDEFINED_OBJECT),
4118-
errmsg("%s with OID %u does not exist", get_object_class_descr(classid), objectid)));
4115+
elog(ERROR, "could not find tuple for %s %u",
4116+
get_object_class_descr(classid), objectid);
41194117

41204118
ownerId = DatumGetObjectId(heap_getattr(tuple,
41214119
get_object_attnum_owner(classid),

src/backend/libpq/be-fsstubs.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,11 @@ be_lo_unlink(PG_FUNCTION_ARGS)
317317

318318
PreventCommandIfReadOnly("lo_unlink()");
319319

320+
if (!LargeObjectExists(lobjId))
321+
ereport(ERROR,
322+
(errcode(ERRCODE_UNDEFINED_OBJECT),
323+
errmsg("large object %u does not exist", lobjId)));
324+
320325
/*
321326
* Must be owner of the large object. It would be cleaner to check this
322327
* in inv_drop(), but we want to throw the error before not after closing

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy