Downgrade errors in object_ownercheck() to internal
authorPeter Eisentraut <peter@eisentraut.org>
Wed, 15 Jan 2025 15:53:53 +0000 (16:53 +0100)
committerPeter Eisentraut <peter@eisentraut.org>
Wed, 15 Jan 2025 15:58:44 +0000 (16:58 +0100)
commitde9037d0d085f25d3c220a45bfbb7abc5794a0c8
tree3c5f8f1a85d205f3157fc26f9995282165111df9
parent6fdd5d9563439285df200f7282f0ca68152ef72d
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
src/backend/catalog/aclchk.c
src/backend/libpq/be-fsstubs.c