From 9935a85fa4c69b45539e7800eed6c38779a75f0a Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 27 Dec 2001 21:36:57 +0000 Subject: [PATCH] Document obj_description and col_description functions; expand description of COMMENT command. --- doc/src/sgml/func.sgml | 66 +++++++++++++++++++++++++++++++++-- doc/src/sgml/ref/comment.sgml | 26 +++++++++++--- 2 files changed, 85 insertions(+), 7 deletions(-) diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index c9af36d550..52f20f2158 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -1,5 +1,5 @@ @@ -2643,7 +2643,7 @@ PostgreSQL documentation current_timestamp timestamp - date and time; see also Date and time; see below @@ -2722,7 +2722,7 @@ PostgreSQL documentation now() timestamp Current date and time (equivalent to - current_timestamp); see also current_timestamp); see below @@ -4399,6 +4399,66 @@ SELECT NULLIF(value, '(none)') ... usesysid value. + + Comment Information Functions</> + <tgroup cols="3"> + <thead> + <row><entry>Name</> <entry>Return Type</> <entry>Description</></row> + </thead> + + <tbody> + <row> + <entry><function>obj_description</>(<parameter>objectOID</parameter>, <parameter>tablename</>)</entry> + <entry><type>text</></entry> + <entry>Get comment for a database object</> + </row> + <row> + <entry><function>obj_description</>(<parameter>objectOID</parameter>)</entry> + <entry><type>text</></entry> + <entry>Get comment for a database object (<emphasis>deprecated</>)</entry> + </row> + <row> + <entry><function>col_description</>(<parameter>tableOID</parameter>, <parameter>columnnumber</>)</entry> + <entry><type>text</></entry> + <entry>Get comment for a table column</> + </row> + </tbody> + </tgroup> + </table> + + <indexterm zone="functions-misc"> + <primary>obj_description</primary> + </indexterm> + + <indexterm zone="functions-misc"> + <primary>col_description</primary> + </indexterm> + + <para> + These functions extract comments previously stored with the + <command>COMMENT</> command. <literal>NULL</> is returned if + no comment can be found matching the specified parameters. + </para> + + <para> + The two-parameter form of <function>obj_description()</> returns the + comment for a database object specified by its OID and the name of the + containing system catalog. For example, + <literal>obj_description(123456,'pg_class')</> + would retrieve the comment for a table with OID 123456. + The one-parameter form of <function>obj_description()</> requires only + the object OID. It is now deprecated since there is no guarantee that + OIDs are unique across different system catalogs; therefore, the wrong + comment could be returned. + </para> + + <para> + <function>col_description()</> returns the comment for a table column, + which is specified by the OID of its table and its column number. + <function>obj_description()</> cannot be used for table columns since + columns do not have OIDs of their own. + </para> + </sect1> diff --git a/doc/src/sgml/ref/comment.sgml b/doc/src/sgml/ref/comment.sgml index af4a3f6588..9a22b75895 100644 --- a/doc/src/sgml/ref/comment.sgml +++ b/doc/src/sgml/ref/comment.sgml @@ -1,5 +1,5 @@ <!-- -$Header: /cvsroot/pgsql/doc/src/sgml/ref/comment.sgml,v 1.11 2001/12/08 03:24:34 thomas Exp $ +$Header: /cvsroot/pgsql/doc/src/sgml/ref/comment.sgml,v 1.12 2001/12/27 21:36:57 tgl Exp $ PostgreSQL documentation --> @@ -98,12 +98,30 @@ COMMENT Description - COMMENT adds a comment to an object that can be + COMMENT stores a comment about a database object. + Comments can be easily retrieved with psql's - \dd, \d+, or \l+ commands. - To remove a comment, write NULL. + \dd, \d+, or \l+ + commands. Other user interfaces to retrieve comments can be built atop + the same built-in functions that psql uses, namely + obj_description() and col_description(). + + + + To modify a comment, issue a new COMMENT command for the + same object. Only one comment string is stored for each object. + To remove a comment, write NULL in place of the text + string. Comments are automatically dropped when the object is dropped. + + + It should be noted that there is presently no security mechanism + for comments: any user connected to a database can see all the comments + for objects in that database (although only superusers can change + comments for objects that they don't own). Therefore, don't put + security-critical information in comments. + -- 2.40.0