Skip to content

Commit ae5205c

Browse files
committed
Make argument names of pg_get_object_address consistent, and fix docs.
pg_get_object_address and pg_identify_object_as_address are supposed to be inverses, but they disagreed as to the names of the arguments representing the textual form of an object address. Moreover, the documented argument names didn't agree with reality at all, either for these functions or pg_identify_object. In HEAD and v11, I think we can get away with renaming the input arguments of pg_get_object_address to match the outputs of pg_identify_object_as_address. In theory that might break queries using named-argument notation to call pg_get_object_address, but it seems really unlikely that anybody is doing that, or that they'd have much trouble adjusting if they were. In older branches, we'll just live with the lack of consistency. Aside from fixing the documentation of these functions to match reality, I couldn't resist the temptation to do some copy-editing. Per complaint from Jean-Pierre Pelletier. Back-patch to 9.5 where these functions were introduced. (Before v11, this is a documentation change only.) Discussion: https://postgr.es/m/CANGqjDnWH8wsTY_GzDUxbt4i=y-85SJreZin4Hm8uOqv1vzRQA@mail.gmail.com
1 parent 2fbdf1b commit ae5205c

File tree

3 files changed

+49
-46
lines changed

3 files changed

+49
-46
lines changed

doc/src/sgml/func.sgml

Lines changed: 47 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -17700,32 +17700,34 @@ SELECT collation for ('foo' COLLATE "de_DE");
1770017700

1770117701
<tbody>
1770217702
<row>
17703-
<entry><literal><function>pg_describe_object(<parameter>catalog_id</parameter>, <parameter>object_id</parameter>, <parameter>object_sub_id</parameter>)</function></literal></entry>
17703+
<entry><literal><function>pg_describe_object(<parameter>classid</parameter> <type>oid</type>, <parameter>objid</parameter> <type>oid</type>, <parameter>objsubid</parameter> <type>integer</type>)</function></literal></entry>
1770417704
<entry><type>text</type></entry>
1770517705
<entry>get description of a database object</entry>
1770617706
</row>
1770717707
<row>
17708-
<entry><literal><function>pg_identify_object(<parameter>catalog_id</parameter> <type>oid</type>, <parameter>object_id</parameter> <type>oid</type>, <parameter>object_sub_id</parameter> <type>integer</type>)</function></literal></entry>
17708+
<entry><literal><function>pg_identify_object(<parameter>classid</parameter> <type>oid</type>, <parameter>objid</parameter> <type>oid</type>, <parameter>objsubid</parameter> <type>integer</type>)</function></literal></entry>
1770917709
<entry><parameter>type</parameter> <type>text</type>, <parameter>schema</parameter> <type>text</type>, <parameter>name</parameter> <type>text</type>, <parameter>identity</parameter> <type>text</type></entry>
1771017710
<entry>get identity of a database object</entry>
1771117711
</row>
1771217712
<row>
17713-
<entry><literal><function>pg_identify_object_as_address(<parameter>catalog_id</parameter> <type>oid</type>, <parameter>object_id</parameter> <type>oid</type>, <parameter>object_sub_id</parameter> <type>integer</type>)</function></literal></entry>
17714-
<entry><parameter>type</parameter> <type>text</type>, <parameter>name</parameter> <type>text[]</type>, <parameter>args</parameter> <type>text[]</type></entry>
17713+
<entry><literal><function>pg_identify_object_as_address(<parameter>classid</parameter> <type>oid</type>, <parameter>objid</parameter> <type>oid</type>, <parameter>objsubid</parameter> <type>integer</type>)</function></literal></entry>
17714+
<entry><parameter>type</parameter> <type>text</type>, <parameter>object_names</parameter> <type>text[]</type>, <parameter>object_args</parameter> <type>text[]</type></entry>
1771517715
<entry>get external representation of a database object's address</entry>
1771617716
</row>
1771717717
<row>
17718-
<entry><literal><function>pg_get_object_address(<parameter>type</parameter> <type>text</type>, <parameter>name</parameter> <type>text[]</type>, <parameter>args</parameter> <type>text[]</type>)</function></literal></entry>
17719-
<entry><parameter>catalog_id</parameter> <type>oid</type>, <parameter>object_id</parameter> <type>oid</type>, <parameter>object_sub_id</parameter> <type>int32</type></entry>
17720-
<entry>get address of a database object, from its external representation</entry>
17718+
<entry><literal><function>pg_get_object_address(<parameter>type</parameter> <type>text</type>, <parameter>object_names</parameter> <type>text[]</type>, <parameter>object_args</parameter> <type>text[]</type>)</function></literal></entry>
17719+
<entry><parameter>classid</parameter> <type>oid</type>, <parameter>objid</parameter> <type>oid</type>, <parameter>objsubid</parameter> <type>integer</type></entry>
17720+
<entry>get address of a database object from its external representation</entry>
1772117721
</row>
1772217722
</tbody>
1772317723
</tgroup>
1772417724
</table>
1772517725

