1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

Eliminate cache lookup errors in SQL functions for object addresses

When using the following functions, users could see various types of
errors of the type "cache lookup failed for OID XXX" with elog(), that
can only be used for internal errors:
* pg_describe_object()
* pg_identify_object()
* pg_identify_object_as_address()

The set of APIs managing object addresses for all object types are made
smarter by gaining a new argument "missing_ok" that allows any caller to
control if an error is raised or not on an undefined object.  The SQL
functions listed above are changed to handle the case where an object is
missing.

Regression tests are added for all object types for the cases where
these are undefined.  Before this commit, these cases failed with cache
lookup errors, and now they basically return NULL (minus the name of the
object type requested).

Author: Michael Paquier
Reviewed-by: Aleksander Alekseev, Dmitry Dolgov, Daniel Gustafsson,
Álvaro Herrera, Kyotaro Horiguchi
Discussion: https://postgr.es/m/CAB7nPqSZxrSmdHK-rny7z8mi=EAFXJ5J-0RbzDw6aus=wB5azQ@mail.gmail.com
This commit is contained in:
Michael Paquier
2020-07-15 09:03:10 +09:00
parent 689696c711
commit 2a10fdc430
19 changed files with 996 additions and 332 deletions

View File

@ -22826,7 +22826,8 @@ SELECT collation for ('foo' COLLATE "de_DE");
object). This description is intended to be human-readable, and might
be translated, depending on server configuration. This is especially
useful to determine the identity of an object referenced in the
<structname>pg_depend</structname> catalog.
<structname>pg_depend</structname> catalog. This function returns
<literal>NULL</literal> values for undefined objects.
</para></entry>
</row>
@ -22858,7 +22859,8 @@ SELECT collation for ('foo' COLLATE "de_DE");
otherwise <literal>NULL</literal>;
<parameter>identity</parameter> is the complete object identity, with
the precise format depending on object type, and each name within the
format being schema-qualified and quoted as necessary.
format being schema-qualified and quoted as necessary. Undefined
objects are identified with <literal>NULL</literal> values.
</para></entry>
</row>
@ -22915,6 +22917,7 @@ SELECT collation for ('foo' COLLATE "de_DE");
<parameter>objsubid</parameter> is the sub-object ID, or zero if none.
This function is the inverse
of <function>pg_identify_object_as_address</function>.
Undefined objects are identified with <literal>NULL</literal> values.
</para></entry>
</row>
</tbody>