|
1 |
| -<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.455 2008/11/04 14:49:11 petere Exp $ --> |
| 1 | +<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.456 2008/11/07 22:54:41 tgl Exp $ --> |
2 | 2 |
|
3 | 3 | <chapter id="functions">
|
4 | 4 | <title>Functions and Operators</title>
|
@@ -11871,7 +11871,24 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
|
11871 | 11871 | <para>
|
11872 | 11872 | <function>pg_typeof</function> returns the OID of the data type of the
|
11873 | 11873 | value that is passed to it. This can be helpful for troubleshooting or
|
11874 |
| - dynamically constructing SQL queries. |
| 11874 | + dynamically constructing SQL queries. The function is declared as |
| 11875 | + returning <type>regtype</>, which is an OID alias type (see |
| 11876 | + <xref linkend="datatype-oid">); this means that it is the same as an |
| 11877 | + OID for comparison purposes but displays as a type name. For example: |
| 11878 | +<programlisting> |
| 11879 | +SELECT pg_typeof(33); |
| 11880 | + |
| 11881 | + pg_typeof |
| 11882 | +----------- |
| 11883 | + integer |
| 11884 | +(1 row) |
| 11885 | + |
| 11886 | +SELECT typlen FROM pg_type WHERE oid = pg_typeof(33); |
| 11887 | + typlen |
| 11888 | +-------- |
| 11889 | + 4 |
| 11890 | +(1 row) |
| 11891 | +</programlisting> |
11875 | 11892 | </para>
|
11876 | 11893 |
|
11877 | 11894 | <indexterm>
|
|