1772617726
<para>
1772717727
<function>pg_describe_object</function> returns a textual description of a database
17728-
object specified by catalog OID, object OID and a (possibly zero) sub-object ID.
17728+
object specified by catalog OID, object OID, and sub-object ID (such as
17729+
a column number within a table; the sub-object ID is zero when referring
17730+
to a whole object).
1772917731
This description is intended to be human-readable, and might be translated,
1773017732
depending on server configuration.
1773117733
This is useful to determine the identity of an object as stored in the
@@ -17734,29 +17736,30 @@ SELECT collation for ('foo' COLLATE "de_DE");
1773417736

1773517737
<para>
1773617738
<function>pg_identify_object</function> returns a row containing enough information
17737-
to uniquely identify the database object specified by catalog OID, object OID and a
17738-
(possibly zero) sub-object ID. This information is intended to be machine-readable,
17739+
to uniquely identify the database object specified by catalog OID, object OID and
17740+
sub-object ID. This information is intended to be machine-readable,
1773917741
and is never translated.
1774017742
<parameter>type</parameter> identifies the type of database object;
1774117743
<parameter>schema</parameter> is the schema name that the object belongs in, or
1774217744
<literal>NULL</literal> for object types that do not belong to schemas;
17743-
<parameter>name</parameter> is the name of the object, quoted if necessary, only
17744-
present if it can be used (alongside schema name, if pertinent) as a unique
17745-
identifier of the object, otherwise <literal>NULL</literal>;
17746-
<parameter>identity</parameter> is the complete object identity, with the precise format
17747-
depending on object type, and each part within the format being
17748-
schema-qualified and quoted as necessary.
17745+
<parameter>name</parameter> is the name of the object, quoted if necessary,
17746+
if the name (along with schema name, if pertinent) is sufficient to
17747+
uniquely identify the object, otherwise <literal>NULL</literal>;
17748+
<parameter>identity</parameter> is the complete object identity, with the
17749+
precise format depending on object type, and each name within the format
17750+
being schema-qualified and quoted as necessary.
1774917751
</para>
1775017752

