Eliminate cache lookup errors in SQL functions for object addresses
authorMichael Paquier <michael@paquier.xyz>
Wed, 15 Jul 2020 00:03:10 +0000 (09:03 +0900)
committerMichael Paquier <michael@paquier.xyz>
Wed, 15 Jul 2020 00:03:10 +0000 (09:03 +0900)
commit2a10fdc4307a667883f7a3369cb93a721ade9680
tree634b6964507faa666395bef8542be4c5c7eef5f4
parent689696c7110f148ede8004aae50d7543d05b5587
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
19 files changed:
contrib/sepgsql/database.c
contrib/sepgsql/dml.c
contrib/sepgsql/label.c
contrib/sepgsql/proc.c
contrib/sepgsql/relation.c
contrib/sepgsql/schema.c
doc/src/sgml/func.sgml
src/backend/catalog/dependency.c
src/backend/catalog/objectaddress.c
src/backend/catalog/pg_depend.c
src/backend/catalog/pg_shdepend.c
src/backend/commands/event_trigger.c
src/backend/commands/extension.c
src/backend/commands/tablecmds.c
src/backend/utils/adt/regproc.c
src/include/catalog/objectaddress.h
src/include/utils/regproc.h
src/test/regress/expected/object_address.out
src/test/regress/sql/object_address.sql