1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-17 17:02:08 +03:00

Allow extracting machine-readable object identity

Introduce pg_identify_object(oid,oid,int4), which is similar in spirit
to pg_describe_object but instead produces a row of machine-readable
information to uniquely identify the given object, without resorting to
OIDs or other internal representation.  This is intended to be used in
the event trigger implementation, to report objects being operated on;
but it has usefulness of its own.

Catalog version bumped because of the new function.
This commit is contained in:
Alvaro Herrera
2013-03-20 18:19:19 -03:00
parent a7921f71a3
commit f8348ea32e
12 changed files with 2141 additions and 955 deletions

View File

@ -13930,6 +13930,10 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
<primary>pg_describe_object</primary>
</indexterm>
<indexterm>
<primary>pg_identify_object</primary>
</indexterm>
<indexterm>
<primary>pg_get_constraintdef</primary>
</indexterm>
@ -14029,6 +14033,11 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
<entry><type>text</type></entry>
<entry>get description of a database object</entry>
</row>
<row>
<entry><literal><function>pg_identify_object(<parameter>catalog_id</parameter> <type>oid</>, <parameter>object_id</parameter> <type>oid</>, <parameter>object_sub_id</parameter> <type>integer</>)</function></literal></entry>
<entry><parameter>type</> <type>text</>, <parameter>schema</> <type>text</>, <parameter>name</> <type>text</>, <parameter>identity</> <type>text</></entry>
<entry>get identity of a database object</entry>
</row>
<row>
<entry><literal><function>pg_get_constraintdef(<parameter>constraint_oid</parameter>)</function></literal></entry>
<entry><type>text</type></entry>
@ -14273,12 +14282,30 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
</para>
<para>
<function>pg_describe_object</function> returns a description of a database
<function>pg_describe_object</function> returns a textual description of a database
object specified by catalog OID, object OID and a (possibly zero) sub-object ID.
This description is intended to be human-readable, and might be translated,
depending on server configuration.
This is useful to determine the identity of an object as stored in the
<structname>pg_depend</structname> catalog.
</para>
<para>
<function>pg_identify_object</function> returns a row containing enough information
to uniquely identify the database object specified by catalog OID, object OID and a
(possibly zero) sub-object ID. This information is intended to be machine-readable,
and is never translated.
<parameter>type</> identifies the type of database object;
<parameter>schema</> is the schema name that the object belongs in, or
<literal>NULL</> for object types that do not belong to schemas;
<parameter>name</> is the name of the object, quoted if necessary, only
present if it can be used (alongside schema name, if pertinent) as an unique
identifier of the object, otherwise <literal>NULL</>;
<parameter>identity</> is the complete object identity, with the precise format
depending on object type, and each part within the format being
schema-qualified and quoted as necessary.
</para>
<para>
<function>pg_typeof</function> returns the OID of the data type of the
value that is passed to it. This can be helpful for troubleshooting or