1775117753
<para>
1775217754
<function>pg_identify_object_as_address</function> returns a row containing
1775317755
enough information to uniquely identify the database object specified by
17754-
catalog OID, object OID and a (possibly zero) sub-object ID. The returned
17756+
catalog OID, object OID and sub-object ID. The returned
1775517757
information is independent of the current server, that is, it could be used
1775617758
to identify an identically named object in another server.
1775717759
<parameter>type</parameter> identifies the type of database object;
17758-
<parameter>name</parameter> and <parameter>args</parameter> are text arrays that together
17759-
form a reference to the object. These three columns can be passed to
17760+
<parameter>object_names</parameter> and <parameter>object_args</parameter>
17761+
are text arrays that together form a reference to the object.
17762+
These three values can be passed to
1776017763
<function>pg_get_object_address</function> to obtain the internal address
1776117764
of the object.
1776217765
This function is the inverse of <function>pg_get_object_address</function>.
@@ -17769,10 +17772,10 @@ SELECT collation for ('foo' COLLATE "de_DE");
1776917772
ones that would be used in system catalogs such as <structname>pg_depend</structname>
1777017773
and can be passed to other system functions such as
1777117774
<function>pg_identify_object</function> or <function>pg_describe_object</function>.
17772-
<parameter>catalog_id</parameter> is the OID of the system catalog containing the
17775+
<parameter>classid</parameter> is the OID of the system catalog containing the
1777317776
object;
17774-
<parameter>object_id</parameter> is the OID of the object itself, and
17775-
<parameter>object_sub_id</parameter> is the object sub-ID, or zero if none.
17777+
<parameter>objid</parameter> is the OID of the object itself, and
17778+
<parameter>objsubid</parameter> is the sub-object ID, or zero if none.
1777617779
This function is the inverse of <function>pg_identify_object_as_address</function>.
1777717780
</para>
1777817781

