From 399ad77c66a17ff354e5fbf01ca35c76e2ae88ed Mon Sep 17 00:00:00 2001 From: Tom Lane <tgl@sss.pgh.pa.us> Date: Fri, 7 Nov 2008 22:54:41 +0000 Subject: [PATCH] Improve documentation of pg_typeof, per gripe from David Wheeler. --- doc/src/sgml/func.sgml | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 61460f3c0fc..1e329904512 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -1,4 +1,4 @@ -<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.455 2008/11/04 14:49:11 petere Exp $ --> +<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.456 2008/11/07 22:54:41 tgl Exp $ --> <chapter id="functions"> <title>Functions and Operators</title> @@ -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> -- GitLab