Improve documentation of pg_typeof, per gripe from David Wheeler.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 7 Nov 2008 22:54:41 +0000 (22:54 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 7 Nov 2008 22:54:41 +0000 (22:54 +0000)
doc/src/sgml/func.sgml

index f257238b998f1b43054272f06c9cff34f658a66c..07dcb9baf6c4318ec605abb76a79e184fe633d59 100644 (file)
@@ -11871,7 +11871,24 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
   <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
-   dynamically constructing SQL queries.
+   dynamically constructing SQL queries.  The function is declared as
+   returning <type>regtype</>, which is an OID alias type (see
+   <xref linkend="datatype-oid">); this means that it is the same as an
+   OID for comparison purposes but displays as a type name.  For example:
+<programlisting>
+SELECT pg_typeof(33);
+
+ pg_typeof 
+-----------
+ integer
+(1 row)
+
+SELECT typlen FROM pg_type WHERE oid = pg_typeof(33);
+ typlen 
+--------
+      4
+(1 row)
+</programlisting>
   </para>
 
    <indexterm>