@@ -20661,23 +20664,23 @@ FOR EACH ROW EXECUTE FUNCTION suppress_redundant_updates_trigger();
2066120664
<tbody>
2066220665
<row>
2066320666
<entry><literal>classid</literal></entry>
20664-
<entry><type>Oid</type></entry>
20667+
<entry><type>oid</type></entry>
2066520668
<entry>OID of catalog the object belongs in</entry>
2066620669
</row>
2066720670
<row>
2066820671
<entry><literal>objid</literal></entry>
20669-
<entry><type>Oid</type></entry>
20670-
<entry>OID of the object in the catalog</entry>
20672+
<entry><type>oid</type></entry>
20673+
<entry>OID of the object itself</entry>
2067120674
</row>
2067220675
<row>
2067320676
<entry><literal>objsubid</literal></entry>
2067420677
<entry><type>integer</type></entry>
20675-
<entry>Object sub-id (e.g. attribute number for columns)</entry>
20678+
<entry>Sub-object ID (e.g. attribute number for a column)</entry>
2067620679
</row>
2067720680
<row>
2067820681
<entry><literal>command_tag</literal></entry>
2067920682
<entry><type>text</type></entry>
20680-
<entry>command tag</entry>
20683+
<entry>Command tag</entry>
2068120684
</row>
2068220685
<row>
2068320686
<entry><literal>object_type</literal></entry>
@@ -20696,14 +20699,14 @@ FOR EACH ROW EXECUTE FUNCTION suppress_redundant_updates_trigger();
2069620699
<entry><literal>object_identity</literal></entry>
2069720700
<entry><type>text</type></entry>
2069820701
<entry>
20699-
Text rendering of the object identity, schema-qualified. Each and every
20700-
identifier present in the identity is quoted if necessary.
20702+
Text rendering of the object identity, schema-qualified. Each
20703+
identifier included in the identity is quoted if necessary.
2070120704
</entry>
2070220705
</row>
2070320706
<row>
2070420707
<entry><literal>in_extension</literal></entry>
2070520708
<entry><type>bool</type></entry>
20706-
<entry>whether the command is part of an extension script</entry>
20709+
<entry>True if the command is part of an extension script</entry>
2070720710
</row>
2070820711
<row>
2070920712
<entry><literal>command</literal></entry>
@@ -20748,37 +20751,37 @@ FOR EACH ROW EXECUTE FUNCTION suppress_redundant_updates_trigger();
2074820751
<tbody>
2074920752
<row>
2075020753
<entry><literal>classid</literal></entry>
20751-
<entry><type>Oid</type></entry>
20754+
<entry><type>oid</type></entry>
2075220755
<entry>OID of catalog the object belonged in</entry>
2075320756
</row>
2075420757
<row>
2075520758
<entry><literal>objid</literal></entry>
20756-
<entry><type>Oid</type></entry>
20757-
<entry>OID the object had within the catalog</entry>
20759+
<entry><type>oid</type></entry>
20760+
<entry>OID of the object itself</entry>
2075820761
</row>
2075920762
<row>
2076020763
<entry><literal>objsubid</literal></entry>
20761-
<entry><type>int32</type></entry>
20762-
<entry>Object sub-id (e.g. attribute number for columns)</entry>
20764+
<entry><type>integer</type></entry>
20765+
<entry>Sub-object ID (e.g. attribute number for a column)</entry>
2076320766
</row>
2076420767
<row>
2076520768
<entry><literal>original</literal></entry>
2076620769
<entry><type>bool</type></entry>
20767-
<entry>Flag used to identify the root object(s) of the deletion</entry>
20770+
<entry>True if this was one of the root object(s) of the deletion</entry>
2076820771
</row>
2076920772
<row>
2077020773
<entry><literal>normal</literal></entry>
2077120774
<entry><type>bool</type></entry>
2077220775
<entry>
20773-
Flag indicating that there's a normal dependency relationship
20776+
True if there was a normal dependency relationship
2077420777
in the dependency graph leading to this object
2077520778
</entry>
2077620779
</row>
2077720780
<row>
2077820781
<entry><literal>is_temporary</literal></entry>
2077920782
<entry><type>bool</type></entry>
2078020783
<entry>
20781-
Flag indicating that the object was a temporary object.
20784+
True if this was a temporary object
2078220785
</entry>
2078320786
</row>
2078420787
<row>
@@ -20807,26 +20810,26 @@ FOR EACH ROW EXECUTE FUNCTION suppress_redundant_updates_trigger();
2080720810
<entry><literal>object_identity</literal></entry>
2080820811
<entry><type>text</type></entry>
2080920812
<entry>
20810-
Text rendering of the object identity, schema-qualified. Each and every
20811-
identifier present in the identity is quoted if necessary.
20813+
Text rendering of the object identity, schema-qualified. Each
20814+
identifier included in the identity is quoted if necessary.
2081220815
</entry>
2081320816
</row>
2081420817
<row>
2081520818
<entry><literal>address_names</literal></entry>
2081620819
<entry><type>text[]</type></entry>
2081720820
<entry>
2081820821
An array that, together with <literal>object_type</literal> and
20819-
<literal>address_args</literal>,
20820-
can be used by the <function>pg_get_object_address()</function> to
20822+
<literal>address_args</literal>, can be used by
20823+
the <function>pg_get_object_address()</function> function to
2082120824
recreate the object address in a remote server containing an
20822-
identically named object of the same kind.
20825+
identically named object of the same kind
2082320826
</entry>
2082420827
</row>
2082520828
<row>
2082620829
<entry><literal>address_args</literal></entry>
2082720830
<entry><type>text[]</type></entry>
2082820831
<entry>
20829-
Complement for <literal>address_names</literal> above.
20832+
Complement for <literal>address_names</literal>
2083020833
</entry>
2083120834
</row>
2083220835
</tbody>

src/include/catalog/catversion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/* yyyymmddN */
56-
#define CATALOG_VERSION_NO 201809042
56+
#define CATALOG_VERSION_NO 201809052
5757

5858
#endif

src/include/catalog/pg_proc.dat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5907,7 +5907,7 @@
59075907
prorettype => 'record', proargtypes => 'text _text _text',
59085908
proallargtypes => '{text,_text,_text,oid,oid,int4}',
59095909
proargmodes => '{i,i,i,o,o,o}',
5910-
proargnames => '{type,name,args,classid,objid,objsubid}',
5910+
proargnames => '{type,object_names,object_args,classid,objid,objsubid}',
59115911
prosrc => 'pg_get_object_address' },
59125912

59135913
{ oid => '2079', descr => 'is table visible in search path?',

0 commit comments

Comments
 (0)