Skip site navigation (1) Skip section navigation (2)

pg_typeof() (was: Mysterious Bus Error with get_fn_expr_argtype())

From: "Brendan Jurd" <direvus(at)gmail(dot)com>
To: pgsql-patches(at)postgresql(dot)org, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "David E(dot) Wheeler" <david(at)kineticode(dot)com>, "Neil Conway" <neilc(at)samurai(dot)com>
Subject: pg_typeof() (was: Mysterious Bus Error with get_fn_expr_argtype())
Date: 2008-09-03 07:15:36
Message-ID: 37ed240d0809030015u73b65b66v70fd76741317c6f5@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-patches
Hi folks,

As discussed on -hackers [1], here is a patch to add a pg_typeof()
builtin function to core.

The function accepts one argument (type "any") and returns the regtype
of that argument.  This can be helpful in various circumstances,
including troubleshooting cast/coercion behaviour in a query, or
constructing dynamic SQL statements.

It's declared in builtins.h and defined in utils/adt/misc.c.

The patch includes a small documentation update; I added pg_typeof()
to Table 9-47. System Catalog Information Functions, and a brief
descriptive paragraph underneath the table.

This didn't seem like it warranted any additional regression tests.

Added to the November commitfest.

Cheers,
BJ

 doc/src/sgml/func.sgml           |   15 +++++++++++++++
 src/backend/utils/adt/misc.c     |    9 +++++++++
 src/include/catalog/catversion.h |    2 !!
 src/include/catalog/pg_proc.h    |    2 ++
 src/include/utils/builtins.h     |    1 +
 5 files changed, 27 insertions(+), 2 modifications(!)

[1] http://archives.postgresql.org/message-id/37ed240d0809012135k1a7621d5x2acf18b31c7f9281@mail.gmail.com

Attachment: pg_typeof.diff
Description: application/octet-stream (3.5 KB)

In response to

pgsql-hackers by date

Next:From: Heikki LinnakangasDate: 2008-09-03 07:25:16
Subject: Re: Window functions patch v04 for the September commit fest
Previous:From: Heikki LinnakangasDate: 2008-09-03 06:51:43
Subject: Re: Window functions patch v04 for the September commit fest

pgsql-patches by date

Next:From: Andrew ChernowDate: 2008-09-03 14:09:36
Subject: Re: libpq object hooks (libpq events)
Previous:From: Andrew ChernowDate: 2008-09-03 03:27:32
Subject: Re: libpq object hooks (libpq events)

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group