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

Commitde9037d

Browse files
committed
Downgrade errors in object_ownercheck() to internal
The "does not exist" errors in object_ownership() were written asereport(), suggesting that they are user-facing. But no code pathexcept one can reach this function without first checking that theobject exists. If this were actually a user-facing error message,then there would be some problems: get_object_class_descr() is meantto be for internal errors only and does not support translation.The one case that can reach this without first checking the objectexistence is from be_lo_unlink(). (This makes some sense since largeobjects are referred to by their OID directly.) In this one case, wecan 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 newmessage 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 parent6fdd5d9 commitde9037d

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)

[8]ページ先頭

©2009-2025 Movatter.jp